diff mbox series

[FFmpeg-devel,05/10] libavcodec/qsvenc: Add transform skip for hevc_qsv

Message ID 20210126023213.146185-5-wenbin.chen@intel.com
State New
Headers show
Series [FFmpeg-devel,01/10] libavcodec/qsvenc.c: add max_frame_size support for hevc_qsv
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Chen, Wenbin Jan. 26, 2021, 2:32 a.m. UTC
From: Wenbinc-Bin <wenbin.chen@intel.com>

Add transform skip option for hevc_qsv. Command line option
is "transform_skip". By enabling this option, the
transform_skip_enabled_flag in PPS will be set to 1. This option
is only supported in the platform newer than ICL.

Signed-off-by Wenbin Chen <wenbin.chen@intel.com>
---
 libavcodec/qsvenc.c      | 10 ++++++++--
 libavcodec/qsvenc.h      |  1 +
 libavcodec/qsvenc_hevc.c |  3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index a811d06329..f2fcd09ae0 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -304,7 +304,9 @@  static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q,
            info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN);
 
     av_log(avctx, AV_LOG_VERBOSE, "DisableDeblockingIdc: %"PRIu32" \n", co2->DisableDeblockingIdc);
-
+#if QSV_VERSION_ATLEAST(1, 26)
+    av_log(avctx, AV_LOG_VERBOSE, "TransformSkip: %s \n", print_threestate(co3->TransformSkip));
+#endif
 }
 
 static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)
@@ -813,10 +815,14 @@  FF_ENABLE_DEPRECATION_WARNINGS
             av_log(avctx, AV_LOG_WARNING, "Please set max_b_frames(-bf) to 0 to enable P-pyramid\n");
         }
 
+        if (avctx->codec_id == AV_CODEC_ID_HEVC) {
+#if QSV_VERSION_ATLEAST(1, 26)
+            q->extco3.TransformSkip  = q->transform_skip ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
+#endif
 #if QSV_HAVE_GPB
-        if (avctx->codec_id == AV_CODEC_ID_HEVC)
             q->extco3.GPB              = q->gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 #endif
+        }
         q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco3;
 #endif
     }
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 7da6e0a50f..d1de914724 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -197,6 +197,7 @@  typedef struct QSVEncContext {
     int repeat_pps;
     int low_power;
     int gpb;
+    int transform_skip;
 
     int a53_cc;
 
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 347f30655e..07a7e3b2be 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -246,6 +246,9 @@  static const AVOption options[] = {
 
     { "tile_cols",  "Number of columns for tiled encoding",   OFFSET(qsv.tile_cols),    AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, VE },
     { "tile_rows",  "Number of rows for tiled encoding",      OFFSET(qsv.tile_rows),    AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, VE },
+#if QSV_VERSION_ATLEAST(1, 26)
+    { "transform_skip", "Turn this option ON to enable transformskip",   OFFSET(qsv.transform_skip),          AV_OPT_TYPE_INT,    { .i64 = -1},   -1, 1,  VE},
+#endif
 
     { NULL },
 };