comparison h264.c @ 8235:61b5b99f3b77 libavcodec

Get rid of now unneeded pps/sps correctness code as pps/sps will not be used at all when anything fails sanity checks.
author michael
date Mon, 01 Dec 2008 16:24:19 +0000
parents 4a8f9bbc5e81
children 2e8368ea591a
comparison
equal deleted inserted replaced
8234:4a8f9bbc5e81 8235:61b5b99f3b77
6911 get_bits1(&s->gb); /* low_delay_hrd_flag */ 6911 get_bits1(&s->gb); /* low_delay_hrd_flag */
6912 sps->pic_struct_present_flag = get_bits1(&s->gb); 6912 sps->pic_struct_present_flag = get_bits1(&s->gb);
6913 6913
6914 sps->bitstream_restriction_flag = get_bits1(&s->gb); 6914 sps->bitstream_restriction_flag = get_bits1(&s->gb);
6915 if(sps->bitstream_restriction_flag){ 6915 if(sps->bitstream_restriction_flag){
6916 unsigned int num_reorder_frames;
6917 get_bits1(&s->gb); /* motion_vectors_over_pic_boundaries_flag */ 6916 get_bits1(&s->gb); /* motion_vectors_over_pic_boundaries_flag */
6918 get_ue_golomb(&s->gb); /* max_bytes_per_pic_denom */ 6917 get_ue_golomb(&s->gb); /* max_bytes_per_pic_denom */
6919 get_ue_golomb(&s->gb); /* max_bits_per_mb_denom */ 6918 get_ue_golomb(&s->gb); /* max_bits_per_mb_denom */
6920 get_ue_golomb(&s->gb); /* log2_max_mv_length_horizontal */ 6919 get_ue_golomb(&s->gb); /* log2_max_mv_length_horizontal */
6921 get_ue_golomb(&s->gb); /* log2_max_mv_length_vertical */ 6920 get_ue_golomb(&s->gb); /* log2_max_mv_length_vertical */
6922 num_reorder_frames= get_ue_golomb(&s->gb); 6921 sps->num_reorder_frames= get_ue_golomb(&s->gb);
6923 get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/ 6922 get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/
6924 6923
6925 if(num_reorder_frames > 16 /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){ 6924 if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
6926 av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", num_reorder_frames); 6925 av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames);
6927 return -1; 6926 return -1;
6928 } 6927 }
6929
6930 sps->num_reorder_frames= num_reorder_frames;
6931 } 6928 }
6932 6929
6933 return 0; 6930 return 0;
6934 } 6931 }
6935 6932
6978 } 6975 }
6979 6976
6980 static inline int decode_seq_parameter_set(H264Context *h){ 6977 static inline int decode_seq_parameter_set(H264Context *h){
6981 MpegEncContext * const s = &h->s; 6978 MpegEncContext * const s = &h->s;
6982 int profile_idc, level_idc; 6979 int profile_idc, level_idc;
6983 unsigned int sps_id, tmp, mb_width, mb_height; 6980 unsigned int sps_id;
6984 int i; 6981 int i;
6985 SPS *sps; 6982 SPS *sps;
6986 6983
6987 profile_idc= get_bits(&s->gb, 8); 6984 profile_idc= get_bits(&s->gb, 8);
6988 get_bits1(&s->gb); //constraint_set0_flag 6985 get_bits1(&s->gb); //constraint_set0_flag
7027 sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4; 7024 sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4;
7028 } else if(sps->poc_type == 1){//FIXME #define 7025 } else if(sps->poc_type == 1){//FIXME #define
7029 sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb); 7026 sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
7030 sps->offset_for_non_ref_pic= get_se_golomb(&s->gb); 7027 sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
7031 sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb); 7028 sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
7032 tmp= get_ue_golomb(&s->gb); 7029 sps->poc_cycle_length = get_ue_golomb(&s->gb);
7033 7030
7034 if(tmp >= FF_ARRAY_ELEMS(sps->offset_for_ref_frame)){ 7031 if((unsigned)sps->poc_cycle_length >= FF_ARRAY_ELEMS(sps->offset_for_ref_frame)){
7035 av_log(h->s.avctx, AV_LOG_ERROR, "poc_cycle_length overflow %u\n", tmp); 7032 av_log(h->s.avctx, AV_LOG_ERROR, "poc_cycle_length overflow %u\n", sps->poc_cycle_length);
7036 goto fail; 7033 goto fail;
7037 } 7034 }
7038 sps->poc_cycle_length= tmp;
7039 7035
7040 for(i=0; i<sps->poc_cycle_length; i++) 7036 for(i=0; i<sps->poc_cycle_length; i++)
7041 sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb); 7037 sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
7042 }else if(sps->poc_type != 2){ 7038 }else if(sps->poc_type != 2){
7043 av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type); 7039 av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
7044 goto fail; 7040 goto fail;
7045 } 7041 }
7046 7042
7047 tmp= get_ue_golomb(&s->gb); 7043 sps->ref_frame_count= get_ue_golomb(&s->gb);
7048 if(tmp > MAX_PICTURE_COUNT-2 || tmp >= 32){ 7044 if(sps->ref_frame_count > MAX_PICTURE_COUNT-2 || sps->ref_frame_count >= 32U){
7049 av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n"); 7045 av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
7050 goto fail; 7046 goto fail;
7051 } 7047 }
7052 sps->ref_frame_count= tmp;
7053 sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb); 7048 sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
7054 mb_width= get_ue_golomb(&s->gb) + 1; 7049 sps->mb_width = get_ue_golomb(&s->gb) + 1;
7055 mb_height= get_ue_golomb(&s->gb) + 1; 7050 sps->mb_height= get_ue_golomb(&s->gb) + 1;
7056 if(mb_width >= INT_MAX/16 || mb_height >= INT_MAX/16 || 7051 if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
7057 avcodec_check_dimensions(NULL, 16*mb_width, 16*mb_height)){ 7052 avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height)){
7058 av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n"); 7053 av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
7059 goto fail; 7054 goto fail;
7060 } 7055 }
7061 sps->mb_width = mb_width;
7062 sps->mb_height= mb_height;
7063 7056
7064 sps->frame_mbs_only_flag= get_bits1(&s->gb); 7057 sps->frame_mbs_only_flag= get_bits1(&s->gb);
7065 if(!sps->frame_mbs_only_flag) 7058 if(!sps->frame_mbs_only_flag)
7066 sps->mb_aff= get_bits1(&s->gb); 7059 sps->mb_aff= get_bits1(&s->gb);
7067 else 7060 else
7126 pps->chroma_qp_table[t][i] = chroma_qp[av_clip(i + index, 0, 51)]; 7119 pps->chroma_qp_table[t][i] = chroma_qp[av_clip(i + index, 0, 51)];
7127 } 7120 }
7128 7121
7129 static inline int decode_picture_parameter_set(H264Context *h, int bit_length){ 7122 static inline int decode_picture_parameter_set(H264Context *h, int bit_length){
7130 MpegEncContext * const s = &h->s; 7123 MpegEncContext * const s = &h->s;
7131 unsigned int tmp, pps_id= get_ue_golomb(&s->gb); 7124 unsigned int pps_id= get_ue_golomb(&s->gb);
7132 PPS *pps; 7125 PPS *pps;
7133 7126
7134 if(pps_id >= MAX_PPS_COUNT) { 7127 if(pps_id >= MAX_PPS_COUNT) {
7135 av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); 7128 av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
7136 return -1; 7129 return -1;
7137 } 7130 }
7138 7131
7139 tmp= get_ue_golomb(&s->gb);
7140 if(tmp>=MAX_SPS_COUNT || h->sps_buffers[tmp] == NULL){
7141 av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n");
7142 return -1;
7143 }
7144 pps= av_mallocz(sizeof(PPS)); 7132 pps= av_mallocz(sizeof(PPS));
7145 if(pps == NULL) 7133 if(pps == NULL)
7146 return -1; 7134 return -1;
7147 pps->sps_id= tmp; 7135 pps->sps_id= get_ue_golomb(&s->gb);
7136 if((unsigned)pps->sps_id>=MAX_SPS_COUNT || h->sps_buffers[pps->sps_id] == NULL){
7137 av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n");
7138 goto fail;
7139 }
7148 7140
7149 pps->cabac= get_bits1(&s->gb); 7141 pps->cabac= get_bits1(&s->gb);
7150 pps->pic_order_present= get_bits1(&s->gb); 7142 pps->pic_order_present= get_bits1(&s->gb);
7151 pps->slice_group_count= get_ue_golomb(&s->gb) + 1; 7143 pps->slice_group_count= get_ue_golomb(&s->gb) + 1;
7152 if(pps->slice_group_count > 1 ){ 7144 if(pps->slice_group_count > 1 ){
7188 } 7180 }
7189 pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; 7181 pps->ref_count[0]= get_ue_golomb(&s->gb) + 1;
7190 pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; 7182 pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;
7191 if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){ 7183 if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){
7192 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n"); 7184 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
7193 pps->ref_count[0]= pps->ref_count[1]= 1;
7194 goto fail; 7185 goto fail;
7195 } 7186 }
7196 7187
7197 pps->weighted_pred= get_bits1(&s->gb); 7188 pps->weighted_pred= get_bits1(&s->gb);
7198 pps->weighted_bipred_idc= get_bits(&s->gb, 2); 7189 pps->weighted_bipred_idc= get_bits(&s->gb, 2);