Re: [FFmpeg-devel] [PATCH v2] avcodec/av1dec: export pixel format even if no hardware decoder is present

2023-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2023 at 02:55:25PM -0300, James Almer wrote:
> And remove the AVOID_PROBING flag, given it's the last av1 decoder to be 
> tested
> either way.
> This fixes a regression introduced in 
> 1652f2492f88434010053289d946dab6a57e4d58,
> where even if forcing the native av1 decoder, if another decoder was present,
> like libdav1d or libaom-av1, they'd be used for probing and some fate tests
> would have different results.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/av1dec.c | 50 -
>  tests/fate/lavf-container.mak   |  8 +++---
>  tests/ref/fate/av1-annexb-demux |  2 +-
>  tests/ref/lavf-fate/av1.mkv |  4 +--
>  tests/ref/lavf-fate/av1.mp4 |  4 +--
>  5 files changed, 39 insertions(+), 29 deletions(-)

breaks some fate tests like:
make fate-cbs-av1-non_uniform_tiling
TESTcbs-av1-non_uniform_tiling
--- ./tests/ref/fate/cbs-av1-non_uniform_tiling 2023-09-07 20:08:32.252582673 
+0200
+++ tests/data/fate/cbs-av1-non_uniform_tiling  2023-09-08 01:40:11.103091424 
+0200
@@ -1 +0,0 @@
-3e204ee8a71273cf0247f48e977e64b7
Test cbs-av1-non_uniform_tiling failed. Look at 
tests/data/fate/cbs-av1-non_uniform_tiling.err for details.
tests/Makefile:308: recipe for target 'fate-cbs-av1-non_uniform_tiling' failed
make: *** [fate-cbs-av1-non_uniform_tiling] Error 134

V=2 output:
Assertion n >= 1 failed at libavcodec/decode.c:1274
Aborted (core dumped)
threads=1
tests/Makefile:308: recipe for target 'fate-cbs-av1-non_uniform_tiling' failed
make: *** [fate-cbs-av1-non_uniform_tiling] Error 134



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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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 v2] avcodec/av1dec: export pixel format even if no hardware decoder is present

2023-09-07 Thread James Almer
And remove the AVOID_PROBING flag, given it's the last av1 decoder to be tested
either way.
This fixes a regression introduced in 1652f2492f88434010053289d946dab6a57e4d58,
where even if forcing the native av1 decoder, if another decoder was present,
like libdav1d or libaom-av1, they'd be used for probing and some fate tests
would have different results.

Signed-off-by: James Almer 
---
 libavcodec/av1dec.c | 50 -
 tests/fate/lavf-container.mak   |  8 +++---
 tests/ref/fate/av1-annexb-demux |  2 +-
 tests/ref/lavf-fate/av1.mkv |  4 +--
 tests/ref/lavf-fate/av1.mp4 |  4 +--
 5 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index ec8401f4e0..3766290c0f 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -440,20 +440,11 @@ static int get_tiles_info(AVCodecContext *avctx, const 
AV1RawTileGroup *tile_gro
 
 }
 
-static int get_pixel_format(AVCodecContext *avctx)
+static enum AVPixelFormat get_sw_pixel_format(AVCodecContext *avctx,
+  const AV1RawSequenceHeader *seq)
 {
-AV1DecContext *s = avctx->priv_data;
-const AV1RawSequenceHeader *seq = s->raw_seq;
-uint8_t bit_depth;
-int ret;
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
-#define HWACCEL_MAX (CONFIG_AV1_DXVA2_HWACCEL + \
- CONFIG_AV1_D3D11VA_HWACCEL * 2 + \
- CONFIG_AV1_NVDEC_HWACCEL + \
- CONFIG_AV1_VAAPI_HWACCEL + \
- CONFIG_AV1_VDPAU_HWACCEL + \
- CONFIG_AV1_VULKAN_HWACCEL)
-enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
+uint8_t bit_depth;
 
 if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
 bit_depth = seq->color_config.twelve_bit ? 12 : 10;
@@ -505,15 +496,29 @@ static int get_pixel_format(AVCodecContext *avctx)
 pix_fmt = AV_PIX_FMT_GRAY10;
 else if (bit_depth == 12)
 pix_fmt = AV_PIX_FMT_GRAY12;
-else
-av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
 }
 
-av_log(avctx, AV_LOG_DEBUG, "AV1 decode get format: %s.\n",
-   av_get_pix_fmt_name(pix_fmt));
+return pix_fmt;
+}
 
-if (pix_fmt == AV_PIX_FMT_NONE)
+static int get_pixel_format(AVCodecContext *avctx)
+{
+AV1DecContext *s = avctx->priv_data;
+const AV1RawSequenceHeader *seq = s->raw_seq;
+int ret;
+enum AVPixelFormat pix_fmt = get_sw_pixel_format(avctx, seq);
+#define HWACCEL_MAX (CONFIG_AV1_DXVA2_HWACCEL + \
+ CONFIG_AV1_D3D11VA_HWACCEL * 2 + \
+ CONFIG_AV1_NVDEC_HWACCEL + \
+ CONFIG_AV1_VAAPI_HWACCEL + \
+ CONFIG_AV1_VDPAU_HWACCEL + \
+ CONFIG_AV1_VULKAN_HWACCEL)
+enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
+
+if (pix_fmt == AV_PIX_FMT_NONE) {
+av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
 return -1;
+}
 
 switch (pix_fmt) {
 case AV_PIX_FMT_YUV420P:
@@ -605,13 +610,14 @@ static int get_pixel_format(AVCodecContext *avctx)
 break;
 }
 
-*fmtp++ = pix_fmt;
 *fmtp = AV_PIX_FMT_NONE;
 
 ret = ff_thread_get_format(avctx, pix_fmts);
 if (ret < 0)
 return ret;
 
+avctx->pix_fmt = ret;
+
 /**
  * check if the HW accel is inited correctly. If not, return 
un-implemented.
  * Since now the av1 decoder doesn't support native decode, if it will be
@@ -624,7 +630,9 @@ static int get_pixel_format(AVCodecContext *avctx)
 }
 
 s->pix_fmt = pix_fmt;
-avctx->pix_fmt = ret;
+
+av_log(avctx, AV_LOG_DEBUG, "AV1 decode get format: %s.\n",
+   av_get_pix_fmt_name(pix_fmt));
 
 return 0;
 }
@@ -865,6 +873,8 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 goto end;
 }
 
+avctx->pix_fmt = get_sw_pixel_format(avctx, seq);
+
 end:
 ff_cbs_fragment_reset(>current_obu);
 }
@@ -1518,7 +1528,7 @@ const FFCodec ff_av1_decoder = {
 .init  = av1_decode_init,
 .close = av1_decode_free,
 FF_CODEC_RECEIVE_FRAME_CB(av1_receive_frame),
-.p.capabilities= AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING,
+.p.capabilities= AV_CODEC_CAP_DR1,
 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
 .flush = av1_decode_flush,
 .p.profiles= NULL_IF_CONFIG_SMALL(ff_av1_profiles),
diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak
index 0d4a224601..0081b45eea 100644
--- a/tests/fate/lavf-container.mak
+++ b/tests/fate/lavf-container.mak
@@ -70,9 +70,9 @@ fate-lavf-wtv: CMD = lavf_container "" "-c:a mp2 -threads 1"
 FATE_AVCONV += $(FATE_LAVF_CONTAINER)
 fate-lavf-container fate-lavf: $(FATE_LAVF_CONTAINER)
 
-FATE_LAVF_CONTAINER_FATE-$(call ALLYES, IVF_DEMUXER AV1_PARSER