Mercurial > libavcodec.hg
comparison h264.c @ 8263:2e8368ea591a libavcodec
Check that cpb_count is within the allowed range.
author | michael |
---|---|
date | Fri, 05 Dec 2008 21:44:18 +0000 |
parents | 61b5b99f3b77 |
children | 0de488aa4fb0 |
comparison
equal
deleted
inserted
replaced
8262:f0bf2db65dc3 | 8263:2e8368ea591a |
---|---|
6832 } | 6832 } |
6833 | 6833 |
6834 return 0; | 6834 return 0; |
6835 } | 6835 } |
6836 | 6836 |
6837 static inline void decode_hrd_parameters(H264Context *h, SPS *sps){ | 6837 static inline int decode_hrd_parameters(H264Context *h, SPS *sps){ |
6838 MpegEncContext * const s = &h->s; | 6838 MpegEncContext * const s = &h->s; |
6839 int cpb_count, i; | 6839 int cpb_count, i; |
6840 cpb_count = get_ue_golomb(&s->gb) + 1; | 6840 cpb_count = get_ue_golomb(&s->gb) + 1; |
6841 | |
6842 if(cpb_count > 32U){ | |
6843 av_log(h->s.avctx, AV_LOG_ERROR, "cpb_count %d invalid\n", cpb_count); | |
6844 return -1; | |
6845 } | |
6846 | |
6841 get_bits(&s->gb, 4); /* bit_rate_scale */ | 6847 get_bits(&s->gb, 4); /* bit_rate_scale */ |
6842 get_bits(&s->gb, 4); /* cpb_size_scale */ | 6848 get_bits(&s->gb, 4); /* cpb_size_scale */ |
6843 for(i=0; i<cpb_count; i++){ | 6849 for(i=0; i<cpb_count; i++){ |
6844 get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */ | 6850 get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */ |
6845 get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */ | 6851 get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */ |
6847 } | 6853 } |
6848 get_bits(&s->gb, 5); /* initial_cpb_removal_delay_length_minus1 */ | 6854 get_bits(&s->gb, 5); /* initial_cpb_removal_delay_length_minus1 */ |
6849 sps->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; | 6855 sps->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; |
6850 sps->dpb_output_delay_length = get_bits(&s->gb, 5) + 1; | 6856 sps->dpb_output_delay_length = get_bits(&s->gb, 5) + 1; |
6851 sps->time_offset_length = get_bits(&s->gb, 5); | 6857 sps->time_offset_length = get_bits(&s->gb, 5); |
6858 return 0; | |
6852 } | 6859 } |
6853 | 6860 |
6854 static inline int decode_vui_parameters(H264Context *h, SPS *sps){ | 6861 static inline int decode_vui_parameters(H264Context *h, SPS *sps){ |
6855 MpegEncContext * const s = &h->s; | 6862 MpegEncContext * const s = &h->s; |
6856 int aspect_ratio_info_present_flag; | 6863 int aspect_ratio_info_present_flag; |
6901 sps->fixed_frame_rate_flag = get_bits1(&s->gb); | 6908 sps->fixed_frame_rate_flag = get_bits1(&s->gb); |
6902 } | 6909 } |
6903 | 6910 |
6904 sps->nal_hrd_parameters_present_flag = get_bits1(&s->gb); | 6911 sps->nal_hrd_parameters_present_flag = get_bits1(&s->gb); |
6905 if(sps->nal_hrd_parameters_present_flag) | 6912 if(sps->nal_hrd_parameters_present_flag) |
6906 decode_hrd_parameters(h, sps); | 6913 if(decode_hrd_parameters(h, sps) < 0) |
6914 return -1; | |
6907 sps->vcl_hrd_parameters_present_flag = get_bits1(&s->gb); | 6915 sps->vcl_hrd_parameters_present_flag = get_bits1(&s->gb); |
6908 if(sps->vcl_hrd_parameters_present_flag) | 6916 if(sps->vcl_hrd_parameters_present_flag) |
6909 decode_hrd_parameters(h, sps); | 6917 if(decode_hrd_parameters(h, sps) < 0) |
6918 return -1; | |
6910 if(sps->nal_hrd_parameters_present_flag || sps->vcl_hrd_parameters_present_flag) | 6919 if(sps->nal_hrd_parameters_present_flag || sps->vcl_hrd_parameters_present_flag) |
6911 get_bits1(&s->gb); /* low_delay_hrd_flag */ | 6920 get_bits1(&s->gb); /* low_delay_hrd_flag */ |
6912 sps->pic_struct_present_flag = get_bits1(&s->gb); | 6921 sps->pic_struct_present_flag = get_bits1(&s->gb); |
6913 | 6922 |
6914 sps->bitstream_restriction_flag = get_bits1(&s->gb); | 6923 sps->bitstream_restriction_flag = get_bits1(&s->gb); |