diff mbox series

[FFmpeg-devel,v2,2/4] avformat/argo_asf: add version_major and version_minor options

Message ID 20200808133717.2311422-2-zane@zanevaniperen.com
State Superseded
Headers show
Series [FFmpeg-devel,v2,1/4] avformat/argo_asf: don't check or probe file version
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Zane van Iperen Aug. 8, 2020, 1:37 p.m. UTC
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavformat/argo_asf.c | 47 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index beec46a0d4..c693cfd045 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -23,6 +23,7 @@ 
 #include "internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
+#include "libavutil/opt.h"
 
 #define ASF_TAG                 MKTAG('A', 'S', 'F', '\0')
 #define ASF_FILE_HEADER_SIZE    24
@@ -69,6 +70,12 @@  typedef struct ArgoASFDemuxContext {
     uint32_t            blocks_read;
 } ArgoASFDemuxContext;
 
+typedef struct ArgoASFMuxContext {
+    const AVClass *class;
+    int            version_major;
+    int            version_minor;
+} ArgoASFMuxContext;
+
 #if CONFIG_ARGO_ASF_DEMUXER
 static void argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf)
 {
@@ -293,12 +300,13 @@  static void argo_asf_write_chunk_header(const ArgoASFChunkHeader *ckhdr, AVIOCon
 static int argo_asf_write_header(AVFormatContext *s)
 {
     const AVCodecParameters  *par = s->streams[0]->codecpar;
+    ArgoASFMuxContext        *ctx = s->priv_data;
     ArgoASFFileHeader  fhdr;
     ArgoASFChunkHeader chdr;
 
     fhdr.magic         = ASF_TAG;
-    fhdr.version_major = 2;
-    fhdr.version_minor = 1;
+    fhdr.version_major = (uint16_t)ctx->version_major;
+    fhdr.version_minor = (uint16_t)ctx->version_minor;
     fhdr.num_chunks    = 1;
     fhdr.chunk_offset  = ASF_FILE_HEADER_SIZE;
     strncpy(fhdr.name, av_basename(s->url), FF_ARRAY_ELEMS(fhdr.name));
@@ -341,6 +349,37 @@  static int argo_asf_write_trailer(AVFormatContext *s)
     return 0;
 }
 
+static const AVOption argo_asf_options[] = {
+    {
+        .name        = "version_major",
+        .help        = "set file major version",
+        .offset      = offsetof(ArgoASFMuxContext, version_major),
+        .type        = AV_OPT_TYPE_INT,
+        .default_val = {.i64 = 2},
+        .min         = 0,
+        .max         = UINT16_MAX,
+        .flags       = AV_OPT_FLAG_ENCODING_PARAM
+    },
+    {
+        .name        = "version_minor",
+        .help        = "set file minor version",
+        .offset      = offsetof(ArgoASFMuxContext, version_minor),
+        .type        = AV_OPT_TYPE_INT,
+        .default_val = {.i64 = 1},
+        .min         = 0,
+        .max         = UINT16_MAX,
+        .flags       = AV_OPT_FLAG_ENCODING_PARAM
+    },
+    { NULL }
+};
+
+static const AVClass argo_asf_muxer_class = {
+    .class_name = "argo_asf_muxer",
+    .item_name  = av_default_item_name,
+    .option     = argo_asf_options,
+    .version    = LIBAVUTIL_VERSION_INT
+};
+
 AVOutputFormat ff_argo_asf_muxer = {
     .name           = "argo_asf",
     .long_name      = NULL_IF_CONFIG_SMALL("Argonaut Games ASF"),
@@ -353,6 +392,8 @@  AVOutputFormat ff_argo_asf_muxer = {
     .init           = argo_asf_write_init,
     .write_header   = argo_asf_write_header,
     .write_packet   = argo_asf_write_packet,
-    .write_trailer  = argo_asf_write_trailer
+    .write_trailer  = argo_asf_write_trailer,
+    .priv_class     = &argo_asf_muxer_class,
+    .priv_data_size = sizeof(ArgoASFMuxContext)
 };
 #endif