diff mbox series

[FFmpeg-devel,v2,3/3] avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option

Message ID 1642150837-22960-3-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit edd305ed54dd3e16f2edc3ad150178483e67b78a
Headers show
Series [FFmpeg-devel,v2,1/3] avcodec/libopenh264enc: support for colorspace and range information | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished

Commit Message

Limin Wang Jan. 14, 2022, 9 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

For high/main profile, user can choose to use cavlc by specify "-coder cavlc",
for default, it'll will use cabac, if it's baseline, we'll use cavlc by specs anyway.

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc -frames:v 1 -bsf trace_headers -f null -
before the patch:
entropy_coding_mode_flag                                    0 = 1

after the patch:
entropy_coding_mode_flag                                    0 = 0

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/libopenh264enc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Martin Storsjö Jan. 14, 2022, 9:30 a.m. UTC | #1
On Fri, 14 Jan 2022, lance.lmwang@gmail.com wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> For high/main profile, user can choose to use cavlc by specify "-coder cavlc",
> for default, it'll will use cabac, if it's baseline, we'll use cavlc by specs anyway.
>
> ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc -frames:v 1 -bsf trace_headers -f null -
> before the patch:
> entropy_coding_mode_flag                                    0 = 1
>
> after the patch:
> entropy_coding_mode_flag                                    0 = 0
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavcodec/libopenh264enc.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index 8e27edb..4c0997b 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -193,7 +193,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
> #endif
>     param.bPrefixNalAddingCtrl       = 0;
>     param.iLoopFilterDisableIdc      = !s->loopfilter;
> -    param.iEntropyCodingModeFlag     = 0;
> +    param.iEntropyCodingModeFlag     = s->coder >= 0 ? s->coder : 1;
>     param.iMultipleThreadIdc         = avctx->thread_count;
>
>     /* Allow specifying the libopenh264 profile through AVCodecContext. */
> @@ -221,14 +221,14 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
>
>     switch (s->profile) {
>     case FF_PROFILE_H264_HIGH:
> -        param.iEntropyCodingModeFlag = 1;
> -        av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
> -                "select EProfileIdc PRO_HIGH in libopenh264.\n");
> +        av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
> +                "select EProfileIdc PRO_HIGH in libopenh264.\n",
> +                param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
>         break;
>     case FF_PROFILE_H264_MAIN:
> -        param.iEntropyCodingModeFlag = 1;
> -        av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
> -                "select EProfileIdc PRO_MAIN in libopenh264.\n");
> +        av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
> +                "select EProfileIdc PRO_MAIN in libopenh264.\n",
> +                param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
>         break;
>     case FF_PROFILE_H264_CONSTRAINED_BASELINE:
>     case FF_PROFILE_UNKNOWN:
> -- 
> 1.8.3.1

This looks good to me now I think, thanks!

// Martin
diff mbox series

Patch

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 8e27edb..4c0997b 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -193,7 +193,7 @@  static av_cold int svc_encode_init(AVCodecContext *avctx)
 #endif
     param.bPrefixNalAddingCtrl       = 0;
     param.iLoopFilterDisableIdc      = !s->loopfilter;
-    param.iEntropyCodingModeFlag     = 0;
+    param.iEntropyCodingModeFlag     = s->coder >= 0 ? s->coder : 1;
     param.iMultipleThreadIdc         = avctx->thread_count;
 
     /* Allow specifying the libopenh264 profile through AVCodecContext. */
@@ -221,14 +221,14 @@  static av_cold int svc_encode_init(AVCodecContext *avctx)
 
     switch (s->profile) {
     case FF_PROFILE_H264_HIGH:
-        param.iEntropyCodingModeFlag = 1;
-        av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-                "select EProfileIdc PRO_HIGH in libopenh264.\n");
+        av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+                "select EProfileIdc PRO_HIGH in libopenh264.\n",
+                param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
         break;
     case FF_PROFILE_H264_MAIN:
-        param.iEntropyCodingModeFlag = 1;
-        av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
-                "select EProfileIdc PRO_MAIN in libopenh264.\n");
+        av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
+                "select EProfileIdc PRO_MAIN in libopenh264.\n",
+                param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
         break;
     case FF_PROFILE_H264_CONSTRAINED_BASELINE:
     case FF_PROFILE_UNKNOWN: