From 7c1f6df4b5f80ead35b66e5373af6c8046bace56 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 11 Aug 2011 14:44:05 +0200 Subject: rmdec: correct DTS calculation in RealMedia container. First, container stores only DTS and not PTS as it was believed. Second, multiple frames in a packet store timestamp instead of position after the frame length. Signed-off-by: Anton Khirnov --- libavformat/rmdec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libavformat/rmdec.c') diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 54267485b7..5ee75b53b9 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -568,7 +568,8 @@ skip: static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, RMDemuxContext *rm, RMStream *vst, - AVPacket *pkt, int len, int *pseq) + AVPacket *pkt, int len, int *pseq, + int64_t *timestamp) { int hdr, seq, pic_num, len2, pos; int type; @@ -588,8 +589,10 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, return -1; rm->remaining_len = len; if(type&1){ // frame, not slice - if(type == 3) // frame as a part of packet + if(type == 3){ // frame as a part of packet len= len2; + *timestamp = pos; + } if(rm->remaining_len < len) return -1; rm->remaining_len -= len; @@ -697,7 +700,7 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { rm->current_stream= st->id; - if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len, seq)) + if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len, seq, ×tamp)) return -1; //got partial frame } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if ((st->codec->codec_id == CODEC_ID_RA_288) || @@ -772,7 +775,7 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb, } #endif - pkt->pts= timestamp; + pkt->pts = timestamp; if (flags & 2) pkt->flags |= AV_PKT_FLAG_KEY; -- cgit v1.2.3 From 48ce8b8da714558c8738610d5512b6c3c95c901a Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 15 Aug 2011 12:03:40 +0200 Subject: Use parsers for RealVideo 3/4 to determine correct PTS Signed-off-by: Anton Khirnov --- libavformat/rmdec.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libavformat/rmdec.c') diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 5ee75b53b9..cf5c46a095 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -298,6 +298,7 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb, st->codec->time_base.num= 1; fps= avio_rb16(pb); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; avio_rb32(pb); avio_skip(pb, 2); avio_rb16(pb); -- cgit v1.2.3 From a43b1e74e2abaac6e63eb001474855bd44335988 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 16 Aug 2011 09:10:57 +0200 Subject: rmdec: parse FPS in RealMedia properly Signed-off-by: Anton Khirnov --- libavformat/rmdec.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libavformat/rmdec.c') diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index cf5c46a095..7cf5720fe0 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -293,21 +293,21 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb, // av_log(s, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); if (st->codec->codec_id == CODEC_ID_NONE) goto fail1; - st->codec->width = avio_rb16(pb); + st->codec->width = avio_rb16(pb); st->codec->height = avio_rb16(pb); - st->codec->time_base.num= 1; - fps= avio_rb16(pb); + avio_skip(pb, 2); // looks like bits per sample + avio_skip(pb, 4); // always zero? st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS; - avio_rb32(pb); - avio_skip(pb, 2); - avio_rb16(pb); + fps = avio_rb32(pb); if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0) return ret; -// av_log(s, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); - st->codec->time_base.den = fps * st->codec->time_base.num; + av_reduce(&st->codec->time_base.num, &st->codec->time_base.den, + 0x10000, fps, (1 << 30) - 1); + st->avg_frame_rate.num = st->codec->time_base.den; + st->avg_frame_rate.den = st->codec->time_base.num; } skip: -- cgit v1.2.3