Commit 25cf828e authored by michael's avatar michael

mpeg audio timestamp fix


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3150 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 9580615e
...@@ -17,7 +17,7 @@ extern "C" { ...@@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000408 #define FFMPEG_VERSION_INT 0x000408
#define FFMPEG_VERSION "0.4.8" #define FFMPEG_VERSION "0.4.8"
#define LIBAVCODEC_BUILD 4714 #define LIBAVCODEC_BUILD 4715
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION #define LIBAVCODEC_VERSION FFMPEG_VERSION
...@@ -2090,6 +2090,7 @@ typedef struct AVCodecParserContext { ...@@ -2090,6 +2090,7 @@ typedef struct AVCodecParserContext {
/* private data */ /* private data */
int64_t last_pts; int64_t last_pts;
int64_t last_dts; int64_t last_dts;
int fetch_timestamp;
#define AV_PARSER_PTS_NB 4 #define AV_PARSER_PTS_NB 4
int cur_frame_start_index; int cur_frame_start_index;
......
...@@ -60,6 +60,7 @@ AVCodecParserContext *av_parser_init(int codec_id) ...@@ -60,6 +60,7 @@ AVCodecParserContext *av_parser_init(int codec_id)
return NULL; return NULL;
} }
} }
s->fetch_timestamp=1;
return s; return s;
} }
...@@ -87,7 +88,8 @@ int av_parser_parse(AVCodecParserContext *s, ...@@ -87,7 +88,8 @@ int av_parser_parse(AVCodecParserContext *s,
s->cur_frame_dts[k] = dts; s->cur_frame_dts[k] = dts;
/* fill first PTS/DTS */ /* fill first PTS/DTS */
if (s->cur_offset == 0) { if (s->fetch_timestamp){
s->fetch_timestamp=0;
s->last_pts = pts; s->last_pts = pts;
s->last_dts = dts; s->last_dts = dts;
} }
...@@ -95,6 +97,7 @@ int av_parser_parse(AVCodecParserContext *s, ...@@ -95,6 +97,7 @@ int av_parser_parse(AVCodecParserContext *s,
/* WARNING: the returned index can be negative */ /* WARNING: the returned index can be negative */
index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size); index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size);
//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);
/* update the file pointer */ /* update the file pointer */
if (*poutbuf_size) { if (*poutbuf_size) {
/* fill the data for the current frame */ /* fill the data for the current frame */
...@@ -116,8 +119,15 @@ int av_parser_parse(AVCodecParserContext *s, ...@@ -116,8 +119,15 @@ int av_parser_parse(AVCodecParserContext *s,
break; break;
k = (k - 1) & (AV_PARSER_PTS_NB - 1); k = (k - 1) & (AV_PARSER_PTS_NB - 1);
} }
s->last_pts = s->cur_frame_pts[k]; s->last_pts = s->cur_frame_pts[k];
s->last_dts = s->cur_frame_dts[k]; s->last_dts = s->cur_frame_dts[k];
/* some parsers tell us the packet size even before seeing the first byte of the next packet,
so the next pts/dts is in the next chunk */
if(index == buf_size){
s->fetch_timestamp=1;
}
} }
if (index < 0) if (index < 0)
index = 0; index = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment