Mercurial > libavcodec.hg
comparison mpeg12.c @ 2786:ee07e99e034f libavcodec
fix decoding of (broken) files with f_code=0
fix segfault if the first P frames header is damaged
author | michael |
---|---|
date | Mon, 11 Jul 2005 22:15:03 +0000 |
parents | b71d3566fc6d |
children | 0a8c847ad5e7 |
comparison
equal
deleted
inserted
replaced
2785:c8d53188048d | 2786:ee07e99e034f |
---|---|
2218 | 2218 |
2219 vbv_delay= get_bits(&s->gb, 16); | 2219 vbv_delay= get_bits(&s->gb, 16); |
2220 if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { | 2220 if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { |
2221 s->full_pel[0] = get_bits1(&s->gb); | 2221 s->full_pel[0] = get_bits1(&s->gb); |
2222 f_code = get_bits(&s->gb, 3); | 2222 f_code = get_bits(&s->gb, 3); |
2223 if (f_code == 0) | 2223 if (f_code == 0 && avctx->error_resilience >= FF_ER_COMPLIANT) |
2224 return -1; | 2224 return -1; |
2225 s->mpeg_f_code[0][0] = f_code; | 2225 s->mpeg_f_code[0][0] = f_code; |
2226 s->mpeg_f_code[0][1] = f_code; | 2226 s->mpeg_f_code[0][1] = f_code; |
2227 } | 2227 } |
2228 if (s->pict_type == B_TYPE) { | 2228 if (s->pict_type == B_TYPE) { |
2229 s->full_pel[1] = get_bits1(&s->gb); | 2229 s->full_pel[1] = get_bits1(&s->gb); |
2230 f_code = get_bits(&s->gb, 3); | 2230 f_code = get_bits(&s->gb, 3); |
2231 if (f_code == 0) | 2231 if (f_code == 0 && avctx->error_resilience >= FF_ER_COMPLIANT) |
2232 return -1; | 2232 return -1; |
2233 s->mpeg_f_code[1][0] = f_code; | 2233 s->mpeg_f_code[1][0] = f_code; |
2234 s->mpeg_f_code[1][1] = f_code; | 2234 s->mpeg_f_code[1][1] = f_code; |
2235 } | 2235 } |
2236 s->current_picture.pict_type= s->pict_type; | 2236 s->current_picture.pict_type= s->pict_type; |
3136 default: | 3136 default: |
3137 if (start_code >= SLICE_MIN_START_CODE && | 3137 if (start_code >= SLICE_MIN_START_CODE && |
3138 start_code <= SLICE_MAX_START_CODE) { | 3138 start_code <= SLICE_MAX_START_CODE) { |
3139 int mb_y= start_code - SLICE_MIN_START_CODE; | 3139 int mb_y= start_code - SLICE_MIN_START_CODE; |
3140 | 3140 |
3141 if(s2->last_picture_ptr==NULL){ | |
3141 /* skip b frames if we dont have reference frames */ | 3142 /* skip b frames if we dont have reference frames */ |
3142 if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break; | 3143 if(s2->pict_type==B_TYPE) break; |
3144 /* skip P frames if we dont have reference frame no valid header */ | |
3145 if(s2->pict_type==P_TYPE && !s2->first_slice) break; | |
3146 } | |
3143 /* skip b frames if we are in a hurry */ | 3147 /* skip b frames if we are in a hurry */ |
3144 if(avctx->hurry_up && s2->pict_type==B_TYPE) break; | 3148 if(avctx->hurry_up && s2->pict_type==B_TYPE) break; |
3145 /* skip everything if we are in a hurry>=5 */ | 3149 /* skip everything if we are in a hurry>=5 */ |
3146 if(avctx->hurry_up>=5) break; | 3150 if(avctx->hurry_up>=5) break; |
3147 | 3151 |