diff mbox series

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

Message ID 1642070709-3104-3-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,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

Commit Message

Lance Wang Jan. 13, 2022, 10:45 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

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. 13, 2022, 10:01 p.m. UTC | #1
On Thu, 13 Jan 2022, lance.lmwang@gmail.com wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> 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

I don't understand what this bit in the commit message tries to say?


Doesn't this patch have the effect, that if I only specify "-profile 
high", I'll end up with CAVLC unless I specifically pass "-coder cabac" 
too? If coder wasn't specified, I think we should still default to CABAC 
for main/high.

// Martin
Lance Wang Jan. 14, 2022, 3:20 a.m. UTC | #2
On Fri, Jan 14, 2022 at 12:01:26AM +0200, Martin Storsjö wrote:
> On Thu, 13 Jan 2022, lance.lmwang@gmail.com wrote:
> 
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > 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
> 
> I don't understand what this bit in the commit message tries to say?
> 
> 
> Doesn't this patch have the effect, that if I only specify "-profile high",
> I'll end up with CAVLC unless I specifically pass "-coder cabac" too? If
> coder wasn't specified, I think we should still default to CABAC for
> main/high.

Sorry, I'll update the message.
it's high profile, we can't to use cavlc even if specify -coder. Yes, if haven't
set coder, it's preferable to enable cabac for high.

> 
> // Martin
>
diff mbox series

Patch

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 995ee37..91deb6c 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 : 0;
     param.iMultipleThreadIdc         = avctx->thread_count;
 
     /* Allow specifying the libopenh264 profile through AVCodecContext. */
@@ -222,15 +222,15 @@  static av_cold int svc_encode_init(AVCodecContext *avctx)
     switch (s->profile) {
     case FF_PROFILE_H264_HIGH:
         s->profile = PRO_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",
+                s->coder == 1 ? "CABAC" : "CAVLC");
         break;
     case FF_PROFILE_H264_MAIN:
         s->profile = PRO_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",
+                s->coder == 1 ? "CABAC" : "CAVLC");
         break;
     case FF_PROFILE_H264_CONSTRAINED_BASELINE:
     case FF_PROFILE_UNKNOWN: