From patchwork Mon Nov 12 14:18:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 10997 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 6CF0E44DEA0 for ; Mon, 12 Nov 2018 16:19:39 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D693368A385; Mon, 12 Nov 2018 16:19:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3AAF568A37C for ; Mon, 12 Nov 2018 16:19:04 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id j26-v6so9552043wre.1 for ; Mon, 12 Nov 2018 06:19:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WVRUKNpAd0xZm1ZBosurb+21kQdy0XKVbmMIRaIDmMI=; b=Q6Lz0beb9MbrE78ScOC5Uj2xe17ApehQDoRzA2KVzZeWmrEa63q941rkVg5mnYszEL Ypu1MjChZ/yrdAOayweY98lLQdBYJ81Dx24l0ko70xHzIUTiovuOerDHrHK4zNbXoiS3 HdL8t5yYpfuOSjT980oJyr8Cz0lW64bEyzFNe5/FSBH80uVZK691h6dasR1UasKhGu4+ NtFwJ/e3ulMLsKALpC3dy9H3BDGxuBQqKMR8Fcia6QM+VBUQpJEr01TORlW4GTn4qhe1 b4ytKgS/Y1j8WHd3TC8iTVtCgGACt5Clfw8MD81RFIhVg3fPCrRhzG7YR54Hu3qTvTet YCIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WVRUKNpAd0xZm1ZBosurb+21kQdy0XKVbmMIRaIDmMI=; b=Q5N2+wRjmeYVlQa4YVOxt0mq5NUijNG2JuJv3yQEmx8OSW1odpswurVpd6pJy+aAwb 2H1ZlDNLiKulNdI/o1q9+kW8qu626seDvl8GxAwY8N4EGqnsQI1pjk51VMemcd69XbP7 Lm208+09ScYKOzUiW9AGIT+Vz+ttbudVq1MeTH43wk1GWhQb7HmSpobc2klGrqXZHz+7 g97OPbprAdN66iWe/jNs1GNNUyVo5ld2D6NJIkosNryrfA8n13uZFpaq519oCL5pFLoP F13fn0khpQiVlNKHbQDqIf1q1ibatU9WFMjCWwltLPqtNjia697SUD06uQJPGqNLdSnf N5PA== X-Gm-Message-State: AGRZ1gLDrMBsfpI/2oFzhuKpikVH0nP3N9s6xBUDPEovsXIOxny+b86i bBIjwbP7cbrk9CXXVGw+2it29BKr X-Google-Smtp-Source: AJdET5fLJFHHzBG2z24IGYMDDoqkuaoe01na1SeNObwCQiqxKeR+79lPIYheBgmETBXa+3Jvd2RGEg== X-Received: by 2002:adf:d246:: with SMTP id o6-v6mr1102114wri.66.1542032380414; Mon, 12 Nov 2018 06:19:40 -0800 (PST) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.googlemail.com with ESMTPSA id 11-v6sm16981626wmk.26.2018.11.12.06.19.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 06:19:38 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Nov 2018 15:18:15 +0100 Message-Id: <20181112141815.4472-5-andreas.rheinhardt@googlemail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181112141815.4472-1-andreas.rheinhardt@googlemail.com> References: <20181112141815.4472-1-andreas.rheinhardt@googlemail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] h264_metadata: Don't use inferred value of buffering frames 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Using the value of buffering frames inferred from the old level is not a sensible approach when one wants to guess the level. Signed-off-by: Andreas Rheinhardt --- libavcodec/h264_metadata_bsf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 7fe213e8cd..cb3e45e8b3 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -222,7 +222,7 @@ static int h264_metadata_update_sps(AVBSFContext *bsf, if (ctx->level == LEVEL_AUTO) { const H264LevelDescriptor *desc; int64_t bit_rate; - int width, height; + int width, height, frames; if (sps->vui.nal_hrd_parameters_present_flag) { bit_rate = (sps->vui.nal_hrd_parameters.bit_rate_value_minus1[0] + 1) * @@ -236,13 +236,16 @@ static int h264_metadata_update_sps(AVBSFContext *bsf, bit_rate = 0; } + // Don't use max_dec_frame_buffering if it is only inferred. + frames = sps->vui.bitstream_restriction_flag + ? sps->vui.max_dec_frame_buffering : H264_MAX_DPB_FRAMES; + width = 16 * (sps->pic_width_in_mbs_minus1 + 1); height = 16 * (sps->pic_height_in_map_units_minus1 + 1) * (2 - sps->frame_mbs_only_flag); desc = ff_h264_guess_level(sps->profile_idc, bit_rate, - width, height, - sps->vui.max_dec_frame_buffering); + width, height, frames); if (desc) { if ((desc->level_idc == 11) && desc->constraint_set3_flag) // This ensures that for level 1b the correct level