Mercurial > libavcodec.hg
comparison h264.c @ 8972:eaf39f9b25df libavcodec
Parse buffering period (H.264, D.1.1).
Patch by Ivan Schreter, schreter gmx net
author | cehoyos |
---|---|
date | Wed, 18 Feb 2009 23:33:30 +0000 |
parents | 9757b2f87d83 |
children | bf9d9a79a737 |
comparison
equal
deleted
inserted
replaced
8971:734114ba02fa | 8972:eaf39f9b25df |
---|---|
2209 h->outputed_poc = INT_MIN; | 2209 h->outputed_poc = INT_MIN; |
2210 h->prev_poc_msb= 1<<16; | 2210 h->prev_poc_msb= 1<<16; |
2211 h->sei_recovery_frame_cnt = -1; | 2211 h->sei_recovery_frame_cnt = -1; |
2212 h->sei_dpb_output_delay = 0; | 2212 h->sei_dpb_output_delay = 0; |
2213 h->sei_cpb_removal_delay = -1; | 2213 h->sei_cpb_removal_delay = -1; |
2214 h->sei_buffering_period_present = 0; | |
2214 return 0; | 2215 return 0; |
2215 } | 2216 } |
2216 | 2217 |
2217 static int frame_start(H264Context *h){ | 2218 static int frame_start(H264Context *h){ |
2218 MpegEncContext * const s = &h->s; | 2219 MpegEncContext * const s = &h->s; |
3146 h->s.current_picture_ptr->reference= 0; | 3147 h->s.current_picture_ptr->reference= 0; |
3147 h->s.first_field= 0; | 3148 h->s.first_field= 0; |
3148 h->sei_recovery_frame_cnt = -1; | 3149 h->sei_recovery_frame_cnt = -1; |
3149 h->sei_dpb_output_delay = 0; | 3150 h->sei_dpb_output_delay = 0; |
3150 h->sei_cpb_removal_delay = -1; | 3151 h->sei_cpb_removal_delay = -1; |
3152 h->sei_buffering_period_present = 0; | |
3151 ff_mpeg_flush(avctx); | 3153 ff_mpeg_flush(avctx); |
3152 } | 3154 } |
3153 | 3155 |
3154 /** | 3156 /** |
3155 * Find a Picture in the short term reference list by frame number. | 3157 * Find a Picture in the short term reference list by frame number. |
6862 skip_bits(&s->gb, 4); /* 1b exact_match_flag, 1b broken_link_flag, 2b changing_slice_group_idc */ | 6864 skip_bits(&s->gb, 4); /* 1b exact_match_flag, 1b broken_link_flag, 2b changing_slice_group_idc */ |
6863 | 6865 |
6864 return 0; | 6866 return 0; |
6865 } | 6867 } |
6866 | 6868 |
6869 static int decode_buffering_period(H264Context *h){ | |
6870 MpegEncContext * const s = &h->s; | |
6871 unsigned int sps_id; | |
6872 int sched_sel_idx; | |
6873 SPS *sps; | |
6874 | |
6875 sps_id = get_ue_golomb_31(&s->gb); | |
6876 if(sps_id > 31 || !h->sps_buffers[sps_id]) { | |
6877 av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %d referenced in buffering period\n", sps_id); | |
6878 return -1; | |
6879 } | |
6880 sps = h->sps_buffers[sps_id]; | |
6881 | |
6882 // NOTE: This is really so duplicated in the standard... See H.264, D.1.1 | |
6883 if (sps->nal_hrd_parameters_present_flag) { | |
6884 for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) { | |
6885 h->initial_cpb_removal_delay[sched_sel_idx] = get_bits(&s->gb, sps->initial_cpb_removal_delay_length); | |
6886 skip_bits(&s->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset | |
6887 } | |
6888 } | |
6889 if (sps->vcl_hrd_parameters_present_flag) { | |
6890 for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) { | |
6891 h->initial_cpb_removal_delay[sched_sel_idx] = get_bits(&s->gb, sps->initial_cpb_removal_delay_length); | |
6892 skip_bits(&s->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset | |
6893 } | |
6894 } | |
6895 | |
6896 h->sei_buffering_period_present = 1; | |
6897 return 0; | |
6898 } | |
6899 | |
6867 static int decode_sei(H264Context *h){ | 6900 static int decode_sei(H264Context *h){ |
6868 MpegEncContext * const s = &h->s; | 6901 MpegEncContext * const s = &h->s; |
6869 | 6902 |
6870 while(get_bits_count(&s->gb) + 16 < s->gb.size_in_bits){ | 6903 while(get_bits_count(&s->gb) + 16 < s->gb.size_in_bits){ |
6871 int size, type; | 6904 int size, type; |
6889 if(decode_unregistered_user_data(h, size) < 0) | 6922 if(decode_unregistered_user_data(h, size) < 0) |
6890 return -1; | 6923 return -1; |
6891 break; | 6924 break; |
6892 case SEI_TYPE_RECOVERY_POINT: | 6925 case SEI_TYPE_RECOVERY_POINT: |
6893 if(decode_recovery_point(h) < 0) | 6926 if(decode_recovery_point(h) < 0) |
6927 return -1; | |
6928 break; | |
6929 case SEI_BUFFERING_PERIOD: | |
6930 if(decode_buffering_period(h) < 0) | |
6894 return -1; | 6931 return -1; |
6895 break; | 6932 break; |
6896 default: | 6933 default: |
6897 skip_bits(&s->gb, 8*size); | 6934 skip_bits(&s->gb, 8*size); |
6898 } | 6935 } |
7696 | 7733 |
7697 MPV_frame_end(s); | 7734 MPV_frame_end(s); |
7698 h->sei_recovery_frame_cnt = -1; | 7735 h->sei_recovery_frame_cnt = -1; |
7699 h->sei_dpb_output_delay = 0; | 7736 h->sei_dpb_output_delay = 0; |
7700 h->sei_cpb_removal_delay = -1; | 7737 h->sei_cpb_removal_delay = -1; |
7738 h->sei_buffering_period_present = 0; | |
7701 | 7739 |
7702 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { | 7740 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { |
7703 /* Wait for second field. */ | 7741 /* Wait for second field. */ |
7704 *data_size = 0; | 7742 *data_size = 0; |
7705 | 7743 |