diff mbox

[FFmpeg-devel] lavc/vaapi_encode_h264: add "cabac" option support

Message ID a19f5f32-6899-c48f-7e48-1f2360941003@gmail.com
State New
Headers show

Commit Message

Jun Zhao Aug. 8, 2017, 7:40 a.m. UTC
From c95be027e1f109fbcec3102371a6cb0cbfc7e551 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] lavc/vaapi_encode_h264: add "cabac" option support

0 means no-cabac, 1 means enable cabac when profile > baseline.
Default is enable 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 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Hendrik Leppkes Aug. 8, 2017, 7:49 a.m. UTC | #1
On Tue, Aug 8, 2017 at 9:40 AM, Jun Zhao <mypopydev@gmail.com> wrote:
>

Making the option compatible with what libx264 takes, for example,
would probably be best.

ie. libx264 uses for CABAC:
-coder cabac
-coder ac

or for CAVLC:
-coder cavlc
-coder vlc

Check the options table in libx264.c how its done.

- Hendrik
Jun Zhao Aug. 8, 2017, 8:32 a.m. UTC | #2
On 2017/8/8 15:49, Hendrik Leppkes wrote:
> On Tue, Aug 8, 2017 at 9:40 AM, Jun Zhao <mypopydev@gmail.com> wrote:
>>
> 
> Making the option compatible with what libx264 takes, for example,
> would probably be best.
> 
> ie. libx264 uses for CABAC:
> -coder cabac
> -coder ac
> 
> or for CAVLC:
> -coder cavlc
> -coder vlc
> 
> Check the options table in libx264.c how its done.
> 
> - Hendrik

Ok, will follow x264 style. :)

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f9fcd805a4..8107dc62a8 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -168,6 +168,7 @@  typedef struct VAAPIEncodeH264Options {
     int qp;
     int quality;
     int low_power;
+    int cabac;
 } VAAPIEncodeH264Options;
 
 
@@ -783,6 +784,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 +930,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->cabac) {
+            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 +1290,8 @@  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 },
+    { "cabac", "Use CABAC (Context-adaptive binary arithmetic coding) entropy coding.",
+      OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS },
     { NULL },
 };