Ticket #5755: t5755_h264_aspect.diff
File t5755_h264_aspect.diff, 6.9 KB (added by , 12 years ago) |
---|
-
libs/libmythtv/recorderbase.cpp
void RecorderBase::AspectChange(AspectRatio aspect 294 294 case ASPECT_21_1_1 : 295 295 mark = MARK_ASPECT_21_1_1; 296 296 break; 297 case ASPECT_OTHER : 298 mark = MARK_ASPECT_OTHER; 299 break; 297 300 default : 298 301 mark = MARK_ASPECT_4_3; 299 302 } -
libs/libmythtv/dtvrecorder.cpp
bool DTVRecorder::FindH264Keyframes(const TSPacket 483 483 _start_code = 0xffffffff; 484 484 } 485 485 486 uint aspectRatio = 0; 486 487 uint height = 0; 487 488 uint width = 0; 488 489 … … bool DTVRecorder::FindH264Keyframes(const TSPacket 567 568 hasKeyFrame = m_h264_parser.onKeyFrameStart(); 568 569 hasFrame = true; 569 570 _seen_sps |= hasKeyFrame; 571 572 width = m_h264_parser.pictureWidth(); 573 height = m_h264_parser.pictureHeight(); 574 aspectRatio = m_h264_parser.aspectRatio(); 570 575 } 571 width = m_h264_parser.pictureWidth();572 height = m_h264_parser.pictureHeight();573 576 } 574 577 } // for (; i < TSPacket::SIZE; i++) 575 578 … … bool DTVRecorder::FindH264Keyframes(const TSPacket 586 589 _frames_written_count++; 587 590 } 588 591 592 if ((aspectRatio > 0) && (aspectRatio != m_videoAspect)) 593 { 594 m_videoAspect = aspectRatio; 595 AspectChange((AspectRatio)aspectRatio, _frames_written_count); 596 } 597 589 598 if (height && width && (height != m_videoHeight || m_videoWidth != width)) 590 599 { 591 600 m_videoHeight = height; -
libs/libmythtv/recorderbase.h
class MPUBLIC RecorderBase 217 217 ASPECT_1_1 = 0x01, 218 218 ASPECT_4_3 = 0x02, 219 219 ASPECT_16_9 = 0x03, 220 ASPECT_21_1_1 = 0x04 220 ASPECT_21_1_1 = 0x04, 221 ASPECT_OTHER = 0x05, 221 222 }; 222 223 223 224 protected: -
libs/libmythtv/mpeg/H264Parser.h
class H264Parser { 108 108 uint pictureWidth(void) const { return pic_width; } 109 109 uint pictureHeight(void) const { return pic_height; } 110 110 111 /** \brief Computes aspect ratio from picture size and sample aspect ratio 112 */ 113 uint aspectRatio(void) const; 114 111 115 uint64_t frameAUstreamOffset(void) const {return frame_start_offset;} 112 116 uint64_t keyframeAUstreamOffset(void) const {return keyframe_start_offset;} 113 117 … … class H264Parser { 177 181 uint frame_crop_right_offset; 178 182 uint frame_crop_top_offset; 179 183 uint frame_crop_bottom_offset; 184 uint8_t aspect_ratio_idc; 180 185 uint sar_width, sar_height; 181 186 182 187 uint64_t AU_offset, frame_start_offset, keyframe_start_offset; -
libs/libmythtv/mpeg/H264Parser.cpp
extern "C" { 7 7 #include "avcodec.h" 8 8 } 9 9 10 // #include <math.h>10 #include <cmath> 11 11 12 static const float eps = 1E-5; 13 12 14 /* 13 15 Most of the comments below were cut&paste from ITU-T Rec. H.264 14 16 as found here: http://www.itu.int/rec/T-REC-H.264/e … … void H264Parser::Reset(void) 129 131 pic_width = pic_height = 0; 130 132 frame_crop_left_offset = frame_crop_right_offset = 0; 131 133 frame_crop_top_offset = frame_crop_bottom_offset = 0; 134 aspect_ratio_idc = 0; 132 135 sar_width = sar_height = 0; 133 136 134 137 AU_offset = frame_start_offset = keyframe_start_offset = 0; … … void H264Parser::vui_parameters(GetBitContext * gb 819 822 present, aspect_ratio_idc value shall be inferred to be 820 823 equal to 0. 821 824 */ 822 uint8_taspect_ratio_idc = get_bits(gb, 8);825 aspect_ratio_idc = get_bits(gb, 8); 823 826 824 827 switch (aspect_ratio_idc) 825 828 { … … void H264Parser::vui_parameters(GetBitContext * gb 921 924 else 922 925 sar_width = sar_height = 0; 923 926 } 927 928 uint H264Parser::aspectRatio(void) const 929 { 930 931 double aspect = 0.0; 932 933 if (pic_height) 934 aspect = pic_width / (double)pic_height; 935 936 switch (aspect_ratio_idc) 937 { 938 case 0: 939 // Unspecified 940 break; 941 case 1: 942 // 1:1 943 break; 944 case 2: 945 // 12:11 946 aspect *= 1.0909090909090908; 947 break; 948 case 3: 949 // 10:11 950 aspect *= 0.90909090909090906; 951 break; 952 case 4: 953 // 16:11 954 aspect *= 1.4545454545454546; 955 break; 956 case 5: 957 // 40:33 958 aspect *= 1.2121212121212122; 959 break; 960 case 6: 961 // 24:11 962 aspect *= 2.1818181818181817; 963 break; 964 case 7: 965 // 20:11 966 aspect *= 1.8181818181818181; 967 break; 968 case 8: 969 // 32:11 970 aspect *= 2.9090909090909092; 971 break; 972 case 9: 973 // 80:33 974 aspect *= 2.4242424242424243; 975 break; 976 case 10: 977 // 18:11 978 aspect *= 1.6363636363636365; 979 break; 980 case 11: 981 // 15:11 982 aspect *= 1.3636363636363635; 983 break; 984 case 12: 985 // 64:33 986 aspect *= 1.9393939393939394; 987 break; 988 case 13: 989 // 160:99 990 aspect *= 1.6161616161616161; 991 break; 992 case EXTENDED_SAR: 993 if (sar_height) 994 aspect *= sar_width / (double)sar_height; 995 else 996 aspect = 0.0; 997 break; 998 } 999 1000 if (aspect == 0.0) 1001 return 0; 1002 if (fabs(aspect - 1.3333333333333333) < eps) 1003 return 2; 1004 if (fabs(aspect - 1.7777777777777777) < eps) 1005 return 3; 1006 if (fabs(aspect - 2.21) < eps) 1007 return 4; 1008 1009 return 5; 1010 } -
libs/libmythtv/programinfo.h
typedef enum { 46 46 MARK_ASPECT_4_3 = 11, 47 47 MARK_ASPECT_16_9 = 12, 48 48 MARK_ASPECT_21_1_1 = 13, 49 MARK_ASPECT_OTHER = 14, 49 50 MARK_VIDEO_WIDTH = 30, 50 51 MARK_VIDEO_HEIGHT = 31, 51 52 } MarkTypes;