aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2012-02-21 18:15:51 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2012-02-22 10:50:42 -0500
commit58700edb94a3ddd7267fd7430d19b4a7e2a6b82b (patch)
tree316e50ee52ce1d67d7104fb6faa1a2e61f0b74e6
parent6bbaf6e0dd09430b7f8ba7f114eebc24925e1bce (diff)
downloadffmpeg-58700edb94a3ddd7267fd7430d19b4a7e2a6b82b.tar.gz
cdxl: correctly synchronize video timestamps to audio
Signed-off-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
-rw-r--r--libavformat/cdxl.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libavformat/cdxl.c b/libavformat/cdxl.c
index 49077b4a36..b056d691c9 100644
--- a/libavformat/cdxl.c
+++ b/libavformat/cdxl.c
@@ -43,7 +43,7 @@ static int cdxl_read_header(AVFormatContext *s)
CDXLDemuxContext *cdxl = s->priv_data;
int ret;
- if ((ret = av_parse_video_rate(&cdxl->fps, cdxl->framerate)) < 0) {
+ if (cdxl->framerate && (ret = av_parse_video_rate(&cdxl->fps, cdxl->framerate)) < 0) {
av_log(s, AV_LOG_ERROR,
"Could not parse framerate: %s.\n", cdxl->framerate);
return ret;
@@ -103,8 +103,9 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
st->codec->codec_id = CODEC_ID_PCM_S8;
st->codec->channels = cdxl->header[1] & 0x10 ? 2 : 1;
st->codec->sample_rate = cdxl->sample_rate;
+ st->start_time = 0;
cdxl->audio_stream_index = st->index;
- avpriv_set_pts_info(st, 32, 1, cdxl->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
}
ret = av_get_packet(pb, pkt, audio_size);
@@ -125,8 +126,12 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
st->codec->codec_id = CODEC_ID_CDXL;
st->codec->width = width;
st->codec->height = height;
+ st->start_time = 0;
cdxl->video_stream_index = st->index;
- avpriv_set_pts_info(st, 63, cdxl->fps.den, cdxl->fps.num);
+ if (cdxl->framerate)
+ avpriv_set_pts_info(st, 64, cdxl->fps.den, cdxl->fps.num);
+ else
+ avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
}
if (av_new_packet(pkt, video_size + CDXL_HEADER_SIZE) < 0)
@@ -140,6 +145,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = cdxl->video_stream_index;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pos = pos;
+ pkt->duration = cdxl->framerate ? 1 : audio_size ? audio_size : 220;
cdxl->read_chunk = audio_size;
}
@@ -151,7 +157,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
#define OFFSET(x) offsetof(CDXLDemuxContext, x)
static const AVOption cdxl_options[] = {
{ "sample_rate", "", OFFSET(sample_rate), AV_OPT_TYPE_INT, { .dbl = 11025 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
- { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, { .str = "10" }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
+ { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
{ NULL },
};