diff mbox series

[FFmpeg-devel,v5,2/3] lavc/libopenh264enc: Allow specifying the profile through AVCodecContext

Message ID 20200506134752.2055-2-linjie.fu@intel.com
State Accepted
Commit e3e2702d400e047d7a12b3c4f7ee666ffdafd090
Headers show
Series [FFmpeg-devel,v5,1/3] lavc/libopenh264enc: Rewrite profile handling
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Fu, Linjie May 6, 2020, 1:47 p.m. UTC
And determine the profile with following priority:
1. s->profile; then
2. avctx->profile; then
3. s->cabac; then
4. a default profile.

This seems more natural in case user somehow sets both avctx->profile and
s->profile.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/libopenh264enc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Martin Storsjö May 12, 2020, 9:37 a.m. UTC | #1
On Wed, 6 May 2020, Linjie Fu wrote:

> And determine the profile with following priority:
> 1. s->profile; then
> 2. avctx->profile; then
> 3. s->cabac; then
> 4. a default profile.
>
> This seems more natural in case user somehow sets both avctx->profile and
> s->profile.
>
> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> ---
> libavcodec/libopenh264enc.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index 12c71ca0e9..4c57fa1c89 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -182,6 +182,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
>     param.iEntropyCodingModeFlag     = 0;
>     param.iMultipleThreadIdc         = avctx->thread_count;
> 
> +    /* Allow specifying the libopenh264 profile through AVCodecContext. */
> +    if (FF_PROFILE_UNKNOWN == s->profile &&
> +        FF_PROFILE_UNKNOWN != avctx->profile)
> +        switch (avctx->profile) {
> +        case FF_PROFILE_H264_HIGH:
> +        case FF_PROFILE_H264_MAIN:
> +        case FF_PROFILE_H264_CONSTRAINED_BASELINE:
> +            s->profile = avctx->profile;
> +            break;
> +        default:
> +            av_log(avctx, AV_LOG_WARNING,
> +                   "Unsupported avctx->profile: %d.\n", avctx->profile);
> +            break;
> +        }
> +
>     if (s->profile == FF_PROFILE_UNKNOWN)
>         s->profile = !s->cabac ? FF_PROFILE_H264_CONSTRAINED_BASELINE :
> #if OPENH264_VER_AT_LEAST(1, 8)
> -- 
> 2.17.1

LGTM

// Martin
diff mbox series

Patch

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 12c71ca0e9..4c57fa1c89 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -182,6 +182,21 @@  FF_ENABLE_DEPRECATION_WARNINGS
     param.iEntropyCodingModeFlag     = 0;
     param.iMultipleThreadIdc         = avctx->thread_count;
 
+    /* Allow specifying the libopenh264 profile through AVCodecContext. */
+    if (FF_PROFILE_UNKNOWN == s->profile &&
+        FF_PROFILE_UNKNOWN != avctx->profile)
+        switch (avctx->profile) {
+        case FF_PROFILE_H264_HIGH:
+        case FF_PROFILE_H264_MAIN:
+        case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+            s->profile = avctx->profile;
+            break;
+        default:
+            av_log(avctx, AV_LOG_WARNING,
+                   "Unsupported avctx->profile: %d.\n", avctx->profile);
+            break;
+        }
+
     if (s->profile == FF_PROFILE_UNKNOWN)
         s->profile = !s->cabac ? FF_PROFILE_H264_CONSTRAINED_BASELINE :
 #if OPENH264_VER_AT_LEAST(1, 8)