comparison mpeg12.c @ 9090:cecf81f93756 libavcodec

Call ff_fetch_timestamp() for mpeg1/2 when a picture start code is found instead of calling it at the end of a frame with a large negative offset. This significantly reduces the maximal distance in container packets between the point where the first byte of the "access unit" was stored and where we call ff_fetch_timestamp() thus reducing the constraints on our parser. Also change the parser from next_frame_offset to cur, this is needed because now the reference is from container packet start instead of frame start. (i previously misinterpreted this as bug)
author michael
date Mon, 02 Mar 2009 14:53:18 +0000
parents 0d39a5203bf0
children 54bc8a2727b0
comparison
equal deleted inserted replaced
9089:bea68afbf199 9090:cecf81f93756
2194 } 2194 }
2195 /** 2195 /**
2196 * Finds the end of the current frame in the bitstream. 2196 * Finds the end of the current frame in the bitstream.
2197 * @return the position of the first byte of the next frame, or -1 2197 * @return the position of the first byte of the next frame, or -1
2198 */ 2198 */
2199 int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size) 2199 int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s)
2200 { 2200 {
2201 int i; 2201 int i;
2202 uint32_t state= pc->state; 2202 uint32_t state= pc->state;
2203 2203
2204 /* EOF considered as end of frame */ 2204 /* EOF considered as end of frame */
2242 pc->frame_start_found=0; 2242 pc->frame_start_found=0;
2243 pc->state=-1; 2243 pc->state=-1;
2244 return i-3; 2244 return i-3;
2245 } 2245 }
2246 } 2246 }
2247 if(s && state == PICTURE_START_CODE){
2248 ff_fetch_timestamp(s, i-4, 1);
2249 }
2247 } 2250 }
2248 } 2251 }
2249 pc->state= state; 2252 pc->state= state;
2250 return END_NOT_FOUND; 2253 return END_NOT_FOUND;
2251 } 2254 }
2274 } 2277 }
2275 return buf_size; 2278 return buf_size;
2276 } 2279 }
2277 2280
2278 if(s2->flags&CODEC_FLAG_TRUNCATED){ 2281 if(s2->flags&CODEC_FLAG_TRUNCATED){
2279 int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size); 2282 int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
2280 2283
2281 if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 ) 2284 if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
2282 return buf_size; 2285 return buf_size;
2283 } 2286 }
2284 2287