comparison mpegvideo_parser.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 8e5fe9e56b93
children 9311c65558c0
comparison
equal deleted inserted replaced
9089:bea68afbf199 9090:cecf81f93756
27 AVCodecContext *avctx, 27 AVCodecContext *avctx,
28 const uint8_t *buf, int buf_size) 28 const uint8_t *buf, int buf_size)
29 { 29 {
30 ParseContext1 *pc = s->priv_data; 30 ParseContext1 *pc = s->priv_data;
31 const uint8_t *buf_end; 31 const uint8_t *buf_end;
32 const uint8_t *buf_start= buf;
33 uint32_t start_code; 32 uint32_t start_code;
34 int frame_rate_index, ext_type, bytes_left; 33 int frame_rate_index, ext_type, bytes_left;
35 int frame_rate_ext_n, frame_rate_ext_d; 34 int frame_rate_ext_n, frame_rate_ext_d;
36 int picture_structure, top_field_first, repeat_first_field, progressive_frame; 35 int picture_structure, top_field_first, repeat_first_field, progressive_frame;
37 int horiz_size_ext, vert_size_ext, bit_rate_ext; 36 int horiz_size_ext, vert_size_ext, bit_rate_ext;
42 start_code= -1; 41 start_code= -1;
43 buf= ff_find_start_code(buf, buf_end, &start_code); 42 buf= ff_find_start_code(buf, buf_end, &start_code);
44 bytes_left = buf_end - buf; 43 bytes_left = buf_end - buf;
45 switch(start_code) { 44 switch(start_code) {
46 case PICTURE_START_CODE: 45 case PICTURE_START_CODE:
47 ff_fetch_timestamp(s, buf-buf_start-4, 1);
48
49 if (bytes_left >= 2) { 46 if (bytes_left >= 2) {
50 s->pict_type = (buf[1] >> 3) & 7; 47 s->pict_type = (buf[1] >> 3) & 7;
51 } 48 }
52 break; 49 break;
53 case SEQ_START_CODE: 50 case SEQ_START_CODE:
135 int next; 132 int next;
136 133
137 if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ 134 if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
138 next= buf_size; 135 next= buf_size;
139 }else{ 136 }else{
140 next= ff_mpeg1_find_frame_end(pc, buf, buf_size); 137 next= ff_mpeg1_find_frame_end(pc, buf, buf_size, s);
141 138
142 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { 139 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
143 *poutbuf = NULL; 140 *poutbuf = NULL;
144 *poutbuf_size = 0; 141 *poutbuf_size = 0;
145 return buf_size; 142 return buf_size;