From patchwork Fri Jan 14 09:55:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 33591 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp177528iog; Fri, 14 Jan 2022 01:55:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzr6WqsD+S+28UEix2TuAbTDd/aeQl5JB6+dkOXdV4tgFBoBX6ocmvYX9vUjs0Sv4a7LsRn X-Received: by 2002:a17:907:1ca2:: with SMTP id nb34mr6412337ejc.67.1642154134808; Fri, 14 Jan 2022 01:55:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642154134; cv=none; d=google.com; s=arc-20160816; b=elgGoDucovHsdgTMwKj+U6dypHYS9lT1ZI17bMA/leJuD5gzlmp/z3ieQhsXt0QKHt 8QVgNUCap95ecyrSNApmghYLmN74ReMuvX2+POfg1OjX4fsJVYQ5YGAwZyzJ6w1gBG8n 3F0bbXbcTKmJ33wNFvYIi5A7faIaSsDN7CEcDj0e7LRSSH37vZRPUsnUnhaUJ5b10xfR 4FrBqqmjRkcjWUCi5vi2gDKHVsFh5/6P5ztsAU/JSrfjgcG2Y4BKGt0JveXyQWmRCMkY RMZTEQi93bWK9sV3CZwOamkKFmU/F/qiZqkgPhdjPxkf8lXlGECKRerj4RfbHWLxXMuK LeAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=gmiwmEUUumspgnqTcMiAMGobCaiKmyjJqSTkCU7jl6A=; b=WpQmQmuybB6Y5PbObLZR1aBwcNLncgGq1yW1H7NsDcvG4tl5f/syyFETiHs1s+rhvG TagrhzmClGf4jmydgFjcI79mExAer0xOuKw4D3/IxRFQexGy/BGrm/8ESAOrI3AOtLkb T1eswIIA2hXl3dpTXyDNN61ZF5Ca5LEEi8juwD33rklXJm1xwruuJKNUdcT6dQvsQGNp lo4j5uoXK38NB+fFBRnsRpav4pkvdXrezm8Y2BAlV0tx3sRg4VsTIAI4JQT9NzWJ7v7A Wln2M3MwlArVUc8uBQQpf8FoNXWFjlmpmifLnGGFlrrH82HlluXHAmr0z/NPf0r7cFSn v5bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=e1Uq2pmR; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hd41si2963792ejc.817.2022.01.14.01.55.34; Fri, 14 Jan 2022 01:55:34 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=e1Uq2pmR; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 842CD68B35D; Fri, 14 Jan 2022 11:55:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 626A568B317 for ; Fri, 14 Jan 2022 11:55:25 +0200 (EET) Received: by mail-pf1-f175.google.com with SMTP id 78so2314864pfu.10 for ; Fri, 14 Jan 2022 01:55:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eMGAOTjXmLwU7IOxuUw7O0qqCKhZhICMXgLJSgZn3zw=; b=e1Uq2pmRz9EyP8L6GUA1GyFQbGTDSBG1HzejxSXDj7dRlJV32ZZxqZgsa7vdsb+kHN y/SLWbXUtEkdVTFmVaTW2KWwEkbKOFvB59Y/IWL0sF8nkXNBl061iE/wnsU1rAoO2FrX RWxrp0RyBk9+0Z55pqTg9G7ck7QDkZnpnY3ERE2hg+LJ01p37z3yeesjfo9Pu8NqcADc X97OwXi+pTCHPnQPkJVl4IR4h02euyjRA8foMWkrUY1EhQ43vclVF6VXXzsbo3ZOOA8W ruLckb4S+rHkQEJKKeuQDBdyNeSsLIjDGFZV54xHOrxBBXKxU67uIJ+2kUbLy0kl4wQ4 DSVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eMGAOTjXmLwU7IOxuUw7O0qqCKhZhICMXgLJSgZn3zw=; b=5SZSWmyICJU2T4hxiwerS7ZcZVijyFm1eNSotEyeR+GcAOJ0Ms4s2HVS+LtrER51ma 1BDd3LoNZV2h0Tsj+luHmsnGzekjSOXHldu9X2ImuZ0dQPQeZSio3rF8SmZ8MCVvJcQN 41is2GKp5Ldy+Btmqc6vaNf4p7WzyncFn3EXB+co4OrOSIgLjLrI/nYszpUQ9CXSNE5x KVTKKBk4KRVLzpGICunHrhCsxYJ3Hq8W5NyLx6esQ+D/ImKKHFWpuS1QtsvwuWRosxtH OdC0LBwQJtlp34fVMb7CsErbSnMa2GaOaZ1tsy+cuU5laSEpX2Wp547z1PdMCOGJh4X1 ZL0Q== X-Gm-Message-State: AOAM5313lVAJK2yTcRwptHzTqcWE1f12Md4nY0hcDDYSfhgm2wngW1jy mxhWnAIyVsiEUHRqRi4A/d8fUyTDKVg= X-Received: by 2002:a63:6886:: with SMTP id d128mr7448675pgc.418.1642154123398; Fri, 14 Jan 2022 01:55:23 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id l12sm5535400pfc.181.2022.01.14.01.55.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jan 2022 01:55:23 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Jan 2022 17:55:15 +0800 Message-Id: <1642154117-24138-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642070709-3104-1-git-send-email-lance.lmwang@gmail.com> References: <1642070709-3104-1-git-send-email-lance.lmwang@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/3] avcodec/libopenh264enc: support for colorspace and range information X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Limin Wang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: NVDXxnryOFGV From: Limin Wang Reviewed-by: Martin Storsjö Signed-off-by: Limin Wang --- libavcodec/libopenh264enc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index de4b85c..5b5914c 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -330,6 +330,28 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) } } +#if OPENH264_VER_AT_LEAST(1, 6) + param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF; + if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) { + param.sSpatialLayers[0].bVideoSignalTypePresent = true; + param.sSpatialLayers[0].bFullRange = (avctx->color_range == AVCOL_RANGE_JPEG); + } + + if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED || + avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || + avctx->color_trc != AVCOL_TRC_UNSPECIFIED) { + param.sSpatialLayers[0].bVideoSignalTypePresent = true; + param.sSpatialLayers[0].bColorDescriptionPresent = true; + } + + if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED) + param.sSpatialLayers[0].uiColorMatrix = avctx->colorspace; + if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) + param.sSpatialLayers[0].uiColorPrimaries = avctx->color_primaries; + if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED) + param.sSpatialLayers[0].uiTransferCharacteristics = avctx->color_trc; +#endif + if ((*s->encoder)->InitializeExt(s->encoder, ¶m) != cmResultSuccess) { av_log(avctx, AV_LOG_ERROR, "Initialize failed\n"); return AVERROR_UNKNOWN; From patchwork Fri Jan 14 09:55:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 33592 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp177629iog; Fri, 14 Jan 2022 01:55:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxK1qkHFgsZUQzffxG/tlh/AQj3kWAdekHKB8JC9hnzAwq0QrwphL5jw9MDMMVm49t1YUSD X-Received: by 2002:a17:906:f2c8:: with SMTP id gz8mr5379478ejb.220.1642154143387; Fri, 14 Jan 2022 01:55:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642154143; cv=none; d=google.com; s=arc-20160816; b=wys1h+fUwYWnnnBXGTlS6DCBoTH9QJargMjc7/pBw0kmiB/Fk9j1RbD1KRjhcp7Thn 9hJAVHKDCa7D13cjQNZdSardAbOD2ihHITkFmxhYJNN7mcHXCWuAWYcpy7nP/UBbKhWg u9IpXBqYS+AZJkjwzugoaIjIdn/noKM+kaWaRDvFslCT8JoTHyrWyb+n6XZCkcZSPjzl Vta5zpVSIKE1/IggXS49dzBFf3zyqhX/yyTCUzg0E/ohEAKOF5pWB9fKIU3QfkU8gulL YuQO4jcRvHOckZuoeKw1+NaDsA/dcCsvUoqTiZEhLnEBhzWknMnEQXjVvr27pjgtQJHC Yhgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=pxyz+HsEcyixBO0UD8d+qRJB2AhzB+5LHTV+0eiwMbY=; b=P+mVXx36Ek655a54WdDKV3HEGkTTkIIwKUoPzg1Il4ku+pmuTDXLQY125KZsUbl+7F nJ85vU62gfxtGakHyVerEvqC92rvCmfPqJQh/BmMVqU9vUQmCINs9x3oQmuR98rPmacQ zdf6cvvtO+tp1ZdUkt7DqrEDnOIVSuvaIl+kJ5IZMwVsdbBsTq3MLvBimwGHPq67j7pF cgSi8KX/MIKatbKFOilgAQK+ZJ2QzhEDoqaAA4I2/UtIKlKlB1eIMTrwmvL+mS3AnCDw b6YGT5txPBg4kT+gASHu5PrVHmmnruLETI+KlykmxmdgLwuqKhTz35G9J2oouUIdBhT8 bFPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=eRlv3NRi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a17si2717591edu.311.2022.01.14.01.55.43; Fri, 14 Jan 2022 01:55:43 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=eRlv3NRi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7C07E68B504; Fri, 14 Jan 2022 11:55:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A388368B366 for ; Fri, 14 Jan 2022 11:55:26 +0200 (EET) Received: by mail-pj1-f49.google.com with SMTP id ie23-20020a17090b401700b001b38a5318easo13659545pjb.2 for ; Fri, 14 Jan 2022 01:55:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oHMKE5FTh65UKWhBMwygamlODY/qfCG9kWRNNJ0v0sQ=; b=eRlv3NRiMQlNpFXncV+SxBM04ghfh4jdgZM9iD6aPBXOgBsC16c4XyBqS1v4s/Oj2L zyccIfLAdL3iqO+zQQcpS5zAHZCp+ytpPZ9tQZEtPKyFN+EI/5woatQrEBDsBfUzrSvL DK3kqSOvwvCqC7RLL1WKR5Mkcgs+ZE5VeGz2/WWuzPR6eaGs1tThNHDQ7TEa9/yIDrPS Qas+037kTpUnkDJhvWXNN1kc9xDTwYVL42WrgSodmKbb5XeOB3ZxokWja6HWATs2Ydt4 pPNeAt+whJQ8VeLiJSnLg9Ub9jdeXzfMhG3kLEzpLRQiD1SyOpUm4yF6aOG+CqeijAZk 7h7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oHMKE5FTh65UKWhBMwygamlODY/qfCG9kWRNNJ0v0sQ=; b=ln+XfZn28O3v75p22aCUIHOCQYq78gMjC0L/lN7lEL8lUAxLd4RTlytZRWnDD3Npew hIHwDUMKr3XG4Panf3wDRju0zyjuel/Me9EiQepFJt0MPoMzLy8aaAK25vbyf+cCovxC e3VoVHy10SE8i6jiiHmU4rNxtSg3wpnaspcJPeLHSPAUsNOq/YpCexs3WnKbGZC1syFJ 6D8s2kwjf2nThQqyJDPKB4/lsegU7hkim7fE+/HZATlRkrHQih3HBGRyMiadSjs+gsCP 3nXjsgN6FR62ipK6+7zGCpoFcNC/tFK086j3tMg8NwgzsikWwnWLlkrQDJnxWmZRMUrX 8P6w== X-Gm-Message-State: AOAM530Nejc4mrdLF7c+IcO0E+A9WkLVExv/3lFOcd9jFCdYJWXDkVBt UwbQwjSu5M3z9iU/LA9soMpbn+cxmOA= X-Received: by 2002:a17:90b:1bc9:: with SMTP id oa9mr19254637pjb.241.1642154124740; Fri, 14 Jan 2022 01:55:24 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id l12sm5535400pfc.181.2022.01.14.01.55.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jan 2022 01:55:24 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Jan 2022 17:55:16 +0800 Message-Id: <1642154117-24138-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642154117-24138-1-git-send-email-lance.lmwang@gmail.com> References: <1642070709-3104-1-git-send-email-lance.lmwang@gmail.com> <1642154117-24138-1-git-send-email-lance.lmwang@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/3] avcodec/libopenh264enc: make the profile configuablable correctly X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Limin Wang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /1yuY8uOynd0 From: Limin Wang due to the limitations set in d3a7bdd4ac54349aea9150a234478635d50ebd87, you weren't able to use main profile with OpenH264 1.8, or high profile with older versions Reviewed-by: Martin Storsjö Signed-off-by: Limin Wang --- libavcodec/libopenh264enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 5b5914c..1bad233 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -220,26 +220,25 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) #endif switch (s->profile) { -#if OPENH264_VER_AT_LEAST(1, 8) case FF_PROFILE_H264_HIGH: param.iEntropyCodingModeFlag = 1; av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, " "select EProfileIdc PRO_HIGH in libopenh264.\n"); break; -#else case FF_PROFILE_H264_MAIN: param.iEntropyCodingModeFlag = 1; av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, " "select EProfileIdc PRO_MAIN in libopenh264.\n"); break; -#endif - case FF_PROFILE_H264_CONSTRAINED_BASELINE: case FF_PROFILE_UNKNOWN: + s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE; + case FF_PROFILE_H264_CONSTRAINED_BASELINE: param.iEntropyCodingModeFlag = 0; av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, " "select EProfileIdc PRO_BASELINE in libopenh264.\n"); break; default: + s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE; param.iEntropyCodingModeFlag = 0; av_log(avctx, AV_LOG_WARNING, "Unsupported profile, " "select EProfileIdc PRO_BASELINE in libopenh264.\n"); @@ -251,6 +250,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) param.sSpatialLayers[0].fFrameRate = param.fMaxFrameRate; param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate; param.sSpatialLayers[0].iMaxSpatialBitrate = param.iMaxBitrate; + param.sSpatialLayers[0].uiProfileIdc = s->profile; #if OPENH264_VER_AT_LEAST(1, 7) if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) { From patchwork Fri Jan 14 09:55:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 33593 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp177716iog; Fri, 14 Jan 2022 01:55:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzidKoenuI+ZqR6MjSJmxIl7Of6fBGyG/mwECES+Vnf1yFc6bD539/bnmfSrZHVpD/ypEKp X-Received: by 2002:a17:906:31c4:: with SMTP id f4mr6673574ejf.6.1642154152487; Fri, 14 Jan 2022 01:55:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642154152; cv=none; d=google.com; s=arc-20160816; b=cjWxmfo7uTjZAAcW31KipmPcIng3MxQr+eWhIk5iU8Xb1XWr23ML/ol0zTUfdh3sUP b5+tmPpe/WC1wMLQEHmRY5Ns/vVVg0q9evHqMWePEZoprY+TX94WHUz0rBSmY5J+aTcn R3V/LIb2HTVsvbG5DeqrowDj2ZXP/Vg5c2JREChzuqx9k4ahYdwcc4BojxDpP0SShvyg jSMMAo08OczmByjpDMSlQLbxVVmoF5TLIAACPuEREszem0p43sUEEnlM7PYvxgl+uToY yhwPNiFS2wOAqWPllyoVe+GfOHmK//ZuWrTbfocQ1kHvgJgOHyEsuiIQm6WBcogJngZo S73g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=TjfzSxA6V1Dr8WrwdjG0FTpZN7AAmhm29GyhkcSQTJA=; b=r51MCs9Zy5jkW+Nl4AK17o2G58NBT/Xq/hHARsXMjGpzr4h29QLeiRwBLRZ2ZckdlX MyDlGv7c8UAmvVEWVCc3VgPWMSqQBb9kLuqRnh4Xsq4mIwX0J6j56R0RH8UYUvrduSRV xJRcMpxYx+KUeAF+4a12nSncXFXp42vuKquerrQvCYyjhYD/rCse4nlowrSN7eva3nUZ SNLNK4S87qqNc3BZivsvcLndiGwSTjNbgEFzoM73SkPKUrO1tcqW3JEk/IWSEmaG4JG6 m4KPOyYlziyXFxZC249k4wkojwVkUJmHXVdekewxyzdFYqQUhXRw55yMk3Qk9RCXzdlk Ab/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=p3y0c11Z; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t13si3033726edd.590.2022.01.14.01.55.52; Fri, 14 Jan 2022 01:55:52 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=p3y0c11Z; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C7D868B4F9; Fri, 14 Jan 2022 11:55:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C4DB68B317 for ; Fri, 14 Jan 2022 11:55:27 +0200 (EET) Received: by mail-pj1-f43.google.com with SMTP id l10-20020a17090a384a00b001b22190e075so21453784pjf.3 for ; Fri, 14 Jan 2022 01:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PZmUiG/FR/vMkJW+dorrSMk5yEqz310SN/sPk/32AvU=; b=p3y0c11ZBuVUuOKG2HDdKzyWj89TewO4DtKcMKN8G1TpqyjufjyIfNmwR8LHCQq2cH IsvL48x4w3QpFZu9+UtkucvZxnoQIFdWjLXM/qONpgAaPN0RJWkxP0FgQv6nz+94eigZ kLs47eHr9iYkwYAe+Xz58jm1N6cL7gEd3MtjP4ImO3Vr6fe39saOq9SJM2Cz+yGwV7Xm v0FLrV04fruMp1V+AHAm+6IALYekI/Eh/ji3kSWj5E2v/tF0l9cNlKK9OqQtHbC4Hfi+ XT8r8flcfxyFxvNfY4xNcO5SfkJOuqzqTeLOakvl91EAayFxf1zFV8iKlJPa4FMgvxm7 s6LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PZmUiG/FR/vMkJW+dorrSMk5yEqz310SN/sPk/32AvU=; b=p1mwvLFtzuX5+6XPae5zEbcJ2lF/iqdaWmTok4ZijGvwgP4/fy/223wq0TTZr76qrz W/pwjIQpA/WzKM1RNdqymrsdpPC2Wbd9l1UJqpnoIBEhVyRS/BME49l0KzxEuowaSl0d AQLE/30v3j1vRyGyki4f2uv6p68puEBKJ8fmIQAU7B9hSUIyJGGGr0BwQFr9mUDxgjwJ 1D7NdIHI8JNiaTIwMhUuxcw4uo0tWKYZgthUk9Q53y7QixyY+sbZv3KqzkV7+JI/HBRe 7rjmZY039UYQpBvSqTPdMVai9t5kN4Sj0ZR0lqwwrMQM3VvzAwbmrdH0we2pnGdnn7V5 3s+g== X-Gm-Message-State: AOAM530oXMWC1HsLU0KIVh00K/J/J0ubDfP1MffQCGM+LA2xo/8qlTC8 bkIJpXBAl8sF+h2bCuWzSCB3PVKtgf4= X-Received: by 2002:a17:90a:c918:: with SMTP id v24mr19461811pjt.208.1642154125969; Fri, 14 Jan 2022 01:55:25 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id l12sm5535400pfc.181.2022.01.14.01.55.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jan 2022 01:55:25 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Jan 2022 17:55:17 +0800 Message-Id: <1642154117-24138-3-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1642154117-24138-1-git-send-email-lance.lmwang@gmail.com> References: <1642070709-3104-1-git-send-email-lance.lmwang@gmail.com> <1642154117-24138-1-git-send-email-lance.lmwang@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 3/3] avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Limin Wang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mj4fmYI3w7IZ From: Limin Wang For high/main profile, user can choose to use cavlc by specify "-coder cavlc", for default, it'll will use cabac, if it's baseline, we'll use cavlc by specs anyway. 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 Reviewed-by: Martin Storsjö Signed-off-by: Limin Wang --- libavcodec/libopenh264enc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 1bad233..a1e78c9 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 : 1; param.iMultipleThreadIdc = avctx->thread_count; /* Allow specifying the libopenh264 profile through AVCodecContext. */ @@ -221,14 +221,14 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) switch (s->profile) { case FF_PROFILE_H264_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", + param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC"); break; case FF_PROFILE_H264_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", + param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC"); break; case FF_PROFILE_UNKNOWN: s->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;