diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-02-03 11:10:05 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-02-15 16:35:16 +0100 |
commit | 2c541554076cc8a72e7145d4da30389ca763f32f (patch) | |
tree | b404051a202e1ffffe4ecee2df1b89f9f92a70f5 /libavcodec/h264_sei.c | |
parent | 1d0feb5d1ac04d187b335f0e8d411c9f40b3a885 (diff) | |
download | ffmpeg-2c541554076cc8a72e7145d4da30389ca763f32f.tar.gz |
h264: deMpegEncContextize
Most of the changes are just trivial are just trivial replacements of
fields from MpegEncContext with equivalent fields in H264Context.
Everything in h264* other than h264.c are those trivial changes.
The nontrivial parts are:
1) extracting a simplified version of the frame management code from
mpegvideo.c. We don't need last/next_picture anymore, since h264 uses
its own more complex system already and those were set only to appease
the mpegvideo parts.
2) some tables that need to be allocated/freed in appropriate places.
3) hwaccels -- mostly trivial replacements.
for dxva, the draw_horiz_band() call is moved from
ff_dxva2_common_end_frame() to per-codec end_frame() callbacks,
because it's now different for h264 and MpegEncContext-based
decoders.
4) svq3 -- it does not use h264 complex reference system, so I just
added some very simplistic frame management instead and dropped the
use of ff_h264_frame_start(). Because of this I also had to move some
initialization code to svq3.
Additional fixes for chroma format and bit depth changes by
Janne Grunau <janne-libav@jannau.net>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/h264_sei.c')
-rw-r--r-- | libavcodec/h264_sei.c | 91 |
1 files changed, 42 insertions, 49 deletions
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 2e5fb65f0d..df4c49fe3e 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -45,14 +45,13 @@ void ff_h264_reset_sei(H264Context *h) { } static int decode_picture_timing(H264Context *h){ - MpegEncContext * const s = &h->s; if(h->sps.nal_hrd_parameters_present_flag || h->sps.vcl_hrd_parameters_present_flag){ - h->sei_cpb_removal_delay = get_bits(&s->gb, h->sps.cpb_removal_delay_length); - h->sei_dpb_output_delay = get_bits(&s->gb, h->sps.dpb_output_delay_length); + h->sei_cpb_removal_delay = get_bits(&h->gb, h->sps.cpb_removal_delay_length); + h->sei_dpb_output_delay = get_bits(&h->gb, h->sps.dpb_output_delay_length); } if(h->sps.pic_struct_present_flag){ unsigned int i, num_clock_ts; - h->sei_pic_struct = get_bits(&s->gb, 4); + h->sei_pic_struct = get_bits(&h->gb, 4); h->sei_ct_type = 0; if (h->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING) @@ -61,42 +60,41 @@ static int decode_picture_timing(H264Context *h){ num_clock_ts = sei_num_clock_ts_table[h->sei_pic_struct]; for (i = 0 ; i < num_clock_ts ; i++){ - if(get_bits(&s->gb, 1)){ /* clock_timestamp_flag */ + if(get_bits(&h->gb, 1)){ /* clock_timestamp_flag */ unsigned int full_timestamp_flag; - h->sei_ct_type |= 1<<get_bits(&s->gb, 2); - skip_bits(&s->gb, 1); /* nuit_field_based_flag */ - skip_bits(&s->gb, 5); /* counting_type */ - full_timestamp_flag = get_bits(&s->gb, 1); - skip_bits(&s->gb, 1); /* discontinuity_flag */ - skip_bits(&s->gb, 1); /* cnt_dropped_flag */ - skip_bits(&s->gb, 8); /* n_frames */ + h->sei_ct_type |= 1<<get_bits(&h->gb, 2); + skip_bits(&h->gb, 1); /* nuit_field_based_flag */ + skip_bits(&h->gb, 5); /* counting_type */ + full_timestamp_flag = get_bits(&h->gb, 1); + skip_bits(&h->gb, 1); /* discontinuity_flag */ + skip_bits(&h->gb, 1); /* cnt_dropped_flag */ + skip_bits(&h->gb, 8); /* n_frames */ if(full_timestamp_flag){ - skip_bits(&s->gb, 6); /* seconds_value 0..59 */ - skip_bits(&s->gb, 6); /* minutes_value 0..59 */ - skip_bits(&s->gb, 5); /* hours_value 0..23 */ + skip_bits(&h->gb, 6); /* seconds_value 0..59 */ + skip_bits(&h->gb, 6); /* minutes_value 0..59 */ + skip_bits(&h->gb, 5); /* hours_value 0..23 */ }else{ - if(get_bits(&s->gb, 1)){ /* seconds_flag */ - skip_bits(&s->gb, 6); /* seconds_value range 0..59 */ - if(get_bits(&s->gb, 1)){ /* minutes_flag */ - skip_bits(&s->gb, 6); /* minutes_value 0..59 */ - if(get_bits(&s->gb, 1)) /* hours_flag */ - skip_bits(&s->gb, 5); /* hours_value 0..23 */ + if(get_bits(&h->gb, 1)){ /* seconds_flag */ + skip_bits(&h->gb, 6); /* seconds_value range 0..59 */ + if(get_bits(&h->gb, 1)){ /* minutes_flag */ + skip_bits(&h->gb, 6); /* minutes_value 0..59 */ + if(get_bits(&h->gb, 1)) /* hours_flag */ + skip_bits(&h->gb, 5); /* hours_value 0..23 */ } } } if(h->sps.time_offset_length > 0) - skip_bits(&s->gb, h->sps.time_offset_length); /* time_offset */ + skip_bits(&h->gb, h->sps.time_offset_length); /* time_offset */ } } - if(s->avctx->debug & FF_DEBUG_PICT_INFO) - av_log(s->avctx, AV_LOG_DEBUG, "ct_type:%X pic_struct:%d\n", h->sei_ct_type, h->sei_pic_struct); + if(h->avctx->debug & FF_DEBUG_PICT_INFO) + av_log(h->avctx, AV_LOG_DEBUG, "ct_type:%X pic_struct:%d\n", h->sei_ct_type, h->sei_pic_struct); } return 0; } static int decode_unregistered_user_data(H264Context *h, int size){ - MpegEncContext * const s = &h->s; uint8_t user_data[16+256]; int e, build, i; @@ -104,7 +102,7 @@ static int decode_unregistered_user_data(H264Context *h, int size){ return -1; for(i=0; i<sizeof(user_data)-1 && i<size; i++){ - user_data[i]= get_bits(&s->gb, 8); + user_data[i]= get_bits(&h->gb, 8); } user_data[i]= 0; @@ -112,33 +110,30 @@ static int decode_unregistered_user_data(H264Context *h, int size){ if(e==1 && build>0) h->x264_build= build; - if(s->avctx->debug & FF_DEBUG_BUGS) - av_log(s->avctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data+16); + if(h->avctx->debug & FF_DEBUG_BUGS) + av_log(h->avctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data+16); for(; i<size; i++) - skip_bits(&s->gb, 8); + skip_bits(&h->gb, 8); return 0; } static int decode_recovery_point(H264Context *h){ - MpegEncContext * const s = &h->s; - - h->sei_recovery_frame_cnt = get_ue_golomb(&s->gb); - skip_bits(&s->gb, 4); /* 1b exact_match_flag, 1b broken_link_flag, 2b changing_slice_group_idc */ + h->sei_recovery_frame_cnt = get_ue_golomb(&h->gb); + skip_bits(&h->gb, 4); /* 1b exact_match_flag, 1b broken_link_flag, 2b changing_slice_group_idc */ return 0; } static int decode_buffering_period(H264Context *h){ - MpegEncContext * const s = &h->s; unsigned int sps_id; int sched_sel_idx; SPS *sps; - sps_id = get_ue_golomb_31(&s->gb); + sps_id = get_ue_golomb_31(&h->gb); if(sps_id > 31 || !h->sps_buffers[sps_id]) { - av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %d referenced in buffering period\n", sps_id); + av_log(h->avctx, AV_LOG_ERROR, "non-existing SPS %d referenced in buffering period\n", sps_id); return -1; } sps = h->sps_buffers[sps_id]; @@ -146,14 +141,14 @@ static int decode_buffering_period(H264Context *h){ // NOTE: This is really so duplicated in the standard... See H.264, D.1.1 if (sps->nal_hrd_parameters_present_flag) { for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) { - h->initial_cpb_removal_delay[sched_sel_idx] = get_bits(&s->gb, sps->initial_cpb_removal_delay_length); - skip_bits(&s->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset + h->initial_cpb_removal_delay[sched_sel_idx] = get_bits(&h->gb, sps->initial_cpb_removal_delay_length); + skip_bits(&h->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset } } if (sps->vcl_hrd_parameters_present_flag) { for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) { - h->initial_cpb_removal_delay[sched_sel_idx] = get_bits(&s->gb, sps->initial_cpb_removal_delay_length); - skip_bits(&s->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset + h->initial_cpb_removal_delay[sched_sel_idx] = get_bits(&h->gb, sps->initial_cpb_removal_delay_length); + skip_bits(&h->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset } } @@ -162,20 +157,18 @@ static int decode_buffering_period(H264Context *h){ } int ff_h264_decode_sei(H264Context *h){ - MpegEncContext * const s = &h->s; - - while (get_bits_left(&s->gb) > 16) { + while (get_bits_left(&h->gb) > 16) { int size, type; type=0; do{ - type+= show_bits(&s->gb, 8); - }while(get_bits(&s->gb, 8) == 255); + type+= show_bits(&h->gb, 8); + }while(get_bits(&h->gb, 8) == 255); size=0; do{ - size+= show_bits(&s->gb, 8); - }while(get_bits(&s->gb, 8) == 255); + size+= show_bits(&h->gb, 8); + }while(get_bits(&h->gb, 8) == 255); switch(type){ case SEI_TYPE_PIC_TIMING: // Picture timing SEI @@ -195,11 +188,11 @@ int ff_h264_decode_sei(H264Context *h){ return -1; break; default: - skip_bits(&s->gb, 8*size); + skip_bits(&h->gb, 8*size); } //FIXME check bits here - align_get_bits(&s->gb); + align_get_bits(&h->gb); } return 0; |