]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/av1dec: fix setting pix_fmt
authorJames Almer <jamrial@gmail.com>
Sat, 12 Sep 2020 20:39:45 +0000 (17:39 -0300)
committerJames Almer <jamrial@gmail.com>
Sat, 12 Sep 2020 20:39:45 +0000 (17:39 -0300)
Fill the array with the software pix_fmt and move the avctx->hwaccel
check back to the proper place.
Also remove the avoid probing flag to ensure an external av1 decoder
will not set a pix_fmt we don't want during format probing.

Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/av1dec.c

index 4a419d69d6e645328d57db54ecdc4fb72553b7dd..bd8acdaafe7ca1b505c5d4f211a89c73902f0d79 100644 (file)
@@ -257,18 +257,7 @@ static int get_pixel_format(AVCodecContext *avctx)
     int ret;
     enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
 #define HWACCEL_MAX (0)
-    enum AVPixelFormat pix_fmts[HWACCEL_MAX + 1], *fmtp = pix_fmts;
-
-    /**
-     * 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
-     * implemented in the future, need remove this check.
-     */
-    if (!avctx->hwaccel) {
-        av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
-               " hardware accelerated AV1 decoding.\n");
-        return AVERROR(ENOSYS);
-    }
+    enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
 
     if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
         bit_depth = seq->color_config.twelve_bit ? 12 : 10;
@@ -328,12 +317,24 @@ static int get_pixel_format(AVCodecContext *avctx)
         return -1;
     s->pix_fmt = pix_fmt;
 
+    *fmtp++ = s->pix_fmt;
     *fmtp = AV_PIX_FMT_NONE;
-    avctx->sw_pix_fmt = s->pix_fmt;
+
     ret = ff_thread_get_format(avctx, pix_fmts);
     if (ret < 0)
         return 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
+     * implemented in the future, need remove this check.
+     */
+    if (!avctx->hwaccel) {
+        av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport"
+               " hardware accelerated AV1 decoding.\n");
+        return AVERROR(ENOSYS);
+    }
+
     avctx->pix_fmt = ret;
 
     return 0;
@@ -858,7 +859,7 @@ AVCodec ff_av1_decoder = {
     .init                  = av1_decode_init,
     .close                 = av1_decode_free,
     .decode                = av1_decode_frame,
-    .capabilities          = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING,
+    .capabilities          = AV_CODEC_CAP_DR1,
     .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE |
                              FF_CODEC_CAP_INIT_CLEANUP |
                              FF_CODEC_CAP_SETS_PKT_DTS,