[FFmpeg-cvslog] lavc/takdsp: R-V V decorrelate_sm

2023-12-22 Thread sunyuechi
ffmpeg | branch: master | sunyuechi  | Mon Dec 18 
22:53:39 2023 +0800| [3d39b8d4e7ca43baafa3b4cd5784dd64197dd232] | committer: 
Rémi Denis-Courmont

lavc/takdsp: R-V V decorrelate_sm

C908:
decorrelate_sm_c: 130.0
decorrelate_sm_rvv_i32: 43.2

Signed-off-by: Rémi Denis-Courmont 
(with minor changes)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d39b8d4e7ca43baafa3b4cd5784dd64197dd232
---

 libavcodec/riscv/takdsp_init.c |  2 ++
 libavcodec/riscv/takdsp_rvv.S  | 18 ++
 2 files changed, 20 insertions(+)

diff --git a/libavcodec/riscv/takdsp_init.c b/libavcodec/riscv/takdsp_init.c
index 2d5c974459..4312c8d99d 100644
--- a/libavcodec/riscv/takdsp_init.c
+++ b/libavcodec/riscv/takdsp_init.c
@@ -27,6 +27,7 @@
 
 void ff_decorrelate_ls_rvv(const int32_t *p1, int32_t *p2, int length);
 void ff_decorrelate_sr_rvv(int32_t *p1, const int32_t *p2, int length);
+void ff_decorrelate_sm_rvv(int32_t *p1, int32_t *p2, int length);
 
 av_cold void ff_takdsp_init_riscv(TAKDSPContext *dsp)
 {
@@ -36,6 +37,7 @@ av_cold void ff_takdsp_init_riscv(TAKDSPContext *dsp)
 if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
 dsp->decorrelate_ls = ff_decorrelate_ls_rvv;
 dsp->decorrelate_sr = ff_decorrelate_sr_rvv;
+dsp->decorrelate_sm = ff_decorrelate_sm_rvv;
 }
 #endif
 }
diff --git a/libavcodec/riscv/takdsp_rvv.S b/libavcodec/riscv/takdsp_rvv.S
index 65672cdfb8..b593d9139a 100644
--- a/libavcodec/riscv/takdsp_rvv.S
+++ b/libavcodec/riscv/takdsp_rvv.S
@@ -47,3 +47,21 @@ func ff_decorrelate_sr_rvv, zve32x
 bnez a2, 1b
 ret
 endfunc
+
+func ff_decorrelate_sm_rvv, zve32x
+1:
+vsetvli  t0, a2, e32, m8, ta, ma
+vle32.v  v8, (a1)
+sub  a2, a2, t0
+vle32.v  v0, (a0)
+vsra.vi  v16, v8, 1
+vsub.vv  v0, v0, v16
+vse32.v  v0, (a0)
+sh2add   a0, t0, a0
+vadd.vv  v8, v0, v8
+vse32.v  v8, (a1)
+sh2add   a1, t0, a1
+bnez a2, 1b
+
+ret
+endfunc

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] checkasm/takdsp: add decorrelate_sf test

2023-12-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Dec 21 22:11:25 
2023 -0300| [c5029bb19352524463f3560fe7f6cb794e147b1f] | committer: James Almer

checkasm/takdsp: add decorrelate_sf test

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c5029bb19352524463f3560fe7f6cb794e147b1f
---

 tests/checkasm/takdsp.c | 35 ---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/tests/checkasm/takdsp.c b/tests/checkasm/takdsp.c
index 3aecee1f72..b27bb92976 100644
--- a/tests/checkasm/takdsp.c
+++ b/tests/checkasm/takdsp.c
@@ -24,6 +24,7 @@
 #include "libavutil/mem_internal.h"
 
 #include "libavcodec/takdsp.h"
+#include "libavcodec/mathops.h"
 
 #include "checkasm.h"
 
@@ -33,8 +34,9 @@
 buf[i] = rnd(); \
 } while (0)
 
-static void test_decorrelate_ls(TAKDSPContext *s) {
 #define BUF_SIZE 1024
+
+static void test_decorrelate_ls(TAKDSPContext *s) {
 declare_func(void, int32_t *, int32_t *, int);
 
 if (check_func(s->decorrelate_ls, "decorrelate_ls")) {
@@ -60,7 +62,6 @@ static void test_decorrelate_ls(TAKDSPContext *s) {
 }
 
 static void test_decorrelate_sr(TAKDSPContext *s) {
-#define BUF_SIZE 1024
 declare_func(void, int32_t *, int32_t *, int);
 
 if (check_func(s->decorrelate_sr, "decorrelate_sr")) {
@@ -86,7 +87,6 @@ static void test_decorrelate_sr(TAKDSPContext *s) {
 }
 
 static void test_decorrelate_sm(TAKDSPContext *s) {
-#define BUF_SIZE 1024
 declare_func(void, int32_t *, int32_t *, int);
 
 if (check_func(s->decorrelate_sm, "decorrelate_sm")) {
@@ -114,6 +114,34 @@ static void test_decorrelate_sm(TAKDSPContext *s) {
 report("decorrelate_sm");
 }
 
+static void test_decorrelate_sf(TAKDSPContext *s) {
+declare_func(void, int32_t *, int32_t *, int, int, int);
+
+if (check_func(s->decorrelate_sf, "decorrelate_sf")) {
+LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]);
+LOCAL_ALIGNED_32(int32_t, p1_2, [BUF_SIZE]);
+LOCAL_ALIGNED_32(int32_t, p2, [BUF_SIZE]);
+int dshift, dfactor;
+
+randomize(p1, BUF_SIZE);
+memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1));
+randomize(p2, BUF_SIZE);
+dshift = (rnd() & 0xF) + 1;
+dfactor = sign_extend(rnd(), 10);
+
+call_ref(p1, p2, BUF_SIZE, dshift, dfactor);
+call_new(p1_2, p2, BUF_SIZE, dshift, dfactor);
+
+if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0) {
+fail();
+}
+
+bench_new(p1, p2, BUF_SIZE, dshift, dfactor);
+}
+
+report("decorrelate_sf");
+}
+
 void checkasm_check_takdsp(void)
 {
 TAKDSPContext s = { 0 };
@@ -122,4 +150,5 @@ void checkasm_check_takdsp(void)
 test_decorrelate_ls();
 test_decorrelate_sr();
 test_decorrelate_sm();
+test_decorrelate_sf();
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avcodec/takdsp: fix const correctness

2023-12-22 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Dec 22 09:09:33 
2023 -0300| [46775e64f8b34f5e4d09df8458654f9f50626c4b] | committer: James Almer

avcodec/takdsp: fix const correctness

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46775e64f8b34f5e4d09df8458654f9f50626c4b
---

 libavcodec/riscv/takdsp_init.c | 4 ++--
 libavcodec/takdsp.c| 6 +++---
 libavcodec/takdsp.h| 6 +++---
 libavcodec/x86/takdsp_init.c   | 6 +++---
 tests/checkasm/takdsp.c| 6 +++---
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/riscv/takdsp_init.c b/libavcodec/riscv/takdsp_init.c
index 0b4ec18086..2d5c974459 100644
--- a/libavcodec/riscv/takdsp_init.c
+++ b/libavcodec/riscv/takdsp_init.c
@@ -25,8 +25,8 @@
 #include "libavutil/riscv/cpu.h"
 #include "libavcodec/takdsp.h"
 
-void ff_decorrelate_ls_rvv(int32_t *p1, int32_t *p2, int length);
-void ff_decorrelate_sr_rvv(int32_t *p1, int32_t *p2, int length);
+void ff_decorrelate_ls_rvv(const int32_t *p1, int32_t *p2, int length);
+void ff_decorrelate_sr_rvv(int32_t *p1, const int32_t *p2, int length);
 
 av_cold void ff_takdsp_init_riscv(TAKDSPContext *dsp)
 {
diff --git a/libavcodec/takdsp.c b/libavcodec/takdsp.c
index 25cac558ce..51b6658de4 100644
--- a/libavcodec/takdsp.c
+++ b/libavcodec/takdsp.c
@@ -23,7 +23,7 @@
 #include "takdsp.h"
 #include "config.h"
 
-static void decorrelate_ls(int32_t *p1, int32_t *p2, int length)
+static void decorrelate_ls(const int32_t *p1, int32_t *p2, int length)
 {
 int i;
 
@@ -34,7 +34,7 @@ static void decorrelate_ls(int32_t *p1, int32_t *p2, int 
length)
 }
 }
 
-static void decorrelate_sr(int32_t *p1, int32_t *p2, int length)
+static void decorrelate_sr(int32_t *p1, const int32_t *p2, int length)
 {
 int i;
 
@@ -58,7 +58,7 @@ static void decorrelate_sm(int32_t *p1, int32_t *p2, int 
length)
 }
 }
 
-static void decorrelate_sf(int32_t *p1, int32_t *p2, int length, int dshift, 
int dfactor)
+static void decorrelate_sf(int32_t *p1, const int32_t *p2, int length, int 
dshift, int dfactor)
 {
 int i;
 
diff --git a/libavcodec/takdsp.h b/libavcodec/takdsp.h
index 55f1a10cd3..13b5e530b2 100644
--- a/libavcodec/takdsp.h
+++ b/libavcodec/takdsp.h
@@ -22,10 +22,10 @@
 #include 
 
 typedef struct TAKDSPContext {
-void (*decorrelate_ls)(int32_t *p1, int32_t *p2, int length);
-void (*decorrelate_sr)(int32_t *p1, int32_t *p2, int length);
+void (*decorrelate_ls)(const int32_t *p1, int32_t *p2, int length);
+void (*decorrelate_sr)(int32_t *p1, const int32_t *p2, int length);
 void (*decorrelate_sm)(int32_t *p1, int32_t *p2, int length);
-void (*decorrelate_sf)(int32_t *p1, int32_t *p2, int length, int dshift, 
int dfactor);
+void (*decorrelate_sf)(int32_t *p1, const int32_t *p2, int length, int 
dshift, int dfactor);
 } TAKDSPContext;
 
 void ff_takdsp_init(TAKDSPContext *c);
diff --git a/libavcodec/x86/takdsp_init.c b/libavcodec/x86/takdsp_init.c
index b2e6e639ee..12b62b8247 100644
--- a/libavcodec/x86/takdsp_init.c
+++ b/libavcodec/x86/takdsp_init.c
@@ -23,10 +23,10 @@
 #include "libavutil/x86/cpu.h"
 #include "config.h"
 
-void ff_tak_decorrelate_ls_sse2(int32_t *p1, int32_t *p2, int length);
-void ff_tak_decorrelate_sr_sse2(int32_t *p1, int32_t *p2, int length);
+void ff_tak_decorrelate_ls_sse2(const int32_t *p1, int32_t *p2, int length);
+void ff_tak_decorrelate_sr_sse2(int32_t *p1, const int32_t *p2, int length);
 void ff_tak_decorrelate_sm_sse2(int32_t *p1, int32_t *p2, int length);
-void ff_tak_decorrelate_sf_sse4(int32_t *p1, int32_t *p2, int length, int 
dshift, int dfactor);
+void ff_tak_decorrelate_sf_sse4(int32_t *p1, const int32_t *p2, int length, 
int dshift, int dfactor);
 
 av_cold void ff_takdsp_init_x86(TAKDSPContext *c)
 {
diff --git a/tests/checkasm/takdsp.c b/tests/checkasm/takdsp.c
index b27bb92976..544edc621d 100644
--- a/tests/checkasm/takdsp.c
+++ b/tests/checkasm/takdsp.c
@@ -37,7 +37,7 @@
 #define BUF_SIZE 1024
 
 static void test_decorrelate_ls(TAKDSPContext *s) {
-declare_func(void, int32_t *, int32_t *, int);
+declare_func(void, const int32_t *, int32_t *, int);
 
 if (check_func(s->decorrelate_ls, "decorrelate_ls")) {
 LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]);
@@ -62,7 +62,7 @@ static void test_decorrelate_ls(TAKDSPContext *s) {
 }
 
 static void test_decorrelate_sr(TAKDSPContext *s) {
-declare_func(void, int32_t *, int32_t *, int);
+declare_func(void, int32_t *, const int32_t *, int);
 
 if (check_func(s->decorrelate_sr, "decorrelate_sr")) {
 LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]);
@@ -115,7 +115,7 @@ static void test_decorrelate_sm(TAKDSPContext *s) {
 }
 
 static void test_decorrelate_sf(TAKDSPContext *s) {
-declare_func(void, int32_t *, int32_t *, int, int, int);
+declare_func(void, int32_t *, const int32_t *, int, int, int);
 
 if (check_func(s->decorrelate_sf, "decorrelate_sf")) {
 LOCAL_ALIGNED_32(int32_t, p1, 

[FFmpeg-cvslog] checkasm: Fix the takdsp tests

2023-12-22 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Fri Dec 22 
11:39:57 2023 +0200| [935837c3d388f47de39fab40337e4b356d03c298] | committer: 
Martin Storsjö

checkasm: Fix the takdsp tests

For memcpy and memcmp, we need to multiply by the element size,
otherwise we're copying and comparing only a fraction of the buffer.

For decorrelate_sr, the buffer p1 is the one that is mutated;
copy and check p1 instead of p2.

For decorrelate_sm, both buffers are mutated, so copy and check
both of them.

For decorrelate_sm, the memcpy initialization of p1 and p1_2 was
reversed - p1 is filled with randomize, but then memcpy copies from
p1_2 to p1. As p1_2 is uninitialized at this point, clang concluded
that the copy was bogus and omitted it entirely, triggering failures
in this test on x86 (where there was an existing assembly implementation
to test).

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=935837c3d388f47de39fab40337e4b356d03c298
---

 tests/checkasm/takdsp.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tests/checkasm/takdsp.c b/tests/checkasm/takdsp.c
index 495b7242c5..3aecee1f72 100644
--- a/tests/checkasm/takdsp.c
+++ b/tests/checkasm/takdsp.c
@@ -44,12 +44,12 @@ static void test_decorrelate_ls(TAKDSPContext *s) {
 
 randomize(p1, BUF_SIZE);
 randomize(p2, BUF_SIZE);
-memcpy(p2_2, p2, BUF_SIZE);
+memcpy(p2_2, p2, BUF_SIZE * sizeof(*p2));
 
 call_ref(p1, p2, BUF_SIZE);
 call_new(p1, p2_2, BUF_SIZE);
 
-if (memcmp(p2, p2_2, BUF_SIZE) != 0){
+if (memcmp(p2, p2_2, BUF_SIZE * sizeof(*p2)) != 0) {
 fail();
 }
 
@@ -65,17 +65,17 @@ static void test_decorrelate_sr(TAKDSPContext *s) {
 
 if (check_func(s->decorrelate_sr, "decorrelate_sr")) {
 LOCAL_ALIGNED_32(int32_t, p1, [BUF_SIZE]);
+LOCAL_ALIGNED_32(int32_t, p1_2, [BUF_SIZE]);
 LOCAL_ALIGNED_32(int32_t, p2, [BUF_SIZE]);
-LOCAL_ALIGNED_32(int32_t, p2_2, [BUF_SIZE]);
 
 randomize(p1, BUF_SIZE);
+memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1));
 randomize(p2, BUF_SIZE);
-memcpy(p2_2, p2, BUF_SIZE);
 
 call_ref(p1, p2, BUF_SIZE);
-call_new(p1, p2_2, BUF_SIZE);
+call_new(p1_2, p2, BUF_SIZE);
 
-if (memcmp(p2, p2_2, BUF_SIZE) != 0){
+if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0) {
 fail();
 }
 
@@ -96,14 +96,15 @@ static void test_decorrelate_sm(TAKDSPContext *s) {
 LOCAL_ALIGNED_32(int32_t, p2_2, [BUF_SIZE]);
 
 randomize(p1, BUF_SIZE);
-memcpy(p1, p1_2, BUF_SIZE);
+memcpy(p1_2, p1, BUF_SIZE * sizeof(*p1));
 randomize(p2, BUF_SIZE);
-memcpy(p2_2, p2, BUF_SIZE);
+memcpy(p2_2, p2, BUF_SIZE * sizeof(*p2));
 
 call_ref(p1, p2, BUF_SIZE);
 call_new(p1_2, p2_2, BUF_SIZE);
 
-if (memcmp(p2, p2_2, BUF_SIZE) != 0){
+if (memcmp(p1, p1_2, BUF_SIZE * sizeof(*p1)) != 0 ||
+memcmp(p2, p2_2, BUF_SIZE * sizeof(*p2)) != 0) {
 fail();
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avcodec/libjxldec: emit proper PTS to decoded AVFrame

2023-12-22 Thread Leo Izen
ffmpeg | branch: master | Leo Izen  | Fri Dec 15 16:06:33 
2023 -0500| [5942cf46b6ca4daeff51322ce9fb6e683366a166] | committer: Leo Izen

avcodec/libjxldec: emit proper PTS to decoded AVFrame

If a sequence of JXL images is encapsulated in a container that has PTS
information, we should use the PTS information from the container. At
this time there is no container that does this, but if JPEG XL support
is ever added to NUT, AVTransport, or some other container, this commit
should allow the PTS information those containers provide to work as
expected.

Signed-off-by: Leo Izen 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5942cf46b6ca4daeff51322ce9fb6e683366a166
---

 libavcodec/libjxldec.c | 57 +-
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index d719c06bdf..b830eee784 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -54,10 +54,10 @@ typedef struct LibJxlDecodeContext {
 JxlDecoderStatus events;
 AVBufferRef *iccp;
 AVPacket *avpkt;
-int64_t pts;
+int64_t accumulated_pts;
 int64_t frame_duration;
 int prev_is_last;
-AVRational timebase;
+AVRational anim_timebase;
 AVFrame *frame;
 } LibJxlDecodeContext;
 
@@ -80,7 +80,6 @@ static int libjxl_init_jxl_decoder(AVCodecContext *avctx)
 memset(>basic_info, 0, sizeof(JxlBasicInfo));
 memset(>jxl_pixfmt, 0, sizeof(JxlPixelFormat));
 ctx->prev_is_last = 1;
-ctx->frame_duration = 1;
 
 return 0;
 }
@@ -104,7 +103,6 @@ static av_cold int libjxl_decode_init(AVCodecContext *avctx)
 }
 
 ctx->avpkt = avctx->internal->in_pkt;
-ctx->pts = 0;
 ctx->frame = av_frame_alloc();
 if (!ctx->frame)
 return AVERROR(ENOMEM);
@@ -371,12 +369,15 @@ static int libjxl_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 
 while (1) {
 size_t remaining;
+JxlFrameHeader header;
 
 if (!pkt->size) {
 av_packet_unref(pkt);
 ret = ff_decode_get_packet(avctx, pkt);
 if (ret < 0 && ret != AVERROR_EOF)
 return ret;
+ctx->accumulated_pts = 0;
+ctx->frame_duration = 0;
 if (!pkt->size) {
 /* jret set by the last iteration of the loop */
 if (jret == JXL_DEC_NEED_MORE_INPUT) {
@@ -430,12 +431,8 @@ static int libjxl_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 if ((ret = ff_set_dimensions(avctx, ctx->basic_info.xsize, 
ctx->basic_info.ysize)) < 0)
 return ret;
 if (ctx->basic_info.have_animation)
-ctx->timebase = 
av_make_q(ctx->basic_info.animation.tps_denominator,
-  
ctx->basic_info.animation.tps_numerator);
-else if (avctx->pkt_timebase.num)
-ctx->timebase = avctx->pkt_timebase;
-else
-ctx->timebase = AV_TIME_BASE_Q;
+ctx->anim_timebase = 
av_make_q(ctx->basic_info.animation.tps_denominator,
+   
ctx->basic_info.animation.tps_numerator);
 continue;
 case JXL_DEC_COLOR_ENCODING:
 av_log(avctx, AV_LOG_DEBUG, "COLOR_ENCODING event emitted\n");
@@ -463,23 +460,24 @@ static int libjxl_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 #endif
 continue;
 case JXL_DEC_FRAME:
+/* Frame here refers to the Frame bundle, not a decoded picture */
 av_log(avctx, AV_LOG_DEBUG, "FRAME event emitted\n");
-if (!ctx->basic_info.have_animation || ctx->prev_is_last) {
+if (ctx->prev_is_last) {
+/*
+ * The last frame sent was tagged as "is_last" which
+ * means this is a new image file altogether.
+ */
 ctx->frame->pict_type = AV_PICTURE_TYPE_I;
 ctx->frame->flags |= AV_FRAME_FLAG_KEY;
 }
-if (ctx->basic_info.have_animation) {
-JxlFrameHeader header;
-if (JxlDecoderGetFrameHeader(ctx->decoder, ) != 
JXL_DEC_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Bad libjxl dec frame 
event\n");
-return AVERROR_EXTERNAL;
-}
-ctx->prev_is_last = header.is_last;
-ctx->frame_duration = header.duration;
-} else {
-ctx->prev_is_last = 1;
-ctx->frame_duration = 1;
+if (JxlDecoderGetFrameHeader(ctx->decoder, ) != 
JXL_DEC_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Bad libjxl dec frame event\n");
+return AVERROR_EXTERNAL;
 }
+ctx->prev_is_last = header.is_last;
+/* zero duration for animation means the frame is not presented */
+if (ctx->basic_info.have_animation && 

[FFmpeg-cvslog] avcodec/pngdec: improve handling of bad cICP range tags

2023-12-22 Thread Leo Izen
ffmpeg | branch: master | Leo Izen  | Tue Dec 12 14:41:01 
2023 -0500| [4013b8d3f04966338267aecee2ac7d23ed2064b5] | committer: Leo Izen

avcodec/pngdec: improve handling of bad cICP range tags

FFmpeg doesn't support tv-range RGB throughout most of its pipeline, so
we should keep the warning. However, in case something does support it
we should at least keep it tagged properly. Additionally, the encoder
writes this tag if the space is tagged as such so this makes a round
trip work as it should.

Also, PNG doesn't support nonzero matrices but we only warn and ignore
in that case, so we have no reason to error out for illegal cICP ranges
either (i.e. greater than 1).

Signed-off-by: Leo Izen 
Reported-by: Kacper Michajłow 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4013b8d3f04966338267aecee2ac7d23ed2064b5
---

 libavcodec/pngdec.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index d812ffd348..d1aae4c70e 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -661,8 +661,13 @@ static int populate_avctx_color_fields(AVCodecContext 
*avctx, AVFrame *frame)
 av_log(avctx, AV_LOG_WARNING, "unrecognized cICP transfer\n");
 else
 avctx->color_trc = frame->color_trc = s->cicp_trc;
-if (s->cicp_range == 0)
-av_log(avctx, AV_LOG_WARNING, "unsupported tv-range cICP chunk\n");
+if (s->cicp_range == 0) {
+av_log(avctx, AV_LOG_WARNING, "tv-range cICP tag found. Colors may 
be wrong\n");
+avctx->color_range = frame->color_range = AVCOL_RANGE_MPEG;
+} else if (s->cicp_range != 1) {
+/* we already printed a warning when parsing the cICP chunk */
+avctx->color_range = frame->color_range = AVCOL_RANGE_UNSPECIFIED;
+}
 } else if (s->iccp_data) {
 AVFrameSideData *sd = av_frame_new_side_data(frame, 
AV_FRAME_DATA_ICC_PROFILE, s->iccp_data_len);
 if (!sd)
@@ -713,9 +718,10 @@ static int populate_avctx_color_fields(AVCodecContext 
*avctx, AVFrame *frame)
 avctx->color_trc = frame->color_trc = AVCOL_TRC_LINEAR;
 }
 
-/* we only support pc-range RGB */
+/* PNG only supports RGB */
 avctx->colorspace = frame->colorspace = AVCOL_SPC_RGB;
-avctx->color_range = frame->color_range = AVCOL_RANGE_JPEG;
+if (!s->have_cicp || s->cicp_range == 1)
+avctx->color_range = frame->color_range = AVCOL_RANGE_JPEG;
 
 /*
  * tRNS sets alpha depth to full, so we ignore sBIT if set.
@@ -1455,11 +1461,8 @@ static int decode_frame_common(AVCodecContext *avctx, 
PNGDecContext *s,
 if (bytestream2_get_byte(_chunk) != 0)
 av_log(avctx, AV_LOG_WARNING, "nonzero cICP matrix\n");
 s->cicp_range = bytestream2_get_byte(_chunk);
-if (s->cicp_range != 0 && s->cicp_range != 1) {
-av_log(avctx, AV_LOG_ERROR, "invalid cICP range: %d\n", 
s->cicp_range);
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+if (s->cicp_range != 0 && s->cicp_range != 1)
+av_log(avctx, AV_LOG_WARNING, "invalid cICP range: %d\n", 
s->cicp_range);
 s->have_cicp = 1;
 break;
 case MKTAG('s', 'R', 'G', 'B'):
@@ -1814,8 +1817,6 @@ static av_cold int png_dec_init(AVCodecContext *avctx)
 {
 PNGDecContext *s = avctx->priv_data;
 
-avctx->color_range = AVCOL_RANGE_JPEG;
-
 s->avctx = avctx;
 s->last_picture.f = av_frame_alloc();
 s->picture.f = av_frame_alloc();

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avcodec/libjxldec: produce rgbf32 and rgbaf32 frames

2023-12-22 Thread Leo Izen
ffmpeg | branch: master | Leo Izen  | Mon Dec 11 07:02:32 
2023 -0500| [f6ef6a853cd6334fcc70aa6c1b3f05028d57b82b] | committer: Leo Izen

avcodec/libjxldec: produce rgbf32 and rgbaf32 frames

These pixel formats have always been supported by libjxl, but at the
time this plugin was written, they were not in FFmpeg yet. Now that
they are in FFmpeg, we should support them.

Signed-off-by: Leo Izen 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6ef6a853cd6334fcc70aa6c1b3f05028d57b82b
---

 libavcodec/libjxldec.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 002740d9c1..d719c06bdf 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -130,10 +130,11 @@ static enum AVPixelFormat 
libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecode
 return basic_info->alpha_bits ? AV_PIX_FMT_YA8 : AV_PIX_FMT_GRAY8;
 }
 if (basic_info->exponent_bits_per_sample || 
basic_info->bits_per_sample > 16) {
-if (basic_info->alpha_bits)
-return AV_PIX_FMT_NONE;
-format->data_type = JXL_TYPE_FLOAT;
-return AV_PIX_FMT_GRAYF32;
+if (!basic_info->alpha_bits) {
+format->data_type = JXL_TYPE_FLOAT;
+return AV_PIX_FMT_GRAYF32;
+}
+av_log(avctx, AV_LOG_WARNING, "Downsampling gray+alpha float to 
16-bit integer via libjxl\n");
 }
 format->data_type = JXL_TYPE_UINT16;
 return basic_info->alpha_bits ? AV_PIX_FMT_YA16 : AV_PIX_FMT_GRAY16;
@@ -145,10 +146,10 @@ static enum AVPixelFormat 
libjxl_get_pix_fmt(AVCodecContext *avctx, LibJxlDecode
 format->data_type = JXL_TYPE_UINT8;
 return basic_info->alpha_bits ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24;
 }
-if (basic_info->exponent_bits_per_sample)
-av_log(avctx, AV_LOG_WARNING, "Downsampling float to 16-bit 
integer via libjxl\n");
-else if (basic_info->bits_per_sample > 16)
-av_log(avctx, AV_LOG_WARNING, "Downsampling larger integer to 
16-bit via libjxl\n");
+if (basic_info->exponent_bits_per_sample || 
basic_info->bits_per_sample > 16) {
+format->data_type = JXL_TYPE_FLOAT;
+return basic_info->alpha_bits ? AV_PIX_FMT_RGBAF32 : 
AV_PIX_FMT_RGBF32;
+}
 format->data_type = JXL_TYPE_UINT16;
 return basic_info->alpha_bits ? AV_PIX_FMT_RGBA64 : AV_PIX_FMT_RGB48;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avcodec/libjxlenc: Don't refer to decoder in comments

2023-12-22 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Dec 22 00:01:52 2023 +0100| [577dd7b762c9d81b9886ec967b91a7b03f459f23] | 
committer: Leo Izen

avcodec/libjxlenc: Don't refer to decoder in comments

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=577dd7b762c9d81b9886ec967b91a7b03f459f23
---

 libavcodec/libjxlenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 03fd5ccfe2..3be47d8d08 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -85,8 +85,8 @@ static float quality_to_distance(float quality)
 }
 
 /**
- * Initalize the decoder on a per-frame basis. All of these need to be set
- * once each time the decoder is reset, which it must be each frame to make
+ * Initalize the encoder on a per-frame basis. All of these need to be set
+ * once each time the encoder is reset, which it must be each frame to make
  * the image2 muxer work.
  *
  * @return   0 upon success, negative on failure.
@@ -104,7 +104,7 @@ static int libjxl_init_jxl_encoder(AVCodecContext *avctx)
 return AVERROR_EXTERNAL;
 }
 
-/* This needs to be set each time the decoder is reset */
+/* This needs to be set each time the encoder is reset */
 if (JxlEncoderSetParallelRunner(ctx->encoder, JxlThreadParallelRunner, 
ctx->runner)
 != JXL_ENC_SUCCESS) {
 av_log(avctx, AV_LOG_ERROR, "Failed to set JxlThreadParallelRunner\n");
@@ -446,7 +446,7 @@ static av_cold int libjxl_encode_close(AVCodecContext 
*avctx)
 ctx->runner = NULL;
 
 /*
- * destroying the decoder also frees
+ * destroying the encoder also frees
  * ctx->options so we don't need to
  */
 if (ctx->encoder)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avcodec/libjxlenc: accept rgbf32 and rgbaf32 frames

2023-12-22 Thread Leo Izen
ffmpeg | branch: master | Leo Izen  | Mon Dec 11 07:02:33 
2023 -0500| [42f78925d706ad62c982ec25566351f75d44d482] | committer: Leo Izen

avcodec/libjxlenc: accept rgbf32 and rgbaf32 frames

These pixel formats have always been supported by libjxl, but at the
time this plugin was written, they were not in FFmpeg yet. Now that
they are in FFmpeg, we should support them.

Signed-off-by: Leo Izen 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42f78925d706ad62c982ec25566351f75d44d482
---

 libavcodec/libjxlenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index a72956018d..03fd5ccfe2 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -492,6 +492,7 @@ const FFCodec ff_libjxl_encoder = {
 .p.pix_fmts   = (const enum AVPixelFormat[]) {
 AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
 AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64,
+AV_PIX_FMT_RGBF32, AV_PIX_FMT_RGBAF32,
 AV_PIX_FMT_GRAY8, AV_PIX_FMT_YA8,
 AV_PIX_FMT_GRAY16, AV_PIX_FMT_YA16,
 AV_PIX_FMT_GRAYF32,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avcodec/libjxlenc: Set AV_CODEC_CAP_DR1

2023-12-22 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Dec 22 00:03:03 2023 +0100| [370ce305f4f99073f823628606872f406d4abbff] | 
committer: Leo Izen

avcodec/libjxlenc: Set AV_CODEC_CAP_DR1

This encoder uses ff_get_encode_buffer() to allocate the packet buffer.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=370ce305f4f99073f823628606872f406d4abbff
---

 libavcodec/libjxlenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 3be47d8d08..ab2b5617b3 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -485,6 +485,7 @@ const FFCodec ff_libjxl_encoder = {
 FF_CODEC_ENCODE_CB(libjxl_encode_frame),
 .close= libjxl_encode_close,
 .p.capabilities   = AV_CODEC_CAP_OTHER_THREADS |
+AV_CODEC_CAP_DR1 |
 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 .caps_internal= FF_CODEC_CAP_NOT_INIT_THREADSAFE |
 FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP |

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] configure: Remove/factorize a redundant check for UWP mode

2023-12-22 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Thu Dec 21 
23:22:29 2023 +0200| [6d045187880c9209e8d2a4b995acba7284088f83] | committer: 
Martin Storsjö

configure: Remove/factorize a redundant check for UWP mode

The check for UWP mode was duplicated from right above, in
d54127c41a81cf2078a3504f78e0e4232cfe11b7.

Also, instead of several lines with "enabled uwp && ...", make one
"if enabled uwp; then" block.

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d045187880c9209e8d2a4b995acba7284088f83
---

 configure | 30 +++---
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/configure b/configure
index af0bebc1ac..69b755f274 100755
--- a/configure
+++ b/configure
@@ -7102,9 +7102,8 @@ fi
 
 check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs"
 
-# d3d11va requires linking directly to dxgi and d3d11 if not building for
-# the desktop api partition
-test_cpp <
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
@@ -7117,23 +7116,16 @@ test_cpp <
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-#error desktop, not uwp
-#else
-// WINAPI_FAMILY_APP, WINAPI_FAMILY_PHONE_APP => UWP
-#endif
-#else
-#error no family set
-#endif
-EOF
+mediafoundation_extralibs="-lmfuuid -lole32 -lstrmiids"
 
-# mediafoundation requires linking directly to mfplat if building for uwp 
target
-enabled uwp && mediafoundation_extralibs="-lmfplat -lmfuuid -lole32 
-lstrmiids" || mediafoundation_extralibs="-lmfuuid -lole32 -lstrmiids"
+if enabled uwp; then
+# In UWP mode, we can't use LoadLibrary+GetProcAddress to conditionally
+# try to load these APIs at runtime, like we do in regular desktop mode -
+# therefore, we need to link directly against these APIs.
+d3d11va_extralibs="-ldxgi -ld3d11"
+vaapi_win32_extralibs="-ldxgi"
+mediafoundation_extralibs="-lmfplat $mediafoundation_extralibs"
+fi
 
 enabled libdrm &&
 check_pkg_config libdrm_getfb2 libdrm "xf86drmMode.h" drmModeGetFB2

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] configure: Fix linking d3d12va in UWP mode

2023-12-22 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Thu Dec 21 
23:25:00 2023 +0200| [4f493659fd793f2c0191c56608d0e3e2757badf4] | committer: 
Martin Storsjö

configure: Fix linking d3d12va in UWP mode

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f493659fd793f2c0191c56608d0e3e2757badf4
---

 configure | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 69b755f274..18fe8eaa5c 100755
--- a/configure
+++ b/configure
@@ -3922,7 +3922,7 @@ swscale_suggest="libm stdatomic"
 
 avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs 
lcms2_extralibs"
 avfilter_extralibs="pthreads_extralibs"
-avutil_extralibs="d3d11va_extralibs mediacodec_extralibs nanosleep_extralibs 
pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs 
vaapi_win32_extralibs vdpau_x11_extralibs"
+avutil_extralibs="d3d11va_extralibs d3d12va_extralibs mediacodec_extralibs 
nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs 
vaapi_win32_extralibs vdpau_x11_extralibs"
 
 # programs
 ffmpeg_deps="avcodec avfilter avformat threads"
@@ -7123,6 +7123,7 @@ if enabled uwp; then
 # try to load these APIs at runtime, like we do in regular desktop mode -
 # therefore, we need to link directly against these APIs.
 d3d11va_extralibs="-ldxgi -ld3d11"
+d3d12va_extralibs="-ldxgi -ld3d12"
 vaapi_win32_extralibs="-ldxgi"
 mediafoundation_extralibs="-lmfplat $mediafoundation_extralibs"
 fi

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/cmdutils: renumber option flags sequentially

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Dec 17 
10:56:02 2023 +0100| [66fcfc0009d08ac6ef95f5db4a1b6ee3ba502b8f] | committer: 
Anton Khirnov

fftools/cmdutils: renumber option flags sequentially

Also, document them.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=66fcfc0009d08ac6ef95f5db4a1b6ee3ba502b8f
---

 fftools/cmdutils.h | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index d0242dc6ab..8e22560fc6 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -125,23 +125,31 @@ typedef struct OptionDef {
  * - all other types do
  */
 #define OPT_FUNC_ARG(1 << 0)
+/* Program will immediately exit after processing this option */
+#define OPT_EXIT(1 << 1)
+/* Option is intended for advanced users. Only affects
+ * help output.
+ */
 #define OPT_EXPERT  (1 << 2)
-#define OPT_VIDEO   (1 << 4)
-#define OPT_AUDIO   (1 << 5)
-#define OPT_SUBTITLE(1 << 8)
-#define OPT_EXIT(1 << 10)
-#define OPT_DATA(1 << 11)
-/* The option is per-file (currently ffmpeg-only).
-   implied by OPT_OFFSET or OPT_SPEC */
-#define OPT_PERFILE (1 << 12)
+#define OPT_VIDEO   (1 << 3)
+#define OPT_AUDIO   (1 << 4)
+#define OPT_SUBTITLE(1 << 5)
+#define OPT_DATA(1 << 6)
+/* The option is per-file (currently ffmpeg-only). Implied by OPT_OFFSET or
+ * OPT_SPEC. At least one of OPT_INPUT or OPT_OUTPUT must be set when this flag
+ * is in use.
+   */
+#define OPT_PERFILE (1 << 7)
 /* Option is specified as an offset in a passed optctx */
-#define OPT_OFFSET  (1 << 13)
+#define OPT_OFFSET  (1 << 8)
 /* Option is to be stored in an array of SpecifierOpt. Implies OPT_OFFSET.
Next element after the offset is an int containing element count in the
array. */
-#define OPT_SPEC(1 << 14)
-#define OPT_INPUT   (1 << 17)
-#define OPT_OUTPUT  (1 << 18)
+#define OPT_SPEC(1 << 9)
+/* ffmpeg-only - specifies whether an OPT_PERFILE option applies to input,
+ * output, or both. */
+#define OPT_INPUT   (1 << 10)
+#define OPT_OUTPUT  (1 << 11)
  union {
 void *dst_ptr;
 int (*func_arg)(void *, const char *, const char *);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools: split off option types from other flags

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Dec 15 
08:50:26 2023 +0100| [d2e479a4296b1b3009a1e127ecddac5d550095e1] | committer: 
Anton Khirnov

fftools: split off option types from other flags

These values are not actually flags, as only one of them can be
meaningfully set.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d2e479a4296b1b3009a1e127ecddac5d550095e1
---

 fftools/cmdutils.c   |  51 ++---
 fftools/cmdutils.h   |  21 +-
 fftools/ffmpeg_opt.c | 560 ++-
 fftools/ffplay.c | 102 +-
 fftools/ffprobe.c|  76 +++
 fftools/opt_common.h |  62 +++---
 6 files changed, 490 insertions(+), 382 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index f5b3dc7346..8ff69cabf5 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -83,7 +83,7 @@ void init_dynload(void)
 #endif
 }
 
-int parse_number(const char *context, const char *numstr, int type,
+int parse_number(const char *context, const char *numstr, enum OptionType type,
  double min, double max, double *dst)
 {
 char *tail;
@@ -93,9 +93,9 @@ int parse_number(const char *context, const char *numstr, int 
type,
 error = "Expected number for %s but found: %s\n";
 else if (d < min || d > max)
 error = "The value for %s was %s which is not within %f - %f\n";
-else if (type == OPT_INT64 && (int64_t)d != d)
+else if (type == OPT_TYPE_INT64 && (int64_t)d != d)
 error = "Expected int64 for %s but found %s\n";
-else if (type == OPT_INT && (int)d != d)
+else if (type == OPT_TYPE_INT && (int)d != d)
 error = "Expected int for %s but found %s\n";
 else {
 *dst = d;
@@ -225,13 +225,11 @@ static inline void prepare_app_arguments(int *argc_ptr, 
char ***argv_ptr)
 
 static int opt_has_arg(const OptionDef *o)
 {
-if (o->flags & OPT_BOOL)
+if (o->type == OPT_TYPE_BOOL)
 return 0;
-if (o->flags &
-(OPT_STRING | OPT_INT  | OPT_FLOAT  | OPT_INT64 |
- OPT_SPEC   | OPT_TIME | OPT_DOUBLE))
-return 1;
-return !!(o->flags & HAS_ARG);
+if (o->type == OPT_TYPE_FUNC)
+return !!(o->flags & HAS_ARG);
+return 1;
 }
 
 static int write_option(void *optctx, const OptionDef *po, const char *opt,
@@ -262,46 +260,50 @@ static int write_option(void *optctx, const OptionDef 
*po, const char *opt,
 dst = &(*so)[*dstcount - 1].u;
 }
 
-if (po->flags & OPT_STRING) {
+if (po->type == OPT_TYPE_STRING) {
 char *str;
 str = av_strdup(arg);
 av_freep(dst);
 if (!str)
 return AVERROR(ENOMEM);
 *(char **)dst = str;
-} else if (po->flags & OPT_BOOL || po->flags & OPT_INT) {
-ret = parse_number(opt, arg, OPT_INT64, INT_MIN, INT_MAX, );
+} else if (po->type == OPT_TYPE_BOOL || po->type == OPT_TYPE_INT) {
+ret = parse_number(opt, arg, OPT_TYPE_INT64, INT_MIN, INT_MAX, );
 if (ret < 0)
 return ret;
 
 *(int *)dst = num;
-} else if (po->flags & OPT_INT64) {
-ret = parse_number(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX, );
+} else if (po->type == OPT_TYPE_INT64) {
+ret = parse_number(opt, arg, OPT_TYPE_INT64, INT64_MIN, INT64_MAX, 
);
 if (ret < 0)
 return ret;
 
 *(int64_t *)dst = num;
-} else if (po->flags & OPT_TIME) {
+} else if (po->type == OPT_TYPE_TIME) {
 ret = av_parse_time(dst, arg, 1);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Invalid duration for option %s: %s\n",
opt, arg);
 return ret;
 }
-} else if (po->flags & OPT_FLOAT) {
-ret = parse_number(opt, arg, OPT_FLOAT, -INFINITY, INFINITY, );
+} else if (po->type == OPT_TYPE_FLOAT) {
+ret = parse_number(opt, arg, OPT_TYPE_FLOAT, -INFINITY, INFINITY, 
);
 if (ret < 0)
 return ret;
 
 *(float *)dst = num;
-} else if (po->flags & OPT_DOUBLE) {
-ret = parse_number(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY, );
+} else if (po->type == OPT_TYPE_DOUBLE) {
+ret = parse_number(opt, arg, OPT_TYPE_DOUBLE, -INFINITY, INFINITY, 
);
 if (ret < 0)
 return ret;
 
 *(double *)dst = num;
-} else if (po->u.func_arg) {
-int ret = po->u.func_arg(optctx, opt, arg);
+} else {
+int ret;
+
+av_assert0(po->type == OPT_TYPE_FUNC && po->u.func_arg);
+
+ret = po->u.func_arg(optctx, opt, arg);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR,
"Failed to set value '%s' for option '%s': %s\n",
@@ -320,6 +322,7 @@ int parse_option(void *optctx, const char *opt, const char 
*arg,
 {
 static const OptionDef opt_avoptions = {
 .name   = "AVOption passthrough",
+.type   = OPT_TYPE_FUNC,
 .flags  = HAS_ARG,
 .u.func_arg = opt_default,
 };
@@ -331,9 +334,9 @@ int 

[FFmpeg-cvslog] fftools/cmdutils: include OPT_PERFILE in OPT_OFFSET

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Dec 17 
11:47:33 2023 +0100| [2f1bc3b424f33069e4d870b05898aa1500f9b1ff] | committer: 
Anton Khirnov

fftools/cmdutils: include OPT_PERFILE in OPT_OFFSET

And analogously OPT_OFFSET in OPT_SPEC. Previously the inclusion would
be implicit and required all code to remember this.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f1bc3b424f33069e4d870b05898aa1500f9b1ff
---

 fftools/cmdutils.c   |  6 +++---
 fftools/cmdutils.h   | 21 +
 fftools/ffmpeg_opt.c | 14 ++
 3 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 38f4f542d3..6ca2efef4a 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -237,13 +237,13 @@ static int write_option(void *optctx, const OptionDef 
*po, const char *opt,
 {
 /* new-style options contain an offset into optctx, old-style address of
  * a global var*/
-void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ?
+void *dst = po->flags & OPT_FLAG_OFFSET ?
 (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
 int *dstcount;
 double num;
 int ret;
 
-if (po->flags & OPT_SPEC) {
+if (po->flags & OPT_FLAG_SPEC) {
 SpecifierOpt **so = dst;
 char *p = strchr(opt, ':');
 char *str;
@@ -660,7 +660,7 @@ static int finish_group(OptionParseContext *octx, int 
group_idx,
 static int add_opt(OptionParseContext *octx, const OptionDef *opt,
const char *key, const char *val)
 {
-int global = !(opt->flags & (OPT_PERFILE | OPT_SPEC | OPT_OFFSET));
+int global = !(opt->flags & OPT_PERFILE);
 OptionGroup *g = global ? >global_opts : >cur_group;
 int ret;
 
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 8e22560fc6..dc99573d80 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -135,17 +135,22 @@ typedef struct OptionDef {
 #define OPT_AUDIO   (1 << 4)
 #define OPT_SUBTITLE(1 << 5)
 #define OPT_DATA(1 << 6)
-/* The option is per-file (currently ffmpeg-only). Implied by OPT_OFFSET or
- * OPT_SPEC. At least one of OPT_INPUT or OPT_OUTPUT must be set when this flag
- * is in use.
+/* The option is per-file (currently ffmpeg-only). At least one of OPT_INPUT or
+ * OPT_OUTPUT must be set when this flag is in use.
*/
 #define OPT_PERFILE (1 << 7)
-/* Option is specified as an offset in a passed optctx */
-#define OPT_OFFSET  (1 << 8)
-/* Option is to be stored in an array of SpecifierOpt. Implies OPT_OFFSET.
+
+/* Option is specified as an offset in a passed optctx.
+ * Always use as OPT_OFFSET in option definitions. */
+#define OPT_FLAG_OFFSET (1 << 8)
+#define OPT_OFFSET  (OPT_FLAG_OFFSET | OPT_PERFILE)
+
+/* Option is to be stored in an array of SpecifierOpt.
Next element after the offset is an int containing element count in the
-   array. */
-#define OPT_SPEC(1 << 9)
+   array.
+   Always use as OPT_SPEC in option definitions. */
+#define OPT_FLAG_SPEC   (1 << 9)
+#define OPT_SPEC(OPT_FLAG_SPEC | OPT_OFFSET)
 /* ffmpeg-only - specifies whether an OPT_PERFILE option applies to input,
  * output, or both. */
 #define OPT_INPUT   (1 << 10)
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 63c1d0ccb1..6e8de64a8e 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -109,7 +109,7 @@ static void uninit_options(OptionsContext *o)
 while (po->name) {
 void *dst = (uint8_t*)o + po->u.off;
 
-if (po->flags & OPT_SPEC) {
+if (po->flags & OPT_FLAG_SPEC) {
 SpecifierOpt **so = dst;
 int i, *count = (int*)(so + 1);
 for (i = 0; i < *count; i++) {
@@ -119,7 +119,7 @@ static void uninit_options(OptionsContext *o)
 }
 av_freep(so);
 *count = 0;
-} else if (po->flags & OPT_OFFSET && po->type == OPT_TYPE_STRING)
+} else if (po->flags & OPT_FLAG_OFFSET && po->type == OPT_TYPE_STRING)
 av_freep(dst);
 po++;
 }
@@ -1181,8 +1181,6 @@ static int opt_filter_complex_script(void *optctx, const 
char *opt, const char *
 
 void show_help_default(const char *opt, const char *arg)
 {
-/* per-file options have at least one of those set */
-const int per_file = OPT_SPEC | OPT_OFFSET | OPT_PERFILE;
 int show_advanced = 0, show_avoptions = 0;
 
 if (opt && *opt) {
@@ -1209,17 +1207,17 @@ void show_help_default(const char *opt, const char *arg)
 
 show_help_options(options, "Global options (affect whole program "
   "instead of just one file):",
-  0, per_file | OPT_EXIT | OPT_EXPERT, 0);
+  0, OPT_PERFILE | OPT_EXIT | OPT_EXPERT, 0);
 if (show_advanced)
 show_help_options(options, "Advanced global options:", OPT_EXPERT,
-  per_file | OPT_EXIT, 0);
+  OPT_PERFILE | OPT_EXIT, 0);
 
 show_help_options(options, 

[FFmpeg-cvslog] fftools/cmdutils: rename HAS_ARG to OPT_FUNC_ARG

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Dec 17 
10:45:45 2023 +0100| [5b1b13207245344d27f0e087a734f46ec5afeca7] | committer: 
Anton Khirnov

fftools/cmdutils: rename HAS_ARG to OPT_FUNC_ARG

For consistent namespacing with other option flags. Also, document and
enforce that it can only be set for func-type options.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5b1b13207245344d27f0e087a734f46ec5afeca7
---

 fftools/cmdutils.c   |  8 +++--
 fftools/cmdutils.h   |  8 -
 fftools/ffmpeg_opt.c | 92 ++--
 fftools/ffplay.c | 14 
 fftools/ffprobe.c| 14 
 fftools/opt_common.h | 14 
 6 files changed, 80 insertions(+), 70 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8ff69cabf5..38f4f542d3 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -228,7 +228,7 @@ static int opt_has_arg(const OptionDef *o)
 if (o->type == OPT_TYPE_BOOL)
 return 0;
 if (o->type == OPT_TYPE_FUNC)
-return !!(o->flags & HAS_ARG);
+return !!(o->flags & OPT_FUNC_ARG);
 return 1;
 }
 
@@ -323,7 +323,7 @@ int parse_option(void *optctx, const char *opt, const char 
*arg,
 static const OptionDef opt_avoptions = {
 .name   = "AVOption passthrough",
 .type   = OPT_TYPE_FUNC,
-.flags  = HAS_ARG,
+.flags  = OPT_FUNC_ARG,
 .u.func_arg = opt_default,
 };
 
@@ -481,6 +481,10 @@ static void check_options(const OptionDef *po)
 while (po->name) {
 if (po->flags & OPT_PERFILE)
 av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT));
+
+// OPT_FUNC_ARG can only be ser for OPT_TYPE_FUNC
+av_assert0((po->type == OPT_TYPE_FUNC) || !(po->flags & OPT_FUNC_ARG));
+
 po++;
 }
 }
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index b9ef8b5c15..d0242dc6ab 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -118,7 +118,13 @@ typedef struct OptionDef {
 const char *name;
 enum OptionType type;
 int flags;
-#define HAS_ARG (1 << 0)
+
+/* The OPT_TYPE_FUNC option takes an argument.
+ * Must not be used with other option types, as for those it holds:
+ * - OPT_TYPE_BOOL do not take an argument
+ * - all other types do
+ */
+#define OPT_FUNC_ARG(1 << 0)
 #define OPT_EXPERT  (1 << 2)
 #define OPT_VIDEO   (1 << 4)
 #define OPT_AUDIO   (1 << 5)
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 5af7f068ad..63c1d0ccb1 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1453,7 +1453,7 @@ const OptionDef options[] = {
 { "pre",OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
 { .off   = OFFSET(presets) },
 "preset name", "preset" },
-{ "map",OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT | 
OPT_PERFILE | OPT_OUTPUT,
+{ "map",OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | 
OPT_PERFILE | OPT_OUTPUT,
 { .func_arg = opt_map },
 "set input stream mapping",
 
"[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
@@ -1495,7 +1495,7 @@ const OptionDef options[] = {
 { "itsscale",   OPT_TYPE_DOUBLE, OPT_SPEC | OPT_EXPERT | 
OPT_INPUT,
 { .off = OFFSET(ts_scale) },
 "set the input ts scale", "scale" },
-{ "timestamp",  OPT_TYPE_FUNC,   HAS_ARG | OPT_PERFILE | 
OPT_OUTPUT,
+{ "timestamp",  OPT_TYPE_FUNC,   OPT_FUNC_ARG | OPT_PERFILE | 
OPT_OUTPUT,
 { .func_arg = opt_recording_timestamp },
 "set the recording timestamp ('now' to set the current time)", "time" 
},
 { "metadata",   OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
@@ -1507,7 +1507,7 @@ const OptionDef options[] = {
 { "stream_group",   OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
 { .off = OFFSET(stream_groups) },
 "add stream group with specified streams and group type-specific 
arguments", "id=number:st=number..." },
-{ "dframes",OPT_TYPE_FUNC, HAS_ARG | OPT_PERFILE | 
OPT_EXPERT | OPT_OUTPUT,
+{ "dframes",OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | 
OPT_EXPERT | OPT_OUTPUT,
 { .func_arg = opt_data_frames },
 "set the number of data frames to output", "number" },
 { "benchmark",  OPT_TYPE_BOOL, OPT_EXPERT,
@@ -1516,13 +1516,13 @@ const OptionDef options[] = {
 { "benchmark_all",  OPT_TYPE_BOOL, OPT_EXPERT,
 { _benchmark_all },
   "add timings for each task" },
-{ "progress",   OPT_TYPE_FUNC, HAS_ARG | OPT_EXPERT,
+{ "progress",   OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
 { .func_arg = opt_progress },
   "write program-readable progress information", "url" },
 { "stdin",  OPT_TYPE_BOOL, OPT_EXPERT,
 { _interaction },
   "enable or disable interaction on standard input" },
-{ 

[FFmpeg-cvslog] fftools/cmdutils: check valid flags for OPT_TYPE_FUNC

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Dec 17 
12:03:49 2023 +0100| [579238226901285eff24ef88ae1a53b7f166adf5] | committer: 
Anton Khirnov

fftools/cmdutils: check valid flags for OPT_TYPE_FUNC

SPEC and OFFSET do not make sense for functions.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=579238226901285eff24ef88ae1a53b7f166adf5
---

 fftools/cmdutils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 6ca2efef4a..a52c7c5ae4 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -482,6 +482,9 @@ static void check_options(const OptionDef *po)
 if (po->flags & OPT_PERFILE)
 av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT));
 
+if (po->type == OPT_TYPE_FUNC)
+av_assert0(!(po->flags & (OPT_FLAG_OFFSET | OPT_FLAG_SPEC)));
+
 // OPT_FUNC_ARG can only be ser for OPT_TYPE_FUNC
 av_assert0((po->type == OPT_TYPE_FUNC) || !(po->flags & OPT_FUNC_ARG));
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/cmdutils: add a struct for a list of SpecifierOpt

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Dec 17 
14:20:57 2023 +0100| [0ba70a679216a504ed4ea6f50c37283cf099e8ae] | committer: 
Anton Khirnov

fftools/cmdutils: add a struct for a list of SpecifierOpt

Significantly simplifies the code dealing with OPT_SPEC.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ba70a679216a504ed4ea6f50c37283cf099e8ae
---

 fftools/cmdutils.c|  10 +--
 fftools/cmdutils.h|   9 ++-
 fftools/ffmpeg.h  | 200 --
 fftools/ffmpeg_demux.c|  30 +++
 fftools/ffmpeg_mux_init.c |  36 -
 fftools/ffmpeg_opt.c  |  13 ++-
 6 files changed, 118 insertions(+), 180 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index a52c7c5ae4..f53c4b7aec 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -239,25 +239,23 @@ static int write_option(void *optctx, const OptionDef 
*po, const char *opt,
  * a global var*/
 void *dst = po->flags & OPT_FLAG_OFFSET ?
 (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
-int *dstcount;
 double num;
 int ret;
 
 if (po->flags & OPT_FLAG_SPEC) {
-SpecifierOpt **so = dst;
+SpecifierOptList *sol = dst;
 char *p = strchr(opt, ':');
 char *str;
 
-dstcount = (int *)(so + 1);
-ret = grow_array((void**)so, sizeof(**so), dstcount, *dstcount + 1);
+ret = GROW_ARRAY(sol->opt, sol->nb_opt);
 if (ret < 0)
 return ret;
 
 str = av_strdup(p ? p + 1 : "");
 if (!str)
 return AVERROR(ENOMEM);
-(*so)[*dstcount - 1].specifier = str;
-dst = &(*so)[*dstcount - 1].u;
+sol->opt[sol->nb_opt - 1].specifier = str;
+dst = >opt[sol->nb_opt - 1].u;
 }
 
 if (po->type == OPT_TYPE_STRING) {
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index dc99573d80..8ef9a07e9e 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -114,6 +114,11 @@ typedef struct SpecifierOpt {
 } u;
 } SpecifierOpt;
 
+typedef struct SpecifierOptList {
+SpecifierOpt*opt;
+int   nb_opt;
+} SpecifierOptList;
+
 typedef struct OptionDef {
 const char *name;
 enum OptionType type;
@@ -145,9 +150,7 @@ typedef struct OptionDef {
 #define OPT_FLAG_OFFSET (1 << 8)
 #define OPT_OFFSET  (OPT_FLAG_OFFSET | OPT_PERFILE)
 
-/* Option is to be stored in an array of SpecifierOpt.
-   Next element after the offset is an int containing element count in the
-   array.
+/* Option is to be stored in a SpecifierOptList.
Always use as OPT_SPEC in option definitions. */
 #define OPT_FLAG_SPEC   (1 << 9)
 #define OPT_SPEC(OPT_FLAG_SPEC | OPT_OFFSET)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 74e82bc9f9..111d3ef8de 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -138,22 +138,14 @@ typedef struct OptionsContext {
 int seek_timestamp;
 const char *format;
 
-SpecifierOpt *codec_names;
-intnb_codec_names;
-SpecifierOpt *audio_ch_layouts;
-intnb_audio_ch_layouts;
-SpecifierOpt *audio_channels;
-intnb_audio_channels;
-SpecifierOpt *audio_sample_rate;
-intnb_audio_sample_rate;
-SpecifierOpt *frame_rates;
-intnb_frame_rates;
-SpecifierOpt *max_frame_rates;
-intnb_max_frame_rates;
-SpecifierOpt *frame_sizes;
-intnb_frame_sizes;
-SpecifierOpt *frame_pix_fmts;
-intnb_frame_pix_fmts;
+SpecifierOptList codec_names;
+SpecifierOptList audio_ch_layouts;
+SpecifierOptList audio_channels;
+SpecifierOptList audio_sample_rate;
+SpecifierOptList frame_rates;
+SpecifierOptList max_frame_rates;
+SpecifierOptList frame_sizes;
+SpecifierOptList frame_pix_fmts;
 
 /* input options */
 int64_t input_ts_offset;
@@ -166,18 +158,12 @@ typedef struct OptionsContext {
 int input_sync_ref;
 int find_stream_info;
 
-SpecifierOpt *ts_scale;
-intnb_ts_scale;
-SpecifierOpt *dump_attachment;
-intnb_dump_attachment;
-SpecifierOpt *hwaccels;
-intnb_hwaccels;
-SpecifierOpt *hwaccel_devices;
-intnb_hwaccel_devices;
-SpecifierOpt *hwaccel_output_formats;
-intnb_hwaccel_output_formats;
-SpecifierOpt *autorotate;
-intnb_autorotate;
+SpecifierOptList ts_scale;
+SpecifierOptList dump_attachment;
+SpecifierOptList hwaccels;
+SpecifierOptList hwaccel_devices;
+SpecifierOptList hwaccel_output_formats;
+SpecifierOptList autorotate;
 
 /* output options */
 StreamMap *stream_maps;
@@ -208,104 +194,56 @@ typedef struct OptionsContext {
 // keys are stream indices
 AVDictionary *streamid;
 
-SpecifierOpt *metadata;
-intnb_metadata;
-SpecifierOpt *max_frames;
-intnb_max_frames;
-SpecifierOpt *bitstream_filters;
-intnb_bitstream_filters;
-SpecifierOpt 

[FFmpeg-cvslog] fftools/ffmpeg_opt: move deprecated options to the end of the list

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Dec 15 
09:21:09 2023 +0100| [074abeb57e210d7a13ac89026af2a3f0636c2907] | committer: 
Anton Khirnov

fftools/ffmpeg_opt: move deprecated options to the end of the list

This way they don't clutter this already-cluttered code even further.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=074abeb57e210d7a13ac89026af2a3f0636c2907
---

 fftools/ffmpeg_opt.c | 44 +++-
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 9b6f2850c3..2b69f3df55 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1452,10 +1452,6 @@ const OptionDef options[] = {
 OPT_OUTPUT,  { 
.func_arg = opt_map },
 "set input stream mapping",
 
"[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
-#if FFMPEG_OPT_MAP_CHANNEL
-{ "map_channel",HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { 
.func_arg = opt_map_channel },
-"map an audio channel from one stream to another (deprecated)", 
"file.stream.channel[:syncfile.syncstream]" },
-#endif
 { "map_metadata",   OPT_STRING | OPT_SPEC |
 OPT_OUTPUT,  { .off
   = OFFSET(metadata_map) },
 "set metadata information of outfile from infile",
@@ -1533,10 +1529,6 @@ const OptionDef options[] = {
 "set video sync method globally; deprecated, use -fps_mode", "" },
 { "frame_drop_threshold", OPT_FLOAT | OPT_EXPERT,  { 
_drop_threshold },
 "frame drop threshold", "" },
-#if FFMPEG_OPT_ADRIFT_THRESHOLD
-{ "adrift_threshold", HAS_ARG | OPT_EXPERT,  { 
.func_arg = opt_adrift_threshold },
-"deprecated, does nothing", "threshold" },
-#endif
 { "copyts", OPT_BOOL | OPT_EXPERT,   { 
_ts },
 "copy timestamps" },
 { "start_at_zero",  OPT_BOOL | OPT_EXPERT,   { 
_at_zero },
@@ -1685,10 +1677,6 @@ const OptionDef options[] = {
 { "passlogfile",  OPT_VIDEO | OPT_STRING | OPT_EXPERT | OPT_SPEC |
   OPT_OUTPUT,  
  { .off = OFFSET(passlogfiles) },
 "select two pass log file name prefix", "prefix" },
-#if FFMPEG_OPT_PSNR
-{ "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT,   
  { _psnr },
-"calculate PSNR of compressed frames (deprecated, use -flags +psnr)" },
-#endif
 { "vstats",   OPT_VIDEO | OPT_EXPERT , 
  { .func_arg = opt_vstats },
 "dump video coding statistics to file" },
 { "vstats_file",  OPT_VIDEO | HAS_ARG | OPT_EXPERT ,   
  { .func_arg = opt_vstats_file },
@@ -1706,18 +1694,9 @@ const OptionDef options[] = {
 { "chroma_intra_matrix", OPT_VIDEO | OPT_EXPERT  | OPT_STRING | OPT_SPEC |
   OPT_OUTPUT,  
  { .off = OFFSET(chroma_intra_matrices) },
 "specify intra matrix coeffs", "matrix" },
-#if FFMPEG_OPT_TOP
-{ "top",  OPT_VIDEO | OPT_EXPERT  | OPT_INT| OPT_SPEC |
-  OPT_INPUT | OPT_OUTPUT,  
  { .off = OFFSET(top_field_first) },
-"deprecated, use the setfield video filter", "" },
-#endif
 { "vtag", OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_PERFILE |
   OPT_INPUT | OPT_OUTPUT,  
  { .func_arg = opt_old2new },
 "force video tag/fourcc", "fourcc/tag" },
-#if FFMPEG_OPT_QPHIST
-{ "qphist",   OPT_VIDEO | OPT_EXPERT ,{ 
.func_arg = opt_qphist },
-"deprecated, does nothing" },
-#endif
 { "fps_mode", OPT_VIDEO | OPT_STRING | OPT_EXPERT |
   OPT_SPEC | OPT_OUTPUT,   
  { .off = OFFSET(fps_mode) },
 "set framerate mode for matching video streams; overrides vsync" },
@@ -1858,5 +1837,28 @@ const OptionDef options[] = {
 { "filter_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = 
opt_filter_hw_device },
 "set hardware device used when filtering", "device" },
 
+// deprecated options
+#if FFMPEG_OPT_MAP_CHANNEL
+{ "map_channel",HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { 
.func_arg = opt_map_channel },
+"map an audio channel from one stream to another (deprecated)", 
"file.stream.channel[:syncfile.syncstream]" },
+#endif
+#if FFMPEG_OPT_ADRIFT_THRESHOLD
+{ "adrift_threshold", HAS_ARG | OPT_EXPERT,  { 
.func_arg = opt_adrift_threshold },
+"deprecated, does nothing", "threshold" },
+#endif
+#if FFMPEG_OPT_PSNR
+{ "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT,   
  { _psnr },
+"calculate PSNR of compressed frames (deprecated, use -flags +psnr)" },
+#endif

[FFmpeg-cvslog] fftools/ffmpeg: change the MATCH_PER_TYPE_OPT macro into a function

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Dec 17 
14:42:38 2023 +0100| [148fac277a173473eed4ea6b03c7575e5696b3fa] | committer: 
Anton Khirnov

fftools/ffmpeg: change the MATCH_PER_TYPE_OPT macro into a function

There is no reason for it to be a macro anymore, this makes the code
using it cleaner and simpler.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=148fac277a173473eed4ea6b03c7575e5696b3fa
---

 fftools/cmdutils.c|  6 +-
 fftools/cmdutils.h|  2 ++
 fftools/ffmpeg.h  | 11 ++-
 fftools/ffmpeg_demux.c| 16 
 fftools/ffmpeg_mux_init.c |  4 ++--
 fftools/ffmpeg_opt.c  | 17 ++---
 6 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index f53c4b7aec..26e5e6e986 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -239,14 +239,15 @@ static int write_option(void *optctx, const OptionDef 
*po, const char *opt,
  * a global var*/
 void *dst = po->flags & OPT_FLAG_OFFSET ?
 (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
+SpecifierOptList *sol = NULL;
 double num;
 int ret;
 
 if (po->flags & OPT_FLAG_SPEC) {
-SpecifierOptList *sol = dst;
 char *p = strchr(opt, ':');
 char *str;
 
+sol = dst;
 ret = GROW_ARRAY(sol->opt, sol->nb_opt);
 if (ret < 0)
 return ret;
@@ -312,6 +313,9 @@ static int write_option(void *optctx, const OptionDef *po, 
const char *opt,
 if (po->flags & OPT_EXIT)
 return AVERROR_EXIT;
 
+if (sol)
+sol->type = po->type;
+
 return 0;
 }
 
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 8ef9a07e9e..db91b788f8 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -117,6 +117,8 @@ typedef struct SpecifierOpt {
 typedef struct SpecifierOptList {
 SpecifierOpt*opt;
 int   nb_opt;
+
+enum OptionType type;
 } SpecifierOptList;
 
 typedef struct OptionDef {
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 111d3ef8de..3af929ee43 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -803,15 +803,8 @@ void update_benchmark(const char *fmt, ...);
WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
 }
 
-#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
-{\
-int i;\
-for (i = 0; i < o->name.nb_opt; i++) {\
-char *spec = o->name.opt[i].specifier;\
-if (!strcmp(spec, mediatype))\
-outvar = o->name.opt[i].u.type;\
-}\
-}
+const char *opt_match_per_type_str(const SpecifierOptList *sol,
+   char mediatype);
 
 extern const char * const opt_name_codec_names[];
 extern const char * const opt_name_codec_tags[];
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 238b37ad93..515271fda0 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1333,10 +1333,10 @@ int ifile_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 int64_t timestamp;
 AVDictionary *unused_opts = NULL;
 const AVDictionaryEntry *e = NULL;
-char *   video_codec_name = NULL;
-char *   audio_codec_name = NULL;
-char *subtitle_codec_name = NULL;
-char *data_codec_name = NULL;
+const char*video_codec_name = NULL;
+const char*audio_codec_name = NULL;
+const char* subtitle_codec_name = NULL;
+const char* data_codec_name = NULL;
 int scan_all_pmts_set = 0;
 
 int64_t start_time = o->start_time;
@@ -1426,10 +1426,10 @@ int ifile_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 if (o->frame_pix_fmts.nb_opt)
 av_dict_set(>g->format_opts, "pixel_format", 
o->frame_pix_fmts.opt[o->frame_pix_fmts.nb_opt - 1].u.str, 0);
 
-MATCH_PER_TYPE_OPT(codec_names, str,video_codec_name, ic, "v");
-MATCH_PER_TYPE_OPT(codec_names, str,audio_codec_name, ic, "a");
-MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, ic, "s");
-MATCH_PER_TYPE_OPT(codec_names, str, data_codec_name, ic, "d");
+video_codec_name= opt_match_per_type_str(>codec_names, 'v');
+audio_codec_name= opt_match_per_type_str(>codec_names, 'a');
+subtitle_codec_name = opt_match_per_type_str(>codec_names, 's');
+data_codec_name = opt_match_per_type_str(>codec_names, 'd');
 
 if (video_codec_name)
 ret = err_merge(ret, find_codec(NULL, video_codec_name   , 
AVMEDIA_TYPE_VIDEO   , 0,
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 4917b5c4e3..90bdd3a5fb 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1612,10 +1612,10 @@ static int map_auto_audio(Muxer *mux, const 
OptionsContext *o)
 static int map_auto_subtitle(Muxer *mux, const OptionsContext *o)
 {
 AVFormatContext *oc = mux->fc;
-char *subtitle_codec_name = NULL;
+const char *subtitle_codec_name = NULL;
 
 /* subtitles: pick first */
-

[FFmpeg-cvslog] fftools/ffmpeg: improve WARN_MULTIPLE_OPT_USAGE()

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Dec 17 
18:10:17 2023 +0100| [41716214c2912cf84946c939bea5400581384569] | committer: 
Anton Khirnov

fftools/ffmpeg: improve WARN_MULTIPLE_OPT_USAGE()

Currently it requires every single OPT_SPEC option to be accompanied by
an array of alternate names for this option. The vast majority of
options have no alternate names, resulting in a large numbers of
unnecessary single-element arrays that merely contain the option name.

Extend the option parsing API to allow marking options as having
alternate names, or as being the canonical name for some existing
alternatives. Use this new information to avoid the need for
abovementioned unnecessary single-element arrays.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=41716214c2912cf84946c939bea5400581384569
---

 fftools/cmdutils.c|  13 ++--
 fftools/cmdutils.h|  21 +-
 fftools/ffmpeg.h  |  29 
 fftools/ffmpeg_demux.c|  14 
 fftools/ffmpeg_mux_init.c |  41 
 fftools/ffmpeg_opt.c  | 165 +++---
 6 files changed, 139 insertions(+), 144 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 26e5e6e986..44228ea637 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -233,7 +233,7 @@ static int opt_has_arg(const OptionDef *o)
 }
 
 static int write_option(void *optctx, const OptionDef *po, const char *opt,
-const char *arg)
+const char *arg, const OptionDef *defs)
 {
 /* new-style options contain an offset into optctx, old-style address of
  * a global var*/
@@ -313,8 +313,11 @@ static int write_option(void *optctx, const OptionDef *po, 
const char *opt,
 if (po->flags & OPT_EXIT)
 return AVERROR_EXIT;
 
-if (sol)
+if (sol) {
 sol->type = po->type;
+sol->opt_canon = (po->flags & OPT_HAS_CANON) ?
+ find_option(defs, po->u1.name_canon) : po;
+}
 
 return 0;
 }
@@ -352,7 +355,7 @@ int parse_option(void *optctx, const char *opt, const char 
*arg,
 return AVERROR(EINVAL);
 }
 
-ret = write_option(optctx, po, opt, arg);
+ret = write_option(optctx, po, opt, arg, options);
 if (ret < 0)
 return ret;
 
@@ -395,7 +398,7 @@ int parse_options(void *optctx, int argc, char **argv, 
const OptionDef *options,
 return 0;
 }
 
-int parse_optgroup(void *optctx, OptionGroup *g)
+int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs)
 {
 int i, ret;
 
@@ -418,7 +421,7 @@ int parse_optgroup(void *optctx, OptionGroup *g)
 av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument 
%s.\n",
o->key, o->opt->help, o->val);
 
-ret = write_option(optctx, o->opt, o->key, o->val);
+ret = write_option(optctx, o->opt, o->key, o->val, defs);
 if (ret < 0)
 return ret;
 }
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index db91b788f8..53227abb47 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -118,6 +118,8 @@ typedef struct SpecifierOptList {
 SpecifierOpt*opt;
 int   nb_opt;
 
+/* Canonical option definition that was parsed into this list. */
+const struct OptionDef *opt_canon;
 enum OptionType type;
 } SpecifierOptList;
 
@@ -160,6 +162,14 @@ typedef struct OptionDef {
  * output, or both. */
 #define OPT_INPUT   (1 << 10)
 #define OPT_OUTPUT  (1 << 11)
+
+/* This option is a "canonical" form, to which one or more alternatives
+ * exist. These alternatives are listed in u1.names_alt. */
+#define OPT_HAS_ALT (1 << 12)
+/* This option is an alternative form of some other option, whose
+ * name is stored in u1.name_canon */
+#define OPT_HAS_CANON   (1 << 13)
+
  union {
 void *dst_ptr;
 int (*func_arg)(void *, const char *, const char *);
@@ -167,6 +177,15 @@ typedef struct OptionDef {
 } u;
 const char *help;
 const char *argname;
+
+union {
+/* Name of the canonical form of this option.
+ * Is valid when OPT_HAS_CANON is set. */
+const char *name_canon;
+/* A NULL-terminated list of alternate forms of this option.
+ * Is valid when OPT_HAS_ALT is set. */
+const char * const *names_alt;
+} u1;
 } OptionDef;
 
 /**
@@ -281,7 +300,7 @@ typedef struct OptionParseContext {
  *
  * @param optctx an app-specific options context. NULL for global options group
  */
-int parse_optgroup(void *optctx, OptionGroup *g);
+int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs);
 
 /**
  * Split the commandline into an intermediate form convenient for further
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 3af929ee43..238a02143e 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -776,43 +776,40 @@ void update_benchmark(const char *fmt, ...);
 #define SPECIFIER_OPT_FMT_f"%f"
 #define SPECIFIER_OPT_FMT_dbl  "%lf"
 

[FFmpeg-cvslog] fftools/ffmpeg_opt: update program description to match manpage

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
09:11:44 2023 +0100| [86e8439994d86b33f9b22ad64c4a31a559f05aac] | committer: 
Anton Khirnov

fftools/ffmpeg_opt: update program description to match manpage

Cf. 2244722f1f3

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86e8439994d86b33f9b22ad64c4a31a559f05aac
---

 fftools/ffmpeg_opt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 6a2f242971..ba20df7a65 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1254,7 +1254,7 @@ void show_help_default(const char *opt, const char *arg)
 
 void show_usage(void)
 {
-av_log(NULL, AV_LOG_INFO, "Hyper fast Audio and Video encoder\n");
+av_log(NULL, AV_LOG_INFO, "Universal media converter\n");
 av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i 
infile]... {[outfile options] outfile}...\n", program_name);
 av_log(NULL, AV_LOG_INFO, "\n");
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/cmdutils: simplify handling of the HAS_ARG option flag

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Dec 15 
08:24:14 2023 +0100| [b472c46a7020bfcd74952c04914a929476b701f2] | committer: 
Anton Khirnov

fftools/cmdutils: simplify handling of the HAS_ARG option flag

This option flag only carries nontrivial information for options that
call a function, in all other cases its presence can be inferred from
the option type (bool options do not have arguments, all other types do)
and is thus nothing but useless clutter.

Change the option parsing code to infer its value when it can, and drop
the flag from options where it's not needed.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b472c46a7020bfcd74952c04914a929476b701f2
---

 fftools/cmdutils.c   |  19 --
 fftools/ffmpeg_opt.c | 160 +--
 fftools/ffplay.c |  44 +++---
 fftools/ffprobe.c|  12 ++--
 4 files changed, 123 insertions(+), 112 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 86cd3bddb4..f5b3dc7346 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -223,6 +223,17 @@ static inline void prepare_app_arguments(int *argc_ptr, 
char ***argv_ptr)
 }
 #endif /* HAVE_COMMANDLINETOARGVW */
 
+static int opt_has_arg(const OptionDef *o)
+{
+if (o->flags & OPT_BOOL)
+return 0;
+if (o->flags &
+(OPT_STRING | OPT_INT  | OPT_FLOAT  | OPT_INT64 |
+ OPT_SPEC   | OPT_TIME | OPT_DOUBLE))
+return 1;
+return !!(o->flags & HAS_ARG);
+}
+
 static int write_option(void *optctx, const OptionDef *po, const char *opt,
 const char *arg)
 {
@@ -331,7 +342,7 @@ int parse_option(void *optctx, const char *opt, const char 
*arg,
 av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt);
 return AVERROR(EINVAL);
 }
-if (po->flags & HAS_ARG && !arg) {
+if (opt_has_arg(po) && !arg) {
 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt);
 return AVERROR(EINVAL);
 }
@@ -340,7 +351,7 @@ int parse_option(void *optctx, const char *opt, const char 
*arg,
 if (ret < 0)
 return ret;
 
-return !!(po->flags & HAS_ARG);
+return opt_has_arg(po);
 }
 
 int parse_options(void *optctx, int argc, char **argv, const OptionDef 
*options,
@@ -432,7 +443,7 @@ int locate_option(int argc, char **argv, const OptionDef 
*options,
  (po->name && !strcmp(optname, po->name)))
 return i;
 
-if (!po->name || po->flags & HAS_ARG)
+if (!po->name || opt_has_arg(po))
 i++;
 }
 return 0;
@@ -770,7 +781,7 @@ do {
   \
 if (po->flags & OPT_EXIT) {
 /* optional argument, e.g. -h */
 arg = argv[optindex++];
-} else if (po->flags & HAS_ARG) {
+} else if (opt_has_arg(po)) {
 GET_ARG(arg);
 } else {
 arg = "1";
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 25a7010cf5..9b6f2850c3 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1426,7 +1426,7 @@ static int opt_adrift_threshold(void *optctx, const char 
*opt, const char *arg)
 const OptionDef options[] = {
 /* main options */
 CMDUTILS_COMMON_OPTIONS
-{ "f",  HAS_ARG | OPT_STRING | OPT_OFFSET |
+{ "f",  OPT_STRING | OPT_OFFSET |
 OPT_INPUT | OPT_OUTPUT,  { .off
   = OFFSET(format) },
 "force format", "fmt" },
 { "y",  OPT_BOOL,{ 
 _overwrite },
@@ -1439,13 +1439,13 @@ const OptionDef options[] = {
 "Copy unknown stream types" },
 { "recast_media",   OPT_BOOL | OPT_EXPERT,   { 
 _media },
 "allow recasting stream type in order to force a decoder of different 
media type" },
-{ "c",  HAS_ARG | OPT_STRING | OPT_SPEC |
+{ "c",  OPT_STRING | OPT_SPEC |
 OPT_INPUT | OPT_OUTPUT,  { .off
   = OFFSET(codec_names) },
 "codec name", "codec" },
-{ "codec",  HAS_ARG | OPT_STRING | OPT_SPEC |
+{ "codec",  OPT_STRING | OPT_SPEC |
 OPT_INPUT | OPT_OUTPUT,  { .off
   = OFFSET(codec_names) },
 "codec name", "codec" },
-{ "pre",HAS_ARG | OPT_STRING | OPT_SPEC |
+{ "pre",OPT_STRING | OPT_SPEC |
 OPT_OUTPUT,  { .off
   = OFFSET(presets) },
 "preset name", "preset" },
 { "map",HAS_ARG | OPT_EXPERT | OPT_PERFILE |
@@ -1456,49 +1456,49 @@ const OptionDef options[] = {
 { "map_channel",HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { 
.func_arg = opt_map_channel },
 "map an audio channel from one stream to 

[FFmpeg-cvslog] fftools/ffmpeg_opt: drop HAS_ARG from auto{scale,rotate}

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Dec 15 
02:31:03 2023 +0100| [25c98566e8a45b50415c80ca6450282f2ec0657a] | committer: 
Anton Khirnov

fftools/ffmpeg_opt: drop HAS_ARG from auto{scale,rotate}

It causes those options to be parsed as either
* -autofoo 0/1 (with an argument)
* -noautofoo   (without an argument)
This is unnecessary, confusing, and against the documentation; these are
also the only two bool options that take an argument.

This should not affect the users, as these options are on by default,
and are supposed to be used as -nofoo per the documentation.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=25c98566e8a45b50415c80ca6450282f2ec0657a
---

 fftools/ffmpeg_opt.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 91ae71ff27..25a7010cf5 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1743,11 +1743,9 @@ const OptionDef options[] = {
 "select output format used with HW accelerated decoding", "format" },
 { "hwaccels", OPT_EXIT,
  { .func_arg = show_hwaccels },
 "show available HW acceleration methods" },
-{ "autorotate",   HAS_ARG | OPT_BOOL | OPT_SPEC |
-  OPT_EXPERT | OPT_INPUT,  
  { .off = OFFSET(autorotate) },
+{ "autorotate",   OPT_BOOL | OPT_SPEC | OPT_EXPERT | OPT_INPUT,
  { .off = OFFSET(autorotate) },
 "automatically insert correct rotate filters" },
-{ "autoscale",HAS_ARG | OPT_BOOL | OPT_SPEC |
-  OPT_EXPERT | OPT_OUTPUT, 
  { .off = OFFSET(autoscale) },
+{ "autoscale",OPT_BOOL | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,   
  { .off = OFFSET(autoscale) },
 "automatically insert a scale filter at the end of the filter graph" },
 { "fix_sub_duration_heartbeat", OPT_VIDEO | OPT_BOOL | OPT_EXPERT |
 OPT_SPEC | OPT_OUTPUT, 
  { .off = OFFSET(fix_sub_duration_heartbeat) },

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/ffmpeg_opt: mark more options as OPT_EXPERT

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
09:19:25 2023 +0100| [0125cab38549f187471ca320ea6b37234def3a34] | committer: 
Anton Khirnov

fftools/ffmpeg_opt: mark more options as OPT_EXPERT

Reduces the basic help output to a reasonable size and stops confusing
users with options the vast majority will not need.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0125cab38549f187471ca320ea6b37234def3a34
---

 fftools/ffmpeg_opt.c | 56 ++--
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ba20df7a65..9abf348a32 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1445,7 +1445,7 @@ const OptionDef options[] = {
 { "n",  OPT_TYPE_BOOL, 0,
 {  _file_overwrite },
 "never overwrite output files" },
-{ "ignore_unknown", OPT_TYPE_BOOL, 0,
+{ "ignore_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
 {  _unknown_streams },
 "Ignore unknown stream types" },
 { "copy_unknown",   OPT_TYPE_BOOL, OPT_EXPERT,
@@ -1458,11 +1458,11 @@ const OptionDef options[] = {
 { .off   = OFFSET(codec_names) },
 "codec name", "codec",
 .u1.name_canon = "codec", },
-{ "codec",  OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT | 
OPT_OUTPUT | OPT_HAS_ALT,
+{ "codec",  OPT_TYPE_STRING, OPT_SPEC | OPT_INPUT | 
OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
 { .off   = OFFSET(codec_names) },
 "codec name", "codec",
 .u1.names_alt = alt_codec, },
-{ "pre",OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | 
OPT_HAS_ALT,
+{ "pre",OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | 
OPT_EXPERT | OPT_HAS_ALT,
 { .off   = OFFSET(presets) },
 "preset name", "preset",
 .u1.names_alt = alt_pre, },
@@ -1470,7 +1470,7 @@ const OptionDef options[] = {
 { .func_arg = opt_map },
 "set input stream mapping",
 
"[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
-{ "map_metadata",   OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+{ "map_metadata",   OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | 
OPT_EXPERT,
 { .off   = OFFSET(metadata_map) },
 "set metadata information of outfile from infile",
 "outfile[,metadata]:infile[,metadata]" },
@@ -1484,16 +1484,16 @@ const OptionDef options[] = {
 { "to", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | 
OPT_OUTPUT,
 { .off = OFFSET(stop_time) },
 "record or transcode stop time", "time_stop" },
-{ "fs", OPT_TYPE_INT64, OPT_OFFSET | OPT_OUTPUT,
+{ "fs", OPT_TYPE_INT64, OPT_OFFSET | OPT_OUTPUT | 
OPT_EXPERT,
 { .off = OFFSET(limit_filesize) },
 "set the limit file size in bytes", "limit_size" },
 { "ss", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | 
OPT_OUTPUT,
 { .off = OFFSET(start_time) },
 "set the start time offset", "time_off" },
-{ "sseof",  OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT,
+{ "sseof",  OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | 
OPT_EXPERT,
 { .off = OFFSET(start_time_eof) },
 "set the start time offset relative to EOF", "time_off" },
-{ "seek_timestamp", OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT,
+{ "seek_timestamp", OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT | 
OPT_EXPERT,
 { .off = OFFSET(seek_timestamp) },
 "enable/disable seeking by timestamp with -ss" },
 { "accurate_seek",  OPT_TYPE_BOOL, OPT_OFFSET | OPT_EXPERT | 
OPT_INPUT,
@@ -1508,13 +1508,13 @@ const OptionDef options[] = {
 { "itsscale",   OPT_TYPE_DOUBLE, OPT_SPEC | OPT_EXPERT | 
OPT_INPUT,
 { .off = OFFSET(ts_scale) },
 "set the input ts scale", "scale" },
-{ "timestamp",  OPT_TYPE_FUNC,   OPT_FUNC_ARG | OPT_PERFILE | 
OPT_OUTPUT,
+{ "timestamp",  OPT_TYPE_FUNC,   OPT_FUNC_ARG | OPT_PERFILE | 
OPT_EXPERT | OPT_OUTPUT,
 { .func_arg = opt_recording_timestamp },
 "set the recording timestamp ('now' to set the current time)", "time" 
},
 { "metadata",   OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
 { .off = OFFSET(metadata) },
 "add metadata", "string=string" },
-{ "program",OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
+{ "program",OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | 
OPT_OUTPUT,
 { .off = OFFSET(program) },
 "add program with specified streams", "title=string:st=number..." },
 { "stream_group",   OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
@@ -1554,7 +1554,7 @@ const OptionDef options[] = {
 { "readrate_initial_burst", OPT_TYPE_DOUBLE, OPT_OFFSET | OPT_EXPERT | 
OPT_INPUT,
 { .off = 

[FFmpeg-cvslog] fftools/ffmpeg_opt: refine printing type-specific options

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
10:20:06 2023 +0100| [74df1b73d491e790190d8a484ba2c8a531f90f07] | committer: 
Anton Khirnov

fftools/ffmpeg_opt: refine printing type-specific options

* filter subtitle/data options out of main, video and audio sections
* add filters that were missing entirely from the subtitle section
* add a missing section for advanced subtitle options

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=74df1b73d491e790190d8a484ba2c8a531f90f07
---

 fftools/ffmpeg_opt.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 9abf348a32..2ce83b6a61 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1216,25 +1216,29 @@ void show_help_default(const char *opt, const char *arg)
   OPT_PERFILE | OPT_EXIT, 0);
 
 show_help_options(options, "Per-file main options:", 0,
-  OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
+  OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | 
OPT_DATA |
   OPT_EXIT, OPT_PERFILE);
 if (show_advanced)
 show_help_options(options, "Advanced per-file options:",
   OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, 
OPT_PERFILE);
 
 show_help_options(options, "Video options:",
-  OPT_VIDEO, OPT_EXPERT | OPT_AUDIO, 0);
+  OPT_VIDEO, OPT_EXPERT | OPT_AUDIO | OPT_SUBTITLE | 
OPT_DATA, 0);
 if (show_advanced)
 show_help_options(options, "Advanced Video options:",
-  OPT_EXPERT | OPT_VIDEO, OPT_AUDIO, 0);
+  OPT_EXPERT | OPT_VIDEO, OPT_AUDIO | OPT_SUBTITLE | 
OPT_DATA, 0);
 
 show_help_options(options, "Audio options:",
-  OPT_AUDIO, OPT_EXPERT | OPT_VIDEO, 0);
+  OPT_AUDIO, OPT_EXPERT | OPT_VIDEO | OPT_SUBTITLE | 
OPT_DATA, 0);
 if (show_advanced)
 show_help_options(options, "Advanced Audio options:",
-  OPT_EXPERT | OPT_AUDIO, OPT_VIDEO, 0);
+  OPT_EXPERT | OPT_AUDIO, OPT_VIDEO | OPT_SUBTITLE | 
OPT_DATA, 0);
+
 show_help_options(options, "Subtitle options:",
-  OPT_SUBTITLE, 0, 0);
+  OPT_SUBTITLE, OPT_EXPERT | OPT_VIDEO | OPT_AUDIO | 
OPT_DATA, 0);
+if (show_advanced)
+show_help_options(options, "Advanced Subtitle options:",
+  OPT_EXPERT | OPT_SUBTITLE, OPT_VIDEO | OPT_AUDIO | 
OPT_DATA, 0);
 printf("\n");
 
 if (show_avoptions) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/ffmpeg_opt: print a section for data-stream options

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
10:24:45 2023 +0100| [84352c989198935f76a189e355c8f3848049caf8] | committer: 
Anton Khirnov

fftools/ffmpeg_opt: print a section for data-stream options

Only show it with show_advanced (triggered by -h long), since data
streams themselves are an advanced topic.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84352c989198935f76a189e355c8f3848049caf8
---

 fftools/ffmpeg_opt.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 2ce83b6a61..465e25d7a8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1239,6 +1239,10 @@ void show_help_default(const char *opt, const char *arg)
 if (show_advanced)
 show_help_options(options, "Advanced Subtitle options:",
   OPT_EXPERT | OPT_SUBTITLE, OPT_VIDEO | OPT_AUDIO | 
OPT_DATA, 0);
+
+if (show_advanced)
+show_help_options(options, "Data stream options:",
+  OPT_DATA, OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE, 0);
 printf("\n");
 
 if (show_avoptions) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/ffmpeg_opt: fix -dn flags

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
10:24:45 2023 +0100| [8d8c2b410fd5cdc51428c5e8d473f78b193a0b6c] | committer: 
Anton Khirnov

fftools/ffmpeg_opt: fix -dn flags

It's a data, not video option.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d8c2b410fd5cdc51428c5e8d473f78b193a0b6c
---

 fftools/ffmpeg_opt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 465e25d7a8..2eba1f22cb 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1958,7 +1958,7 @@ const OptionDef options[] = {
 { .func_arg = opt_data_codec },
 "force data codec ('copy' to copy stream)", "codec",
 .u1.name_canon = "codec", },
-{ "dn", OPT_TYPE_BOOL, OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
+{ "dn", OPT_TYPE_BOOL, OPT_DATA | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
 { .off = OFFSET(data_disable) }, "disable data" },
 
 #if CONFIG_VAAPI

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/ffmpeg: mark -vsync for future removal

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
10:50:44 2023 +0100| [7f982065a8025a65ef0e3e719b0fb1a59b2a0d77] | committer: 
Anton Khirnov

fftools/ffmpeg: mark -vsync for future removal

It has already been deprecated over a year ago.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f982065a8025a65ef0e3e719b0fb1a59b2a0d77
---

 fftools/ffmpeg.h  |  1 +
 fftools/ffmpeg_mux_init.c |  4 
 fftools/ffmpeg_opt.c  | 15 ---
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 238a02143e..6137ac991e 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -61,6 +61,7 @@
 #define FFMPEG_OPT_TOP 1
 #define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1
 #define FFMPEG_OPT_VSYNC_DROP 1
+#define FFMPEG_OPT_VSYNC 1
 
 #define FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D')
 
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 89e5261191..5d272f5472 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -756,7 +756,11 @@ static int new_stream_video(Muxer *mux, const 
OptionsContext *o,
 av_log(ost, AV_LOG_WARNING, "-top is deprecated, use the setfield 
filter instead\n");
 #endif
 
+#if FFMPEG_OPT_VSYNC
 ost->vsync_method = video_sync_method;
+#else
+ost->vsync_method = VSYNC_AUTO;
+#endif
 MATCH_PER_STREAM_OPT(fps_mode, str, fps_mode, oc, st);
 if (fps_mode) {
 ret = parse_and_set_vsync(fps_mode, >vsync_method, 
ost->file->index, ost->index, 0);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 2eba1f22cb..594a644dec 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -62,7 +62,9 @@ float audio_drift_threshold = 0.1;
 float dts_delta_threshold   = 10;
 float dts_error_threshold   = 3600*30;
 
+#if FFMPEG_OPT_VSYNC
 enum VideoSyncMethod video_sync_method = VSYNC_AUTO;
+#endif
 float frame_drop_threshold = 0;
 int do_benchmark  = 0;
 int do_benchmark_all  = 0;
@@ -205,6 +207,7 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, 
int file_idx, int st_id
 return AVERROR(EINVAL);
 }
 
+#if FFMPEG_OPT_VSYNC
 if (is_global && *vsync_var == VSYNC_AUTO) {
 int ret;
 double num;
@@ -217,6 +220,8 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, 
int file_idx, int st_id
 av_log(NULL, AV_LOG_WARNING, "Passing a number to -vsync is 
deprecated,"
" use a string argument as described in the manual.\n");
 }
+#endif
+
 return 0;
 }
 
@@ -1136,11 +1141,13 @@ static int opt_audio_filters(void *optctx, const char 
*opt, const char *arg)
 return parse_option(o, "filter:a", arg, options);
 }
 
+#if FFMPEG_OPT_VSYNC
 static int opt_vsync(void *optctx, const char *opt, const char *arg)
 {
 av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
 return parse_and_set_vsync(arg, _sync_method, -1, -1, 1);
 }
+#endif
 
 static int opt_timecode(void *optctx, const char *opt, const char *arg)
 {
@@ -1566,9 +1573,6 @@ const OptionDef options[] = {
 { .func_arg = opt_target },
 "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or 
\"dv50\" "
 "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
-{ "vsync",  OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
-{ .func_arg = opt_vsync },
-"set video sync method globally; deprecated, use -fps_mode", "" },
 { "frame_drop_threshold",   OPT_TYPE_FLOAT, OPT_EXPERT,
 { _drop_threshold },
 "frame drop threshold", "" },
@@ -2006,6 +2010,11 @@ const OptionDef options[] = {
 { .func_arg = opt_qphist },
 "deprecated, does nothing" },
 #endif
+#if FFMPEG_OPT_VSYNC
+{ "vsync",  OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
+{ .func_arg = opt_vsync },
+"set video sync method globally; deprecated, use -fps_mode", "" },
+#endif
 
 { NULL, },
 };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/ffmpeg: remove deprecated -[av]bsf

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
10:54:11 2023 +0100| [6325aede08d5c7086b3798cb7041299e1d07f93a] | committer: 
Anton Khirnov

fftools/ffmpeg: remove deprecated -[av]bsf

They were marked as deprecated over 10 years ago.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6325aede08d5c7086b3798cb7041299e1d07f93a
---

 doc/ffmpeg.texi  |  4 
 fftools/ffmpeg_opt.c | 13 ++---
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 28f032df80..ab17d1d687 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1254,8 +1254,6 @@ Specify which version of the vstats format to use. 
Default is @code{2}. See the
 
 @item -vtag @var{fourcc/tag} (@emph{output})
 Force video tag/fourcc. This is an alias for @code{-tag:v}.
-@item -vbsf @var{bitstream_filter}
-Deprecated see -bsf
 
 @item -force_key_frames[:@var{stream_specifier}] @var{time}[,@var{time}...] 
(@emph{output,per-stream})
 @item -force_key_frames[:@var{stream_specifier}] expr:@var{expr} 
(@emph{output,per-stream})
@@ -1624,8 +1622,6 @@ This is an alias for @code{-filter:a}, see the 
@ref{filter_option,,-filter optio
 @table @option
 @item -atag @var{fourcc/tag} (@emph{output})
 Force audio tag/fourcc. This is an alias for @code{-tag:a}.
-@item -absf @var{bitstream_filter}
-Deprecated, see -bsf
 @item -guess_layout_max @var{channels} (@emph{input,per-stream})
 If some input channel layout is not known, try to guess only if it
 corresponds to at most the specified number of channels. For example, 2
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 594a644dec..cf31106fe1 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1920,18 +1920,9 @@ const OptionDef options[] = {
 "0 = use frame rate (video) or sample rate (audio),"
 "-1 = match source time base", "ratio" },
 
-{ "bsf", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_HAS_ALT,
+{ "bsf", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
 { .off = OFFSET(bitstream_filters) },
-"A comma-separated list of bitstream filters", "bitstream_filters",
-.u1.names_alt = alt_bsf, },
-{ "absf", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| 
OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
-{ .func_arg = opt_old2new },
-"deprecated", "audio bitstream_filters",
-.u1.name_canon = "bsf", },
-{ "vbsf", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT| 
OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
-{ .func_arg = opt_old2new },
-"deprecated", "video bitstream_filters",
-.u1.name_canon = "bsf", },
+"A comma-separated list of bitstream filters", "bitstream_filters", },
 
 { "apre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| 
OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
 { .func_arg = opt_preset },

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] lavf: allow setting AVStream.discard as an AVOption

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
19:53:35 2023 +0100| [b26407ccb8e5fdd8b7263de002f7b0a44d8beb92] | committer: 
Anton Khirnov

lavf: allow setting AVStream.discard as an AVOption

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b26407ccb8e5fdd8b7263de002f7b0a44d8beb92
---

 libavformat/options.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/options.c b/libavformat/options.c
index 73e220bb7d..75ec86ce05 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
 { "metadata",   .type = AV_OPT_TYPE_CONST, { .i64 = 
AV_DISPOSITION_METADATA  },.unit = "disposition" },
 { "dependent",  .type = AV_OPT_TYPE_CONST, { .i64 = 
AV_DISPOSITION_DEPENDENT },.unit = "disposition" },
 { "still_image",.type = AV_OPT_TYPE_CONST, { .i64 = 
AV_DISPOSITION_STILL_IMAGE   },.unit = "disposition" },
+
+{ "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = 
AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
+.flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
+{ "none",   .type = AV_OPT_TYPE_CONST, {.i64 = 
AVDISCARD_NONE }, .unit = "avdiscard" },
+{ "default",.type = AV_OPT_TYPE_CONST, {.i64 = 
AVDISCARD_DEFAULT  }, .unit = "avdiscard" },
+{ "noref",  .type = AV_OPT_TYPE_CONST, {.i64 = 
AVDISCARD_NONREF   }, .unit = "avdiscard" },
+{ "bidir",  .type = AV_OPT_TYPE_CONST, {.i64 = 
AVDISCARD_BIDIR}, .unit = "avdiscard" },
+{ "nointra",.type = AV_OPT_TYPE_CONST, {.i64 = 
AVDISCARD_NONINTRA }, .unit = "avdiscard" },
+{ "nokey",  .type = AV_OPT_TYPE_CONST, {.i64 = 
AVDISCARD_NONKEY   }, .unit = "avdiscard" },
+{ "all",.type = AV_OPT_TYPE_CONST, {.i64 = 
AVDISCARD_ALL  }, .unit = "avdiscard" },
 { NULL }
 };
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/ffmpeg_demux: set discard on the AVStream directly

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
20:14:21 2023 +0100| [6916105b11fb2fbb6fb1698da47dc061c995afab] | committer: 
Anton Khirnov

fftools/ffmpeg_demux: set discard on the AVStream directly

Avoid taking an ugly detour through the decoder AVCodecContext.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6916105b11fb2fbb6fb1698da47dc061c995afab
---

 fftools/ffmpeg_demux.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index eca3de709c..a28a94b5ed 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1141,7 +1141,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, 
AVStream *st)
 ist->reinit_filters = -1;
 MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
 
-MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
 ist->user_set_discard = AVDISCARD_NONE;
 
 if ((o->video_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_VIDEO) ||
@@ -1150,20 +1149,20 @@ static int ist_add(const OptionsContext *o, Demuxer *d, 
AVStream *st)
 (o->data_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_DATA))
 ist->user_set_discard = AVDISCARD_ALL;
 
-ist->dec_ctx = avcodec_alloc_context3(ist->dec);
-if (!ist->dec_ctx)
-return AVERROR(ENOMEM);
-
+MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
 if (discard_str) {
-const AVOption *discard_opt = av_opt_find(ist->dec_ctx, "skip_frame",
-  NULL, 0, 0);
-ret = av_opt_eval_int(ist->dec_ctx, discard_opt, discard_str, 
>user_set_discard);
+ret = av_opt_set(ist->st, "discard", discard_str, 0);
 if (ret  < 0) {
 av_log(ist, AV_LOG_ERROR, "Error parsing discard %s.\n", 
discard_str);
 return ret;
 }
+ist->user_set_discard = ist->st->discard;
 }
 
+ist->dec_ctx = avcodec_alloc_context3(ist->dec);
+if (!ist->dec_ctx)
+return AVERROR(ENOMEM);
+
 ret = avcodec_parameters_to_context(ist->dec_ctx, par);
 if (ret < 0) {
 av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n");

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/ffmpeg_filter: only set framerate for video

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Dec 15 
02:25:41 2023 +0100| [dc2fc5a919608e3937137f11548f4be5ee99523d] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: only set framerate for video

Otherwise an unitialized stack value would be copied to FPSConvContext.
As it's then never used, it tends not to be a problem in practice,
however it is UB and some compilers warn about it.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc2fc5a919608e3937137f11548f4be5ee99523d
---

 fftools/ffmpeg_filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 87ab2ca976..c1c3014453 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -2017,9 +2017,9 @@ static int choose_out_timebase(OutputFilterPriv *ofp, 
AVFrame *frame)
 if (!(tb.num > 0 && tb.den > 0))
 tb = frame->time_base;
 
+fps->framerate = fr;
 finish:
 ofp->tb_out= tb;
-fps->framerate = fr;
 ofp->tb_out_locked = 1;
 
 return 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] fftools/opt_common: mark some options as OPT_EXPERT

2023-12-22 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Dec 18 
09:19:25 2023 +0100| [c5a87d8bdbb2f4a20a4374088497d1bab8bf4e91] | committer: 
Anton Khirnov

fftools/opt_common: mark some options as OPT_EXPERT

So they don't clutter the standard help output.

-loglevel is marked because there is no need to show two options (-v and
-loglevel) that do the same thing.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c5a87d8bdbb2f4a20a4374088497d1bab8bf4e91
---

 fftools/opt_common.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fftools/opt_common.h b/fftools/opt_common.h
index e82ada5581..36c591cc94 100644
--- a/fftools/opt_common.h
+++ b/fftools/opt_common.h
@@ -219,10 +219,10 @@ int opt_cpucount(void *optctx, const char *opt, const 
char *arg);
 { "sample_fmts",  OPT_TYPE_FUNC, OPT_EXIT,  { .func_arg = 
show_sample_fmts }, "show available audio sample formats" },   \
 { "dispositions", OPT_TYPE_FUNC, OPT_EXIT,  { .func_arg = 
show_dispositions}, "show available stream dispositions" },\
 { "colors",   OPT_TYPE_FUNC, OPT_EXIT,  { .func_arg = 
show_colors },  "show available color names" },\
-{ "loglevel", OPT_TYPE_FUNC, OPT_FUNC_ARG,  { .func_arg = 
opt_loglevel }, "set logging level", "loglevel" }, \
+{ "loglevel", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = 
opt_loglevel }, "set logging level", "loglevel" }, \
 { "v",OPT_TYPE_FUNC, OPT_FUNC_ARG,  { .func_arg = 
opt_loglevel }, "set logging level", "loglevel" }, \
-{ "report",   OPT_TYPE_FUNC, 0, { .func_arg = 
opt_report },   "generate a report" }, \
-{ "max_alloc",OPT_TYPE_FUNC, OPT_FUNC_ARG,  { .func_arg = 
opt_max_alloc },"set maximum size of a single allocated block", "bytes" }, \
+{ "report",   OPT_TYPE_FUNC, OPT_EXPERT,{ .func_arg = 
opt_report },   "generate a report" }, \
+{ "max_alloc",OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = 
opt_max_alloc },"set maximum size of a single allocated block", "bytes" }, \
 { "cpuflags", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = 
opt_cpuflags }, "force specific cpu flags", "flags" }, \
 { "cpucount", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = 
opt_cpucount }, "force specific cpu count", "count" }, \
 { "hide_banner",  OPT_TYPE_BOOL, OPT_EXPERT,{_banner},
   "do not show program banner", "hide_banner" }, \

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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