[FFmpeg-devel,V2] lavc/vaapi_encode_h264: add "coder" option support

Submitted by Jun Zhao on Aug. 9, 2017, 1:39 a.m.

Details

Message ID 10c31d14-113b-ce88-16ea-00048e32e858@gmail.com
State Superseded
Headers show

Commit Message

Jun Zhao Aug. 9, 2017, 1:39 a.m.
V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.
From 28e4dc3533be2b7c7493a08de7143c042c9923c1 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 V2] lavc/vaapi_encode_h264: add "coder" option support

Follow libx264 style to support coder option, default is
enabled cabac.

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 | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Jun Zhao Aug. 15, 2017, 12:48 a.m.
ping?

On 2017/8/9 9:39, Jun Zhao wrote:
> V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.
>
Steven Liu Aug. 15, 2017, 2:41 a.m.
2017-08-15 8:48 GMT+08:00 Jun Zhao <mypopydev@gmail.com>:
> ping?
No Documentation for the coder options?
>
> On 2017/8/9 9:39, Jun Zhao wrote:
>> V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.
>>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Jun Zhao Aug. 15, 2017, 3:23 a.m.
On 2017/8/15 10:41, Steven Liu wrote:
> 2017-08-15 8:48 GMT+08:00 Jun Zhao <mypopydev@gmail.com>:
>> ping?
> No Documentation for the coder options?

Do you means man page or the other docs ?

>>
>> On 2017/8/9 9:39, Jun Zhao wrote:
>>> V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.
>>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Steven Liu Aug. 15, 2017, 3:33 a.m.
2017-08-15 11:23 GMT+08:00 Jun Zhao <mypopydev@gmail.com>:
>
>
> On 2017/8/15 10:41, Steven Liu wrote:
>> 2017-08-15 8:48 GMT+08:00 Jun Zhao <mypopydev@gmail.com>:
>>> ping?
>> No Documentation for the coder options?
>
> Do you means man page or the other docs ?
doc/encoders.texi
 This one.
>
>>>
>>> On 2017/8/9 9:39, Jun Zhao wrote:
>>>> V2: Follow libx264 "coder" option style, base on Hendrik Leppkes code review.
>>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>

Patch hide | download patch | download mbox

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f9fcd805a4..4e1df182a0 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,12 @@  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);
+        if (opt->coder) {
+            vpic->pic_fields.bits.entropy_coding_mode_flag =
+                ((avctx->profile & 0xff) != 66);
+        } else {
+            vpic->pic_fields.bits.entropy_coding_mode_flag = 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 +1291,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 },
 };