From patchwork Tue Dec 17 22:42:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wonkap Jang X-Patchwork-Id: 16860 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 E4EDE447699 for ; Wed, 18 Dec 2019 00:42:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCF3268830E; Wed, 18 Dec 2019 00:42:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 440F5688177 for ; Wed, 18 Dec 2019 00:42:27 +0200 (EET) Received: by mail-pl1-f201.google.com with SMTP id z9so4634plo.8 for ; Tue, 17 Dec 2019 14:42:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to; bh=tCd5IUC2fx/XHZqHmv65ZSB4zP1aE3tPULkqJJMqAGw=; b=DcHMOolZ0Gn4vCUbmFGWf4vuUtsiEju6V8Vj60sHk0sR1pfNgvgdXmAgM2lmwad7p+ FPCZTwnxddi3RkR4C3Wyt4FogfOoxunipzyVogPj+llX3nw2/H2thvTq/RlqpA/gS4Gx cPB58MXnQMo3+x49nojx5Ly2G1Sn5Kz/59ZxA0PWLihlYukZXIiaG9pL63Ls8W2LkNOJ GjrXXTAHbja9jj5T67yI18duox6iZ6oIo1iR44qJbxNoSdIok72LBQN+0nmq5Ze+CLvF gveujwm5EKAJJ0sE6VylEqxTANlPvpER1frUjsovK6J1oWtRSRHF+vE2dTWvnZNjI6uN tUTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=tCd5IUC2fx/XHZqHmv65ZSB4zP1aE3tPULkqJJMqAGw=; b=Ia26AiMHr6OB+j03aGBoRI+tEYdKBYHLsxuhK6owKDhq9aZAUB1M4H+W6+11CbiqZC uA22Bq4Oycu0DpXtT3fMEWs10yPh9yE4Tpd+uu8ibpK7/0yRLQfwYnhzSvT5umQeYbTa 2uFCEye6ZcLsQK7ePgu4GsLSuiEr2Yd5nSu+IlwXsQo8mmnojRozKS4P96o+cZSReLu9 ubjMsH0YKmGBsP/vVKaIV5YoVV5oOfyupBIZxEMrfMGetnSKTwQ+m0XNAAIgxGdeczLX +gDISQWWdG7OvoUJM/BwzB5zyvVM+MCeFhyEwVpHXJnniYWScu0HGHaAKITSY70oB234 vGTw== X-Gm-Message-State: APjAAAU7ffUKgRwNx3WKWlF0+vC/XkWVcPrvYjqFrbZ8zEtJdabMQVV6 Rlb3iNiZYlbLmuAXpOJ9ORevP4LkE6t1JSxXigrkgM0NvlzoVjWqJeeencl7yjIFcPTBPGUwfqv F/YVfgIcaH4SUq08/E3hwLSR3VKpeHe48R+S6z2HRrSZgPkh5h+/JJVfsbo3CTeM= X-Google-Smtp-Source: APXvYqz0daswF6YapZZ/GXrtx3sTDPIXpAAUPo+m0VdzzOt2CXpOkJCuMTkG91ZpA9Tb28cEOEx8jNVG8co= X-Received: by 2002:a63:1945:: with SMTP id 5mr28618082pgz.310.1576622545405; Tue, 17 Dec 2019 14:42:25 -0800 (PST) Date: Tue, 17 Dec 2019 14:42:21 -0800 In-Reply-To: <20191217224221.47324-1-wonkap@google.com> Message-Id: <20191217224221.47324-2-wonkap@google.com> Mime-Version: 1.0 References: <20191217224221.47324-1-wonkap@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog From: Wonkap Jang To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 2/2] avcodec/libvpxenc: add a way to explicitly set temporal layer id 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" In order for rate control to correctly allocate bitrate to each temporal layer, correct temporal layer id has to be set to each frame. This commit provides the ability to set correct temporal layer id for each frame. --- libavcodec/libvpxenc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 7612551a56..c225447515 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1527,11 +1527,20 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, #endif if (frame->pict_type == AV_PICTURE_TYPE_I) flags |= VPX_EFLAG_FORCE_KF; - if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8 && frame->metadata) { + if (frame->metadata) { AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", NULL, 0); if (en) { flags |= strtoul(en->value, NULL, 10); } + + memset(&layer_id, 0, sizeof(vpx_svc_layer_id_t)); + + en = av_dict_get(frame->metadata, "temporal_id", NULL, 0); + if (en) { + layer_id.temporal_layer_id = strtoul(en->value, NULL, 10); + layer_id.temporal_layer_id_per_spatial[0] = layer_id.temporal_layer_id; + layer_id_valid = 1; + } } if (sd) {