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;