diff mbox series

[FFmpeg-devel,v3,8/9] lavc/libopenh264enc: allow specifying the profile through AVCodecContext

Message ID 1586599419-21122-9-git-send-email-linjie.fu@intel.com
State Superseded
Headers show
Series patchset for the enhancement of libopenh264 encoder
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 April 11, 2020, 10:03 a.m. UTC
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/libopenh264enc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 3a205b7..df2d6ee 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -119,6 +119,22 @@  static av_cold int svc_encode_init_profile(AVCodecContext *avctx, SEncParamExt *
 {
     SVCContext *s = avctx->priv_data;
 
+    /* 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_CONSTRAINED_BASELINE:
+            s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
+            break;
+        case FF_PROFILE_H264_HIGH:
+            s->profile = FF_PROFILE_H264_HIGH;
+            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_HIGH :
                                 FF_PROFILE_H264_CONSTRAINED_BASELINE;