[FFmpeg-devel] [PATCH] doc/developer: Alternative to making tests a requirement.

2023-07-08 Thread Michael Niedermayer
Making tests a strict requirement could increase the burden on new
developers. This is an alternative

Signed-off-by: Michael Niedermayer 
---
 doc/developer.texi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/developer.texi b/doc/developer.texi
index 0c2f2cd7d1..c7536a17b6 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -809,6 +809,8 @@ Consider adding a regression test for your code. All new 
modules
 should be covered by tests. That includes demuxers, muxers, decoders, encoders
 filters, bitstream filters, parsers. If its not possible to do that, add
 an explanation why to your patchset, its ok to not test if theres a reason.
+If your module lacks a test, then you must provide all information and samples
+which are needed for someone else to create a test, limited by what you 
possess.
 
 @item
 If you added YASM code please check that things still work with --disable-yasm.
-- 
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] [RFC] [PATCH] [0/1] doc/developer: Alternative to making tests a requirement.

2023-07-08 Thread Michael Niedermayer
Changing the tests to a requirement, while it seems to have overwhelming support
did have 2 developers, who seemed not to like it.

This is an alternative suggestion, please comment what you think.
Is this better for the project in your opinion or worse ?

thx



___
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/9] avradio/sdr: use AVTree for candidate stations

2023-07-08 Thread Michael Niedermayer
On Fri, Jul 07, 2023 at 07:22:16PM +0200, Michael Niedermayer wrote:
> This is needed so we can keep more information about stations without
> performance issues
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavradio/sdr.h  |   4 +-
>  libavradio/sdrdemux.c | 126 --
>  2 files changed, 110 insertions(+), 20 deletions(-)

will apply patchset

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

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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: fix build failure on osx 10.4

2023-07-08 Thread Pavel Koshevoy
libavutil/random_seed.c calls arc4random_buf which is
not available on OSX 10.4 Tiger, but the configuration
script tests for arc4random which is available.

Fix the configuration test to match the actual API used.
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index d6e78297fe..c18a696b8a 100755
--- a/configure
+++ b/configure
@@ -6381,7 +6381,7 @@ check_func  ${malloc_prefix}memalign&& enable 
memalign
 check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
 
 check_func  access
-check_func_headers stdlib.h arc4random
+check_func_headers stdlib.h arc4random_buf
 check_lib   clock_gettime time.h clock_gettime || check_lib clock_gettime 
time.h clock_gettime -lrt
 check_func  fcntl
 check_func  fork
-- 
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".


Re: [FFmpeg-devel] [PATCH] avutil: fix build failure on osx 10.4

2023-07-08 Thread James Almer

On 7/8/2023 2:48 PM, Pavel Koshevoy wrote:

libavutil/random_seed.c calls arc4random_buf which is
not available on OSX 10.4 Tiger, but the configuration
script tests for arc4random which is available.

Fix the configuration test to match the actual API used.
---
  configure | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index d6e78297fe..c18a696b8a 100755
--- a/configure
+++ b/configure
@@ -6381,7 +6381,7 @@ check_func  ${malloc_prefix}memalign&& enable 
memalign
  check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
  
  check_func  access

-check_func_headers stdlib.h arc4random
+check_func_headers stdlib.h arc4random_buf
  check_lib   clock_gettime time.h clock_gettime || check_lib clock_gettime 
time.h clock_gettime -lrt
  check_func  fcntl
  check_func  fork


Applied with some changes. Thanks.
___
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/libjxldec: build against libjxl 0.9

2023-07-08 Thread Leo Izen
Git master libjxl changed several function signatures, so this commit
adds some #ifdefs to handle the new signatures without breaking old
releases.
---
 libavcodec/libjxldec.c | 21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 50417bcb02..e45ac02c07 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -210,14 +210,22 @@ static int libjxl_get_icc(AVCodecContext *avctx)
 JxlDecoderStatus jret;
 /* an ICC profile is present, and we can meaningfully get it,
  * because the pixel data is not XYB-encoded */
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
 jret = JxlDecoderGetICCProfileSize(ctx->decoder, &ctx->jxl_pixfmt, 
JXL_COLOR_PROFILE_TARGET_DATA, &icc_len);
+#else
+jret = JxlDecoderGetICCProfileSize(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_DATA, &icc_len);
+#endif
 if (jret == JXL_DEC_SUCCESS && icc_len > 0) {
 av_buffer_unref(&ctx->iccp);
 ctx->iccp = av_buffer_alloc(icc_len);
 if (!ctx->iccp)
 return AVERROR(ENOMEM);
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
 jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, &ctx->jxl_pixfmt, 
JXL_COLOR_PROFILE_TARGET_DATA,
-ctx->iccp->data, icc_len);
+  ctx->iccp->data, icc_len);
+#else
+jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_DATA, ctx->iccp->data, icc_len);
+#endif
 if (jret != JXL_DEC_SUCCESS) {
 av_log(avctx, AV_LOG_WARNING, "Unable to obtain ICC Profile\n");
 av_buffer_unref(&ctx->iccp);
@@ -253,12 +261,21 @@ static int libjxl_color_encoding_event(AVCodecContext 
*avctx, AVFrame *frame)
 /* set this flag if we need to fall back on wide gamut */
 int fallback = 0;
 
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
 jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, NULL, 
JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color);
+#else
+jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color);
+#endif
 if (jret == JXL_DEC_SUCCESS) {
 /* enum values describe the colors of this image */
 jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color);
 if (jret == JXL_DEC_SUCCESS)
-jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
&ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
+jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
&ctx->jxl_pixfmt,
+  
JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
+#else
+jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
+#endif
 /* if we couldn't successfully request the pixel data space, we fall 
back on wide gamut */
 /* this code path is very unlikely to happen in practice */
 if (jret != JXL_DEC_SUCCESS)
-- 
2.41.0

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

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


[FFmpeg-devel] [PATCH 1/3] avcodec/decode: move processing discard samples to its own function

2023-07-08 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/decode.c | 182 +++-
 1 file changed, 94 insertions(+), 88 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 269633ce10..793ab975f6 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -289,69 +289,14 @@ static int64_t guess_correct_pts(AVCodecContext *ctx,
 return pts;
 }
 
-/*
- * The core of the receive_frame_wrapper for the decoders implementing
- * the simple API. Certain decoders might consume partial packets without
- * returning any output, so this function needs to be called in a loop until it
- * returns EAGAIN.
- **/
-static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame 
*frame, int64_t *discarded_samples)
+static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t 
*discarded_samples)
 {
-AVCodecInternal   *avci = avctx->internal;
-AVPacket *const pkt = avci->in_pkt;
-const FFCodec *const codec = ffcodec(avctx->codec);
-int got_frame, actual_got_frame;
-int ret;
-
-if (!pkt->data && !avci->draining) {
-av_packet_unref(pkt);
-ret = ff_decode_get_packet(avctx, pkt);
-if (ret < 0 && ret != AVERROR_EOF)
-return ret;
-}
-
-// Some codecs (at least wma lossless) will crash when feeding drain 
packets
-// after EOF was signaled.
-if (avci->draining_done)
-return AVERROR_EOF;
-
-if (!pkt->data &&
-!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
-  avctx->active_thread_type & FF_THREAD_FRAME))
-return AVERROR_EOF;
-
-got_frame = 0;
-
-if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) {
-ret = ff_thread_decode_frame(avctx, frame, &got_frame, pkt);
-} else {
-ret = codec->cb.decode(avctx, frame, &got_frame, pkt);
-
-if (!(codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
-frame->pkt_dts = pkt->dts;
-if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
-#if FF_API_FRAME_PKT
-FF_DISABLE_DEPRECATION_WARNINGS
-if(!avctx->has_b_frames)
-frame->pkt_pos = pkt->pos;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-//FIXME these should be under if(!avctx->has_b_frames)
-/* get_buffer is supposed to set frame parameters */
-if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
-if (!frame->sample_aspect_ratio.num)  
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
-if (!frame->width)frame->width 
  = avctx->width;
-if (!frame->height)   frame->height
  = avctx->height;
-if (frame->format == AV_PIX_FMT_NONE) frame->format
  = avctx->pix_fmt;
-}
-}
-}
-emms_c();
-actual_got_frame = got_frame;
+AVCodecInternal *avci = avctx->internal;
+int ret = 0;
 
 if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
 if (frame->flags & AV_FRAME_FLAG_DISCARD)
-got_frame = 0;
+ret = AVERROR(EAGAIN);
 } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
 uint8_t *side;
 size_t side_size;
@@ -359,16 +304,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 uint8_t skip_reason = 0;
 uint8_t discard_reason = 0;
 
-if (ret >= 0 && got_frame) {
 if (frame->format == AV_SAMPLE_FMT_NONE)
 frame->format = avctx->sample_fmt;
-if (!frame->ch_layout.nb_channels) {
-int ret2 = av_channel_layout_copy(&frame->ch_layout, 
&avctx->ch_layout);
-if (ret2 < 0) {
-ret = ret2;
-got_frame = 0;
-}
-}
+if (!frame->ch_layout.nb_channels)
+ret = av_channel_layout_copy(&frame->ch_layout, 
&avctx->ch_layout);
 #if FF_API_OLD_CHANNEL_LAYOUT
 FF_DISABLE_DEPRECATION_WARNINGS
 if (!frame->channel_layout)
@@ -380,7 +319,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 if (!frame->sample_rate)
 frame->sample_rate = avctx->sample_rate;
-}
 
 side= av_packet_get_side_data(avci->last_pkt_props, 
AV_PKT_DATA_SKIP_SAMPLES, &side_size);
 if(side && side_size>=10) {
@@ -393,21 +331,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
 discard_reason = AV_RL8(side + 9);
 }
 
-if ((frame->flags & AV_FRAME_FLAG_DISCARD) && got_frame &&
+if ((frame->flags & AV_FRAME_FLAG_DISCARD) && !ret &&
 !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
 avci->skip_samples = FFMAX(0, avci->skip_samples - 
frame->nb_samples);
-got_frame = 0;
 *discarded_samples += frame->nb_samples;
+ret = AVERROR(EAGAIN);
 }
 
-if (avci->skip_samples > 0 && got_frame &&
+if (avci->skip_samples > 0 && !ret &&
 !(avctx->flags2 & AV_CODEC_

[FFmpeg-devel] [PATCH 2/3] avcodec/decode: check the output frame for discard samples with all decoders

2023-07-08 Thread James Almer
And not just those with the old decode() API.

Signed-off-by: James Almer 
---
 libavcodec/decode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 793ab975f6..49c8b7e0f4 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -594,8 +594,11 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 av_assert0(!frame->buf[0]);
 
 if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) {
+int64_t discarded_samples = 0;
 ret = codec->cb.receive_frame(avctx, frame);
 emms_c();
+if (!ret)
+ret = discard_samples(avctx, frame, &discarded_samples);
 } else
 ret = decode_simple_receive_frame(avctx, frame);
 
-- 
2.41.0

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

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


[FFmpeg-devel] [PATCH 3/3] avcodec/decode: fill missing frame fields for all decoders

2023-07-08 Thread James Almer
And not just those with the old decode() API.

Signed-off-by: James Almer 
---
 libavcodec/decode.c | 52 +++--
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 49c8b7e0f4..fe07e906c2 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -304,22 +304,6 @@ static int discard_samples(AVCodecContext *avctx, AVFrame 
*frame, int64_t *disca
 uint8_t skip_reason = 0;
 uint8_t discard_reason = 0;
 
-if (frame->format == AV_SAMPLE_FMT_NONE)
-frame->format = avctx->sample_fmt;
-if (!frame->ch_layout.nb_channels)
-ret = av_channel_layout_copy(&frame->ch_layout, 
&avctx->ch_layout);
-#if FF_API_OLD_CHANNEL_LAYOUT
-FF_DISABLE_DEPRECATION_WARNINGS
-if (!frame->channel_layout)
-frame->channel_layout = avctx->ch_layout.order == 
AV_CHANNEL_ORDER_NATIVE ?
-avctx->ch_layout.u.mask : 0;
-if (!frame->channels)
-frame->channels = avctx->ch_layout.nb_channels;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-if (!frame->sample_rate)
-frame->sample_rate = avctx->sample_rate;
-
 side= av_packet_get_side_data(avci->last_pkt_props, 
AV_PKT_DATA_SKIP_SAMPLES, &side_size);
 if(side && side_size>=10) {
 avci->skip_samples = AV_RL32(side);
@@ -452,14 +436,6 @@ FF_DISABLE_DEPRECATION_WARNINGS
 frame->pkt_pos = pkt->pos;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-//FIXME these should be under if(!avctx->has_b_frames)
-/* get_buffer is supposed to set frame parameters */
-if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
-if (!frame->sample_aspect_ratio.num)  
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
-if (!frame->width)frame->width 
  = avctx->width;
-if (!frame->height)   frame->height
  = avctx->height;
-if (frame->format == AV_PIX_FMT_NONE) frame->format
  = avctx->pix_fmt;
-}
 }
 }
 emms_c();
@@ -613,8 +589,34 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 }
 
 if (!ret) {
-if (avctx->codec_type != AVMEDIA_TYPE_VIDEO)
+if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+/* get_buffer is supposed to set frame parameters */
+if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
+if (!frame->sample_aspect_ratio.num)  
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
+if (!frame->width)frame->width 
  = avctx->width;
+if (!frame->height)   frame->height
  = avctx->height;
+if (frame->format == AV_PIX_FMT_NONE) frame->format
  = avctx->pix_fmt;
+}
+} else {
+if (frame->format == AV_SAMPLE_FMT_NONE)
+frame->format = avctx->sample_fmt;
+if (!frame->ch_layout.nb_channels)
+ret = av_channel_layout_copy(&frame->ch_layout, 
&avctx->ch_layout);
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (!frame->channel_layout)
+frame->channel_layout = avctx->ch_layout.order == 
AV_CHANNEL_ORDER_NATIVE ?
+avctx->ch_layout.u.mask : 0;
+if (!frame->channels)
+frame->channels = avctx->ch_layout.nb_channels;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+if (!frame->sample_rate)
+frame->sample_rate = avctx->sample_rate;
+
 frame->flags |= AV_FRAME_FLAG_KEY;
+}
+
 #if FF_API_FRAME_KEY
 FF_DISABLE_DEPRECATION_WARNINGS
 frame->key_frame = !!(frame->flags & AV_FRAME_FLAG_KEY);
-- 
2.41.0

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/libjxldec: build against libjxl 0.9

2023-07-08 Thread Gyan Doshi




On 2023-07-09 12:15 am, Leo Izen wrote:

Git master libjxl changed several function signatures, so this commit
adds some #ifdefs to handle the new signatures without breaking old
releases.


Same objection as to the patch submitted a few days ago, pasted below:


0.9.0 is still unreleased and unfortunately the API change wasn't 
accompanied with a version bump.


The API changes were pushed on Jun 21st and the version bump to 0.9.0 
was pushed on Jan 12th.
So this will still break compilation with older git checkouts of libjxl. 
Ideally libjxl should bump once more to 0.9.1



Regards,
Gyan



---
  libavcodec/libjxldec.c | 21 +++--
  1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 50417bcb02..e45ac02c07 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -210,14 +210,22 @@ static int libjxl_get_icc(AVCodecContext *avctx)
  JxlDecoderStatus jret;
  /* an ICC profile is present, and we can meaningfully get it,
   * because the pixel data is not XYB-encoded */
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
  jret = JxlDecoderGetICCProfileSize(ctx->decoder, &ctx->jxl_pixfmt, 
JXL_COLOR_PROFILE_TARGET_DATA, &icc_len);
+#else
+jret = JxlDecoderGetICCProfileSize(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_DATA, &icc_len);
+#endif
  if (jret == JXL_DEC_SUCCESS && icc_len > 0) {
  av_buffer_unref(&ctx->iccp);
  ctx->iccp = av_buffer_alloc(icc_len);
  if (!ctx->iccp)
  return AVERROR(ENOMEM);
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
  jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, &ctx->jxl_pixfmt, 
JXL_COLOR_PROFILE_TARGET_DATA,
-ctx->iccp->data, icc_len);
+  ctx->iccp->data, icc_len);
+#else
+jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_DATA, ctx->iccp->data, icc_len);
+#endif
  if (jret != JXL_DEC_SUCCESS) {
  av_log(avctx, AV_LOG_WARNING, "Unable to obtain ICC Profile\n");
  av_buffer_unref(&ctx->iccp);
@@ -253,12 +261,21 @@ static int libjxl_color_encoding_event(AVCodecContext 
*avctx, AVFrame *frame)
  /* set this flag if we need to fall back on wide gamut */
  int fallback = 0;
  
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)

  jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, NULL, 
JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color);
+#else
+jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color);
+#endif
  if (jret == JXL_DEC_SUCCESS) {
  /* enum values describe the colors of this image */
  jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color);
  if (jret == JXL_DEC_SUCCESS)
-jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
&ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
+#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0)
+jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
&ctx->jxl_pixfmt,
+  
JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
+#else
+jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, 
JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color);
+#endif
  /* if we couldn't successfully request the pixel data space, we fall 
back on wide gamut */
  /* this code path is very unlikely to happen in practice */
  if (jret != JXL_DEC_SUCCESS)


___
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/3] avcodec/decode: move processing discard samples to its own function

2023-07-08 Thread Andreas Rheinhardt
James Almer:
> Signed-off-by: James Almer 
> ---
>  libavcodec/decode.c | 182 +++-
>  1 file changed, 94 insertions(+), 88 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 269633ce10..793ab975f6 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -289,69 +289,14 @@ static int64_t guess_correct_pts(AVCodecContext *ctx,
>  return pts;
>  }
>  
> -/*
> - * The core of the receive_frame_wrapper for the decoders implementing
> - * the simple API. Certain decoders might consume partial packets without
> - * returning any output, so this function needs to be called in a loop until 
> it
> - * returns EAGAIN.
> - **/
> -static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame 
> *frame, int64_t *discarded_samples)
> +static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t 
> *discarded_samples)
>  {
> -AVCodecInternal   *avci = avctx->internal;
> -AVPacket *const pkt = avci->in_pkt;
> -const FFCodec *const codec = ffcodec(avctx->codec);
> -int got_frame, actual_got_frame;
> -int ret;
> -
> -if (!pkt->data && !avci->draining) {
> -av_packet_unref(pkt);
> -ret = ff_decode_get_packet(avctx, pkt);
> -if (ret < 0 && ret != AVERROR_EOF)
> -return ret;
> -}
> -
> -// Some codecs (at least wma lossless) will crash when feeding drain 
> packets
> -// after EOF was signaled.
> -if (avci->draining_done)
> -return AVERROR_EOF;
> -
> -if (!pkt->data &&
> -!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
> -  avctx->active_thread_type & FF_THREAD_FRAME))
> -return AVERROR_EOF;
> -
> -got_frame = 0;
> -
> -if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) {
> -ret = ff_thread_decode_frame(avctx, frame, &got_frame, pkt);
> -} else {
> -ret = codec->cb.decode(avctx, frame, &got_frame, pkt);
> -
> -if (!(codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
> -frame->pkt_dts = pkt->dts;
> -if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
> -#if FF_API_FRAME_PKT
> -FF_DISABLE_DEPRECATION_WARNINGS
> -if(!avctx->has_b_frames)
> -frame->pkt_pos = pkt->pos;
> -FF_ENABLE_DEPRECATION_WARNINGS
> -#endif
> -//FIXME these should be under if(!avctx->has_b_frames)
> -/* get_buffer is supposed to set frame parameters */
> -if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
> -if (!frame->sample_aspect_ratio.num)  
> frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
> -if (!frame->width)frame->width   
> = avctx->width;
> -if (!frame->height)   frame->height  
> = avctx->height;
> -if (frame->format == AV_PIX_FMT_NONE) frame->format  
> = avctx->pix_fmt;
> -}
> -}
> -}
> -emms_c();
> -actual_got_frame = got_frame;
> +AVCodecInternal *avci = avctx->internal;
> +int ret = 0;
>  
>  if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
>  if (frame->flags & AV_FRAME_FLAG_DISCARD)
> -got_frame = 0;
> +ret = AVERROR(EAGAIN);
>  } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
>  uint8_t *side;
>  size_t side_size;
> @@ -359,16 +304,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  uint8_t skip_reason = 0;
>  uint8_t discard_reason = 0;
>  
> -if (ret >= 0 && got_frame) {
>  if (frame->format == AV_SAMPLE_FMT_NONE)
>  frame->format = avctx->sample_fmt;
> -if (!frame->ch_layout.nb_channels) {
> -int ret2 = av_channel_layout_copy(&frame->ch_layout, 
> &avctx->ch_layout);
> -if (ret2 < 0) {
> -ret = ret2;
> -got_frame = 0;
> -}
> -}
> +if (!frame->ch_layout.nb_channels)
> +ret = av_channel_layout_copy(&frame->ch_layout, 
> &avctx->ch_layout);
>  #if FF_API_OLD_CHANNEL_LAYOUT
>  FF_DISABLE_DEPRECATION_WARNINGS
>  if (!frame->channel_layout)
> @@ -380,7 +319,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
>  if (!frame->sample_rate)
>  frame->sample_rate = avctx->sample_rate;
> -}
>  
>  side= av_packet_get_side_data(avci->last_pkt_props, 
> AV_PKT_DATA_SKIP_SAMPLES, &side_size);
>  if(side && side_size>=10) {
> @@ -393,21 +331,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  discard_reason = AV_RL8(side + 9);
>  }
>  
> -if ((frame->flags & AV_FRAME_FLAG_DISCARD) && got_frame &&
> +if ((frame->flags & AV_FRAME_FLAG_DISCARD) && !ret &&
>  !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
>  avci->skip_samples = FFMAX(0, avci->skip_samples - 
> frame->nb_sample

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/decode: move processing discard samples to its own function

2023-07-08 Thread James Almer

On 7/8/2023 4:38 PM, Andreas Rheinhardt wrote:

James Almer:

Signed-off-by: James Almer 
---
  libavcodec/decode.c | 182 +++-
  1 file changed, 94 insertions(+), 88 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 269633ce10..793ab975f6 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -289,69 +289,14 @@ static int64_t guess_correct_pts(AVCodecContext *ctx,
  return pts;
  }
  
-/*

- * The core of the receive_frame_wrapper for the decoders implementing
- * the simple API. Certain decoders might consume partial packets without
- * returning any output, so this function needs to be called in a loop until it
- * returns EAGAIN.
- **/
-static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame 
*frame, int64_t *discarded_samples)
+static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t 
*discarded_samples)
  {
-AVCodecInternal   *avci = avctx->internal;
-AVPacket *const pkt = avci->in_pkt;
-const FFCodec *const codec = ffcodec(avctx->codec);
-int got_frame, actual_got_frame;
-int ret;
-
-if (!pkt->data && !avci->draining) {
-av_packet_unref(pkt);
-ret = ff_decode_get_packet(avctx, pkt);
-if (ret < 0 && ret != AVERROR_EOF)
-return ret;
-}
-
-// Some codecs (at least wma lossless) will crash when feeding drain 
packets
-// after EOF was signaled.
-if (avci->draining_done)
-return AVERROR_EOF;
-
-if (!pkt->data &&
-!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
-  avctx->active_thread_type & FF_THREAD_FRAME))
-return AVERROR_EOF;
-
-got_frame = 0;
-
-if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) {
-ret = ff_thread_decode_frame(avctx, frame, &got_frame, pkt);
-} else {
-ret = codec->cb.decode(avctx, frame, &got_frame, pkt);
-
-if (!(codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
-frame->pkt_dts = pkt->dts;
-if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
-#if FF_API_FRAME_PKT
-FF_DISABLE_DEPRECATION_WARNINGS
-if(!avctx->has_b_frames)
-frame->pkt_pos = pkt->pos;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-//FIXME these should be under if(!avctx->has_b_frames)
-/* get_buffer is supposed to set frame parameters */
-if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
-if (!frame->sample_aspect_ratio.num)  frame->sample_aspect_ratio 
= avctx->sample_aspect_ratio;
-if (!frame->width)frame->width   
= avctx->width;
-if (!frame->height)   frame->height  
= avctx->height;
-if (frame->format == AV_PIX_FMT_NONE) frame->format  
= avctx->pix_fmt;
-}
-}
-}
-emms_c();
-actual_got_frame = got_frame;
+AVCodecInternal *avci = avctx->internal;
+int ret = 0;
  
  if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {

  if (frame->flags & AV_FRAME_FLAG_DISCARD)
-got_frame = 0;
+ret = AVERROR(EAGAIN);
  } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
  uint8_t *side;
  size_t side_size;
@@ -359,16 +304,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
  uint8_t skip_reason = 0;
  uint8_t discard_reason = 0;
  
-if (ret >= 0 && got_frame) {

  if (frame->format == AV_SAMPLE_FMT_NONE)
  frame->format = avctx->sample_fmt;
-if (!frame->ch_layout.nb_channels) {
-int ret2 = av_channel_layout_copy(&frame->ch_layout, 
&avctx->ch_layout);
-if (ret2 < 0) {
-ret = ret2;
-got_frame = 0;
-}
-}
+if (!frame->ch_layout.nb_channels)
+ret = av_channel_layout_copy(&frame->ch_layout, 
&avctx->ch_layout);
  #if FF_API_OLD_CHANNEL_LAYOUT
  FF_DISABLE_DEPRECATION_WARNINGS
  if (!frame->channel_layout)
@@ -380,7 +319,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
  #endif
  if (!frame->sample_rate)
  frame->sample_rate = avctx->sample_rate;
-}
  
  side= av_packet_get_side_data(avci->last_pkt_props, AV_PKT_DATA_SKIP_SAMPLES, &side_size);

  if(side && side_size>=10) {
@@ -393,21 +331,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
  discard_reason = AV_RL8(side + 9);
  }
  
-if ((frame->flags & AV_FRAME_FLAG_DISCARD) && got_frame &&

+if ((frame->flags & AV_FRAME_FLAG_DISCARD) && !ret &&
  !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
  avci->skip_samples = FFMAX(0, avci->skip_samples - 
frame->nb_samples);
-got_frame = 0;
  *discarded_samples += frame->nb_samples;
+ret = AVERROR(EAGAIN);
  }
  
-if (avci->skip_samples > 0 &&

[FFmpeg-devel] [PATCH 01/18] avradio/sdrdemux: Fix uninitialized access

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index bed74ebd26..3bb5a69cf1 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1500,9 +1500,11 @@ int avpriv_sdr_common_init(AVFormatContext *s)
 SDRStream *sst = st->priv_data;
 av_assert0(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO);
 sst->frame_size   = sdr->width * sdr->height * 4;
-sst->frame_buffer = av_malloc(sst->frame_size * 2);
+sst->frame_buffer = av_mallocz(sst->frame_size * 2);
 if (!sst->frame_buffer)
 return AVERROR(ENOMEM);
+for(int i = 3; iframe_size * 2; i+=4)
+sst->frame_buffer[i] = 255;
 }
 
 sdr->pts = 0;
-- 
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 02/18] avradio/sdrdemux: factor frequency tolerance constants out

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 3bb5a69cf1..1f2d778978 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -61,6 +61,9 @@
 #define FREQ_BITS 22
 #define TIMEBASE ((48000ll / 128) << FREQ_BITS)
 
+#define AM_FREQ_TOLERANCE 5
+#define FM_FREQ_TOLERANCE 500
+
 #define STATION_TIMEOUT 100 ///< The number of frames after which a station is 
removed if it was not detected
 #define CANDIDATE_STATION_TIMEOUT 4
 
@@ -248,7 +251,7 @@ static int create_station(SDRContext *sdr, Station 
*candidate_station) {
 
 nb_candidate_match += candidate_station->nb_frequency - 1;
 for (i=0; ifrequency - freq);
 
@@ -383,7 +386,7 @@ static int create_candidate_station(SDRContext *sdr, enum 
Modulation modulation,
 void *tmp;
 struct AVTreeNode *next = NULL;
 Station *station_list[1000];
-double snapdistance = modulation == AM ? 5 : 500;
+double snapdistance = modulation == AM ? AM_FREQ_TOLERANCE : 
FM_FREQ_TOLERANCE;
 int nb_stations = find_stations(sdr, freq, snapdistance, station_list, 
FF_ARRAY_ELEMS(station_list));
 
 if (nb_stations) {
-- 
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 03/18] avradio/sdr: Add fm multiple parameter

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 doc/demuxers.texi | 7 +++
 libavradio/sdr.h  | 1 +
 libavradio/sdrdemux.c | 9 +
 3 files changed, 17 insertions(+)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 81c46ce08f..86f031b9ed 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -965,6 +965,13 @@ it can also result in the detection of SDR artifacts such 
as reflections of stro
 as weak stations. Future versions may be better able to separate weak stations 
from artifacts
 looking like weak stations.
 
+@item fm_multiple
+Multiple of frequency in hz at which to search for stations.
+you can set this to 10 to probe stations at 0.1MHz increments
+Most SDR artifacts are not at exact multiplies, this is thus an effective
+way to eliminate these artifacts.
+disabled by default.
+
 @item am_mode
 AM Demodulation method. Several different methods are supported.
 @table @samp
diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 1053e45efe..ff4bfcaa1f 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -159,6 +159,7 @@ typedef struct SDRContext {
 
 float am_threshold;
 float fm_threshold;
+float fm_multiple;
 
 pthread_t hw_thread;
 int thread_started;
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 1f2d778978..13cec10505 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -915,6 +915,14 @@ static int probe_fm(SDRContext *sdr)
 
 if (fabs(f2 - f) > 1000)
 continue;
+
+if (sdr->fm_multiple) {
+double f3 = lrint(f2 / sdr->fm_multiple) * 
sdr->fm_multiple;
+if (fabs(f2 - f3) > FM_FREQ_TOLERANCE)
+continue;
+f2 = f3;
+}
+
 create_candidate_station(sdr, FM, f2, bandwidth_f, 
bandwidth_p2, score);
 }
 }
@@ -2169,6 +2177,7 @@ const AVOption avpriv_sdr_options[] = {
 
 { "am_threshold" , "AM detection threshold", OFFSET(am_threshold), 
AV_OPT_TYPE_FLOAT, {.dbl = 20}, 0, FLT_MAX, DEC},
 { "fm_threshold" , "FM detection threshold", OFFSET(fm_threshold), 
AV_OPT_TYPE_FLOAT, {.dbl = 50}, 0, FLT_MAX, DEC},
+{ "fm_multiple"  , "FM frequency mutiple",   OFFSET(fm_multiple ), 
AV_OPT_TYPE_FLOAT, {.dbl =  0}, 0, FLT_MAX, DEC},
 
 { NULL },
 };
-- 
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 04/18] avradio/sdrinradio: Dont automatically select 2.56Mhz on the rtlsdr

2023-07-08 Thread Michael Niedermayer
2.56Mhz produces more artifacts than lower sample rates at least
in the FM broadcast band

Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrinradio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index c6f5742436..052e2298da 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -235,8 +235,8 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 (sdr->sdr_sample_rate < ranges[i].minimum || sdr->sdr_sample_rate 
> ranges[i].maximum))
 continue;
 if (sdr->rtlsdr_fixes)
-// 2.88 and 3.2 Mhz do not work reliable here so lets not 
automatically choose them, the user can override this
-if (ranges[i].maximum > (256 + 288)/2)
+// 2.56, 2.88 and 3.2 Mhz do not work reliable here so lets not 
automatically choose them, the user can override this
+if (ranges[i].maximum > (256 + 216)/2)
 continue;
 max_sample_rate = FFMAX(max_sample_rate, ranges[i].maximum);
 }
-- 
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 05/18] avradio/sdrdemux: Do not timeout negative stations

2023-07-08 Thread Michael Niedermayer
If we identified that a station is an artifact of the SDR, we dont
want to timeout that to avoid it being redetected as station

Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 13cec10505..39eaa0c094 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -347,6 +347,7 @@ static void decay_stations(SDRContext *sdr)
 
 for (int i=0; ifrequency - station->bandwidth/2 < sdr->block_center_freq 
- sdr->bandwidth/2 ||
 station->frequency + station->bandwidth/2 > sdr->block_center_freq 
+ sdr->bandwidth/2)
@@ -355,9 +356,10 @@ static void decay_stations(SDRContext *sdr)
 if (station->timeout)
 station->non_detection_per_mix_frequency[histogram_index(sdr, 
station->frequency)] ++;
 
+hs = histogram_score(station);
+
 if (station->in_station_list) {
 int station_timeout = STATION_TIMEOUT;
-int hs = histogram_score(station);
 
 if (hs == 0) {
 station_timeout = 5; //give the station a moment to be 
properly detected and then discard it
@@ -370,7 +372,13 @@ static void decay_stations(SDRContext *sdr)
 station->in_station_list = 0;
 }
 } else {
-if (station->timeout++ > CANDIDATE_STATION_TIMEOUT) {
+int station_timeout = CANDIDATE_STATION_TIMEOUT;
+
+//We do not want to drop "negative" stations to avoid them being 
redetected
+if (hs <= 0)
+station_timeout = INT_MAX;
+
+if (station->timeout++ > station_timeout) {
 struct AVTreeNode *next = NULL;
 tree_remove(&sdr->station_root, station, station_cmp, &next);
 av_freep(&next);
-- 
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 06/18] avradio/sdrinradio: Factor print_and_free_list() out

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrinradio.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index 052e2298da..e4f17f4bc9 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -93,6 +93,17 @@ static int sdrindev_set_frequency_callback(SDRContext *sdr, 
int64_t freq)
 return 0;
 }
 
+static void print_and_free_list(AVFormatContext *s, char** names, size_t 
length, const char *title)
+{
+if (length) {
+av_log(s, AV_LOG_INFO, "%s:", title);
+for (int i = 0; i < length; i++)
+av_log(s, AV_LOG_INFO, "%c%s", ", "[!i], names[i]);
+av_log(s, AV_LOG_INFO, "\n");
+}
+SoapySDRStrings_clear(&names, length);
+}
+
 /**
  * Initial setup of SDR HW through soapy.
  * This will go over available settings and match them up with what the user 
requested
@@ -162,19 +173,11 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 
 //Go over all Antennas and print them
 names = SoapySDRDevice_listAntennas(soapy, SOAPY_SDR_RX, 0, &length);
-av_log(s, AV_LOG_INFO, "Antennas: ");
-for (i = 0; i < length; i++)
-av_log(s, AV_LOG_INFO, "%s, ", names[i]);
-av_log(s, AV_LOG_INFO, "\n");
-SoapySDRStrings_clear(&names, length);
+print_and_free_list(s, names, length, "Antennas");
 
 //Go over all Gain Elements and print them
 names = SoapySDRDevice_listGains(soapy, SOAPY_SDR_RX, 0, &length);
-av_log(s, AV_LOG_INFO, "Rx Gain Elements: ");
-for (i = 0; i < length; i++)
-av_log(s, AV_LOG_INFO, "%s, ", names[i]);
-av_log(s, AV_LOG_INFO, "\n");
-SoapySDRStrings_clear(&names, length);
+print_and_free_list(s, names, length, "Rx Gain Elements");
 
 //Inform the user if AGC is supported and setup AGC as requested by the 
user
 has_agc = SoapySDRDevice_hasGainMode(soapy, SOAPY_SDR_RX, 0);
-- 
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 12/18] avradio/sdrdemux: Set AVFMTCTX_NOHEADER

2023-07-08 Thread Michael Niedermayer
This is needed as stations may not be detected immedeately

Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 2bce1045f4..1c77583fd4 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1425,6 +1425,7 @@ int ff_sdr_common_init(AVFormatContext *s)
 float scale = 1.0 / sdr->sample_scale;
 
 sdr->avfmt = s;
+s->ctx_flags |= AVFMTCTX_NOHEADER;
 
 if (sdr->width>1 && sdr->height>1) {
 /* video stream */
-- 
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 07/18] avradio/sdrinradio: Print list of Time Sources

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrinradio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index e4f17f4bc9..af87b49495 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -171,6 +171,9 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 return AVERROR_EXTERNAL;
 }
 
+names = SoapySDRDevice_listTimeSources(soapy, &length);
+print_and_free_list(s, names, length, "Clocks");
+
 //Go over all Antennas and print them
 names = SoapySDRDevice_listAntennas(soapy, SOAPY_SDR_RX, 0, &length);
 print_and_free_list(s, names, length, "Antennas");
-- 
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 13/18] avradio/sdrdemux: fix bug adding candidate stations and then crashing

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 1c77583fd4..5300311c3a 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1818,7 +1818,7 @@ process_next_block:
 int nb_stations = ff_sdr_find_stations(sdr, 
sdr->block_center_freq, sdr->sdr_sample_rate*0.5, station_list, 
FF_ARRAY_ELEMS(station_list));
 for(int i = 0; istream) {
+if (!station->stream && station->in_station_list) {
 /* audio stream */
 AVStream *st = avformat_new_stream(s, NULL);
 SDRStream *sst;
-- 
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 08/18] avradio: split out vissualization code

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/Makefile |   4 +-
 libavradio/sdr.h|  21 
 libavradio/sdrdemux.c   | 207 +++-
 libavradio/vissualize.c | 200 ++
 4 files changed, 238 insertions(+), 194 deletions(-)
 create mode 100644 libavradio/vissualize.c

diff --git a/libavradio/Makefile b/libavradio/Makefile
index 23c173bc58..40b38f798e 100644
--- a/libavradio/Makefile
+++ b/libavradio/Makefile
@@ -11,5 +11,5 @@ OBJS= allradios.o 
  \
 
 
 # input/output radios
-OBJS-$(CONFIG_SDR_INRADIO) += sdrinradio.o
-OBJS-$(CONFIG_SDRFILE_INRADIO)  += sdrdemux.o
+OBJS-$(CONFIG_SDR_INRADIO) += sdrinradio.o vissualize.o
+OBJS-$(CONFIG_SDRFILE_INRADIO)  += sdrdemux.o vissualize.o
diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index ff4bfcaa1f..95ff903293 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -34,6 +34,8 @@
 #include "libavutil/tx.h"
 #include "libavformat/avformat.h"
 
+#define FREQ_BITS 22
+#define TIMEBASE ((48000ll / 128) << FREQ_BITS)
 
 #define INDEX2F(INDEX) (((INDEX) - sdr->block_size  + 0.5) * 0.5 * 
sdr->sdr_sample_rate / sdr->block_size  + sdr->block_center_freq)
 #define F2INDEX(F) (((F) - sdr->block_center_freq) * 2   * 
sdr->block_size  / sdr->sdr_sample_rate + sdr->block_size  - 0.5)
@@ -229,6 +231,8 @@ typedef struct BandDescriptor {
 
 extern const AVOption avpriv_sdr_options[];
 
+extern ModulationDescriptor ff_sdr_modulation_descs[];
+
 /**
  * Set the center frequency of the hardware
  * this will check the argument and call set_frequency_callback()
@@ -250,4 +254,21 @@ void avpriv_sdr_stop_threading(AVFormatContext *s);
 
 int avpriv_sdr_read_close(AVFormatContext *s);
 
+int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, AVPacket *pkt);
+
+/**
+ * Find stations within the given parameters.
+ * @param[out] station_list array to return stations in
+ * @param nb_stations size of station array
+ * @returns number of stations found
+ */
+int ff_sdr_find_stations(SDRContext *sdr, double freq, double range, Station 
**station_list, int station_list_size);
+
+int ff_sdr_histogram_score(Station *s);
+
+static inline float len2(AVComplexFloat c)
+{
+return c.re*c.re + c.im*c.im;
+}
+
 #endif /* AVRADIO_SDR_H */
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 39eaa0c094..392fece4e9 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -48,7 +48,6 @@
 #include "libavutil/thread.h"
 #include "libavutil/tree.h"
 #include "libavutil/tx.h"
-#include "libavutil/xga_font_data.h"
 #include "libavcodec/kbdwin.h"
 #include "libavformat/avformat.h"
 #include "libavformat/demux.h"
@@ -58,9 +57,6 @@
 #include "libavutil/lfg.h"
 #endif
 
-#define FREQ_BITS 22
-#define TIMEBASE ((48000ll / 128) << FREQ_BITS)
-
 #define AM_FREQ_TOLERANCE 5
 #define FM_FREQ_TOLERANCE 500
 
@@ -101,11 +97,6 @@ static void apply_deemphasis(SDRContext *sdr, 
AVComplexFloat *data, int len, int
 }
 }
 
-static float len2(AVComplexFloat c)
-{
-return c.re*c.re + c.im*c.im;
-}
-
 static void free_station(Station *station)
 {
 av_freep(&station->name);
@@ -120,7 +111,7 @@ static inline int histogram_index(SDRContext *sdr, double f)
 return av_clip((int)f, 0, HISTOGRAMM_SIZE-1);
 }
 
-static int histogram_score(Station *s)
+int ff_sdr_histogram_score(Station *s)
 {
 int score = 0;
 for(int i = 0; iblock_center_freq, 
sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list));
+int nb_stations = ff_sdr_find_stations(sdr, sdr->block_center_freq, 
sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list));
 for (i=0; ifrequency - freq);
@@ -305,7 +290,7 @@ static void create_stations(SDRContext *sdr)
 if (!sdr->block_center_freq)
 return;
 
-int nb_stations = find_stations(sdr, sdr->block_center_freq, 
sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list));
+int nb_stations = ff_sdr_find_stations(sdr, sdr->block_center_freq, 
sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list));
 
 for(int i = 0; iblock_center_freq, 
sdr->bandwidth*0.5, station_list, FF_ARRAY_ELEMS(station_list));
+int nb_stations = ff_sdr_find_stations(sdr, sdr->block_center_freq, 
sdr->bandwidth*0.5, station_list, FF_ARRAY_ELEMS(station_list));
 
 for (int i=0; itimeout)
 station->non_detection_per_mix_frequency[histogram_index(sdr, 
station->frequency)] ++;
 
-hs = histogram_score(station);
+hs = ff_sdr_histogram_score(station);
 
 if (station->in_station_list) {
 int station_timeout = STATION_TIMEOUT;
@@ -395,7 +380,7 @@ static int create_candidate_station(SDRContext *sdr, enum 
Modulation modulation,
 struct AVTreeNode *next = NULL;
 Station *station_list[1000];
 double snapdistance = modulation == AM ? AM_FREQ_TOLERANCE

[FFmpeg-devel] [PATCH 14/18] avradio/sdrdemux: fm_probe: dont allow bandwidh=sample rate

2023-07-08 Thread Michael Niedermayer
if bandwidth is set incorrectly the noise floor can be very wrong, which
causes issues as the threshold is based on the noise floor

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

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 5300311c3a..b51fa4296a 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -843,7 +843,7 @@ static int probe_fm(SDRContext *sdr)
 int bandwidth_p2 =  38*1000; //phase 2 bandwidth
 int half_bw_i = bandwidth_f * (int64_t)sdr->block_size / 
sdr->sdr_sample_rate;
 float last_score[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
-int border_i = (sdr->sdr_sample_rate - sdr->bandwidth) * sdr->block_size / 
sdr->sdr_sample_rate;
+int border_i = (sdr->sdr_sample_rate - FFMIN(sdr->bandwidth, 
sdr->sdr_sample_rate*7/8)) * sdr->block_size / sdr->sdr_sample_rate;
 double noise_floor = FLT_MAX;
 
 if (2*half_bw_i > 2*sdr->block_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 09/18] avradio/sdrdemux: The RTLSDR DC artifact is not consistent

2023-07-08 Thread Michael Niedermayer
so we need to check every block, we cannot just check a few and
then subtract the same value

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

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 95ff903293..13237707b3 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -202,7 +202,6 @@ typedef struct SDRContext {
 int missing_streams;
 
 int rtlsdr_fixes;
-float rtlsdr_dc_offset;
 } SDRContext;
 
 typedef struct ModulationDescriptor {
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 392fece4e9..6682768461 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1705,21 +1705,20 @@ process_next_block:
 const int8_t *halfblock0 = fifo_element[0].halfblock;
 const int8_t *halfblock1 = fifo_element[1].halfblock;
 if (sdr->rtlsdr_fixes>0) {
-if (!sdr->rtlsdr_dc_offset || !sdr->block_center_freq) {
-int sum = 0;
-for (i = 0; i<2*sdr->block_size; i++)
-sum += halfblock0[i]
-+  halfblock1[i];
-sdr->rtlsdr_dc_offset = -sum / (4.0*sdr->block_size);
-av_log(s, AV_LOG_DEBUG, "Compensating DC offset %f (this 
should be around -0.6)\n", sdr->rtlsdr_dc_offset);
-}
+int sum = 0;
+float offset;
+for (i = 0; i<2*sdr->block_size; i++)
+sum += halfblock0[i]
++  halfblock1[i];
+offset = -sum / (4.0*sdr->block_size);
+av_log(s, AV_LOG_DEBUG, "Compensating DC offset %f (this should be 
around -0.6)\n", offset);
 for (i = 0; iblock_size; i++) {
-sdr->windowed_block[i].re = (halfblock0[2*i+0] + 
sdr->rtlsdr_dc_offset) * sdr->window[i];
-sdr->windowed_block[i].im = (halfblock0[2*i+1] + 
sdr->rtlsdr_dc_offset) * sdr->window[i];
+sdr->windowed_block[i].re = (halfblock0[2*i+0] + offset) * 
sdr->window[i];
+sdr->windowed_block[i].im = (halfblock0[2*i+1] + offset) * 
sdr->window[i];
 }
 for (i = sdr->block_size; i<2*sdr->block_size; i++) {
-sdr->windowed_block[i].re = (halfblock1[2*(i - 
sdr->block_size)+0] + sdr->rtlsdr_dc_offset) * sdr->window[i];
-sdr->windowed_block[i].im = (halfblock1[2*(i - 
sdr->block_size)+1] + sdr->rtlsdr_dc_offset) * sdr->window[i];
+sdr->windowed_block[i].re = (halfblock1[2*(i - 
sdr->block_size)+0] + offset) * sdr->window[i];
+sdr->windowed_block[i].im = (halfblock1[2*(i - 
sdr->block_size)+1] + offset) * sdr->window[i];
 }
 } else {
 for (i = 0; iblock_size; i++) {
-- 
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 15/18] doc: add sdr examples

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 doc/demuxers.texi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 86f031b9ed..75ec55170a 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -1003,6 +1003,16 @@ No emphasis used
 
 @end table
 
+Example: Use ffplay to listen to radio, arrow keys allow switching stations
+@example
+ffplay -sdr_freq 88M -f sdr a -video_size 1600x600
+@end example
+
+Example: Record all radio stations between about 101Mhz and 107Mhz
+@example
+ffmpeg -sdr_freq 104M -sdr_sr 7M -mode all_mode -f sdr -i a -map 0 -y fm.nut
+@end example
+
 @end table
 
 @section tedcaptions
-- 
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 10/18] avradio/sdr: eliminate avpriv_*

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h| 14 +++---
 libavradio/sdrdemux.c   | 32 
 libavradio/sdrinradio.c | 14 +++---
 3 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 13237707b3..2940ffa389 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -228,7 +228,7 @@ typedef struct BandDescriptor {
 int64_t freq_max;
 } BandDescriptor ;
 
-extern const AVOption avpriv_sdr_options[];
+extern const AVOption ff_sdr_options[];
 
 extern ModulationDescriptor ff_sdr_modulation_descs[];
 
@@ -237,21 +237,21 @@ extern ModulationDescriptor ff_sdr_modulation_descs[];
  * this will check the argument and call set_frequency_callback()
  * It can be called before the thread is started or from within the thread,
  */
-int avpriv_sdr_set_freq(SDRContext *sdr, int64_t freq);
+int ff_sdr_set_freq(SDRContext *sdr, int64_t freq);
 
-int avpriv_sdr_common_init(AVFormatContext *s);
+int ff_sdr_common_init(AVFormatContext *s);
 
-int avpriv_sdr_read_packet(AVFormatContext *s, AVPacket *pkt);
+int ff_sdr_read_packet(AVFormatContext *s, AVPacket *pkt);
 
-int avpriv_sdr_read_seek(AVFormatContext *s, int stream_index, int64_t target, 
int flags);
+int ff_sdr_read_seek(AVFormatContext *s, int stream_index, int64_t target, int 
flags);
 
 /**
  * shuts down threads, destroys mutex
  * Safe to call if no thread was started or after it was shutdown
  */
-void avpriv_sdr_stop_threading(AVFormatContext *s);
+void ff_sdr_stop_threading(AVFormatContext *s);
 
-int avpriv_sdr_read_close(AVFormatContext *s);
+int ff_sdr_read_close(AVFormatContext *s);
 
 int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, AVPacket *pkt);
 
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 6682768461..2bce1045f4 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1056,7 +1056,7 @@ ModulationDescriptor ff_sdr_modulation_descs[] = {
 {"Frequency Modulation", "FM", FM, AVMEDIA_TYPE_AUDIO, probe_fm, 
demodulate_fm},
 };
 
-int avpriv_sdr_set_freq(SDRContext *sdr, int64_t freq)
+int ff_sdr_set_freq(SDRContext *sdr, int64_t freq)
 {
 freq = av_clip64(freq, sdr->min_center_freq, sdr->max_center_freq);
 
@@ -1390,9 +1390,9 @@ static void *soapy_needs_bigger_buffers_worker(SDRContext 
*sdr)
 }
 if (sdr->wanted_freq != sdr->freq) {
 //We could use a seperate MUTEX for the FIFO and for soapy
-avpriv_sdr_set_freq(sdr, sdr->wanted_freq);
+ff_sdr_set_freq(sdr, sdr->wanted_freq);
 //This shouldnt really cause any problem if we just continue on 
error except that we continue returning data with the previous target frequency 
range
-//And theres not much else we can do, an error message was already 
printed by avpriv_sdr_set_freq() in that case
+//And theres not much else we can do, an error message was already 
printed by ff_sdr_set_freq() in that case
 block_counter = 0; // we just changed the frequency, do not trust 
the next blocks content
 }
 pthread_mutex_unlock(&sdr->mutex);
@@ -1416,7 +1416,7 @@ static void *soapy_needs_bigger_buffers_worker(SDRContext 
*sdr)
 return NULL;
 }
 
-int avpriv_sdr_common_init(AVFormatContext *s)
+int ff_sdr_common_init(AVFormatContext *s)
 {
 SDRContext *sdr = s->priv_data;
 AVStream *st;
@@ -1588,16 +1588,16 @@ static int sdrfile_initial_setup(AVFormatContext *s)
 //After reading the first packet header we return to the begin so the 
packet can be read whole
 avio_seek(s->pb, 0, SEEK_SET);
 
-ret = avpriv_sdr_set_freq(sdr, sdr->wanted_freq);
+ret = ff_sdr_set_freq(sdr, sdr->wanted_freq);
 if (ret < 0)
 return ret;
 
 sdr->read_callback = sdrfile_read_callback;
 
-return avpriv_sdr_common_init(s);
+return ff_sdr_common_init(s);
 }
 
-int avpriv_sdr_read_packet(AVFormatContext *s, AVPacket *pkt)
+int ff_sdr_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 SDRContext *sdr = s->priv_data;
 int ret, i, full_blocks, seek_direction;
@@ -1860,7 +1860,7 @@ process_next_block:
 return AVERROR(EAGAIN);
 }
 
-int avpriv_sdr_read_seek(AVFormatContext *s, int stream_index,
+int ff_sdr_read_seek(AVFormatContext *s, int stream_index,
  int64_t target, int flags)
 {
 SDRContext *sdr = s->priv_data;
@@ -1900,7 +1900,7 @@ int avpriv_sdr_read_seek(AVFormatContext *s, int 
stream_index,
 return 0;
 }
 
-void avpriv_sdr_stop_threading(AVFormatContext *s)
+void ff_sdr_stop_threading(AVFormatContext *s)
 {
 SDRContext *sdr = s->priv_data;
 
@@ -1919,12 +1919,12 @@ void avpriv_sdr_stop_threading(AVFormatContext *s)
 sdr->thread_started = 0;
 }
 
-int avpriv_sdr_read_close(AVFormatContext *s)
+int ff_sdr_read_close(AVFormatContext *s)
 {
 SDRContext *sdr = s->priv_data;
 int i;
 
-avpriv_sdr_stop_threading(s);
+ff_sdr_stop_threading(s);
 
 av_fifo_free

[FFmpeg-devel] [PATCH 16/18] avradio/sdr: rename fft_p2

2023-07-08 Thread Michael Niedermayer
The FFT really is from the point of view of the stream Phase 1 not
Phase 2 of the demodulation.

Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h  | 4 ++--
 libavradio/sdrdemux.c | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 8a2ab1c78a..1582f70d86 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -95,10 +95,10 @@ typedef struct FIFOElement {
 
 typedef struct SDRStream {
 AVTXContext *ifft_ctx;
-AVTXContext *fft_p2_ctx;
+AVTXContext *fft_ctx;
 AVTXContext *ifft_p2_ctx;
 av_tx_fn ifft;
-av_tx_fn fft_p2;
+av_tx_fn fft;
 av_tx_fn ifft_p2;
 int block_size;
 int block_size_p2;
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index b51fa4296a..1ded01e957 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -979,7 +979,7 @@ static int demodulate_fm(SDRContext *sdr, int stream_index, 
AVPacket *pkt)
 //FIXME this only needs to be a RDFT
 //CONSIDER, this and in fact alot can be done with bandpass and lowpass 
filters instead of FFTs, find out which is better
 //CONSIDER synthesizing the carrier instead of IFFT, we have all 
parameters for that
-sst->fft_p2(sst->fft_p2_ctx, sst->block, sst->iblock, 
sizeof(AVComplexFloat));
+sst->fft(sst->fft_ctx, sst->block, sst->iblock, sizeof(AVComplexFloat));
 // Only the low N/2+1 are used the upper is just a reflection
 
 carrier19_i_exact = find_am_carrier(sdr, sst->block, 2*sst->block_size, 
(void*)(sst->block + 1 + sst->block_size), carrier19_i, 10, 10);
@@ -1078,10 +1078,10 @@ static void free_stream(SDRContext *sdr, int 
stream_index)
 SDRStream *sst = st->priv_data;
 
 av_tx_uninit(&sst->ifft_ctx);
-av_tx_uninit(&sst->fft_p2_ctx);
+av_tx_uninit(&sst->fft_ctx);
 av_tx_uninit(&sst->ifft_p2_ctx);
 sst->ifft = NULL;
-sst->fft_p2 = NULL;
+sst->fft  = NULL;
 sst->ifft_p2 = NULL;
 sst->block_size = 0;
 
@@ -1127,7 +1127,7 @@ static int setup_stream(SDRContext *sdr, int 
stream_index, Station *station)
 
 if (sst->station->bandwidth_p2) {
 //Allocate 2nd stage demodulation fields if needed
-ret = av_tx_init(&sst-> fft_p2_ctx, &sst-> fft_p2, 
AV_TX_FLOAT_FFT, 0, 2*sst->block_size   , NULL, 0);
+ret = av_tx_init(&sst-> fft_ctx, &sst-> fft, AV_TX_FLOAT_FFT, 0, 
2*sst->block_size   , NULL, 0);
 if (ret < 0)
 return ret;
 
-- 
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 11/18] avradio/vissualize: rotate waterfall

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h|  1 +
 libavradio/vissualize.c | 35 ++-
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 2940ffa389..8a2ab1c78a 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -116,6 +116,7 @@ typedef struct SDRStream {
 int frame_size;
 int frame_buffer_line;
 uint8_t *frame_buffer;
+int64_t last_block_center_freq;
 } SDRStream;
 
 typedef struct SDRContext {
diff --git a/libavradio/vissualize.c b/libavradio/vissualize.c
index c165e0fb63..b27f78f171 100644
--- a/libavradio/vissualize.c
+++ b/libavradio/vissualize.c
@@ -90,6 +90,14 @@ static void draw_string(uint8_t *frame_buffer, ptrdiff_t 
stride, char *str, int
 }
 }
 
+static void advance_waterfall(SDRStream *sst, int h) {
+if (!sst->frame_buffer_line) {
+memcpy(sst->frame_buffer + sst->frame_size, sst->frame_buffer, 
sst->frame_size);
+sst->frame_buffer_line = h-1;
+} else
+sst->frame_buffer_line--;
+}
+
 int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, AVPacket *pkt)
 {
 SDRStream *sst = st->priv_data;
@@ -101,6 +109,27 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, 
AVPacket *pkt)
 int skip = frame_index == last_index || sdr->missing_streams;
 av_assert0(sdr->missing_streams >= 0);
 
+if (sdr->block_center_freq) {
+if (sst->last_block_center_freq) {
+int last_center = lrint((F2INDEX(sst->last_block_center_freq) - 
sdr->block_size) * w / (2*sdr->block_size));
+
+last_center %= w;
+if (last_center < 0)
+last_center += w;
+av_assert0(last_center >= 0 && last_center < w);
+
+for(int y= 0; yframe_buffer + 4*w*(sst->frame_buffer_line 
+ y);
+uint8_t *src = dst + 4*w;
+
+memcpy(dst + 4*last_center, src,   4*(w - 
last_center));
+memcpy(dst, src + 4*(w - last_center), 4* 
last_center );
+}
+advance_waterfall(sst, h);
+}
+sst->last_block_center_freq = sdr->block_center_freq;
+}
+
 for(int x= 0; xframe_buffer_line*w);
@@ -188,11 +217,7 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, 
AVPacket *pkt)
 }
 }
 
-if (!sst->frame_buffer_line) {
-memcpy(sst->frame_buffer + sst->frame_size, sst->frame_buffer, 
sst->frame_size);
-sst->frame_buffer_line = h-1;
-} else
-sst->frame_buffer_line--;
+advance_waterfall(sst, h);
 
 //TODO
 // draw RDS*
-- 
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 17/18] avradio/sdrdemux: more correct phase 2 bandwidth of FM demodulation

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 1ded01e957..d73cbc0a06 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -840,7 +840,7 @@ static int probe_fm(SDRContext *sdr)
 {
 int i;
 int bandwidth_f  = 180*1000;
-int bandwidth_p2 =  38*1000; //phase 2 bandwidth
+int bandwidth_p2 =  18*1000; //phase 2 bandwidth
 int half_bw_i = bandwidth_f * (int64_t)sdr->block_size / 
sdr->sdr_sample_rate;
 float last_score[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
 int border_i = (sdr->sdr_sample_rate - FFMIN(sdr->bandwidth, 
sdr->sdr_sample_rate*7/8)) * sdr->block_size / sdr->sdr_sample_rate;
-- 
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 18/18] avradio/sdrdemux: Fix DC offset issue in AM demodulation

2023-07-08 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index d73cbc0a06..7cc71b2cfb 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -740,7 +740,8 @@ static int demodulate_am(SDRContext *sdr, int stream_index, 
AVPacket *pkt)
 AVComplexFloat mm;
 double s2 = 0;
 double dcw = 0;
-float amp, amp2;
+float amp, stamp, wamp;
+
 for(i = 0; i<2*sst->block_size; i++) {
 double tmp;
 AVComplexFloat v = sst->iblock[i];
@@ -755,17 +756,17 @@ static int demodulate_am(SDRContext *sdr, int 
stream_index, AVPacket *pkt)
 dcw+= sst->window[i] * sst->window[i];
 }
 
-amp = dcw / (dc1.re*dc1.re + dc1.im*dc1.im);
-amp2= dcw / s2;
-amp = FFMIN(amp, amp2 * 0.1);
+stamp = dcw / (dc1.re*dc1.re + dc1.im*dc1.im);
+amp = FFMIN(stamp, dcw / s2 * 0.1);
 if (sst->am_amplitude)
 amp = 0.9*sst->am_amplitude + 0.1*amp;
 sst->am_amplitude = amp;
+wamp = amp/stamp;
 
 mm = (AVComplexFloat){dc1.re * amp, -dc1.im * amp};
 for(i = 0; i<2*sst->block_size; i++) {
 AVComplexFloat v = sst->iblock[i];
-sst->iblock[i].re = v.re*mm.re - v.im*mm.im - sst->window[i];
+sst->iblock[i].re = v.re*mm.re - v.im*mm.im - sst->window[i] * 
wamp;
 sst->iblock[i].im = v.re*mm.im + v.im*mm.re;
 }
 
-- 
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 v2 13/14] vvcdec: add CTU thread logical

2023-07-08 Thread Michael Niedermayer
On Fri, Jul 07, 2023 at 10:05:39PM +0800, Nuo Mi wrote:
> This is the main entry point for the CTU (Coding Tree Unit) decoder.
> The code will divide the CTU decoder into several stages.
> It will check the stage dependencies and run the stage decoder.
> ---
>  libavcodec/vvc/Makefile |   3 +-
>  libavcodec/vvc/vvc_thread.c | 804 
>  libavcodec/vvc/vvc_thread.h |  73 
>  3 files changed, 879 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/vvc/vvc_thread.c
>  create mode 100644 libavcodec/vvc/vvc_thread.h

seems not to build with enable-shared

src/libavcodec/vvc/vvc_thread.c:235:9: error: address argument to atomic 
operation must be a pointer to non-const _Atomic type ('const atomic_int *' 
(aka 'const _Atomic(int) *') invalid)
if (atomic_load(&ft->ret))
^   
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: expanded 
from macro 'atomic_load'
#define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
^ ~~
1 error generated.
src/ffbuild/common.mak:81: recipe for target 'libavcodec/vvc/vvc_thread.o' 
failed
make: *** [libavcodec/vvc/vvc_thread.o] Error 1
make: *** Waiting for unfinished jobs


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

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


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 01/14] vvcdec: add thread executor

2023-07-08 Thread Michael Niedermayer
On Fri, Jul 07, 2023 at 10:05:27PM +0800, Nuo Mi wrote:
> The executor design pattern was inroduced by java
> 
> it also adapted by python
> 
> Compared to handcrafted thread pool management, it greatly simplifies the 
> thread code.
> ---
>  libavcodec/Makefile |   1 +
>  libavcodec/executor.c   | 182 
>  libavcodec/executor.h   |  67 +++
>  libavcodec/vvc/Makefile |   4 +
>  4 files changed, 254 insertions(+)
>  create mode 100644 libavcodec/executor.c
>  create mode 100644 libavcodec/executor.h
>  create mode 100644 libavcodec/vvc/Makefile

This seems to need some fallback if pthreads are unavailable

src/libavcodec/executor.c: In function ‘executor_worker_task’:
src/libavcodec/executor.c:64:5: error: implicit declaration of function 
‘pthread_mutex_lock’; did you mean ‘ff_mutex_lock’? 
[-Werror=implicit-function-declaration]
 pthread_mutex_lock(&e->lock);
 ^~
 ff_mutex_lock
src/libavcodec/executor.c:78:13: error: implicit declaration of function 
‘pthread_mutex_unlock’; did you mean ‘ff_mutex_unlock’? 
[-Werror=implicit-function-declaration]
 pthread_mutex_unlock(&e->lock);
 ^~~~
 ff_mutex_unlock
src/libavcodec/executor.c:83:13: error: implicit declaration of function 
‘pthread_cond_wait’; did you mean ‘__fread_chk_warn’? 
[-Werror=implicit-function-declaration]
 pthread_cond_wait(&e->cond, &e->lock);
 ^
 __fread_chk_warn
src/libavcodec/executor.c: In function ‘ff_executor_alloc’:
src/libavcodec/executor.c:108:11: error: implicit declaration of function 
‘pthread_mutex_init’; did you mean ‘ff_mutex_init’? 
[-Werror=implicit-function-declaration]
 ret = pthread_mutex_init(&e->lock, NULL);
   ^~
   ff_mutex_init
src/libavcodec/executor.c:112:11: error: implicit declaration of function 
‘pthread_cond_init’ [-Werror=implicit-function-declaration]
 ret = pthread_cond_init(&e->cond, NULL);
   ^
src/libavcodec/executor.c:119:15: error: implicit declaration of function 
‘pthread_create’; did you mean ‘ff_thread_setname’? 
[-Werror=implicit-function-declaration]
 ret = pthread_create(&ti->thread, NULL, executor_worker_task, ti);
   ^~
   ff_thread_setname
src/libavcodec/executor.c:129:5: error: implicit declaration of function 
‘pthread_cond_broadcast’ [-Werror=implicit-function-declaration]
 pthread_cond_broadcast(&e->cond);
 ^~
src/libavcodec/executor.c:132:9: error: implicit declaration of function 
‘pthread_join’; did you mean ‘ff_thread_once’? 
[-Werror=implicit-function-declaration]
 pthread_join(e->threads[j].thread, NULL);
 ^~~~
 ff_thread_once
src/libavcodec/executor.c:133:5: error: implicit declaration of function 
‘pthread_cond_destroy’ [-Werror=implicit-function-declaration]
 pthread_cond_destroy(&e->cond);
 ^~~~
src/libavcodec/executor.c:135:5: error: implicit declaration of function 
‘pthread_mutex_destroy’; did you mean ‘ff_mutex_destroy’? 
[-Werror=implicit-function-declaration]
 pthread_mutex_destroy(&e->lock);
 ^
 ff_mutex_destroy
src/libavcodec/executor.c: In function ‘ff_executor_execute’:
src/libavcodec/executor.c:180:5: error: implicit declaration of function 
‘pthread_cond_signal’ [-Werror=implicit-function-declaration]
 pthread_cond_signal(&e->cond);
 ^~~
cc1: some warnings being treated as errors
ffmpeg/ffbuild/common.mak:81: recipe for target 'libavcodec/executor.o' failed
make: *** [libavcodec/executor.o] Error 1
make: *** Waiting for unfinished jobs

thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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 13/22] fftools/ffmpeg_filter: stop disregarding user-specified pixel format

2023-07-08 Thread Michael Niedermayer
On Fri, Jul 07, 2023 at 11:48:38AM +0200, Anton Khirnov wrote:
> When the user explicitly specifies a pixel format that is not supported
> by the encoder, ffmpeg CLI will currently use some heuristics to pick
> another supported format. This is wrong and the correct action here is
> to fail.
> 
> Surprisingly, a number of FATE tests are affected by this and actually
> use a different pixel format than is specified in the makefiles.
> ---
>  fftools/ffmpeg_filter.c   | 36 ++-
>  tests/fate/fits.mak   |  6 ++--
>  tests/fate/lavf-video.mak |  2 +-
>  tests/fate/vcodec.mak |  4 +--
>  .../{fitsdec-gbrap16le => fitsdec-gbrap16be}  |  4 +--
>  .../fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} |  4 +--
>  tests/ref/lavf/gif|  2 +-
>  7 files changed, 13 insertions(+), 45 deletions(-)
>  rename tests/ref/fate/{fitsdec-gbrap16le => fitsdec-gbrap16be} (79%)
>  rename tests/ref/fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} (79%)

breaks png

./ffmpeg -y  -i lena.pnm -s 696x300 -pix_fmt rgb48 -y out2.png

Error while opening encoder - maybe incorrect parameters such as bit_rate, 
rate, width or height.
Conversion failed!

before
./ffprobe out2.png
...
Stream #0:0: Video: png, rgb48be(pc, gbr/unknown/unknown), 696x300, 25 fps, 25 
tbr, 25 tbn

Yes internally its BE vs LE but thats not what the user wrote on the command 
line

thx


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

Republics decline into democracies and democracies degenerate into
despotisms. -- 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".


Re: [FFmpeg-devel] [PATCH 13/22] fftools/ffmpeg_filter: stop disregarding user-specified pixel format

2023-07-08 Thread Michael Niedermayer
On Fri, Jul 07, 2023 at 11:48:38AM +0200, Anton Khirnov wrote:
> When the user explicitly specifies a pixel format that is not supported
> by the encoder, ffmpeg CLI will currently use some heuristics to pick
> another supported format. This is wrong and the correct action here is
> to fail.
> 
> Surprisingly, a number of FATE tests are affected by this and actually
> use a different pixel format than is specified in the makefiles.
> ---
>  fftools/ffmpeg_filter.c   | 36 ++-
>  tests/fate/fits.mak   |  6 ++--
>  tests/fate/lavf-video.mak |  2 +-
>  tests/fate/vcodec.mak |  4 +--
>  .../{fitsdec-gbrap16le => fitsdec-gbrap16be}  |  4 +--
>  .../fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} |  4 +--
>  tests/ref/lavf/gif|  2 +-
>  7 files changed, 13 insertions(+), 45 deletions(-)
>  rename tests/ref/fate/{fitsdec-gbrap16le => fitsdec-gbrap16be} (79%)
>  rename tests/ref/fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} (79%)

This also seems to break the user interface and seems to violates what is 
documented:
(unless iam too tired and mix something up here)

@item -pix_fmt[:@var{stream_specifier}] @var{format} 
(@emph{input/output,per-stream})
Set pixel format. Use @code{-pix_fmts} to show all the supported
pixel formats.
If the selected pixel format can not be selected, ffmpeg will print a
warning and select the best pixel format supported by the encoder.
If @var{pix_fmt} is prefixed by a @code{+}, ffmpeg will exit with an error
if the requested pixel format can not be selected, and automatic conversions
inside filtergraphs are disabled.
If @var{pix_fmt} is a single @code{+}, ffmpeg selects the same pixel format
as the input (or graph output) and automatic conversions are disabled.



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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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 13/14] vvcdec: add CTU thread logical

2023-07-08 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Fri, Jul 07, 2023 at 10:05:39PM +0800, Nuo Mi wrote:
>> This is the main entry point for the CTU (Coding Tree Unit) decoder.
>> The code will divide the CTU decoder into several stages.
>> It will check the stage dependencies and run the stage decoder.
>> ---
>>  libavcodec/vvc/Makefile |   3 +-
>>  libavcodec/vvc/vvc_thread.c | 804 
>>  libavcodec/vvc/vvc_thread.h |  73 
>>  3 files changed, 879 insertions(+), 1 deletion(-)
>>  create mode 100644 libavcodec/vvc/vvc_thread.c
>>  create mode 100644 libavcodec/vvc/vvc_thread.h
> 
> seems not to build with enable-shared
> 
> src/libavcodec/vvc/vvc_thread.c:235:9: error: address argument to atomic 
> operation must be a pointer to non-const _Atomic type ('const atomic_int *' 
> (aka 'const _Atomic(int) *') invalid)
> if (atomic_load(&ft->ret))
> ^   
> /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: expanded 
> from macro 'atomic_load'
> #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
> ^ ~~
> 1 error generated.
> src/ffbuild/common.mak:81: recipe for target 'libavcodec/vvc/vvc_thread.o' 
> failed
> make: *** [libavcodec/vvc/vvc_thread.o] Error 1
> make: *** Waiting for unfinished jobs
> 
> 

atomic_load() does not accept pointers to non-const atomic objects in
the original C11 spec (presumably the reason for this was that on
systems that lack atomics of the appropriate size an atomic would need
to be emulated somehow and this may involve locking and therefore
require the object to be writable). Your system is old and abides by the
original spec; AFAIK this point has been changed in later specs.
The solution is to use a cast.

- Andreas

PS: Exactly the same thing happened in the HEVC decoder.

___
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 13/22] fftools/ffmpeg_filter: stop disregarding user-specified pixel format

2023-07-08 Thread Anton Khirnov
Quoting Michael Niedermayer (2023-07-09 00:15:30)
> On Fri, Jul 07, 2023 at 11:48:38AM +0200, Anton Khirnov wrote:
> > When the user explicitly specifies a pixel format that is not supported
> > by the encoder, ffmpeg CLI will currently use some heuristics to pick
> > another supported format. This is wrong and the correct action here is
> > to fail.
> > 
> > Surprisingly, a number of FATE tests are affected by this and actually
> > use a different pixel format than is specified in the makefiles.
> > ---
> >  fftools/ffmpeg_filter.c   | 36 ++-
> >  tests/fate/fits.mak   |  6 ++--
> >  tests/fate/lavf-video.mak |  2 +-
> >  tests/fate/vcodec.mak |  4 +--
> >  .../{fitsdec-gbrap16le => fitsdec-gbrap16be}  |  4 +--
> >  .../fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} |  4 +--
> >  tests/ref/lavf/gif|  2 +-
> >  7 files changed, 13 insertions(+), 45 deletions(-)
> >  rename tests/ref/fate/{fitsdec-gbrap16le => fitsdec-gbrap16be} (79%)
> >  rename tests/ref/fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} (79%)
> 
> breaks png
> 
> ./ffmpeg -y  -i lena.pnm -s 696x300 -pix_fmt rgb48 -y out2.png
> 
> Error while opening encoder - maybe incorrect parameters such as bit_rate, 
> rate, width or height.
> Conversion failed!
> 
> before
> ./ffprobe out2.png
> ...
> Stream #0:0: Video: png, rgb48be(pc, gbr/unknown/unknown), 696x300, 25 fps, 
> 25 tbr, 25 tbn
> 
> Yes internally its BE vs LE but thats not what the user wrote on the command 
> line

The pixel format that is printed in your "before" is different from what
the user wrote as well, so the new behavior is correct IMO.

-- 
Anton Khirnov
___
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] avcodec/libjxldec: build against libjxl 0.9

2023-07-08 Thread Gyan Doshi




On 2023-07-09 01:00 am, Leo Izen wrote:

On 7/8/23 15:25, Gyan Doshi wrote:



On 2023-07-09 12:15 am, Leo Izen wrote:

Git master libjxl changed several function signatures, so this commit
adds some #ifdefs to handle the new signatures without breaking old
releases.


Same objection as to the patch submitted a few days ago, pasted below:


0.9.0 is still unreleased and unfortunately the API change wasn't 
accompanied with a version bump.


The API changes were pushed on Jun 21st and the version bump to 0.9.0 
was pushed on Jan 12th.
So this will still break compilation with older git checkouts of 
libjxl. Ideally libjxl should bump once more to 0.9.1



Regards,
Gyan



Oh, I missed that patch.

In either case, why do we care about breaking old development versions 
that aren't releases?


Ok. Just make a note in the commit msg then.

Regards,
Gyan

___
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".