diff mbox

[FFmpeg-devel,V3,1/2] lavc/vaapi_encode_h264: add "coder" option support

Message ID 86bd3b38-e8ff-1d06-cb4d-8b14b443ff74@gmail.com
State New
Headers show

Commit Message

Jun Zhao Aug. 16, 2017, 2:47 a.m. UTC
V3: Clean the code and add docs for "coder" option base on Steven code review.
V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.
From 5a8927c04ed7b7f4820d26a124df99b5419deab1 Mon Sep 17 00:00:00 2001
From: Jun Zhao <jun.zhao@intel.com>
Date: Tue, 8 Aug 2017 03:33:53 -0400
Subject: [PATCH V3 1/2] lavc/vaapi_encode_h264: add "coder" option support

Follow libx264 style to support "coder" option, and set it to
cabac by default.

Signed-off-by: Yi A Wang <yi.a.wang@intel.com>
Signed-off-by: Jun Zhao <jun.zhao@intel.com>
---
 libavcodec/vaapi_encode_h264.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Steven Liu Aug. 16, 2017, 5:53 a.m. UTC | #1
2017-08-16 10:47 GMT+08:00 Jun Zhao <mypopydev@gmail.com>:
> V3: Clean the code and add docs for "coder" option base on Steven code review.
> V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.



LGTM
Mark Thompson Aug. 20, 2017, 2:04 p.m. UTC | #2
On 16/08/17 03:47, Jun Zhao wrote:
> V3: Clean the code and add docs for "coder" option base on Steven code review.
> V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.

LGTM; applied.

Thanks,

- Mark
diff mbox

Patch

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f9fcd805a4..c658e4e4d6 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -168,6 +168,8 @@  typedef struct VAAPIEncodeH264Options {
     int qp;
     int quality;
     int low_power;
+    // Entropy encoder type
+    int coder;
 } VAAPIEncodeH264Options;
 
 
@@ -783,6 +785,8 @@  static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
     VAEncPictureParameterBufferH264   *vpic = ctx->codec_picture_params;
     VAAPIEncodeH264Context            *priv = ctx->priv_data;
     VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
+    VAAPIEncodeH264Options             *opt =
+        (VAAPIEncodeH264Options*)ctx->codec_options_data;
     int i;
 
     {
@@ -927,8 +931,8 @@  static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
         vpic->num_ref_idx_l0_active_minus1 = 0;
         vpic->num_ref_idx_l1_active_minus1 = 0;
 
-        vpic->pic_fields.bits.entropy_coding_mode_flag =
-            ((avctx->profile & 0xff) != 66);
+        vpic->pic_fields.bits.entropy_coding_mode_flag
+            = opt->coder ? ((avctx->profile & 0xff) != 66) : 0;
         vpic->pic_fields.bits.weighted_pred_flag = 0;
         vpic->pic_fields.bits.weighted_bipred_idc = 0;
         vpic->pic_fields.bits.transform_8x8_mode_flag =
@@ -1283,6 +1287,12 @@  static const AVOption vaapi_encode_h264_options[] = {
     { "low_power", "Use low-power encoding mode (experimental: only supported "
       "on some platforms, does not support all features)",
       OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
+    { "coder", "Entropy coder type",
+      OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" },
+        { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "coder" },
+        { "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS, "coder" },
+        { "vlc",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "coder" },
+        { "ac",    NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS, "coder" },
     { NULL },
 };