[FFmpeg-cvslog] avformat/cdxl: add back options to override sample and frame rate
Paul B Mahol
git at videolan.org
Fri Feb 5 19:12:28 EET 2021
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Feb 5 18:06:28 2021 +0100| [6b8ef5119cab9e772c6afd23e474bbd543c47039] | committer: Paul B Mahol
avformat/cdxl: add back options to override sample and frame rate
It make sense to allow to control speed of playback when
no infomation is provided.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6b8ef5119cab9e772c6afd23e474bbd543c47039
---
libavformat/cdxl.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/libavformat/cdxl.c b/libavformat/cdxl.c
index 721919c1ef..33b6d5cbad 100644
--- a/libavformat/cdxl.c
+++ b/libavformat/cdxl.c
@@ -33,6 +33,8 @@ typedef struct CDXLDemuxContext {
int read_chunk;
AVRational frate;
int srate;
+ AVRational frame_rate;
+ int sample_rate;
uint8_t header[CDXL_HEADER_SIZE];
int video_stream_index;
int audio_stream_index;
@@ -143,7 +145,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
audio_size = AV_RB16(&cdxl->header[22]) * channels;
cdxl->srate = AV_RB16(&cdxl->header[24]);
if (!cdxl->srate && audio_size)
- cdxl->srate = 11025;
+ cdxl->srate = cdxl->sample_rate;
cdxl->frate.num = cdxl->header[26];
cdxl->frate.den = 1;
if (cdxl->header[19] == 0 ||
@@ -164,7 +166,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!cdxl->frate.num && audio_size && cdxl->srate > 0) {
cdxl->frate = (AVRational){ cdxl->srate, audio_size };
} else if (!cdxl->frate.num) {
- cdxl->frate.num = 15;
+ cdxl->frate = cdxl->frame_rate;
}
if (cdxl->read_chunk && audio_size) {
@@ -242,10 +244,25 @@ static int read_seek(AVFormatContext *s, int stream_index,
return -1;
}
+#define OFFSET(x) offsetof(CDXLDemuxContext, x)
+static const AVOption cdxl_options[] = {
+ { "sample_rate", "", OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64=11025 }, 8000, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { "frame_rate", "", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str="15" }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { NULL },
+};
+
+static const AVClass cdxl_demuxer_class = {
+ .class_name = "CDXL demuxer",
+ .item_name = av_default_item_name,
+ .option = cdxl_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVInputFormat ff_cdxl_demuxer = {
.name = "cdxl",
.long_name = NULL_IF_CONFIG_SMALL("Commodore CDXL video"),
.priv_data_size = sizeof(CDXLDemuxContext),
+ .priv_class = &cdxl_demuxer_class,
.read_probe = cdxl_read_probe,
.read_header = cdxl_read_header,
.read_packet = cdxl_read_packet,
More information about the ffmpeg-cvslog
mailing list