From patchwork Fri Apr 3 15:14:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 18598 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4C314449C73 for ; Fri, 3 Apr 2020 18:21:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 31C8268AF78; Fri, 3 Apr 2020 18:21:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 00C8768AF38 for ; Fri, 3 Apr 2020 18:21:18 +0300 (EEST) IronPort-SDR: UHZ6S49BYdNABCyTq5rzoK9DAwR+bBCgXsl9DioMgPBp8uOUTT1CniGsrwBdUdeL9m+1vQFfbD f65QOTa7xUcg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 08:21:17 -0700 IronPort-SDR: j9pEscdQ2PtlXE5UEhmTzcEXKpqhpZlD5cujGUaXjqs+HJ6sFl1aatdd0WN1Hl+1YGw9LOK908 Fv/G4H4GFgMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,340,1580803200"; d="scan'208";a="273984591" Received: from unknown (HELO icl-dev.sh.intel.com) ([10.239.158.73]) by fmsmga004.fm.intel.com with ESMTP; 03 Apr 2020 08:21:15 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Apr 2020 23:14:51 +0800 Message-Id: <1585926891-23470-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile high option support X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention mode, which determined by iEntropyCodingModeFlag in ParamTranscode(). Signed-off-by: Linjie Fu --- libavcodec/libopenh264enc.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index f02c5fd..d331cfd 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -42,7 +42,7 @@ typedef struct SVCContext { ISVCEncoder *encoder; int slice_mode; // deprecated int loopfilter; - char *profile; + int profile; int max_nal_size; int skip_frames; int skipped; @@ -71,7 +71,11 @@ static const AVOption options[] = { { "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = SM_DYN_SLICE }, 0, 0, VE, "slice_mode" }, #endif { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE }, - { "profile", "set profile restrictions", OFFSET(profile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, + { "profile", "Set profile restrictions", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 0xffff, VE, "profile" }, +#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = value }, 0, 0, VE, "profile" + { PROFILE("constrained_baseline", FF_PROFILE_H264_CONSTRAINED_BASELINE) }, + { PROFILE("high", FF_PROFILE_H264_HIGH) }, +#undef PROFILE { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, { "allow_skip_frames", "allow skipping frames to hit the target bitrate", OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, @@ -107,12 +111,28 @@ static av_cold int svc_encode_init_profile(AVCodecContext *avctx, SEncParamExt * { SVCContext *s = avctx->priv_data; - if (s->profile && !strcmp(s->profile, "main")) - param->iEntropyCodingModeFlag = 1; //< 0:CAVLC 1:CABAC - else if (!s->profile && s->cabac) + if (s->profile == FF_PROFILE_UNKNOWN) + s->profile = s->cabac ? FF_PROFILE_H264_HIGH : + FF_PROFILE_H264_CONSTRAINED_BASELINE; + + switch (s->profile) { + case FF_PROFILE_H264_HIGH: param->iEntropyCodingModeFlag = 1; - else + av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, " + "select EProfileIdc PRO_HIGH in libopenh264.\n"); + break; + case FF_PROFILE_H264_CONSTRAINED_BASELINE: + case FF_PROFILE_UNKNOWN: + param->iEntropyCodingModeFlag = 0; + av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, " + "select EProfileIdc PRO_BASELINE in libopenh264.\n"); + break; + default: param->iEntropyCodingModeFlag = 0; + av_log(avctx, AV_LOG_WARNING, "Unsupported profile, " + "select EProfileIdc PRO_BASELINE in libopenh264.\n"); + break; + } return 0; }