Mercurial > libavcodec.hg
comparison h264.c @ 1174:2de2a847af67 libavcodec
some checks to avoid segfault
author | michaelni |
---|---|
date | Mon, 07 Apr 2003 19:23:21 +0000 |
parents | 4710976004a5 |
children | fea03d2c4946 |
comparison
equal
deleted
inserted
replaced
1173:86d5a33eaec8 | 1174:2de2a847af67 |
---|---|
2824 if(pps_id>255){ | 2824 if(pps_id>255){ |
2825 fprintf(stderr, "pps_id out of range\n"); | 2825 fprintf(stderr, "pps_id out of range\n"); |
2826 return -1; | 2826 return -1; |
2827 } | 2827 } |
2828 h->pps= h->pps_buffer[pps_id]; | 2828 h->pps= h->pps_buffer[pps_id]; |
2829 if(h->pps.slice_group_count == 0){ | |
2830 fprintf(stderr, "non existing PPS referenced\n"); | |
2831 return -1; | |
2832 } | |
2833 | |
2829 h->sps= h->sps_buffer[ h->pps.sps_id ]; | 2834 h->sps= h->sps_buffer[ h->pps.sps_id ]; |
2835 if(h->sps.log2_max_frame_num == 0){ | |
2836 fprintf(stderr, "non existing SPS referenced\n"); | |
2837 return -1; | |
2838 } | |
2830 | 2839 |
2831 s->mb_width= h->sps.mb_width; | 2840 s->mb_width= h->sps.mb_width; |
2832 s->mb_height= h->sps.mb_height; | 2841 s->mb_height= h->sps.mb_height; |
2833 h->mb_stride= s->mb_width + 1; | 2842 h->mb_stride= s->mb_width + 1; |
2834 | 2843 |
4033 h->intra_gb_ptr= &h->intra_gb; | 4042 h->intra_gb_ptr= &h->intra_gb; |
4034 break; | 4043 break; |
4035 case NAL_DPC: | 4044 case NAL_DPC: |
4036 init_get_bits(&h->inter_gb, ptr, bit_length); | 4045 init_get_bits(&h->inter_gb, ptr, bit_length); |
4037 h->inter_gb_ptr= &h->inter_gb; | 4046 h->inter_gb_ptr= &h->inter_gb; |
4038 | 4047 |
4039 if(h->redundant_pic_count==0) | 4048 if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning) |
4040 decode_slice(h); | 4049 decode_slice(h); |
4041 break; | 4050 break; |
4042 case NAL_SEI: | 4051 case NAL_SEI: |
4043 break; | 4052 break; |
4044 case NAL_SPS: | 4053 case NAL_SPS: |
4065 //FIXME move after where irt is set | 4074 //FIXME move after where irt is set |
4066 s->current_picture.pict_type= s->pict_type; | 4075 s->current_picture.pict_type= s->pict_type; |
4067 s->current_picture.key_frame= s->pict_type == I_TYPE; | 4076 s->current_picture.key_frame= s->pict_type == I_TYPE; |
4068 } | 4077 } |
4069 | 4078 |
4079 if(!s->current_picture_ptr) return buf_index; //no frame | |
4080 | |
4070 h->prev_frame_num_offset= h->frame_num_offset; | 4081 h->prev_frame_num_offset= h->frame_num_offset; |
4071 h->prev_frame_num= h->frame_num; | 4082 h->prev_frame_num= h->frame_num; |
4072 if(s->current_picture_ptr->reference){ | 4083 if(s->current_picture_ptr->reference){ |
4073 h->prev_poc_msb= h->poc_msb; | 4084 h->prev_poc_msb= h->poc_msb; |
4074 h->prev_poc_lsb= h->poc_lsb; | 4085 h->prev_poc_lsb= h->poc_lsb; |
4145 *pict= *(AVFrame*)&s->current_picture; | 4156 *pict= *(AVFrame*)&s->current_picture; |
4146 } else { | 4157 } else { |
4147 *pict= *(AVFrame*)&s->last_picture; | 4158 *pict= *(AVFrame*)&s->last_picture; |
4148 } | 4159 } |
4149 #endif | 4160 #endif |
4161 if(!s->current_picture_ptr){ | |
4162 fprintf(stderr, "error, NO frame\n"); | |
4163 return -1; | |
4164 } | |
4165 | |
4150 *pict= *(AVFrame*)&s->current_picture; //FIXME | 4166 *pict= *(AVFrame*)&s->current_picture; //FIXME |
4151 assert(pict->data[0]); | 4167 assert(pict->data[0]); |
4152 //printf("out %d\n", (int)pict->data[0]); | 4168 //printf("out %d\n", (int)pict->data[0]); |
4153 if(avctx->debug&FF_DEBUG_QP){ | |
4154 int8_t *qtab= pict->qscale_table; | |
4155 int x,y; | |
4156 | |
4157 for(y=0; y<s->mb_height; y++){ | |
4158 for(x=0; x<s->mb_width; x++){ | |
4159 printf("%2d ", qtab[x + y*s->mb_width]); | |
4160 } | |
4161 printf("\n"); | |
4162 } | |
4163 printf("\n"); | |
4164 } | |
4165 #if 0 //? | 4169 #if 0 //? |
4166 | 4170 |
4167 /* Return the Picture timestamp as the frame number */ | 4171 /* Return the Picture timestamp as the frame number */ |
4168 /* we substract 1 because it is added on utils.c */ | 4172 /* we substract 1 because it is added on utils.c */ |
4169 avctx->frame_number = s->picture_number - 1; | 4173 avctx->frame_number = s->picture_number - 1; |