diff options
Diffstat (limited to 'abs/core-testing/mythtv/trunk/mythtv/H264Parser-fixes-v1.1.patch')
-rw-r--r-- | abs/core-testing/mythtv/trunk/mythtv/H264Parser-fixes-v1.1.patch | 368 |
1 files changed, 0 insertions, 368 deletions
diff --git a/abs/core-testing/mythtv/trunk/mythtv/H264Parser-fixes-v1.1.patch b/abs/core-testing/mythtv/trunk/mythtv/H264Parser-fixes-v1.1.patch deleted file mode 100644 index f8e2100..0000000 --- a/abs/core-testing/mythtv/trunk/mythtv/H264Parser-fixes-v1.1.patch +++ /dev/null @@ -1,368 +0,0 @@ -Index: libs/libmythtv/mpeg/H264Parser.cpp -=================================================================== ---- libs/libmythtv/mpeg/H264Parser.cpp.orig -+++ libs/libmythtv/mpeg/H264Parser.cpp -@@ -3,7 +3,9 @@ - - extern "C" { - // from libavcodec -- extern const uint8_t *ff_find_start_code(const uint8_t * p, const uint8_t *end, uint32_t * state); -+ extern const uint8_t *ff_find_start_code(const uint8_t * p, -+ const uint8_t *end, -+ uint32_t * state); - #include "avcodec.h" - } - -@@ -88,19 +90,18 @@ static const float eps = 1E-5; - H264Parser::H264Parser(void) - { - Reset(); -+ I_is_keyframe = false; - } - - void H264Parser::Reset(void) - { - state_changed = false; -- seen_sps = seen_IDR = false; -+ seen_sps = false; -+ is_keyframe = false; - - sync_accumulator = 0xffffffff; -- find_AU = false; - AU_pending = false; - -- NAL_type = UNKNOWN; -- - frame_num = prev_frame_num = -1; - slice_type = SLICE_UNDEF; - prev_pic_parameter_set_id = pic_parameter_set_id = -1; -@@ -112,7 +113,7 @@ void H264Parser::Reset(void) - prev_delta_pic_order_cnt_bottom = delta_pic_order_cnt_bottom = 0; - prev_delta_pic_order_cnt[0] = delta_pic_order_cnt[0] = 0; - prev_delta_pic_order_cnt[1] = delta_pic_order_cnt[1] = 0; -- prev_nal_unit_type = nal_unit_type = 0; -+ prev_nal_unit_type = nal_unit_type = UNKNOWN; - prev_idr_pic_id = idr_pic_id = 0; - - log2_max_frame_num = log2_max_pic_order_cnt_lsb = 0; -@@ -136,8 +137,6 @@ void H264Parser::Reset(void) - - AU_offset = frame_start_offset = keyframe_start_offset = 0; - on_frame = on_key_frame = false; -- -- wait_for_IDR = false; - } - - -@@ -214,13 +213,7 @@ bool H264Parser::new_AU(void) - { - // Need previous slice information for comparison - -- if (NAL_type == AU_DELIMITER || -- NAL_type == SPS || -- NAL_type == PPS || -- NAL_type == SEI || -- (NAL_type > SPS_EXT && NAL_type < AUXILIARY_SLICE)) -- result = true; -- else if (NAL_type != SLICE_IDR && frame_num != prev_frame_num) -+ if (nal_unit_type != SLICE_IDR && frame_num != prev_frame_num) - result = true; - else if (prev_pic_parameter_set_id != -1 && - pic_parameter_set_id != prev_pic_parameter_set_id) -@@ -230,9 +223,6 @@ bool H264Parser::new_AU(void) - else if ((bottom_field_flag != -1 && prev_bottom_field_flag != -1) && - bottom_field_flag != prev_bottom_field_flag) - result = true; -- else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) && -- nal_ref_idc != prev_nal_ref_idc) -- result = true; - else if ((pic_order_cnt_type == 0 && prev_pic_order_cnt_type == 0) && - (pic_order_cnt_lsb != prev_pic_order_cnt_lsb || - delta_pic_order_cnt_bottom != -@@ -256,7 +246,6 @@ bool H264Parser::new_AU(void) - prev_pic_parameter_set_id = pic_parameter_set_id; - prev_field_pic_flag = field_pic_flag; - prev_bottom_field_flag = bottom_field_flag; -- prev_nal_ref_idc = nal_ref_idc; - prev_pic_order_cnt_lsb = pic_order_cnt_lsb; - prev_delta_pic_order_cnt_bottom = delta_pic_order_cnt_bottom; - prev_delta_pic_order_cnt[0] = delta_pic_order_cnt[0]; -@@ -273,7 +262,7 @@ uint32_t H264Parser::addBytes(const uint - { - const uint8_t *byteP = bytes; - const uint8_t *endP = bytes + byte_count; -- -+ const uint8_t *nalP; - uint8_t first_byte; - - state_changed = false; -@@ -305,10 +294,11 @@ uint32_t H264Parser::addBytes(const uint - 11 End of stream end_of_stream_rbsp( ) - */ - first_byte = *(byteP - 1); -- NAL_type = first_byte & 0x1f; -+ nal_unit_type = first_byte & 0x1f; - nal_ref_idc = (first_byte >> 5) & 0x3; - -- if (NALisSlice(NAL_type) || NAL_type == SPS || NAL_type == PPS) -+ if (nal_unit_type == SPS || nal_unit_type == PPS || -+ nal_unit_type == SEI || NALisSlice(nal_unit_type)) - { - /* - bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE -@@ -318,27 +308,51 @@ uint32_t H264Parser::addBytes(const uint - { - init_get_bits(&gb, byteP, 8 * (endP - byteP)); - -- if (NAL_type == SPS) -+ if (nal_unit_type == SEI) -+ { -+ nalP = ff_find_start_code(byteP+1, endP, -+ &sync_accumulator) - 8; -+ decode_SEI(&gb, (nalP - byteP) * 8); -+ set_AU_pending(stream_offset); -+ } -+ else if (nal_unit_type == SPS) -+ { - decode_SPS(&gb); -- else if (NAL_type == PPS) -+ set_AU_pending(stream_offset); -+ } -+ else if (nal_unit_type == PPS) -+ { - decode_PPS(&gb); -+ set_AU_pending(stream_offset); -+ } - else -- find_AU = decode_Header(&gb); -+ { -+ decode_Header(&gb); -+ if (new_AU()) -+ set_AU_pending(stream_offset); -+ } - - byteP += (get_bits_count(&gb) / 8); - } - } -- -- if (find_AU && new_AU()) -+ else if (!AU_pending) - { -- /* After finding a new AU, don't look for another one -- until we decode a SLICE */ -- find_AU = false; -- AU_pending = true; -- AU_offset = stream_offset; -+ if (nal_unit_type == AU_DELIMITER || -+ (nal_unit_type > SPS_EXT && -+ nal_unit_type < AUXILIARY_SLICE)) -+ { -+ AU_pending = true; -+ AU_offset = stream_offset; -+ } -+ else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) && -+ nal_ref_idc != prev_nal_ref_idc) -+ { -+ AU_pending = true; -+ AU_offset = stream_offset; -+ } - } -- -- if (AU_pending && NALisSlice(NAL_type)) -+ -+ if (AU_pending && NALisSlice(nal_unit_type)) - { - /* Once we know the slice type of a new AU, we can - * determine if it is a keyframe or just a frame */ -@@ -349,10 +363,11 @@ uint32_t H264Parser::addBytes(const uint - on_frame = true; - frame_start_offset = AU_offset; - -- if (isKeySlice(slice_type) && (!wait_for_IDR || seen_IDR)) -+ if (is_keyframe) - { - on_key_frame = true; - keyframe_start_offset = AU_offset; -+ is_keyframe = false; - } - else - on_key_frame = false; -@@ -360,6 +375,8 @@ uint32_t H264Parser::addBytes(const uint - else - on_frame = on_key_frame = false; - -+ prev_nal_ref_idc = nal_ref_idc; -+ - return byteP - bytes; - } - } -@@ -440,8 +457,6 @@ bool H264Parser::decode_Header(GetBitCon - */ - - frame_num = get_bits(gb, log2_max_frame_num); -- if (NAL_type == SLICE_IDR || frame_num == 0) -- seen_IDR = true; - - /* - field_pic_flag equal to 1 specifies that the slice is a slice of a -@@ -475,8 +490,14 @@ bool H264Parser::decode_Header(GetBitCon - second such IDR access unit. The value of idr_pic_id shall be in - the range of 0 to 65535, inclusive. - */ -+ - if (nal_unit_type == SLICE_IDR) -+ { -+ is_keyframe = true; - idr_pic_id = get_ue_golomb(gb); -+ } -+ else -+ is_keyframe |= (I_is_keyframe && isKeySlice(slice_type)); - - /* - pic_order_cnt_lsb specifies the picture order count modulo -@@ -806,6 +827,44 @@ void H264Parser::decode_PPS(GetBitContex - #endif - } - -+void H264Parser::decode_SEI(GetBitContext * gb, int bitlen) -+{ -+ int recovery_frame_cnt = -1; -+ bool exact_match_flag = false; -+ bool broken_link_flag = false; -+ int changing_group_slice_idc = -1; -+ -+ while (get_bits_count(gb) < bitlen) -+ { -+ int type = 0, size = 0; -+ -+ do { -+ type += show_bits(gb, 8); -+ } while (get_bits(gb, 8) == 255); -+ -+ do { -+ size += show_bits(gb, 8); -+ } while (get_bits(gb, 8) == 255); -+ -+ switch (type) -+ { -+ case SEI_TYPE_RECOVERY_POINT: -+ recovery_frame_cnt = get_ue_golomb(gb); -+ exact_match_flag = get_bits1(gb); -+ broken_link_flag = get_bits1(gb); -+ changing_group_slice_idc = get_bits(gb, 2); -+ is_keyframe |= (recovery_frame_cnt >= 0); -+ return; -+ -+ default: -+ skip_bits(gb, size * 8); -+ break; -+ } -+ -+ align_get_bits(gb); -+ } -+} -+ - void H264Parser::vui_parameters(GetBitContext * gb) - { - /* -Index: libs/libmythtv/mpeg/H264Parser.h -=================================================================== ---- libs/libmythtv/mpeg/H264Parser.h.orig -+++ libs/libmythtv/mpeg/H264Parser.h -@@ -53,6 +53,12 @@ class H264Parser { - AUXILIARY_SLICE = 19 - }; - -+ enum SEI_type { -+ SEI_TYPE_PIC_TIMING = 1, -+ SEI_TYPE_USER_DATA_UNREGISTERED = 5, -+ SEI_TYPE_RECOVERY_POINT = 6 -+ }; -+ - /* - slice_type values in the range 5..9 specify, in addition to the - coding type of the current slice, that all other slices of the -@@ -90,9 +96,7 @@ class H264Parser { - - bool stateChanged(void) const { return state_changed; } - -- // seenIDR implies that a SPS has also been seen -- bool seenIDR(void) const { return seen_IDR; } -- uint8_t lastNALtype(void) const { return NAL_type; } -+ uint8_t lastNALtype(void) const { return nal_unit_type; } - - frame_type FieldType(void) const - { -@@ -130,29 +134,36 @@ class H264Parser { - nal_type == SLICE_IDR); - } - -- void waitForIDR(bool wait) { wait_for_IDR = wait; } -+ void use_I_forKeyframes(bool val) { I_is_keyframe = val; } - - private: - enum constants {EXTENDED_SAR = 255}; - -- bool is_first_VCL_NAL_unit(void); -+ inline void set_AU_pending(const uint64_t & stream_offset) -+ { -+ if (!AU_pending) -+ { -+ AU_pending = true; -+ AU_offset = stream_offset; -+ } -+ } -+ - bool new_AU(void); - bool decode_Header(GetBitContext *gb); - void decode_SPS(GetBitContext *gb); - void decode_PPS(GetBitContext * gb); -+ void decode_SEI(GetBitContext * gb, int len); - void vui_parameters(GetBitContext * gb); - -- bool find_AU; - bool AU_pending; - bool state_changed; - bool seen_sps; -- bool seen_IDR; -+ bool is_keyframe; -+ bool I_is_keyframe; - - uint32_t sync_accumulator; - GetBitContext gb; - -- uint8_t NAL_type; -- - int prev_frame_num, frame_num; - uint slice_type; - int prev_pic_parameter_set_id, pic_parameter_set_id; -@@ -188,8 +199,6 @@ class H264Parser { - - uint64_t AU_offset, frame_start_offset, keyframe_start_offset; - bool on_frame, on_key_frame; -- -- bool wait_for_IDR; - }; - - #endif /* H264PARSER_H */ -Index: libs/libmythtv/mpegrecorder.cpp -=================================================================== ---- libs/libmythtv/mpegrecorder.cpp.orig -+++ libs/libmythtv/mpegrecorder.cpp -@@ -423,6 +423,7 @@ bool MpegRecorder::OpenV4L2DeviceAsInput - bzero(_stream_id, sizeof(_stream_id)); - bzero(_pid_status, sizeof(_pid_status)); - memset(_continuity_counter, 0xff, sizeof(_continuity_counter)); -+ m_h264_parser.use_I_forKeyframes(true); - } - else - { -@@ -1373,8 +1374,6 @@ void MpegRecorder::ResetForNewFile(void) - bzero(_stream_id, sizeof(_stream_id)); - bzero(_pid_status, sizeof(_pid_status)); - memset(_continuity_counter, 0xff, sizeof(_continuity_counter)); -- -- m_h264_parser.waitForIDR(true); - } - - void MpegRecorder::Reset(void) |