[FFmpeg-devel] [PATCH 2/4] lavc: Remove libva 1.x support

Mark Thompson sw at jkqxz.net
Wed Apr 3 22:45:15 EEST 2024


libva 2.0 was released in 2017 and the 2.x versions are included in all
supported distributions nowadays.
---
  libavcodec/vaapi_decode.c      | 10 ++--------
  libavcodec/vaapi_encode.c      | 31 +++++++++++--------------------
  libavcodec/vaapi_encode_h264.c | 18 ------------------
  3 files changed, 13 insertions(+), 46 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 5665639dd7..4e8910ed25 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -191,16 +191,10 @@ int ff_vaapi_decode_issue(AVCodecContext *avctx,
          av_log(avctx, AV_LOG_ERROR, "Failed to end picture decode "
                 "issue: %d (%s).\n", vas, vaErrorStr(vas));
          err = AVERROR(EIO);
-        if (CONFIG_VAAPI_1 || ctx->hwctx->driver_quirks &
-            AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
-            goto fail;
-        else
-            goto fail_at_end;
+        goto fail;
      }

-    if (CONFIG_VAAPI_1 || ctx->hwctx->driver_quirks &
-        AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
-        ff_vaapi_decode_destroy_buffers(avctx, pic);
+    ff_vaapi_decode_destroy_buffers(avctx, pic);

      err = 0;
      goto exit;
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index f54b2579ec..0e19281ed4 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -618,26 +618,17 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
          av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
                 "%d (%s).\n", vas, vaErrorStr(vas));
          err = AVERROR(EIO);
-        // vaRenderPicture() has been called here, so we should not destroy
-        // the parameter buffers unless separate destruction is required.
-        if (CONFIG_VAAPI_1 || ctx->hwctx->driver_quirks &
-            AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
-            goto fail;
-        else
-            goto fail_at_end;
-    }
-
-    if (CONFIG_VAAPI_1 || ctx->hwctx->driver_quirks &
-        AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
-        for (i = 0; i < pic->nb_param_buffers; i++) {
-            vas = vaDestroyBuffer(ctx->hwctx->display,
-                                  pic->param_buffers[i]);
-            if (vas != VA_STATUS_SUCCESS) {
-                av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
-                       "param buffer %#x: %d (%s).\n",
-                       pic->param_buffers[i], vas, vaErrorStr(vas));
-                // And ignore.
-            }
+        goto fail;
+    }
+
+    for (i = 0; i < pic->nb_param_buffers; i++) {
+        vas = vaDestroyBuffer(ctx->hwctx->display,
+                              pic->param_buffers[i]);
+        if (vas != VA_STATUS_SUCCESS) {
+            av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
+                   "param buffer %#x: %d (%s).\n",
+                   pic->param_buffers[i], vas, vaErrorStr(vas));
+            // And ignore.
          }
      }

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index bf51df0f51..4f4191e23b 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -106,7 +106,6 @@ typedef struct VAAPIEncodeH264Context {

      int aud_needed;
      int sei_needed;
-    int sei_cbr_workaround_needed;
  } VAAPIEncodeH264Context;


@@ -271,19 +270,6 @@ static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,

          *type = VAEncPackedHeaderRawData;
          return 0;
-
-#if !CONFIG_VAAPI_1
-    } else if (priv->sei_cbr_workaround_needed) {
-        // Insert a zero-length header using the old SEI type.  This is
-        // required to avoid triggering broken behaviour on Intel platforms
-        // in CBR mode where an invalid SEI message is generated by the
-        // driver and inserted into the stream.
-        *data_len = 0;
-        *type = VAEncPackedHeaderH264_SEI;
-        priv->sei_cbr_workaround_needed = 0;
-        return 0;
-#endif
-
      } else {
          return AVERROR_EOF;
      }
@@ -681,10 +667,6 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,

      if (priv->sei & SEI_IDENTIFIER && pic->encode_order == 0)
          priv->sei_needed |= SEI_IDENTIFIER;
-#if !CONFIG_VAAPI_1
-    if (ctx->va_rc_mode == VA_RC_CBR)
-        priv->sei_cbr_workaround_needed = 1;
-#endif

      if (priv->sei & SEI_TIMING) {
          priv->sei_pic_timing = (H264RawSEIPicTiming) {
-- 
2.43.0


More information about the ffmpeg-devel mailing list