Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/apvdec: add framerate option
@ 2025-06-26 19:34 James Almer
  0 siblings, 0 replies; only message in thread
From: James Almer @ 2025-06-26 19:34 UTC (permalink / raw)
  To: ffmpeg-devel

Based on code from rawvideo demuxer.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/apvdec.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index 1e5497bcd3..70f6babbb7 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/opt.h"
+
 #include "libavcodec/apv.h"
 #include "libavcodec/bytestream.h"
 
@@ -24,6 +26,10 @@
 #include "demux.h"
 #include "internal.h"
 
+typedef struct APVDemuxerContext {
+    const AVClass *class;     /**< Class for private options. */
+    AVRational frame_rate;    /**< AVRational describing framerate, set by a private option. */
+} APVDemuxerContext;
 
 typedef struct APVHeaderInfo {
     uint8_t  pbu_type;
@@ -145,6 +151,7 @@ static int apv_probe(const AVProbeData *p)
 
 static int apv_read_header(AVFormatContext *s)
 {
+    APVDemuxerContext *apv = s->priv_data;
     AVStream *st;
     GetByteContext gbc;
     uint8_t buffer[12];
@@ -184,8 +191,8 @@ static int apv_read_header(AVFormatContext *s)
     st->codecpar->codec_id   = AV_CODEC_ID_APV;
 
     ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS;
-    st->avg_frame_rate = (AVRational){ 30, 1 };
-    avpriv_set_pts_info(st, 64, 1, 30);
+    st->avg_frame_rate = apv->frame_rate;
+    avpriv_set_pts_info(st, 64, apv->frame_rate.den, apv->frame_rate.num);
 
     avio_seek(s->pb, -size, SEEK_CUR);
 
@@ -221,11 +228,27 @@ static int apv_read_packet(AVFormatContext *s, AVPacket *pkt)
     return 0;
 }
 
+#define OFFSET(x) offsetof(APVDemuxerContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption apv_options[] = {
+    { "framerate", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "30" }, 0, INT_MAX, DEC },
+    { NULL },
+};
+
+static const AVClass apv_demuxer_class = {
+    .class_name = "apv demuxer",
+    .item_name  = av_default_item_name,
+    .option     = apv_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 const FFInputFormat ff_apv_demuxer = {
     .p.name         = "apv",
     .p.long_name    = NULL_IF_CONFIG_SMALL("APV raw bitstream"),
     .p.extensions   = "apv",
     .p.flags        = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
+    .p.priv_class   = &apv_demuxer_class,
+    .priv_data_size = sizeof(APVDemuxerContext),
     .read_probe     = apv_probe,
     .read_header    = apv_read_header,
     .read_packet    = apv_read_packet,
-- 
2.50.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-06-26 19:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-26 19:34 [FFmpeg-devel] [PATCH] avformat/apvdec: add framerate option James Almer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git