summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-17 16:11:20 +0100
committerAnton Khirnov <anton@khirnov.net>2024-02-07 11:46:55 +0100
commitba2b96f8691621e41fdbef07a6925b30335bff71 (patch)
tree7a5bdb847c50fe26648511ecd06448492170b4ca
parentb696da001873bbad8594452256303eaef23ab239 (diff)
lavf/bfi: set ts_flags and framerate/audio duration, stop settings pts
The container does not store any kind of timestamps, the demuxer makes them up based on framerate/audio packet sizes (the audio is U8 PCM) We can just as well leave that to higher level code.
-rw-r--r--libavformat/bfi.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libavformat/bfi.c b/libavformat/bfi.c
index 6bcd3cd400..d76e5f2ff7 100644
--- a/libavformat/bfi.c
+++ b/libavformat/bfi.c
@@ -34,8 +34,6 @@
typedef struct BFIContext {
int nframes;
- int audio_frame;
- int video_frame;
int video_size;
int avflag;
} BFIContext;
@@ -80,6 +78,11 @@ static int bfi_read_header(AVFormatContext * s)
avio_rl32(pb);
avio_rl32(pb);
fps = avio_rl32(pb);
+ if (!fps) {
+ av_log(s, AV_LOG_ERROR, "Invalid video framerate.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
avio_skip(pb, 12);
vstream->codecpar->width = avio_rl32(pb);
vstream->codecpar->height = avio_rl32(pb);
@@ -98,6 +101,9 @@ static int bfi_read_header(AVFormatContext * s)
/* Set up the video codec... */
avpriv_set_pts_info(vstream, 32, 1, fps);
+ vstream->avg_frame_rate = (AVRational){ fps, 1 };
+ vstream->ts_flags = AVFORMAT_TS_FLAG_RATE;
+
vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vstream->codecpar->codec_id = AV_CODEC_ID_BFI;
vstream->codecpar->format = AV_PIX_FMT_PAL8;
@@ -113,6 +119,8 @@ static int bfi_read_header(AVFormatContext * s)
(int64_t)astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
avio_seek(pb, chunk_header - 3, SEEK_SET);
avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
+ astream->ts_flags = AVFORMAT_TS_FLAG_DURATION;
+
return 0;
}
@@ -152,8 +160,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
if (ret < 0)
return ret;
- pkt->pts = bfi->audio_frame;
- bfi->audio_frame += ret;
+ pkt->duration = audio_size;
} else if (bfi->video_size > 0) {
//Tossing a video packet at the video decoder.
@@ -161,9 +168,6 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
if (ret < 0)
return ret;
- pkt->pts = bfi->video_frame;
- bfi->video_frame += ret / bfi->video_size;
-
/* One less frame to read. A cursory decrement. */
bfi->nframes--;
} else {