From patchwork Wed Apr 15 04:53:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 18967 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 568A944B668 for ; Wed, 15 Apr 2020 08:02:00 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3A5BF68BAED; Wed, 15 Apr 2020 08:02:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 41DED68BAE0 for ; Wed, 15 Apr 2020 08:01:55 +0300 (EEST) IronPort-SDR: tPp6emM+uNNxeUCbjWZCuGmiJLFD7CV3w8MnPAgpV4ySAwxmA1AghiedJgwEUbI6r2sr36C6bu tGALyivzFLEQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 22:01:53 -0700 IronPort-SDR: NjcT79F6M7zLcbG7yY7gSBnkoq9NERAlsdwNBL14EOIMra/49uAKVwNshGEmh6pU19kiBYjgYx ZBLJilYa5+SA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,385,1580803200"; d="scan'208";a="288439586" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by fmsmga002.fm.intel.com with ESMTP; 14 Apr 2020 22:01:53 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Apr 2020 12:53:47 +0800 Message-Id: <1586926427-20170-10-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586926427-20170-1-git-send-email-linjie.fu@intel.com> References: <1586926427-20170-1-git-send-email-linjie.fu@intel.com> Subject: [FFmpeg-devel] [PATCH v4 9/9] lavc/libopenh264enc: Add coder option to replace cabac 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" Set DEPRECATED flag to option cabac, replace with coder. Change the default option to -1 and allow the default cabac to be determined by profile. Add FF_API_OPENH264_CABAC macro for cabac to remove this option after LIBAVCODEC_VERSION_MAJOR = 59. Signed-off-by: Linjie Fu --- libavcodec/libopenh264enc.c | 35 ++++++++++++++++++++++++----------- libavcodec/version.h | 3 +++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 4d337d2..6b7aa87 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -46,7 +46,10 @@ typedef struct SVCContext { int max_nal_size; int skip_frames; int skipped; - int cabac; +#if FF_API_OPENH264_CABAC + int cabac; // deprecated +#endif + int coder; // rate control mode int rc_mode; @@ -80,7 +83,15 @@ static const AVOption options[] = { #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 }, +#if FF_API_OPENH264_CABAC + { "cabac", "Enable cabac(deprecated, use coder)", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE|DEPRECATED }, +#endif + { "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, "coder" }, + { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, VE, "coder" }, + { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "coder" }, + { "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "coder" }, + { "vlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "coder" }, + { "ac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "coder" }, { "rc_mode", "Select rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = RC_QUALITY_MODE }, RC_OFF_MODE, RC_TIMESTAMP_MODE, VE, "rc_mode" }, { "off", "bit rate control off", 0, AV_OPT_TYPE_CONST, { .i64 = RC_OFF_MODE }, 0, 0, VE, "rc_mode" }, @@ -129,8 +140,17 @@ static av_cold int svc_encode_init_profile(AVCodecContext *avctx, SEncParamExt * break; } - if (s->profile == FF_PROFILE_UNKNOWN) - s->profile = s->cabac ? FF_PROFILE_H264_HIGH : +#if FF_API_CODER_TYPE && FF_API_OPENH264_CABAC +FF_DISABLE_DEPRECATION_WARNINGS + if (s->coder < 0 && avctx->coder_type == FF_CODER_TYPE_AC) + s->coder = 1; + else + s->coder = s->cabac; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (s->profile == FF_PROFILE_UNKNOWN && s->coder >= 0) + s->profile = s->coder ? FF_PROFILE_H264_HIGH : FF_PROFILE_H264_CONSTRAINED_BASELINE; switch (s->profile) { @@ -349,13 +369,6 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) (*s->encoder)->GetDefaultParams(s->encoder, ¶m); -#if FF_API_CODER_TYPE -FF_DISABLE_DEPRECATION_WARNINGS - if (!s->cabac) - s->cabac = avctx->coder_type == FF_CODER_TYPE_AC; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - if (err = svc_encode_init_params(avctx, ¶m) < 0) return err; diff --git a/libavcodec/version.h b/libavcodec/version.h index 83075e4..7765bc7 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -138,6 +138,9 @@ #ifndef FF_API_OPENH264_SLICE_MODE #define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 59) #endif +#ifndef FF_API_OPENH264_CABAC +#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */