Re: [FFmpeg-devel] [Internet][PATCH 1/3] avcodec/videotoolboxenc: use color parameters conversion from avutil

2023-07-22 Thread zhilizhao(赵志立)


> On Jul 16, 2023, at 17:13, Zhao Zhili  wrote:
> 
> From: Zhao Zhili 
> 
> ---
> libavcodec/videotoolboxenc.c | 137 ---
> 1 file changed, 13 insertions(+), 124 deletions(-)
> 

Patchset applied.

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/wavarc: Fix k limit

2023-07-22 Thread Michael Niedermayer
On Tue, Apr 25, 2023 at 08:38:13PM +0200, Michael Niedermayer wrote:
> The implementation does not support k=32
> 
> Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
> Fixes: 
> 57976/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVARC_fuzzer-5911925807775744
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/wavarc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply patchset

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 2/2] tools/target_dec_fuzzer: Adjust threshold for jpeg2000

2023-07-22 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
57385/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5394334324490240

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 165951dc9d..10c380ef1c 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -247,7 +247,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 case AV_CODEC_ID_IFF_ILBM:maxpixels  /= 128;   break;
 case AV_CODEC_ID_INDEO4:  maxpixels  /= 128;   break;
 case AV_CODEC_ID_INTERPLAY_ACM: maxsamples /= 16384;  break;
-case AV_CODEC_ID_JPEG2000:maxpixels  /= 4096;  break;
+case AV_CODEC_ID_JPEG2000:maxpixels  /= 16384; break;
 case AV_CODEC_ID_LAGARITH:maxpixels  /= 1024;  break;
 case AV_CODEC_ID_LOCO:maxpixels  /= 1024;  break;
 case AV_CODEC_ID_VORBIS:  maxsamples /= 1024;  break;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/2] avformat/avr: Check sample rate

2023-07-22 Thread Michael Niedermayer
Fixes: 
54979/clusterfuzz-testcase-minimized-ffmpeg_dem_AVR_fuzzer-6681035461230592
Fixes: Timeout

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/avr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/avr.c b/libavformat/avr.c
index 1cc4d56bfb..3fe8614b25 100644
--- a/libavformat/avr.c
+++ b/libavformat/avr.c
@@ -75,6 +75,9 @@ static int avr_read_header(AVFormatContext *s)
 avio_skip(s->pb, 20);
 avio_skip(s->pb, 64);
 
+if (st->codecpar->sample_rate == 0)
+return AVERROR_INVALIDDATA;
+
 st->codecpar->codec_id = ff_get_pcm_codec_id(bps, 0, 1, sign);
 if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
 avpriv_request_sample(s, "Bps %d and sign %d", bps, sign);
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH 01/13] avcodec/avcodec: add side data to AVCodecContext

2023-07-22 Thread James Almer

On 7/20/2023 5:34 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  libavcodec/avcodec.c  |  2 ++
  libavcodec/avcodec.h  |  8 +
  libavcodec/avpacket.c | 84 +++
  libavcodec/packet.h   | 54 
  4 files changed, 148 insertions(+)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 340abe830e..16869e97f2 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -467,6 +467,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
  av_freep(>internal);
  }
  
+av_packet_free_side_data_set(>side_data_set);

+
  for (i = 0; i < avctx->nb_coded_side_data; i++)
  av_freep(>coded_side_data[i].data);
  av_freep(>coded_side_data);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fe41ecc3c9..2902ecf6cb 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2102,6 +2102,14 @@ typedef struct AVCodecContext {
   *   an error.
   */
  int64_t frame_num;
+
+/**
+ * Additional data associated with the entire stream.
+ *
+ * - decoding: set by user
+ * - encoding: unused
+ */
+AVPacketSideDataSet side_data_set;


This name is also used in a patchset by Jan Ekström that added a similar 
struct but for AVFrameSideData. I used it here for this first iteration, 
but if his patchset also goes in, we need non conflicting names.



  } AVCodecContext;
  
  /**

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 5fef65e97a..f569731403 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -645,3 +645,87 @@ int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
  
  return 0;

  }
+
+AVPacketSideData *av_packet_get_side_data_from_set(const AVPacketSideDataSet 
*set,
+   enum AVPacketSideDataType 
type)
+{
+for (int i = 0; i < set->nb_side_data; i++)
+if (set->side_data[i].type == type)
+return >side_data[i];
+
+return NULL;
+}
+
+static int add_side_data_to_set(AVPacketSideDataSet *set,
+AVPacketSideData **psd,
+enum AVPacketSideDataType type,
+uint8_t *data, size_t size)
+{
+AVPacketSideData *sd, *tmp;
+
+for (int i = 0; i < set->nb_side_data; i++) {
+sd = >side_data[i];
+
+if (sd->type == type) {
+av_freep(>data);
+sd->data = data;
+sd->size = size;
+*psd = sd;
+return 0;
+}
+}
+
+if (set->nb_side_data + 1U > FFMIN(INT_MAX, SIZE_MAX / sizeof(*tmp)))
+return AVERROR(ERANGE);
+
+tmp = av_realloc_array(set->side_data, set->nb_side_data + 1, 
sizeof(*tmp));
+if (!tmp)
+return AVERROR(ENOMEM);
+
+set->side_data = tmp;
+set->nb_side_data++;
+
+sd = >side_data[set->nb_side_data - 1];
+sd->type = type;
+sd->data = data;
+sd->size = size;
+*psd = sd;
+
+return 0;
+}
+
+int av_packet_add_side_data_to_set(AVPacketSideDataSet *set,
+   enum AVPacketSideDataType type,
+   uint8_t *data, size_t size)
+{
+AVPacketSideData *sd;
+
+return add_side_data_to_set(set, , type, data, size);
+}
+
+AVPacketSideData *av_packet_new_side_data_to_set(AVPacketSideDataSet *set,
+ enum AVPacketSideDataType 
type,
+ size_t size)
+{
+AVPacketSideData *sd = NULL;
+uint8_t *data = av_malloc(size);
+int ret;
+
+if (!data)
+return NULL;
+
+ret = add_side_data_to_set(set, , type, data, size);
+if (ret < 0)
+av_freep();
+
+return sd;
+}
+
+void av_packet_free_side_data_set(AVPacketSideDataSet *set)
+{
+int i;
+for (i = 0; i < set->nb_side_data; i++)
+av_freep(>side_data[i].data);
+av_freep(>side_data);
+set->nb_side_data = 0;
+}
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index f28e7e7011..590c2bf15a 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -318,6 +318,14 @@ typedef struct AVPacketSideData {
  enum AVPacketSideDataType type;
  } AVPacketSideData;
  
+/**

+ * Structure to hold a set of AVPacketSideDataSet
+ */
+typedef struct AVPacketSideDataSet {
+AVPacketSideData *side_data;


I can alternatively make this pointer to pointer, to be in line with 
AVFrameSideData in AVFrame. It would make it simple to add a function to 
remove a single entry from the array, but it may not be worth the extra 
allocation overhead.



+intnb_side_data;
+} AVPacketSideDataSet;


The reason i introduced this struct is to simplify the helper functions 
defined below, to be generic and usable for both the avctx and codecpar 
side data arrays also introduced in this patchset.
I was told said helpers could take a pointer to pointer to 
AVPacketSideData and a 

Re: [FFmpeg-devel] [PATCH 5/6] fftools: avradio support

2023-07-22 Thread Lynne
Jul 22, 2023, 21:30 by mich...@niedermayer.cc:

> This avoids keeping diffs to fftools in the libavradio repository
> ---
>  fftools/ffmpeg.c |  7 +
>  fftools/ffplay.c |  6 
>  fftools/ffprobe.c|  6 
>  fftools/opt_common.c | 66 
>  fftools/opt_common.h | 27 ++
>  5 files changed, 107 insertions(+), 5 deletions(-)
>

Do you think we should keep this out of the 6.1 branch?
I don't expect packagers to start packaging libavradio immediately,
so I don't feel that strongly about it, but maybe we should let
users test it first in git master for a bit?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 3/6] avformat: add support for demuxers/inputs from avradio

2023-07-22 Thread Paul B Mahol
NAK
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/6] avutil/log: Add AV_CLASS_CATEGORY_RADIO_INPUT

2023-07-22 Thread Paul B Mahol
NAK
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 6/6] tools/uncoded_frame: avradio support

2023-07-22 Thread Michael Niedermayer
This avoids keeping diffs to tools in the libavradio repository

Signed-off-by: Michael Niedermayer 
---
 tools/uncoded_frame.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/uncoded_frame.c b/tools/uncoded_frame.c
index edea2367c4..f856b02c77 100644
--- a/tools/uncoded_frame.c
+++ b/tools/uncoded_frame.c
@@ -1,8 +1,12 @@
 #include 
 #include 
 #include 
+#include "config.h"
 #include "libavutil/avassert.h"
 #include "libavdevice/avdevice.h"
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#endif
 #include "libavfilter/avfilter.h"
 #include "libavfilter/buffersink.h"
 #include "libavformat/avformat.h"
@@ -64,6 +68,9 @@ int main(int argc, char **argv)
 nb_out_dev = argc - 2;
 
 avdevice_register_all();
+#if CONFIG_AVRADIO
+avradio_register_all();
+#endif
 
 /* Create input graph */
 if (!(in_graph = avfilter_graph_alloc())) {
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 5/6] fftools: avradio support

2023-07-22 Thread Michael Niedermayer
This avoids keeping diffs to fftools in the libavradio repository
---
 fftools/ffmpeg.c |  7 +
 fftools/ffplay.c |  6 
 fftools/ffprobe.c|  6 
 fftools/opt_common.c | 66 
 fftools/opt_common.h | 27 ++
 5 files changed, 107 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 6130fd06fc..e9fbc8b636 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -95,6 +95,10 @@
 
 #include "libavdevice/avdevice.h"
 
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#endif
+
 #include "libswresample/swresample.h"
 
 #include "libavfilter/avfilter.h"
@@ -1331,6 +1335,9 @@ int main(int argc, char **argv)
 
 #if CONFIG_AVDEVICE
 avdevice_register_all();
+#endif
+#if CONFIG_AVRADIO
+avradio_register_all();
 #endif
 avformat_network_init();
 
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 5212ad053e..f2e70b2de6 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -45,6 +45,9 @@
 #include "libavutil/bprint.h"
 #include "libavformat/avformat.h"
 #include "libavdevice/avdevice.h"
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#endif
 #include "libswscale/swscale.h"
 #include "libavutil/opt.h"
 #include "libavcodec/avfft.h"
@@ -3651,6 +3654,9 @@ int main(int argc, char **argv)
 /* register all codecs, demux and protocols */
 #if CONFIG_AVDEVICE
 avdevice_register_all();
+#endif
+#if CONFIG_AVRADIO
+avradio_register_all();
 #endif
 avformat_network_init();
 
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a39185f6fe..51a0c2483b 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -56,6 +56,9 @@
 #include "libavutil/timestamp.h"
 #include "libavdevice/avdevice.h"
 #include "libavdevice/version.h"
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#endif
 #include "libswscale/swscale.h"
 #include "libswscale/version.h"
 #include "libswresample/swresample.h"
@@ -4109,6 +4112,9 @@ int main(int argc, char **argv)
 #if CONFIG_AVDEVICE
 avdevice_register_all();
 #endif
+#if CONFIG_AVRADIO
+avradio_register_all();
+#endif
 
 show_banner(argc, argv, options);
 ret = parse_options(NULL, argc, argv, options, opt_input_file);
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 913932c914..f556d95afe 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -51,6 +51,11 @@
 #include "libavdevice/avdevice.h"
 #include "libavdevice/version.h"
 
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#include "libavradio/version.h"
+#endif
+
 #include "libavfilter/avfilter.h"
 #include "libavfilter/version.h"
 
@@ -187,6 +192,9 @@ static void print_all_libs_info(int flags, int level)
 PRINT_LIB_INFO(avutil, AVUTIL, flags, level);
 PRINT_LIB_INFO(avcodec,AVCODEC,flags, level);
 PRINT_LIB_INFO(avformat,   AVFORMAT,   flags, level);
+#if CONFIG_AVRADIO
+PRINT_LIB_INFO(avradio,AVRADIO,flags, level);
+#endif
 PRINT_LIB_INFO(avdevice,   AVDEVICE,   flags, level);
 PRINT_LIB_INFO(avfilter,   AVFILTER,   flags, level);
 PRINT_LIB_INFO(swscale,SWSCALE,flags, level);
@@ -844,6 +852,13 @@ static int is_device(const AVClass *avclass)
 return AV_IS_INPUT_DEVICE(avclass->category) || 
AV_IS_OUTPUT_DEVICE(avclass->category);
 }
 
+static int is_radio(const AVClass *avclass)
+{
+if (!avclass)
+return 0;
+return avclass->category == AV_CLASS_CATEGORY_RADIO_INPUT;
+}
+
 static int show_formats_devices(void *optctx, const char *opt, const char 
*arg, int device_only, int muxdemuxers)
 {
 void *ifmt_opaque = NULL;
@@ -851,12 +866,13 @@ static int show_formats_devices(void *optctx, const char 
*opt, const char *arg,
 void *ofmt_opaque = NULL;
 const AVOutputFormat *ofmt = NULL;
 const char *last_name;
-int is_dev;
+int is_dev, is_rad;
+const char *name[3] = {"File formats:", "Devices:", "Radios:"};
 
 printf("%s\n"
" D. = Demuxing supported\n"
" .E = Muxing supported\n"
-   " --\n", device_only ? "Devices:" : "File formats:");
+   " --\n", name[device_only]);
 last_name = "000";
 for (;;) {
 int decode = 0;
@@ -868,7 +884,9 @@ static int show_formats_devices(void *optctx, const char 
*opt, const char *arg,
 ofmt_opaque = NULL;
 while ((ofmt = av_muxer_iterate(_opaque))) {
 is_dev = is_device(ofmt->priv_class);
-if (!is_dev && device_only)
+if (!is_dev && device_only == 1)
+continue;
+if (device_only == 2)
 continue;
 if ((!name || strcmp(ofmt->name, name) < 0) &&
 strcmp(ofmt->name, last_name) > 0) {
@@ -882,7 +900,10 @@ static int show_formats_devices(void *optctx, const char 
*opt, const char *arg,
 ifmt_opaque = NULL;
 while ((ifmt = av_demuxer_iterate(_opaque))) {
 is_dev = 

[FFmpeg-devel] [PATCH 4/6] avdevice/utils: add test for AV_CLASS_CATEGORY_RADIO_INPUT

2023-07-22 Thread Michael Niedermayer
This avoids keeping diffs for libavdevice in the libavradio repository

Signed-off-by: Michael Niedermayer 
---
 libavdevice/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/utils.c b/libavdevice/utils.c
index d9a52c53ab..faa24fa74d 100644
--- a/libavdevice/utils.c
+++ b/libavdevice/utils.c
@@ -33,7 +33,7 @@ int ff_alloc_input_device_context(AVFormatContext **avctx, 
const AVInputFormat *
 
 if (!iformat)
 iformat = av_find_input_format(format);
-if (!iformat || !iformat->priv_class || 
!AV_IS_INPUT_DEVICE(iformat->priv_class->category)) {
+if (!iformat || !iformat->priv_class || 
(!AV_IS_INPUT_DEVICE(iformat->priv_class->category) && 
iformat->priv_class->category != AV_CLASS_CATEGORY_RADIO_INPUT)) {
 ret = AVERROR(EINVAL);
 goto error;
 }
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 3/6] avformat: add support for demuxers/inputs from avradio

2023-07-22 Thread Michael Niedermayer
This avoids keeping diffs for libavformat in the libavradio repository

Signed-off-by: Michael Niedermayer 
---
 libavformat/allformats.c | 32 +---
 libavformat/internal.h   |  1 +
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6324952bd2..27a32028dd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -570,6 +570,7 @@ extern const AVInputFormat  ff_vapoursynth_demuxer;
 
 static atomic_uintptr_t indev_list_intptr  = ATOMIC_VAR_INIT(0);
 static atomic_uintptr_t outdev_list_intptr = ATOMIC_VAR_INIT(0);
+static atomic_uintptr_t inradio_list_intptr= ATOMIC_VAR_INIT(0);
 
 const AVOutputFormat *av_muxer_iterate(void **opaque)
 {
@@ -594,20 +595,32 @@ const AVOutputFormat *av_muxer_iterate(void **opaque)
 
 const AVInputFormat *av_demuxer_iterate(void **opaque)
 {
-static const uintptr_t size = sizeof(demuxer_list)/sizeof(demuxer_list[0]) 
- 1;
 uintptr_t i = (uintptr_t)*opaque;
 const AVInputFormat *f = NULL;
 uintptr_t tmp;
 
-if (i < size) {
-f = demuxer_list[i];
-} else if (tmp = atomic_load_explicit(_list_intptr, 
memory_order_relaxed)) {
-const AVInputFormat *const *indev_list = (const AVInputFormat *const 
*)tmp;
-f = indev_list[i - size];
+if (i % 4 == 0) {
+f = demuxer_list[i/4];
+if (!f)
+i = 1;
+}
+if (i % 4 == 1) {
+if(tmp = atomic_load_explicit(_list_intptr, 
memory_order_relaxed)) {
+const AVInputFormat *const *indev_list = (const AVInputFormat 
*const *)tmp;
+f = indev_list[i/4];
+}
+if (!f)
+i = 2;
+}
+if (i % 4 == 2) {
+if(tmp = atomic_load_explicit(_list_intptr, 
memory_order_relaxed)) {
+const AVInputFormat *const *indev_list = (const AVInputFormat 
*const *)tmp;
+f = indev_list[i/4];
+}
 }
 
 if (f)
-*opaque = (void*)(i + 1);
+*opaque = (void*)(i + 4);
 return f;
 }
 
@@ -616,3 +629,8 @@ void avpriv_register_devices(const FFOutputFormat * const 
o[], const AVInputForm
 atomic_store_explicit(_list_intptr, (uintptr_t)o, 
memory_order_relaxed);
 atomic_store_explicit(_list_intptr,  (uintptr_t)i, 
memory_order_relaxed);
 }
+
+void avpriv_register_radios(const FFOutputFormat * const o[], const 
AVInputFormat * const i[])
+{
+atomic_store_explicit(_list_intptr,  (uintptr_t)i, 
memory_order_relaxed);
+}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 9fc980601f..aa6b8b21a9 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -719,5 +719,6 @@ int ff_match_url_ext(const char *url, const char 
*extensions);
 
 struct FFOutputFormat;
 void avpriv_register_devices(const struct FFOutputFormat * const o[], const 
AVInputFormat * const i[]);
+void avpriv_register_radios(const struct FFOutputFormat * const o[], const 
AVInputFormat * const i[]);
 
 #endif /* AVFORMAT_INTERNAL_H */
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 2/6] avutil/log: Add AV_CLASS_CATEGORY_RADIO_INPUT

2023-07-22 Thread Michael Niedermayer
This avoids keeping a diff for libavutil in the libavradio repository

Signed-off-by: Michael Niedermayer 
---
 libavutil/log.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/log.h b/libavutil/log.h
index ab7ceabe22..245ad24988 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -43,6 +43,7 @@ typedef enum {
 AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
 AV_CLASS_CATEGORY_DEVICE_OUTPUT,
 AV_CLASS_CATEGORY_DEVICE_INPUT,
+AV_CLASS_CATEGORY_RADIO_INPUT,
 AV_CLASS_CATEGORY_NB  ///< not part of ABI/API
 }AVClassCategory;
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/6] configure: libavradio support

2023-07-22 Thread Michael Niedermayer
Autodetected based on existence of libavradio/version.h

Signed-off-by: Michael Niedermayer 
---
 Makefile  |  5 +++--
 configure | 46 +++---
 2 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index bf1b69f96b..d5689231c3 100644
--- a/Makefile
+++ b/Makefile
@@ -19,13 +19,14 @@ vpath %/fate_config.sh.template $(SRC_PATH)
 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
 HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
 
-ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale 
swresample
+ALLFFLIBS = avcodec avdevice avfilter avformat avradio avutil postproc swscale 
swresample
 
 # $(FFLIBS-yes) needs to be in linking order
 FFLIBS-$(CONFIG_AVDEVICE)   += avdevice
 FFLIBS-$(CONFIG_AVFILTER)   += avfilter
 FFLIBS-$(CONFIG_AVFORMAT)   += avformat
 FFLIBS-$(CONFIG_AVCODEC)+= avcodec
+FFLIBS-$(CONFIG_AVRADIO)+= avradio
 FFLIBS-$(CONFIG_POSTPROC)   += postproc
 FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
 FFLIBS-$(CONFIG_SWSCALE)+= swscale
@@ -171,7 +172,7 @@ distclean:: clean
libavcodec/bsf_list.c libavformat/protocol_list.c \
libavcodec/codec_list.c libavcodec/parser_list.c \
libavfilter/filter_list.c libavdevice/indev_list.c 
libavdevice/outdev_list.c \
-   libavformat/muxer_list.c libavformat/demuxer_list.c
+   libavformat/muxer_list.c libavformat/demuxer_list.c 
libavradio/inradio_list.c
 ifeq ($(SRC_LINK),src)
$(RM) src
 endif
diff --git a/configure b/configure
index eb2fe392b4..363dc8632e 100755
--- a/configure
+++ b/configure
@@ -75,6 +75,7 @@ Help options:
   --list-indevsshow all available input devices
   --list-outdevs   show all available output devices
   --list-filters   show all available filters
+  --list-inradios  show all available input radios
 
 Standard options:
   --logfile=FILE   log tests and output to FILE [ffbuild/config.log]
@@ -128,6 +129,7 @@ Component options:
   --disable-avdevice   disable libavdevice build
   --disable-avcodecdisable libavcodec build
   --disable-avformat   disable libavformat build
+  --disable-avradiodisable libavradio build
   --disable-swresample disable libswresample build
   --disable-swscaledisable libswscale build
   --disable-postproc   disable libpostproc build
@@ -182,6 +184,10 @@ Individual component options:
   --enable-filter=NAME enable filter NAME
   --disable-filter=NAMEdisable filter NAME
   --disable-filtersdisable all filters
+  --enable-inradios=NAME   enable input radio NAME
+  --disable-inradio=NAME   disable input radio NAME
+  --disable-inradios   disable input radios
+  --disable-radios disable all radios
 
 External library support:
 
@@ -270,6 +276,7 @@ External library support:
   --enable-libshineenable fixed-point MP3 encoding via libshine [no]
   --enable-libsmbclientenable Samba protocol via libsmbclient [no]
   --enable-libsnappy   enable Snappy compression, needed for hap encoding 
[no]
+  --enable-libsoapysdr enable SoapySDR, needed for connecting to SDR HW 
[no]
   --enable-libsoxr enable Include libsoxr resampling [no]
   --enable-libspeexenable Speex de/encoding via libspeex [no]
   --enable-libsrt  enable Haivision SRT protocol via libsrt [no]
@@ -1743,11 +1750,16 @@ AVFORMAT_COMPONENTS="
 protocols
 "
 
+AVRADIO_COMPONENTS="
+inradios
+"
+
 COMPONENT_LIST="
 $AVCODEC_COMPONENTS
 $AVDEVICE_COMPONENTS
 $AVFILTER_COMPONENTS
 $AVFORMAT_COMPONENTS
+$AVRADIO_COMPONENTS
 "
 
 EXAMPLE_LIST="
@@ -1890,6 +1902,7 @@ EXTERNAL_LIBRARY_LIST="
 libshine
 libsmbclient
 libsnappy
+libsoapysdr
 libsoxr
 libspeex
 libsrt
@@ -1982,6 +1995,7 @@ FEATURE_LIST="
 # this list should be kept in linking order
 LIBRARY_LIST="
 avdevice
+avradio
 avfilter
 swscale
 postproc
@@ -2228,6 +2242,7 @@ HEADERS_LIST="
 ES2_gl_h
 gsm_h
 io_h
+libavradio_version_h
 linux_dma_buf_h
 linux_perf_event_h
 machine_ioctl_bt848_h
@@ -3622,6 +3637,9 @@ xcbgrab_indev_deps="libxcb"
 xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes"
 xv_outdev_deps="xlib_xv xlib_x11 xlib_xext"
 
+# inradios
+sdr_inradio_deps="libsoapysdr"
+
 # protocols
 async_protocol_deps="threads"
 bluray_protocol_deps="libbluray"
@@ -3886,6 +3904,8 @@ avcodec_deps="avutil"
 avcodec_suggest="libm stdatomic"
 avdevice_deps="avformat avcodec avutil"
 avdevice_suggest="libm stdatomic"
+avradio_deps="avformat avcodec avutil libavradio_version_h"
+avradio_suggest="libm stdatomic"
 avfilter_deps="avutil"
 avfilter_suggest="libm stdatomic"
 avformat_deps="avcodec avutil"
@@ -4079,7 +4099,7 @@ find_things_extern(){
 pattern=$2
 file=$source_path/$3
 out=${4:-$thing}
-sed -n "s/^[^#]*extern.*$pattern *ff_\([^ 

Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Marvin Scholz



On 22 Jul 2023, at 21:10, John Cox wrote:

> On Sat, 22 Jul 2023 20:54:04 +0200, you wrote:
>
>> On 22 Jul 2023, at 18:41, John Cox wrote:
>>
>>> Add a callback to enable user allocation of video frames on the final
>>> stage of a filter chain.
>>>
>>> Signed-off-by: John Cox 
>>> ---
>>>  libavfilter/buffersink.c | 21 +
>>>  libavfilter/buffersink.h | 27 +++
>>>  libavfilter/version.h|  2 +-
>>>  3 files changed, 49 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
>>> index 306c283f77..070b743186 100644
>>> --- a/libavfilter/buffersink.c
>>> +++ b/libavfilter/buffersink.c
>>> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>>>  int sample_rates_size;
>>>
>>>  AVFrame *peeked_frame;
>>> +
>>> +union {
>>> +av_buffersink_alloc_video_frame * video;
>>> +} alloc_cb;
>>> +void * alloc_v;
>>>  } BufferSinkContext;
>>>
>>>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
>>> @@ -154,6 +159,21 @@ int attribute_align_arg 
>>> av_buffersink_get_samples(AVFilterContext *ctx,
>>>  return get_frame_internal(ctx, frame, 0, nb_samples);
>>>  }
>>>
>>> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
>>> +{
>>> +AVFilterContext * const ctx = link->dst;
>>> +BufferSinkContext * const bs = ctx->priv;
>>> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) 
>>> :
>>> +ff_default_get_video_buffer(link, w, h);
>>> +}
>>> +
>>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>>> av_buffersink_alloc_video_frame * cb, void * v)
>>> +{
>>> +BufferSinkContext * const bs = ctx->priv;
>>> +bs->alloc_cb.video = cb;
>>> +bs->alloc_v = v;
>>> +}
>>> +
>>>  static av_cold int common_init(AVFilterContext *ctx)
>>>  {
>>>  BufferSinkContext *buf = ctx->priv;
>>> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] 
>>> = {
>>>  {
>>>  .name = "default",
>>>  .type = AVMEDIA_TYPE_VIDEO,
>>> +.get_buffer = {.video = alloc_video_buffer},
>>>  },
>>>  };
>>>
>>> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
>>> index 64e08de53e..73f0ddc476 100644
>>> --- a/libavfilter/buffersink.h
>>> +++ b/libavfilter/buffersink.h
>>> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
>>> AVFrame *frame);
>>>   */
>>>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
>>> nb_samples);
>>>
>>> +/**
>>> + * Callback from av_buffersink_set_alloc_video_frame to allocate
>>> + * a frame
>>> + *
>>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>>> + * @param v opaque pointer passed to
>>> + *  av_buffersink_set_alloc_video_frame
>>
>> Nit:
>>
>> You can use @ref av_buffersink_set_alloc_video_frame  or even
>> shorter ::av_buffersink_set_alloc_video_frame to get a proper
>> reference to that function that will be linked.
>
> Thanks - will do - Is documentation built from this? I had a quick look
> to see if I could find some output to verify what I'd done but I failed
> to find it.

You can generate it (if you have doxygen installed) by running:

make apidoc

and it will end up in doc/doxy/html.

>
>>> + * @param w width of frame to allocate
>>> + * @param height of frame to allocate
>>> + *
>>> + * @return
>>> + * - The newly allocated frame
>>> + * - NULL if error
>>
>> Nit:
>>
>> This can use retval, for example like that:
>>
>> @retval AVFrame* The newly allocated frame
>> @retval NULL Error allocating the frame
>
> Will do.
>
> Ta
>
> JC
>
>>> + */
>>> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, 
>>> void * v, int w, int h);
>>> +
>>> +/**
>>> + * Set a video frame allocation method for buffersink
>>> + *
>>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>>> + * @param cb Callback to the allocation function. If set to NULL
>>> + *   then the default avfilter allocation function will
>>> + *   be used.
>>> + * @param v  Opaque to pass to the allocation function
>>> + */
>>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>>> av_buffersink_alloc_video_frame * cb, void * v);
>>> +
>>>  /**
>>>   * @}
>>>   */
>>> diff --git a/libavfilter/version.h b/libavfilter/version.h
>>> index c001693e3c..54950497be 100644
>>> --- a/libavfilter/version.h
>>> +++ b/libavfilter/version.h
>>> @@ -31,7 +31,7 @@
>>>
>>>  #include "version_major.h"
>>>
>>> -#define LIBAVFILTER_VERSION_MINOR   8
>>> +#define LIBAVFILTER_VERSION_MINOR   9
>>>  #define LIBAVFILTER_VERSION_MICRO 102
>>>
>>>
>>> -- 
>>> 2.39.2
>>>
>>> ___
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>> 

Re: [FFmpeg-devel] [PATCH v3 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Andreas Rheinhardt
John Cox:
> Add a callback to enable user allocation of video frames on the final
> stage of a filter chain.
> 
> Signed-off-by: John Cox 
> ---
>  libavfilter/buffersink.c | 21 +
>  libavfilter/buffersink.h | 27 +++
>  libavfilter/version.h|  2 +-
>  3 files changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
> index 306c283f77..e99d444530 100644
> --- a/libavfilter/buffersink.c
> +++ b/libavfilter/buffersink.c
> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>  int sample_rates_size;
>  
>  AVFrame *peeked_frame;
> +
> +union {
> +AVBuffersinkAllocVideoFrameFunc video;
> +} alloc_cb;
> +void * alloc_v;
>  } BufferSinkContext;
>  
>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
> @@ -154,6 +159,21 @@ int attribute_align_arg 
> av_buffersink_get_samples(AVFilterContext *ctx,
>  return get_frame_internal(ctx, frame, 0, nb_samples);
>  }
>  
> +static AVFrame *alloc_video_buffer(AVFilterLink *link, int w, int h)
> +{
> +AVFilterContext *const ctx = link->dst;
> +BufferSinkContext *const buf = ctx->priv;
> +return buf->alloc_cb.video ? buf->alloc_cb.video(ctx, buf->alloc_v, w, 
> h) :
> + ff_default_get_video_buffer(link, w, h);
> +}
> +
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> AVBuffersinkAllocVideoFrameFunc cb, void *v)
> +{
> +BufferSinkContext *const buf = ctx->priv;
> +buf->alloc_cb.video = cb;
> +buf->alloc_v = v;
> +}
> +
>  static av_cold int common_init(AVFilterContext *ctx)
>  {
>  BufferSinkContext *buf = ctx->priv;
> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] = 
> {
>  {
>  .name = "default",
>  .type = AVMEDIA_TYPE_VIDEO,
> +.get_buffer = {.video = alloc_video_buffer},
>  },
>  };
>  
> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
> index 64e08de53e..2419d1bd80 100644
> --- a/libavfilter/buffersink.h
> +++ b/libavfilter/buffersink.h
> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
> AVFrame *frame);
>   */
>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
> nb_samples);
>  
> +/**
> + * Callback from av_buffersink_set_alloc_video_frame to allocate 
> + * a frame 
> + *  
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param v opaque pointer passed to 
> + *  av_buffersink_set_alloc_video_frame
> + * @param w width of frame to allocate 
> + * @param height of frame to allocate 
> + *  
> + * @return 
> + * - The newly allocated frame
> + * - NULL if error
> + */
> +typedef AVFrame *(*AVBuffersinkAllocVideoFrameFunc)(AVFilterContext * ctx, 
> void * v, int w, int h);
> +
> +/**
> + * Set a video frame allocation method for buffersink
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param cb Callback to the allocation function. If set to NULL 
> + *   then the default avfilter allocation function will
> + *   be used.
> + * @param v  Opaque to pass to the allocation function
> + */
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> AVBuffersinkAllocVideoFrameFunc cb, void * v);
> +
>  /**
>   * @}
>   */
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index c001693e3c..54950497be 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>  
>  #include "version_major.h"
>  
> -#define LIBAVFILTER_VERSION_MINOR   8
> +#define LIBAVFILTER_VERSION_MINOR   9
>  #define LIBAVFILTER_VERSION_MICRO 102

Not commenting on the actual patch, but when bumping minor, you need to
reset micro.

- Andreas

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

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


[FFmpeg-devel] [PATCH 5/5] fftools/ffmpeg_opt: Reduce scope of variables for deprecated code

2023-07-22 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_opt.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1860e9d329..dc6044120a 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -372,9 +372,6 @@ static int opt_map(void *optctx, const char *opt, const 
char *arg)
 StreamMap *m = NULL;
 int i, negative = 0, file_idx, disabled = 0;
 int ret;
-#if FFMPEG_OPT_MAP_SYNC
-char *sync;
-#endif
 char *map, *p;
 char *allow_unused;
 
@@ -387,10 +384,14 @@ static int opt_map(void *optctx, const char *opt, const 
char *arg)
 return AVERROR(ENOMEM);
 
 #if FFMPEG_OPT_MAP_SYNC
-/* parse sync stream first, just pick first matching stream */
-if (sync = strchr(map, ',')) {
-*sync = 0;
-av_log(NULL, AV_LOG_WARNING, "Specifying a sync stream is deprecated 
and has no effect\n");
+{
+/* parse sync stream first, just pick first matching stream */
+char *sync = strchr(map, ',');
+
+if (sync) {
+*sync = 0;
+av_log(NULL, AV_LOG_WARNING, "Specifying a sync stream is 
deprecated and has no effect\n");
+}
 }
 #endif
 
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 4/5] fftools/ffmpeg_opt: Fix leak on error

2023-07-22 Thread Andreas Rheinhardt
Fixes Coverity id #1539096.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_opt.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f7606ae6f6..1860e9d329 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -401,13 +401,14 @@ static int opt_map(void *optctx, const char *opt, const 
char *arg)
 
 ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
 if (ret < 0)
-return ret;
+goto fail;
 
 m = >stream_maps[o->nb_stream_maps - 1];
 m->linklabel = av_get_token(, "]");
 if (!m->linklabel) {
 av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", 
map);
-return AVERROR(EINVAL);
+ret = AVERROR(EINVAL);
+goto fail;
 }
 } else {
 if (allow_unused = strchr(map, '?'))
@@ -415,7 +416,8 @@ static int opt_map(void *optctx, const char *opt, const 
char *arg)
 file_idx = strtol(map, , 0);
 if (file_idx >= nb_input_files || file_idx < 0) {
 av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", 
file_idx);
-return AVERROR(EINVAL);
+ret = AVERROR(EINVAL);
+goto fail;
 }
 if (negative)
 /* disable some already defined maps */
@@ -438,7 +440,7 @@ static int opt_map(void *optctx, const char *opt, const 
char *arg)
 }
 ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
 if (ret < 0)
-return ret;
+goto fail;
 
 m = >stream_maps[o->nb_stream_maps - 1];
 
@@ -453,16 +455,19 @@ static int opt_map(void *optctx, const char *opt, const 
char *arg)
 } else if (disabled) {
 av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled 
streams.\n"
"To ignore this, add a trailing '?' to 
the map.\n", arg);
-return AVERROR(EINVAL);
+ret = AVERROR(EINVAL);
+goto fail;
 } else {
 av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n"
"To ignore this, add a trailing '?' to 
the map.\n", arg);
-return AVERROR(EINVAL);
+ret = AVERROR(EINVAL);
+goto fail;
 }
 }
-
+ret = 0;
+fail:
 av_freep();
-return 0;
+return ret;
 }
 
 static int opt_attach(void *optctx, const char *opt, const char *arg)
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread John Cox
On Sat, 22 Jul 2023 20:54:04 +0200, you wrote:

>On 22 Jul 2023, at 18:41, John Cox wrote:
>
>> Add a callback to enable user allocation of video frames on the final
>> stage of a filter chain.
>>
>> Signed-off-by: John Cox 
>> ---
>>  libavfilter/buffersink.c | 21 +
>>  libavfilter/buffersink.h | 27 +++
>>  libavfilter/version.h|  2 +-
>>  3 files changed, 49 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
>> index 306c283f77..070b743186 100644
>> --- a/libavfilter/buffersink.c
>> +++ b/libavfilter/buffersink.c
>> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>>  int sample_rates_size;
>>
>>  AVFrame *peeked_frame;
>> +
>> +union {
>> +av_buffersink_alloc_video_frame * video;
>> +} alloc_cb;
>> +void * alloc_v;
>>  } BufferSinkContext;
>>
>>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
>> @@ -154,6 +159,21 @@ int attribute_align_arg 
>> av_buffersink_get_samples(AVFilterContext *ctx,
>>  return get_frame_internal(ctx, frame, 0, nb_samples);
>>  }
>>
>> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
>> +{
>> +AVFilterContext * const ctx = link->dst;
>> +BufferSinkContext * const bs = ctx->priv;
>> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) :
>> +ff_default_get_video_buffer(link, w, h);
>> +}
>> +
>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>> av_buffersink_alloc_video_frame * cb, void * v)
>> +{
>> +BufferSinkContext * const bs = ctx->priv;
>> +bs->alloc_cb.video = cb;
>> +bs->alloc_v = v;
>> +}
>> +
>>  static av_cold int common_init(AVFilterContext *ctx)
>>  {
>>  BufferSinkContext *buf = ctx->priv;
>> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] 
>> = {
>>  {
>>  .name = "default",
>>  .type = AVMEDIA_TYPE_VIDEO,
>> +.get_buffer = {.video = alloc_video_buffer},
>>  },
>>  };
>>
>> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
>> index 64e08de53e..73f0ddc476 100644
>> --- a/libavfilter/buffersink.h
>> +++ b/libavfilter/buffersink.h
>> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
>> AVFrame *frame);
>>   */
>>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
>> nb_samples);
>>
>> +/**
>> + * Callback from av_buffersink_set_alloc_video_frame to allocate
>> + * a frame
>> + *
>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>> + * @param v opaque pointer passed to
>> + *  av_buffersink_set_alloc_video_frame
>
>Nit:
>
>You can use @ref av_buffersink_set_alloc_video_frame  or even
>shorter ::av_buffersink_set_alloc_video_frame to get a proper
>reference to that function that will be linked.

Thanks - will do - Is documentation built from this? I had a quick look
to see if I could find some output to verify what I'd done but I failed
to find it.

>> + * @param w width of frame to allocate
>> + * @param height of frame to allocate
>> + *
>> + * @return
>> + * - The newly allocated frame
>> + * - NULL if error
>
>Nit:
>
>This can use retval, for example like that:
>
>@retval AVFrame* The newly allocated frame
>@retval NULL Error allocating the frame

Will do.

Ta

JC

>> + */
>> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, 
>> void * v, int w, int h);
>> +
>> +/**
>> + * Set a video frame allocation method for buffersink
>> + *
>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>> + * @param cb Callback to the allocation function. If set to NULL
>> + *   then the default avfilter allocation function will
>> + *   be used.
>> + * @param v  Opaque to pass to the allocation function
>> + */
>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>> av_buffersink_alloc_video_frame * cb, void * v);
>> +
>>  /**
>>   * @}
>>   */
>> diff --git a/libavfilter/version.h b/libavfilter/version.h
>> index c001693e3c..54950497be 100644
>> --- a/libavfilter/version.h
>> +++ b/libavfilter/version.h
>> @@ -31,7 +31,7 @@
>>
>>  #include "version_major.h"
>>
>> -#define LIBAVFILTER_VERSION_MINOR   8
>> +#define LIBAVFILTER_VERSION_MINOR   9
>>  #define LIBAVFILTER_VERSION_MICRO 102
>>
>>
>> -- 
>> 2.39.2
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>To unsubscribe, visit link above, or email
>ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list

[FFmpeg-devel] [PATCH 3/5] fftools/opt_common: Fix leak on error

2023-07-22 Thread Andreas Rheinhardt
Fixes Coverity issue #743443.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/opt_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 913932c914..7c996f140d 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1165,6 +1165,7 @@ int init_report(const char *env, FILE **file)
 av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n");
 av_free(key);
 av_free(val);
+av_free(filename_template);
 return AVERROR(EINVAL);
 }
 envlevel = 1;
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/5] fftools/ffmpeg_opt: Fix leak on error

2023-07-22 Thread Andreas Rheinhardt
Fixes Coverity issue #1539097.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_opt.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 700db706a1..f7606ae6f6 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -497,7 +497,7 @@ static int opt_map_channel(void *optctx, const char *opt, 
const char *arg)
 
 ret = GROW_ARRAY(o->audio_channel_maps, o->nb_audio_channel_maps);
 if (ret < 0)
-return ret;
+goto end;
 
 m = >audio_channel_maps[o->nb_audio_channel_maps - 1];
 
@@ -559,11 +559,13 @@ static int opt_map_channel(void *optctx, const char *opt, 
const char *arg)
 }
 
 }
+ret = 0;
+end:
 av_free(mapchan);
-return 0;
+return ret;
 fail:
-av_free(mapchan);
-return AVERROR(EINVAL);
+ret = AVERROR(EINVAL);
+goto end;
 }
 #endif
 
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/5] fftools/ffmpeg_mux_init: Fix leak on error

2023-07-22 Thread Andreas Rheinhardt
Fixes Coverity issue #1539098.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_mux_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 86521417ec..0289cdabad 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -361,7 +361,7 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, 
int pre,
 
 ret = GROW_ARRAY(es->components, es->nb_components);
 if (ret < 0)
-return ret;
+goto fail;
 
 c = >components[es->nb_components - 1];
 
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Marvin Scholz
On 22 Jul 2023, at 18:41, John Cox wrote:

> Add a callback to enable user allocation of video frames on the final
> stage of a filter chain.
>
> Signed-off-by: John Cox 
> ---
>  libavfilter/buffersink.c | 21 +
>  libavfilter/buffersink.h | 27 +++
>  libavfilter/version.h|  2 +-
>  3 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
> index 306c283f77..070b743186 100644
> --- a/libavfilter/buffersink.c
> +++ b/libavfilter/buffersink.c
> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>  int sample_rates_size;
>
>  AVFrame *peeked_frame;
> +
> +union {
> +av_buffersink_alloc_video_frame * video;
> +} alloc_cb;
> +void * alloc_v;
>  } BufferSinkContext;
>
>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
> @@ -154,6 +159,21 @@ int attribute_align_arg 
> av_buffersink_get_samples(AVFilterContext *ctx,
>  return get_frame_internal(ctx, frame, 0, nb_samples);
>  }
>
> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
> +{
> +AVFilterContext * const ctx = link->dst;
> +BufferSinkContext * const bs = ctx->priv;
> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) :
> +ff_default_get_video_buffer(link, w, h);
> +}
> +
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> av_buffersink_alloc_video_frame * cb, void * v)
> +{
> +BufferSinkContext * const bs = ctx->priv;
> +bs->alloc_cb.video = cb;
> +bs->alloc_v = v;
> +}
> +
>  static av_cold int common_init(AVFilterContext *ctx)
>  {
>  BufferSinkContext *buf = ctx->priv;
> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] = 
> {
>  {
>  .name = "default",
>  .type = AVMEDIA_TYPE_VIDEO,
> +.get_buffer = {.video = alloc_video_buffer},
>  },
>  };
>
> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
> index 64e08de53e..73f0ddc476 100644
> --- a/libavfilter/buffersink.h
> +++ b/libavfilter/buffersink.h
> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
> AVFrame *frame);
>   */
>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
> nb_samples);
>
> +/**
> + * Callback from av_buffersink_set_alloc_video_frame to allocate
> + * a frame
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param v opaque pointer passed to
> + *  av_buffersink_set_alloc_video_frame

Nit:

You can use @ref av_buffersink_set_alloc_video_frame  or even
shorter ::av_buffersink_set_alloc_video_frame to get a proper
reference to that function that will be linked.

> + * @param w width of frame to allocate
> + * @param height of frame to allocate
> + *
> + * @return
> + * - The newly allocated frame
> + * - NULL if error

Nit:

This can use retval, for example like that:

@retval AVFrame* The newly allocated frame
@retval NULL Error allocating the frame

> + */
> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, 
> void * v, int w, int h);
> +
> +/**
> + * Set a video frame allocation method for buffersink
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param cb Callback to the allocation function. If set to NULL
> + *   then the default avfilter allocation function will
> + *   be used.
> + * @param v  Opaque to pass to the allocation function
> + */
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> av_buffersink_alloc_video_frame * cb, void * v);
> +
>  /**
>   * @}
>   */
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index c001693e3c..54950497be 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>
>  #include "version_major.h"
>
> -#define LIBAVFILTER_VERSION_MINOR   8
> +#define LIBAVFILTER_VERSION_MINOR   9
>  #define LIBAVFILTER_VERSION_MICRO 102
>
>
> -- 
> 2.39.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avcodec: fix misleading indentation warnings after ticks_per_frame deprecation

2023-07-22 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavcodec/libaomenc.c  | 3 ++-
 libavcodec/libvpxenc.c  | 3 ++-
 libavcodec/msmpeg4enc.c | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 16747e7e92..f29cb0784a 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -1299,7 +1299,7 @@ static int aom_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 duration = frame->duration;
 else if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
 duration = av_rescale_q(1, av_inv_q(avctx->framerate), 
avctx->time_base);
-else
+else {
 FF_DISABLE_DEPRECATION_WARNINGS
 duration =
 #if FF_API_TICKS_PER_FRAME
@@ -1307,6 +1307,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
 #endif
 1;
 FF_ENABLE_DEPRECATION_WARNINGS
+}
 
 switch (frame->color_range) {
 case AVCOL_RANGE_MPEG:
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 549ac55aaa..7a545527a9 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1830,7 +1830,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 duration = frame->duration;
 else if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
 duration = av_rescale_q(1, av_inv_q(avctx->framerate), 
avctx->time_base);
-else
+else {
 FF_DISABLE_DEPRECATION_WARNINGS
 duration =
 #if FF_API_TICKS_PER_FRAME
@@ -1838,6 +1838,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
 #endif
 1;
 FF_ENABLE_DEPRECATION_WARNINGS
+}
 
 res = vpx_codec_encode(>encoder, rawimg, timestamp,
duration, flags, ctx->deadline);
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index 9828901bea..a8ddb8d8e1 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -284,7 +284,7 @@ void ff_msmpeg4_encode_ext_header(MpegEncContext * s)
 
 if (s->avctx->framerate.num > 0 && s->avctx->framerate.den > 0)
 fps = s->avctx->framerate.num / s->avctx->framerate.den;
-else
+else {
 FF_DISABLE_DEPRECATION_WARNINGS
 fps = s->avctx->time_base.den / s->avctx->time_base.num
 #if FF_API_TICKS_PER_FRAME
@@ -292,6 +292,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
 #endif
 ;
 FF_ENABLE_DEPRECATION_WARNINGS
+}
 
 put_bits(>pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29
 
-- 
2.35.3

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

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


[FFmpeg-devel] [PATCH v3 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread John Cox
Add a callback to enable user allocation of video frames on the final
stage of a filter chain.

Signed-off-by: John Cox 
---
 libavfilter/buffersink.c | 21 +
 libavfilter/buffersink.h | 27 +++
 libavfilter/version.h|  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 306c283f77..e99d444530 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
 int sample_rates_size;
 
 AVFrame *peeked_frame;
+
+union {
+AVBuffersinkAllocVideoFrameFunc video;
+} alloc_cb;
+void * alloc_v;
 } BufferSinkContext;
 
 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
@@ -154,6 +159,21 @@ int attribute_align_arg 
av_buffersink_get_samples(AVFilterContext *ctx,
 return get_frame_internal(ctx, frame, 0, nb_samples);
 }
 
+static AVFrame *alloc_video_buffer(AVFilterLink *link, int w, int h)
+{
+AVFilterContext *const ctx = link->dst;
+BufferSinkContext *const buf = ctx->priv;
+return buf->alloc_cb.video ? buf->alloc_cb.video(ctx, buf->alloc_v, w, h) :
+ ff_default_get_video_buffer(link, w, h);
+}
+
+void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
AVBuffersinkAllocVideoFrameFunc cb, void *v)
+{
+BufferSinkContext *const buf = ctx->priv;
+buf->alloc_cb.video = cb;
+buf->alloc_v = v;
+}
+
 static av_cold int common_init(AVFilterContext *ctx)
 {
 BufferSinkContext *buf = ctx->priv;
@@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] = {
 {
 .name = "default",
 .type = AVMEDIA_TYPE_VIDEO,
+.get_buffer = {.video = alloc_video_buffer},
 },
 };
 
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 64e08de53e..2419d1bd80 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame);
  */
 int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
nb_samples);
 
+/**
+ * Callback from av_buffersink_set_alloc_video_frame to allocate 
+ * a frame 
+ *  
+ * @param ctx pointer to a context of the abuffersink AVFilter.
+ * @param v opaque pointer passed to 
+ *  av_buffersink_set_alloc_video_frame
+ * @param w width of frame to allocate 
+ * @param height of frame to allocate 
+ *  
+ * @return 
+ * - The newly allocated frame
+ * - NULL if error
+ */
+typedef AVFrame *(*AVBuffersinkAllocVideoFrameFunc)(AVFilterContext * ctx, 
void * v, int w, int h);
+
+/**
+ * Set a video frame allocation method for buffersink
+ *
+ * @param ctx pointer to a context of the abuffersink AVFilter.
+ * @param cb Callback to the allocation function. If set to NULL 
+ *   then the default avfilter allocation function will
+ *   be used.
+ * @param v  Opaque to pass to the allocation function
+ */
+void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
AVBuffersinkAllocVideoFrameFunc cb, void * v);
+
 /**
  * @}
  */
diff --git a/libavfilter/version.h b/libavfilter/version.h
index c001693e3c..54950497be 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR   8
+#define LIBAVFILTER_VERSION_MINOR   9
 #define LIBAVFILTER_VERSION_MICRO 102
 
 
-- 
2.39.2

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

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


[FFmpeg-devel] [PATCH v3 0/1] avfilter/buffersink: Add user video frame allocation

2023-07-22 Thread John Cox
This patch adds the ability for the user to allocate frames rather than
being forced to use avfilters default allocator.

This useful for applications like Kodi that wish to be able to control
how the final filter stage frame is allocated so that it is compatible
with whatever it wishes to do next e.g. allocate a dmabuf backed frame
for direct display via DRM. This is similar to the facility provided
by get_buffer2 in avcodec.

Changes from v1:
Style fixes - but for real this time

John Cox (1):
  avfilter/buffersink: Add video frame allocation callback

 libavfilter/buffersink.c | 21 +
 libavfilter/buffersink.h | 27 +++
 libavfilter/version.h|  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)

-- 
2.39.2

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

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


Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Nicolas George
John Cox (12023-07-22):
> Finger trouble - repost of previous patch - please ignore

No problem, I was about to make the remark. But please do not Cc people
who have not asked for it. Especially when the mail says "Reply-To:
ffmpeg-devel@ffmpeg.org".

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread John Cox
Finger trouble - repost of previous patch - please ignore

Sorry

JC

>Add a callback to enable user allocation of video frames on the final
>stage of a filter chain.
>
>Signed-off-by: John Cox 
>---
> libavfilter/buffersink.c | 21 +
> libavfilter/buffersink.h | 27 +++
> libavfilter/version.h|  2 +-
> 3 files changed, 49 insertions(+), 1 deletion(-)
>
>diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
>index 306c283f77..070b743186 100644
>--- a/libavfilter/buffersink.c
>+++ b/libavfilter/buffersink.c
>@@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
> int sample_rates_size;
> 
> AVFrame *peeked_frame;
>+
>+union {
>+av_buffersink_alloc_video_frame * video;
>+} alloc_cb;
>+void * alloc_v;
> } BufferSinkContext;
> 
> #define NB_ITEMS(list) (list ## _size / sizeof(*list))
>@@ -154,6 +159,21 @@ int attribute_align_arg 
>av_buffersink_get_samples(AVFilterContext *ctx,
> return get_frame_internal(ctx, frame, 0, nb_samples);
> }
> 
>+static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
>+{
>+AVFilterContext * const ctx = link->dst;
>+BufferSinkContext * const bs = ctx->priv;
>+return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) :
>+ff_default_get_video_buffer(link, w, h);
>+}
>+
>+void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>av_buffersink_alloc_video_frame * cb, void * v)
>+{
>+BufferSinkContext * const bs = ctx->priv;
>+bs->alloc_cb.video = cb;
>+bs->alloc_v = v;
>+}
>+
> static av_cold int common_init(AVFilterContext *ctx)
> {
> BufferSinkContext *buf = ctx->priv;
>@@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] = {
> {
> .name = "default",
> .type = AVMEDIA_TYPE_VIDEO,
>+.get_buffer = {.video = alloc_video_buffer},
> },
> };
> 
>diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
>index 64e08de53e..73f0ddc476 100644
>--- a/libavfilter/buffersink.h
>+++ b/libavfilter/buffersink.h
>@@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
>*frame);
>  */
> int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
> nb_samples);
> 
>+/**
>+ * Callback from av_buffersink_set_alloc_video_frame to allocate 
>+ * a frame 
>+ *  
>+ * @param ctx pointer to a context of the abuffersink AVFilter.
>+ * @param v opaque pointer passed to 
>+ *  av_buffersink_set_alloc_video_frame
>+ * @param w width of frame to allocate 
>+ * @param height of frame to allocate 
>+ *  
>+ * @return 
>+ * - The newly allocated frame
>+ * - NULL if error
>+ */
>+typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, void 
>* v, int w, int h);
>+
>+/**
>+ * Set a video frame allocation method for buffersink
>+ *
>+ * @param ctx pointer to a context of the abuffersink AVFilter.
>+ * @param cb Callback to the allocation function. If set to NULL 
>+ *   then the default avfilter allocation function will
>+ *   be used.
>+ * @param v  Opaque to pass to the allocation function
>+ */
>+void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>av_buffersink_alloc_video_frame * cb, void * v);
>+
> /**
>  * @}
>  */
>diff --git a/libavfilter/version.h b/libavfilter/version.h
>index c001693e3c..54950497be 100644
>--- a/libavfilter/version.h
>+++ b/libavfilter/version.h
>@@ -31,7 +31,7 @@
> 
> #include "version_major.h"
> 
>-#define LIBAVFILTER_VERSION_MINOR   8
>+#define LIBAVFILTER_VERSION_MINOR   9
> #define LIBAVFILTER_VERSION_MICRO 102
> 
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread John Cox
Add a callback to enable user allocation of video frames on the final
stage of a filter chain.

Signed-off-by: John Cox 
---
 libavfilter/buffersink.c | 21 +
 libavfilter/buffersink.h | 27 +++
 libavfilter/version.h|  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 306c283f77..070b743186 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
 int sample_rates_size;
 
 AVFrame *peeked_frame;
+
+union {
+av_buffersink_alloc_video_frame * video;
+} alloc_cb;
+void * alloc_v;
 } BufferSinkContext;
 
 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
@@ -154,6 +159,21 @@ int attribute_align_arg 
av_buffersink_get_samples(AVFilterContext *ctx,
 return get_frame_internal(ctx, frame, 0, nb_samples);
 }
 
+static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
+{
+AVFilterContext * const ctx = link->dst;
+BufferSinkContext * const bs = ctx->priv;
+return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) :
+ff_default_get_video_buffer(link, w, h);
+}
+
+void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
av_buffersink_alloc_video_frame * cb, void * v)
+{
+BufferSinkContext * const bs = ctx->priv;
+bs->alloc_cb.video = cb;
+bs->alloc_v = v;
+}
+
 static av_cold int common_init(AVFilterContext *ctx)
 {
 BufferSinkContext *buf = ctx->priv;
@@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] = {
 {
 .name = "default",
 .type = AVMEDIA_TYPE_VIDEO,
+.get_buffer = {.video = alloc_video_buffer},
 },
 };
 
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 64e08de53e..73f0ddc476 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame);
  */
 int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
nb_samples);
 
+/**
+ * Callback from av_buffersink_set_alloc_video_frame to allocate 
+ * a frame 
+ *  
+ * @param ctx pointer to a context of the abuffersink AVFilter.
+ * @param v opaque pointer passed to 
+ *  av_buffersink_set_alloc_video_frame
+ * @param w width of frame to allocate 
+ * @param height of frame to allocate 
+ *  
+ * @return 
+ * - The newly allocated frame
+ * - NULL if error
+ */
+typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, void 
* v, int w, int h);
+
+/**
+ * Set a video frame allocation method for buffersink
+ *
+ * @param ctx pointer to a context of the abuffersink AVFilter.
+ * @param cb Callback to the allocation function. If set to NULL 
+ *   then the default avfilter allocation function will
+ *   be used.
+ * @param v  Opaque to pass to the allocation function
+ */
+void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
av_buffersink_alloc_video_frame * cb, void * v);
+
 /**
  * @}
  */
diff --git a/libavfilter/version.h b/libavfilter/version.h
index c001693e3c..54950497be 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR   8
+#define LIBAVFILTER_VERSION_MINOR   9
 #define LIBAVFILTER_VERSION_MICRO 102
 
 
-- 
2.39.2

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

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


[FFmpeg-devel] [PATCH v2 0/1] avfilter/buffersink: Add user video frame allocation

2023-07-22 Thread John Cox
This patch adds the ability for the user to allocate frames rather than
being forced to use avfilters default allocator.

This useful for applications like Kodi that wish to be able to control
how the final filter stage frame is allocated so that it is compatible
with whatever it wishes to do next e.g. allocate a dmabuf backed frame
for direct display via DRM. This is similar to the facility provided
by get_buffer2 in avcodec.

Changes from v1:
Style fixes

John Cox (1):
  avfilter/buffersink: Add video frame allocation callback

 libavfilter/buffersink.c | 21 +
 libavfilter/buffersink.h | 27 +++
 libavfilter/version.h|  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)

-- 
2.39.2

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

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


Re: [FFmpeg-devel] [PATCH 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Paul B Mahol
On Sat, Jul 22, 2023 at 5:25 PM Nicolas George  wrote:

> Paul B Mahol (12023-07-22):
> > What about an audio?
>
> Are we in the business of refusing a patch adding an interesting feature
> because we want two interesting features instead?
>

Double standards, not unexpected from you.


>
> > This works only for sinks mostly, what about filters inside graph?
>
> It is already in place, it has been for years. This patch only adds the
> API to expose it publicly.
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread John Cox
On Sat, 22 Jul 2023 17:28:31 +0200, you wrote:

>On Thu, Jul 20, 2023 at 1:40?PM John Cox  wrote:
>
>> Add a callback to enable user allocation of video frames on the final
>> stage of a filter chain.
>>
>>
>What about an audio?
I have a use case for video and none for audio, but I can add audio if
you want.

>This works only for sinks mostly, what about filters inside graph?
Buffer allocation can already be set by the next filter in the chain
which is the callback I am tapping into. If you want to change that then
I guess the right answer would be to move get_buffer.video & audio out
of AVFilterPad and into somewhere publicly writeable, but I really don't
see the need. It seems sensible to me that buffer allocation internal to
graphs is negotiated between those filter elements and is opaque to the
user and it is only at the point where a buffer is delivered to the user
that the user needs to be able to intervene.

Regards

JC

>> Signed-off-by: John Cox 
>> ---
>>  libavfilter/buffersink.c | 21 +
>>  libavfilter/buffersink.h | 27 +++
>>  libavfilter/version.h|  2 +-
>>  3 files changed, 49 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
>> index 306c283f77..070b743186 100644
>> --- a/libavfilter/buffersink.c
>> +++ b/libavfilter/buffersink.c
>> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>>  int sample_rates_size;
>>
>>  AVFrame *peeked_frame;
>> +
>> +union {
>> +av_buffersink_alloc_video_frame * video;
>> +} alloc_cb;
>> +void * alloc_v;
>>  } BufferSinkContext;
>>
>>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
>> @@ -154,6 +159,21 @@ int attribute_align_arg
>> av_buffersink_get_samples(AVFilterContext *ctx,
>>  return get_frame_internal(ctx, frame, 0, nb_samples);
>>  }
>>
>> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
>> +{
>> +AVFilterContext * const ctx = link->dst;
>> +BufferSinkContext * const bs = ctx->priv;
>> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w,
>> h) :
>> +ff_default_get_video_buffer(link, w, h);
>> +}
>> +
>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx,
>> av_buffersink_alloc_video_frame * cb, void * v)
>> +{
>> +BufferSinkContext * const bs = ctx->priv;
>> +bs->alloc_cb.video = cb;
>> +bs->alloc_v = v;
>> +}
>> +
>>  static av_cold int common_init(AVFilterContext *ctx)
>>  {
>>  BufferSinkContext *buf = ctx->priv;
>> @@ -381,6 +401,7 @@ static const AVFilterPad
>> avfilter_vsink_buffer_inputs[] = {
>>  {
>>  .name = "default",
>>  .type = AVMEDIA_TYPE_VIDEO,
>> +.get_buffer = {.video = alloc_video_buffer},
>>  },
>>  };
>>
>> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
>> index 64e08de53e..73f0ddc476 100644
>> --- a/libavfilter/buffersink.h
>> +++ b/libavfilter/buffersink.h
>> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx,
>> AVFrame *frame);
>>   */
>>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int
>> nb_samples);
>>
>> +/**
>> + * Callback from av_buffersink_set_alloc_video_frame to allocate
>> + * a frame
>> + *
>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>> + * @param v opaque pointer passed to
>> + *  av_buffersink_set_alloc_video_frame
>> + * @param w width of frame to allocate
>> + * @param height of frame to allocate
>> + *
>> + * @return
>> + * - The newly allocated frame
>> + * - NULL if error
>> + */
>> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx,
>> void * v, int w, int h);
>> +
>> +/**
>> + * Set a video frame allocation method for buffersink
>> + *
>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>> + * @param cb Callback to the allocation function. If set to NULL
>> + *   then the default avfilter allocation function will
>> + *   be used.
>> + * @param v  Opaque to pass to the allocation function
>> + */
>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx,
>> av_buffersink_alloc_video_frame * cb, void * v);
>> +
>>  /**
>>   * @}
>>   */
>> diff --git a/libavfilter/version.h b/libavfilter/version.h
>> index c001693e3c..54950497be 100644
>> --- a/libavfilter/version.h
>> +++ b/libavfilter/version.h
>> @@ -31,7 +31,7 @@
>>
>>  #include "version_major.h"
>>
>> -#define LIBAVFILTER_VERSION_MINOR   8
>> +#define LIBAVFILTER_VERSION_MINOR   9
>>  #define LIBAVFILTER_VERSION_MICRO 102
>>
>>
>> --
>> 2.39.2
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread John Cox
Hi

On Sat, 22 Jul 2023 17:12:51 +0200, you wrote:

>John Cox (12023-07-20):
>> Add a callback to enable user allocation of video frames on the final
>> stage of a filter chain.
>> 
>> Signed-off-by: John Cox 
>> ---
>>  libavfilter/buffersink.c | 21 +
>>  libavfilter/buffersink.h | 27 +++
>>  libavfilter/version.h|  2 +-
>>  3 files changed, 49 insertions(+), 1 deletion(-)
>
>Hi.
>
>Thanks for the patch.
Thanks for the prompt attention

>> 
>> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
>> index 306c283f77..070b743186 100644
>> --- a/libavfilter/buffersink.c
>> +++ b/libavfilter/buffersink.c
>> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>>  int sample_rates_size;
>>  
>>  AVFrame *peeked_frame;
>> +
>> +union {
>> +av_buffersink_alloc_video_frame * video;
>> +} alloc_cb;
>
>> +void * alloc_v;
>
>Here and everywhere: our coding style puts a space before the * but not
>after.
Will fix

>>  } BufferSinkContext;
>>  
>>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
>> @@ -154,6 +159,21 @@ int attribute_align_arg 
>> av_buffersink_get_samples(AVFilterContext *ctx,
>>  return get_frame_internal(ctx, frame, 0, nb_samples);
>>  }
>>  
>> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
>> +{
>> +AVFilterContext * const ctx = link->dst;
>
>> +BufferSinkContext * const bs = ctx->priv;
>
>Nit: it is called buf in the rest of this file.
Will fix

>> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) :
>> +ff_default_get_video_buffer(link, w, h);
>
>Nit: align ff_ with bs->.
Will fix

>> +}
>> +
>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>> av_buffersink_alloc_video_frame * cb, void * v)
>> +{
>> +BufferSinkContext * const bs = ctx->priv;
>> +bs->alloc_cb.video = cb;
>> +bs->alloc_v = v;
>> +}
>> +
>>  static av_cold int common_init(AVFilterContext *ctx)
>>  {
>>  BufferSinkContext *buf = ctx->priv;
>> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] 
>> = {
>>  {
>>  .name = "default",
>>  .type = AVMEDIA_TYPE_VIDEO,
>> +.get_buffer = {.video = alloc_video_buffer},
>>  },
>>  };
>>  
>> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
>> index 64e08de53e..73f0ddc476 100644
>> --- a/libavfilter/buffersink.h
>> +++ b/libavfilter/buffersink.h
>> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
>> AVFrame *frame);
>>   */
>>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
>> nb_samples);
>>  
>> +/**
>> + * Callback from av_buffersink_set_alloc_video_frame to allocate 
>> + * a frame 
>> + *  
>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>> + * @param v opaque pointer passed to 
>> + *  av_buffersink_set_alloc_video_frame
>> + * @param w width of frame to allocate 
>> + * @param height of frame to allocate 
>> + *  
>> + * @return 
>> + * - The newly allocated frame
>> + * - NULL if error
>> + */
>
>> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, 
>> void * v, int w, int h);
>
>In the rest of the API, function typedefs are always pointer-to-function
>typedefs.
Fair enough - I've found it convient in the past to be able to use the
function typedef for prototypes of the functions too.

>Also, I find this typedef looks too much like actually a function, maybe
>use CamelCase.
Will do

>> +
>> +/**
>> + * Set a video frame allocation method for buffersink
>> + *
>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>> + * @param cb Callback to the allocation function. If set to NULL 
>> + *   then the default avfilter allocation function will
>> + *   be used.
>> + * @param v  Opaque to pass to the allocation function
>> + */
>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>> av_buffersink_alloc_video_frame * cb, void * v);
>> +
>>  /**
>>   * @}
>>   */
>> diff --git a/libavfilter/version.h b/libavfilter/version.h
>> index c001693e3c..54950497be 100644
>> --- a/libavfilter/version.h
>> +++ b/libavfilter/version.h
>> @@ -31,7 +31,7 @@
>>  
>>  #include "version_major.h"
>>  
>> -#define LIBAVFILTER_VERSION_MINOR   8
>> +#define LIBAVFILTER_VERSION_MINOR   9
>>  #define LIBAVFILTER_VERSION_MICRO 102
>
>A test program would be nice too. I assume you have something to test
>your code: would it be a lot of work to make it public?

Actually my only test code is Kodi (xbmc) on Pi which is already using
it. The patch is simple enough that I didn't feel the need for a
separate test. I can put something together if required though.

Regards

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with 

Re: [FFmpeg-devel] [PATCH 1/5] avutil/tx_template: extend to 2M

2023-07-22 Thread Michael Niedermayer
On Sat, Jun 17, 2023 at 12:20:44AM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavutil/tx_template.c | 12 
>  1 file changed, 12 insertions(+)

will apply patches 1-4
(this should reduce the differences in the avradio repository in 
libavcodec/libavutil)

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avutil/tree: fix typo in documentation

2023-07-22 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavutil/tree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/tree.h b/libavutil/tree.h
index bbb8fbb126..18a191c06d 100644
--- a/libavutil/tree.h
+++ b/libavutil/tree.h
@@ -97,7 +97,7 @@ void *av_tree_find(const struct AVTreeNode *root, void *key,
  * return av_tree_insert(rootp, key, cmp, next);
  * }
  * void *tree_remove(struct AVTreeNode **rootp, void *key,
- *   int (*cmp)(void *key, const void *b, 
AVTreeNode **next))
+ *   int (*cmp)(void *key, const void *b), 
AVTreeNode **next)
  * {
  * av_freep(next);
  * return av_tree_insert(rootp, key, cmp, next);
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/rka: Fix integer overflow in decode_filter()

2023-07-22 Thread Michael Niedermayer
On Fri, Jun 30, 2023 at 02:16:54AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147443649 + 65535 cannot be represented in 
> type 'int'
> Fixes: 
> 60054/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5095674572832768
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/rka.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply patchset

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/rka: bps < 8 is invalid

2023-07-22 Thread Michael Niedermayer
On Tue, Apr 11, 2023 at 01:47:45AM +0200, Michael Niedermayer wrote:
> Fixes: division by zero
> Fixes: 
> 57828/clusterfuzz-testcase-minimized-ffmpeg_dem_RKA_fuzzer-6571818338353152
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/rka.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Nicolas George
Paul B Mahol (12023-07-22):
> What about an audio?

Are we in the business of refusing a patch adding an interesting feature
because we want two interesting features instead?

> This works only for sinks mostly, what about filters inside graph?

It is already in place, it has been for years. This patch only adds the
API to expose it publicly.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Paul B Mahol
On Thu, Jul 20, 2023 at 1:40 PM John Cox  wrote:

> Add a callback to enable user allocation of video frames on the final
> stage of a filter chain.
>
>
What about an audio?

This works only for sinks mostly, what about filters inside graph?


> Signed-off-by: John Cox 
> ---
>  libavfilter/buffersink.c | 21 +
>  libavfilter/buffersink.h | 27 +++
>  libavfilter/version.h|  2 +-
>  3 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
> index 306c283f77..070b743186 100644
> --- a/libavfilter/buffersink.c
> +++ b/libavfilter/buffersink.c
> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>  int sample_rates_size;
>
>  AVFrame *peeked_frame;
> +
> +union {
> +av_buffersink_alloc_video_frame * video;
> +} alloc_cb;
> +void * alloc_v;
>  } BufferSinkContext;
>
>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
> @@ -154,6 +159,21 @@ int attribute_align_arg
> av_buffersink_get_samples(AVFilterContext *ctx,
>  return get_frame_internal(ctx, frame, 0, nb_samples);
>  }
>
> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
> +{
> +AVFilterContext * const ctx = link->dst;
> +BufferSinkContext * const bs = ctx->priv;
> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w,
> h) :
> +ff_default_get_video_buffer(link, w, h);
> +}
> +
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx,
> av_buffersink_alloc_video_frame * cb, void * v)
> +{
> +BufferSinkContext * const bs = ctx->priv;
> +bs->alloc_cb.video = cb;
> +bs->alloc_v = v;
> +}
> +
>  static av_cold int common_init(AVFilterContext *ctx)
>  {
>  BufferSinkContext *buf = ctx->priv;
> @@ -381,6 +401,7 @@ static const AVFilterPad
> avfilter_vsink_buffer_inputs[] = {
>  {
>  .name = "default",
>  .type = AVMEDIA_TYPE_VIDEO,
> +.get_buffer = {.video = alloc_video_buffer},
>  },
>  };
>
> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
> index 64e08de53e..73f0ddc476 100644
> --- a/libavfilter/buffersink.h
> +++ b/libavfilter/buffersink.h
> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx,
> AVFrame *frame);
>   */
>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int
> nb_samples);
>
> +/**
> + * Callback from av_buffersink_set_alloc_video_frame to allocate
> + * a frame
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param v opaque pointer passed to
> + *  av_buffersink_set_alloc_video_frame
> + * @param w width of frame to allocate
> + * @param height of frame to allocate
> + *
> + * @return
> + * - The newly allocated frame
> + * - NULL if error
> + */
> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx,
> void * v, int w, int h);
> +
> +/**
> + * Set a video frame allocation method for buffersink
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param cb Callback to the allocation function. If set to NULL
> + *   then the default avfilter allocation function will
> + *   be used.
> + * @param v  Opaque to pass to the allocation function
> + */
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx,
> av_buffersink_alloc_video_frame * cb, void * v);
> +
>  /**
>   * @}
>   */
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index c001693e3c..54950497be 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>
>  #include "version_major.h"
>
> -#define LIBAVFILTER_VERSION_MINOR   8
> +#define LIBAVFILTER_VERSION_MINOR   9
>  #define LIBAVFILTER_VERSION_MICRO 102
>
>
> --
> 2.39.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Nicolas George
John Cox (12023-07-20):
> Add a callback to enable user allocation of video frames on the final
> stage of a filter chain.
> 
> Signed-off-by: John Cox 
> ---
>  libavfilter/buffersink.c | 21 +
>  libavfilter/buffersink.h | 27 +++
>  libavfilter/version.h|  2 +-
>  3 files changed, 49 insertions(+), 1 deletion(-)

Hi.

Thanks for the patch.

> 
> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
> index 306c283f77..070b743186 100644
> --- a/libavfilter/buffersink.c
> +++ b/libavfilter/buffersink.c
> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>  int sample_rates_size;
>  
>  AVFrame *peeked_frame;
> +
> +union {
> +av_buffersink_alloc_video_frame * video;
> +} alloc_cb;

> +void * alloc_v;

Here and everywhere: our coding style puts a space before the * but not
after.

>  } BufferSinkContext;
>  
>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
> @@ -154,6 +159,21 @@ int attribute_align_arg 
> av_buffersink_get_samples(AVFilterContext *ctx,
>  return get_frame_internal(ctx, frame, 0, nb_samples);
>  }
>  
> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
> +{
> +AVFilterContext * const ctx = link->dst;

> +BufferSinkContext * const bs = ctx->priv;

Nit: it is called buf in the rest of this file.

> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) :
> +ff_default_get_video_buffer(link, w, h);

Nit: align ff_ with bs->.

> +}
> +
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> av_buffersink_alloc_video_frame * cb, void * v)
> +{
> +BufferSinkContext * const bs = ctx->priv;
> +bs->alloc_cb.video = cb;
> +bs->alloc_v = v;
> +}
> +
>  static av_cold int common_init(AVFilterContext *ctx)
>  {
>  BufferSinkContext *buf = ctx->priv;
> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] = 
> {
>  {
>  .name = "default",
>  .type = AVMEDIA_TYPE_VIDEO,
> +.get_buffer = {.video = alloc_video_buffer},
>  },
>  };
>  
> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
> index 64e08de53e..73f0ddc476 100644
> --- a/libavfilter/buffersink.h
> +++ b/libavfilter/buffersink.h
> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
> AVFrame *frame);
>   */
>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
> nb_samples);
>  
> +/**
> + * Callback from av_buffersink_set_alloc_video_frame to allocate 
> + * a frame 
> + *  
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param v opaque pointer passed to 
> + *  av_buffersink_set_alloc_video_frame
> + * @param w width of frame to allocate 
> + * @param height of frame to allocate 
> + *  
> + * @return 
> + * - The newly allocated frame
> + * - NULL if error
> + */

> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, 
> void * v, int w, int h);

In the rest of the API, function typedefs are always pointer-to-function
typedefs.

Also, I find this typedef looks too much like actually a function, maybe
use CamelCase.

> +
> +/**
> + * Set a video frame allocation method for buffersink
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param cb Callback to the allocation function. If set to NULL 
> + *   then the default avfilter allocation function will
> + *   be used.
> + * @param v  Opaque to pass to the allocation function
> + */
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> av_buffersink_alloc_video_frame * cb, void * v);
> +
>  /**
>   * @}
>   */
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index c001693e3c..54950497be 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>  
>  #include "version_major.h"
>  
> -#define LIBAVFILTER_VERSION_MINOR   8
> +#define LIBAVFILTER_VERSION_MINOR   9
>  #define LIBAVFILTER_VERSION_MICRO 102

A test program would be nice too. I assume you have something to test
your code: would it be a lot of work to make it public?

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 5/5] avradio/sdrdemux: store min/max frequency, driver, label and tuner

2023-07-22 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h|  1 +
 libavradio/sdrdemux.c   | 35 ++-
 libavradio/sdrinradio.c | 14 ++
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 4349763bd1..de0a479d26 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -138,6 +138,7 @@ typedef struct SDRContext {
 Mode mode;
 AVRational fps;
 char *driver_name;
+AVDictionary *driver_dict;
 char *dump_url;
 int fileheader_size;
 AVIOContext *dump_avio;
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 09d720de23..bb33c69668 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1723,6 +1723,9 @@ static int sdrfile_initial_setup(AVFormatContext *s)
 } else
 return AVERROR_INVALIDDATA;
 
+sdr->min_freq = 0;
+sdr->max_freq = 40 * 1000*1000*1000LL;
+
 avio_skip(s->pb, 3);//BE
 sdr->sdr_sample_rate = avio_rb32(s->pb);
avio_rb32(s->pb); //block_size
@@ -1731,6 +1734,26 @@ static int sdrfile_initial_setup(AVFormatContext *s)
 if (version > AV_RB24("000")) {
 sdr->bandwidth   = avio_rb32(s->pb);
 sdr->fileheader_size = avio_rb32(s->pb);
+if (sdr->fileheader_size < 48 || sdr->fileheader_size > 10)
+return AVERROR_INVALIDDATA;
+if (version > AV_RB24("001")) {
+char *tmp = av_malloc(sdr->fileheader_size);
+if (!tmp)
+return AVERROR(ENOMEM);
+
+sdr->min_freq= avio_rb64(s->pb);
+sdr->max_freq= avio_rb64(s->pb);
+avio_get_str(s->pb, sdr->fileheader_size, tmp, 
sdr->fileheader_size);
+sdr->driver_name = av_strdup(tmp);
+
+avio_get_str(s->pb, sdr->fileheader_size, tmp, 
sdr->fileheader_size);
+if (*tmp)
+av_dict_set(>driver_dict, "label", tmp, 0);
+
+avio_get_str(s->pb, sdr->fileheader_size, tmp, 
sdr->fileheader_size);
+if (*tmp)
+av_dict_set(>driver_dict, "tuner", tmp, 0);
+}
 } else {
 sdr->bandwidth   = sdr->sdr_sample_rate;
 sdr->fileheader_size = 40;
@@ -1842,9 +1865,11 @@ process_next_block:
 sdr->block_center_freq = fifo_element[0].center_frequency;
 
 if (sdr->dump_avio) {
-uint8_t header[16] = "FFSDR001int16BE";
+uint8_t header[16] = "FFSDR002int16BE";
 uint8_t *tmp = (void*)sdr->windowed_block; //We use an unused array as 
temporary here
 int64_t sizepos, endpos;
+AVDictionaryEntry *e_label = av_dict_get(sdr->driver_dict, "label", 
NULL, 0);
+AVDictionaryEntry *e_tuner = av_dict_get(sdr->driver_dict, "tuner", 
NULL, 0);
 
 if (sdr->sample_size == 2)
 memcpy(header + 11, "08", 2);
@@ -1858,6 +1883,12 @@ process_next_block:
 sizepos = avio_tell(sdr->dump_avio);
 avio_wb32(sdr->dump_avio, 0);
 
+avio_wb64(sdr->dump_avio, sdr->min_freq);
+avio_wb64(sdr->dump_avio, sdr->max_freq);
+avio_put_str(sdr->dump_avio, sdr->driver_name);
+avio_put_str(sdr->dump_avio, e_label ? e_label->value : NULL);
+avio_put_str(sdr->dump_avio, e_tuner ? e_tuner->value : NULL);
+
 endpos = avio_tell(sdr->dump_avio);
 
 avio_seek(sdr->dump_avio, sizepos, SEEK_SET);
@@ -2202,6 +2233,8 @@ int ff_sdr_read_close(AVFormatContext *s)
 
 avio_close(sdr->dump_avio);
 
+av_dict_free(>driver_dict);
+
 return 0;
 }
 
diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index d12b0b73fe..c24a30d746 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -161,6 +161,7 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 SoapySDRDevice *soapy = NULL;
 SoapySDRStream *soapyRxStream = NULL;
 const char * soapy_format;
+AVDictionaryEntry *e_label, *e_serial;
 
 sdr->read_callback  = sdrindev_read_callback;
 sdr->set_frequency_callback = sdrindev_set_frequency_callback;
@@ -171,6 +172,7 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 results = SoapySDRDevice_enumerate(NULL, );
 for (i = 0; i < length; i++) {
 int usable = 1;
+int selected = 0;
 for (int j = 0; j < results[i].size; j++) {
 if (!strcmp("driver", results[i].keys[j])) {
 if (!strcmp("audio", results[i].vals[j])) {
@@ -180,7 +182,11 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 if (!sdr->driver_name)
 return AVERROR(ENOMEM);
 }
+if(usable)
+selected = !strcmp(sdr->driver_name, results[i].vals[j]);
 }
+if (selected)
+av_dict_set(>driver_dict, results[i].keys[j], 
results[i].vals[j], 0);
 }
 if (!usable)
 continue;
@@ -191,6 +197,14 @@ static int 

[FFmpeg-devel] [PATCH 4/5] avradio/sdrdemux: avoid literal offsets in dump code

2023-07-22 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 66130d9662..09d720de23 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1842,20 +1842,27 @@ process_next_block:
 sdr->block_center_freq = fifo_element[0].center_frequency;
 
 if (sdr->dump_avio) {
-uint8_t header[48] = "FFSDR001int16BE";
+uint8_t header[16] = "FFSDR001int16BE";
 uint8_t *tmp = (void*)sdr->windowed_block; //We use an unused array as 
temporary here
+int64_t sizepos, endpos;
 
 if (sdr->sample_size == 2)
 memcpy(header + 11, "08", 2);
 
-AV_WB32(header+16, sdr->sdr_sample_rate);
-AV_WB32(header+20, sdr->block_size);
-AV_WB64(header+24, av_double2int(fifo_element[0].center_frequency));
-AV_WB64(header+32, sdr->pts);
-AV_WB32(header+40, sdr->bandwidth);
-AV_WB32(header+44, sizeof(header));
-
 avio_write(sdr->dump_avio, header, sizeof(header));
+avio_wb32(sdr->dump_avio, sdr->sdr_sample_rate);
+avio_wb32(sdr->dump_avio, sdr->block_size);
+avio_wb64(sdr->dump_avio, 
av_double2int(fifo_element[0].center_frequency));
+avio_wb64(sdr->dump_avio, sdr->pts);
+avio_wb32(sdr->dump_avio, sdr->bandwidth);
+sizepos = avio_tell(sdr->dump_avio);
+avio_wb32(sdr->dump_avio, 0);
+
+endpos = avio_tell(sdr->dump_avio);
+
+avio_seek(sdr->dump_avio, sizepos, SEEK_SET);
+avio_wb32(sdr->dump_avio, endpos);
+avio_seek(sdr->dump_avio, endpos, SEEK_SET);
 
 if (sdr->sample_size == 2) {
 avio_write(sdr->dump_avio, fifo_element[0].halfblock, 
sdr->block_size * sdr->sample_size);
-- 
2.31.1

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

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


[FFmpeg-devel] [PATCH 3/5] avradio/sdr: Remove direct inclusion of pthread.h

2023-07-22 Thread Michael Niedermayer
Fate tests pass on mingw32 & 64 with this

Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h  | 1 -
 libavradio/sdrdemux.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index c651ba0d99..4349763bd1 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -22,7 +22,6 @@
 #ifndef AVRADIO_SDR_H
 #define AVRADIO_SDR_H
 
-#include 
 #include 
 #include 
 
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 8967ff1ea9..66130d9662 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -35,7 +35,6 @@
 
 #include "sdr.h"
 
-#include 
 #include 
 #include 
 #include "libavutil/avassert.h"
-- 
2.31.1

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

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


[FFmpeg-devel] [PATCH 2/5] avradio/vissualize: change color of the active station

2023-07-22 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/vissualize.c | 6 --
 tests/ref/fate/sdr-am   | 2 +-
 tests/ref/fate/sdr-fm   | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavradio/vissualize.c b/libavradio/vissualize.c
index 2d397546dc..15d7f9e95f 100644
--- a/libavradio/vissualize.c
+++ b/libavradio/vissualize.c
@@ -219,9 +219,11 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, 
AVPacket *pkt)
 } else {
 snprintf(text, sizeof(text), "%s ", 
ff_sdr_modulation_descs[s->modulation].shortname);
 }
-av_strlcatf(text, sizeof(text), "%f Mhz %d %d %d",
+draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, 
color, color, color*(s->stream ? 2 : 1), w, h, 0);
+pos = strlen(text);
+snprintf(text, sizeof(text), "%f Mhz %d %d %d",
  f/100, (int)s->score, ff_sdr_histogram_score(s), 
s->timeout);
-draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, 
color, color, color, w, h, 0);
+draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, 
color, color, color, w, h, pos);
 if (s->radiotext[0]) {
 draw_string(pkt->data, 4*w, s->radiotext, xmid + 8*yd, 320*h2 
+ 24*yd, xd, yd, color, color, color, w, h, 0);
 }
diff --git a/tests/ref/fate/sdr-am b/tests/ref/fate/sdr-am
index d0fdc48cf5..b8a34ee488 100644
--- a/tests/ref/fate/sdr-am
+++ b/tests/ref/fate/sdr-am
@@ -52,4 +52,4 @@
 4,   4096,   4096, 1024, 2048, 0xdcd6ff8d
 5,   4096,   4096, 1024, 2048, 0xedac0493
 6,   4096,   4096, 1024, 2048, 0x970a0066
-0,  3,  3,1,   32, 0x73e13a75
+0,  3,  3,1,   32, 0x9fb0c309
diff --git a/tests/ref/fate/sdr-fm b/tests/ref/fate/sdr-fm
index 0a3aaa48d4..3ae5adc2c0 100644
--- a/tests/ref/fate/sdr-fm
+++ b/tests/ref/fate/sdr-fm
@@ -19,7 +19,7 @@
 2,   8196,   8196, 4096, 8192, 0xb966fb19
 1,  12292,  12292, 4096, 8192, 0x6d8ffe6e
 2,  12292,  12292, 4096, 8192, 0x51d1fb50
-0,  3,  3,1,   32, 0x1b178638
+0,  3,  3,1,   32, 0xf8b7b144
 1,  16388,  16388, 4096, 8192, 0x8c000600
 2,  16388,  16388, 4096, 8192, 0x335ff20c
-0,  4,  4,1,   32, 0x49dd90cc
+0,  4,  4,1,   32, 0xab42bbc7
-- 
2.31.1

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

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


[FFmpeg-devel] [PATCH 1/5] avradio/vissualize: support simple skiping of chars

2023-07-22 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/vissualize.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavradio/vissualize.c b/libavradio/vissualize.c
index a3dcf5801b..2d397546dc 100644
--- a/libavradio/vissualize.c
+++ b/libavradio/vissualize.c
@@ -81,8 +81,11 @@ static void draw_char(uint8_t *frame_buffer, ptrdiff_t 
stride, char ch, int x0,
 }
 }
 
-static void draw_string(uint8_t *frame_buffer, ptrdiff_t stride, char *str, 
int x0, int y0, int xd, int yd, int r, int g, int b, int w, int h)
+static void draw_string(uint8_t *frame_buffer, ptrdiff_t stride, char *str, 
int x0, int y0, int xd, int yd, int r, int g, int b, int w, int h, int skipx)
 {
+x0 += xd*9*skipx;
+y0 += yd*9*skipx;
+
 while(*str) {
 draw_char(frame_buffer, stride, *str++, x0, y0, xd, yd, r, g, b, w, h);
 x0 += xd*9;
@@ -206,6 +209,7 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, 
AVPacket *pkt)
 int color = s->stream ? 64 : 32;
 int size = s->stream ? 181 : 128;
 int xd = size, yd = size;
+int pos;
 
 if (!s->in_station_list)
 continue;
@@ -217,14 +221,14 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, 
AVPacket *pkt)
 }
 av_strlcatf(text, sizeof(text), "%f Mhz %d %d %d",
  f/100, (int)s->score, ff_sdr_histogram_score(s), 
s->timeout);
-draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, 
color, color, color, w, h);
+draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, 
color, color, color, w, h, 0);
 if (s->radiotext[0]) {
-draw_string(pkt->data, 4*w, s->radiotext, xmid + 8*yd, 320*h2 
+ 24*yd, xd, yd, color, color, color, w, h);
+draw_string(pkt->data, 4*w, s->radiotext, xmid + 8*yd, 320*h2 
+ 24*yd, xd, yd, color, color, color, w, h, 0);
 }
 if (s->title[0] || s->artist[0]) {
 int len = strlen(s->title) + 1;
-draw_string(pkt->data, 4*w, s->title , xmid + 8*yd, 320*h2 + 
2*24*yd, xd, yd, color, color*1.5, color, w, h);
-draw_string(pkt->data, 4*w, s->artist, xmid + 8*yd + 9*xd*len, 
320*h2 + 2*24*yd + 9*yd*len, xd, yd, color, color*2, color, w, h);
+draw_string(pkt->data, 4*w, s->title , xmid + 8*yd, 320*h2 + 
2*24*yd, xd, yd, color, color*1.5, color, w, h, 0);
+draw_string(pkt->data, 4*w, s->artist, xmid + 8*yd, 320*h2 + 
2*24*yd, xd, yd, color, color*2, color, w, h, len);
 }
 }
 }
-- 
2.31.1

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

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


Re: [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band

2023-07-22 Thread Michael Niedermayer
On Tue, Jul 18, 2023 at 11:45:29PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavradio/sdrdemux.c | 1 +
>  1 file changed, 1 insertion(+)

will apply patchset (with fate test fixed as described)

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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