Mercurial > libavcodec.hg
comparison parser.c @ 2030:f796043935f3 libavcodec
mpeg audio timestamp fix
| author | michael |
|---|---|
| date | Sun, 23 May 2004 01:10:15 +0000 |
| parents | f65d87bfdd5a |
| children | bec4623c2201 |
comparison
equal
deleted
inserted
replaced
| 2029:934117474c3b | 2030:f796043935f3 |
|---|---|
| 58 av_free(s->priv_data); | 58 av_free(s->priv_data); |
| 59 av_free(s); | 59 av_free(s); |
| 60 return NULL; | 60 return NULL; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 s->fetch_timestamp=1; | |
| 63 return s; | 64 return s; |
| 64 } | 65 } |
| 65 | 66 |
| 66 /* NOTE: buf_size == 0 is used to signal EOF so that the last frame | 67 /* NOTE: buf_size == 0 is used to signal EOF so that the last frame |
| 67 can be returned if necessary */ | 68 can be returned if necessary */ |
| 85 s->cur_frame_offset[k] = s->cur_offset; | 86 s->cur_frame_offset[k] = s->cur_offset; |
| 86 s->cur_frame_pts[k] = pts; | 87 s->cur_frame_pts[k] = pts; |
| 87 s->cur_frame_dts[k] = dts; | 88 s->cur_frame_dts[k] = dts; |
| 88 | 89 |
| 89 /* fill first PTS/DTS */ | 90 /* fill first PTS/DTS */ |
| 90 if (s->cur_offset == 0) { | 91 if (s->fetch_timestamp){ |
| 92 s->fetch_timestamp=0; | |
| 91 s->last_pts = pts; | 93 s->last_pts = pts; |
| 92 s->last_dts = dts; | 94 s->last_dts = dts; |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 | 97 |
| 96 /* WARNING: the returned index can be negative */ | 98 /* WARNING: the returned index can be negative */ |
| 97 index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size); | 99 index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size); |
| 100 //av_log(NULL, AV_LOG_DEBUG, "parser: in:%lld, %lld, out:%lld, %lld, in:%d out:%d %d\n", pts, dts, s->last_pts, s->last_dts, buf_size, *poutbuf_size, avctx->codec_id); | |
| 98 /* update the file pointer */ | 101 /* update the file pointer */ |
| 99 if (*poutbuf_size) { | 102 if (*poutbuf_size) { |
| 100 /* fill the data for the current frame */ | 103 /* fill the data for the current frame */ |
| 101 s->frame_offset = s->last_frame_offset; | 104 s->frame_offset = s->last_frame_offset; |
| 102 s->pts = s->last_pts; | 105 s->pts = s->last_pts; |
| 114 for(i = 0; i < AV_PARSER_PTS_NB; i++) { | 117 for(i = 0; i < AV_PARSER_PTS_NB; i++) { |
| 115 if (s->last_frame_offset >= s->cur_frame_offset[k]) | 118 if (s->last_frame_offset >= s->cur_frame_offset[k]) |
| 116 break; | 119 break; |
| 117 k = (k - 1) & (AV_PARSER_PTS_NB - 1); | 120 k = (k - 1) & (AV_PARSER_PTS_NB - 1); |
| 118 } | 121 } |
| 122 | |
| 119 s->last_pts = s->cur_frame_pts[k]; | 123 s->last_pts = s->cur_frame_pts[k]; |
| 120 s->last_dts = s->cur_frame_dts[k]; | 124 s->last_dts = s->cur_frame_dts[k]; |
| 125 | |
| 126 /* some parsers tell us the packet size even before seeing the first byte of the next packet, | |
| 127 so the next pts/dts is in the next chunk */ | |
| 128 if(index == buf_size){ | |
| 129 s->fetch_timestamp=1; | |
| 130 } | |
| 121 } | 131 } |
| 122 if (index < 0) | 132 if (index < 0) |
| 123 index = 0; | 133 index = 0; |
| 124 s->cur_offset += index; | 134 s->cur_offset += index; |
| 125 return index; | 135 return index; |
