From patchwork Sat Oct 27 22:19:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 10807 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 B576044D94D for ; Sun, 28 Oct 2018 01:20:05 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E30D689EEC; Sun, 28 Oct 2018 01:19:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9D763689B90 for ; Sun, 28 Oct 2018 01:19:30 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id d17-v6so4410280wre.11 for ; Sat, 27 Oct 2018 15:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=chKaemagXOqDCwoEefqLHs5QLS864nzWIkOLcdu2Ipk=; b=mdinZsOlhbT9FLErRfvz61Oeq7UZQ1qBPElRgSClBLN9EIKOvh2K+UitBjuTZrIrzv ZLjJZh2I3suF1loahTExNL+UD6XL3DT+I749idzO65tKY+Vw6MzQpjnhq9BAXDvMSyFe 2RKCI3WgHQSvRz5DEfM8T3MPYlYDnsnP7iw980kBJq8ZagEUoYXUTVWIUTUy9Mqed8pE k8hoHyxD4EncoLG63GqoqvgQ00W6qc6tGpOlrAy20Obp5djfOmPZRJzY7yCFXLXsnzPS rRhkPzIhV8ZWLy/mvu0j8/fcMGcHsZLrzX/82dh/Bfl0xov3xE7TWEr3bn7o8m8qkolQ NBlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=chKaemagXOqDCwoEefqLHs5QLS864nzWIkOLcdu2Ipk=; b=jGreqrT9OKv+2rxx18Z5BAYPfYYx/52RUL3Dj7Y+yC2Y5JFjV6HXiEcTsm/giHw4Qt gqPKMn0sU6JZ+PIJeFmoYA9juGiSOvjR6pRy8HjktuEjxR3z/OPcbRKpdXld2tQ0+7Lz 6hzjaCvOzoQsRvQpMURzd6dd+bdlkBo7HuMe0Q+7k4XZCQ3uam5LCKIOcl7VkkjLnD8d kswvv0cRLzlzUPefk1r2k3h2bqwh95mbX35huB1juteJoIh0x1bgjz9ybNi6el0qAH0w vQE44QYPjv/vQKQP8RYILx09EIw7NmLne8LqR1WxVsgpie19EVfzJiWlgZmh1fCGUyVr Ghxw== X-Gm-Message-State: AGRZ1gLydPLoxvMnZxvW7wG7u0IZqcFlUasiCvc/umRKKlfJZAskRWlL dIgk2r3UFXSeA37E7ZD7Kpzv2JDqbxk= X-Google-Smtp-Source: AJdET5cQcvVJQQH9X96cTmCXh+0C6f+dQFK29eTeWNi/bUanW8jYy1WylBXr+V3OSa1jqHIjxM4JHA== X-Received: by 2002:adf:92a6:: with SMTP id 35-v6mr10363206wrn.137.1540678799824; Sat, 27 Oct 2018 15:19:59 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id v189-v6sm1255527wmd.40.2018.10.27.15.19.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 15:19:59 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Sat, 27 Oct 2018 23:19:50 +0100 Message-Id: <20181027221954.8589-2-sw@jkqxz.net> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181027221954.8589-1-sw@jkqxz.net> References: <20181027221954.8589-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/6] lavc/h265_profile_level: Fix DPB size calculation 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" The maxDpbPicBuf value which is used in the DPB size calculation depends on the profile (it's usually 6, but 7 for screen-extended profiles). --- libavcodec/h265_profile_level.c | 86 ++++++++++++++++----------------- libavcodec/h265_profile_level.h | 1 + 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c index 6604ca254d..692252bb4d 100644 --- a/libavcodec/h265_profile_level.c +++ b/libavcodec/h265_profile_level.c @@ -43,76 +43,76 @@ static const H265ProfileDescriptor h265_profiles[] = { // profile_idc 8bit one-picture // HT-profile | 422chroma | lower-bit-rate // | 14bit | | 420chroma | | CpbVclFactor MinCrScaleFactor - // | | 12bit | | | monochrome| | CpbNalFactor | + // | | 12bit | | | monochrome| | CpbNalFactor | maxDpbPicBuf // | | | 10bit | | | intra | | | FormatCapabilityFactor - { "Monochrome", // | | | | | | | | | | - 4, 0, 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 667, 733, 1.000, 1.0 }, + { "Monochrome", // | | | | | | | | | | | + 4, 0, 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 667, 733, 1.000, 1.0, 6 }, { "Monochrome 12", - 4, 0, 2, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1000, 1100, 1.500, 1.0 }, + 4, 0, 2, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1000, 1100, 1.500, 1.0, 6 }, { "Monochrome 16", - 4, 0, 2, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1333, 1467, 2.000, 1.0 }, + 4, 0, 2, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1333, 1467, 2.000, 1.0, 6 }, { "Main", - 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0 }, + 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0, 6 }, { "Screen-Extended Main", - 9, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.500, 1.0 }, + 9, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.500, 1.0, 7 }, { "Main 10", - 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.875, 1.0 }, + 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.875, 1.0, 6 }, { "Screen-Extended Main 10", - 9, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.875, 1.0 }, + 9, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.875, 1.0, 7 }, { "Main 12", - 4, 0, 2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1500, 1650, 2.250, 1.0 }, + 4, 0, 2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1500, 1650, 2.250, 1.0, 6 }, { "Main Still Picture", - 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0 }, + 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0, 6 }, { "Main 4:2:2 10", - 4, 0, 2, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1667, 1833, 2.500, 0.5 }, + 4, 0, 2, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1667, 1833, 2.500, 0.5, 6 }, { "Main 4:2:2 12", - 4, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, + 4, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 6 }, { "Main 4:4:4", - 4, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, + 4, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 6 }, { "High Throughput 4:4:4", - 5, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, + 5, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 6 }, { "Screen-Extended Main 4:4:4", - 9, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, + 9, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 7 }, { "Screen-Extended High Throughput 4:4:4", - 9, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, + 9, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 7 }, { "Main 4:4:4 10", - 4, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, + 4, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 6 }, { "High Throughput 4:4:4 10", - 5, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, + 5, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 6 }, { "Screen-Extended Main 4:4:4 10", - 9, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, + 9, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 7 }, { "Screen-Extended High Throughput 4:4:4 10", - 9, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, + 9, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 7 }, { "Main 4:4:4 12", - 4, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3000, 3300, 4.500, 0.5 }, + 4, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3000, 3300, 4.500, 0.5, 6 }, { "High Throughput 4:4:4 14", - 5, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5 }, + 5, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5, 6 }, { "Screen-Extended High Throughput 4:4:4 14", - 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5 }, + 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5, 7 }, { "Main Intra", - 4, 0, 2, 1, 1, 1, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.500, 1.0 }, + 4, 0, 2, 1, 1, 1, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.500, 1.0, 6 }, { "Main 10 Intra", - 4, 0, 2, 1, 1, 0, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.875, 1.0 }, + 4, 0, 2, 1, 1, 0, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.875, 1.0, 6 }, { "Main 12 Intra", - 4, 0, 2, 1, 0, 0, 1, 1, 0, 1, 0, 2, 1500, 1650, 2.250, 1.0 }, + 4, 0, 2, 1, 0, 0, 1, 1, 0, 1, 0, 2, 1500, 1650, 2.250, 1.0, 6 }, { "Main 4:2:2 10 Intra", - 4, 0, 2, 1, 1, 0, 1, 0, 0, 1, 0, 2, 1667, 1833, 2.500, 0.5 }, + 4, 0, 2, 1, 1, 0, 1, 0, 0, 1, 0, 2, 1667, 1833, 2.500, 0.5, 6 }, { "Main 4:2:2 12 Intra", - 4, 0, 2, 1, 0, 0, 1, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5 }, + 4, 0, 2, 1, 0, 0, 1, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5, 6 }, { "Main 4:4:4 Intra", - 4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5 }, + 4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5, 6 }, { "Main 4:4:4 10 Intra", - 4, 0, 2, 1, 1, 0, 0, 0, 0, 1, 0, 2, 2500, 2750, 3.750, 0.5 }, + 4, 0, 2, 1, 1, 0, 0, 0, 0, 1, 0, 2, 2500, 2750, 3.750, 0.5, 6 }, { "Main 4:4:4 12 Intra", - 4, 0, 2, 1, 0, 0, 0, 0, 0, 1, 0, 2, 3000, 3300, 4.500, 0.5 }, + 4, 0, 2, 1, 0, 0, 0, 0, 0, 1, 0, 2, 3000, 3300, 4.500, 0.5, 6 }, { "Main 4:4:4 16 Intra", - 4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5 }, + 4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 }, { "Main 4:4:4 Still Picture", - 4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 1, 2, 2000, 2200, 3.000, 0.5 }, + 4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 1, 2, 2000, 2200, 3.000, 0.5, 6 }, { "Main 4:4:4 16 Still Picture", - 4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 2, 4000, 4400, 6.000, 0.5 }, + 4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 2, 4000, 4400, 6.000, 0.5, 6 }, { "High Throughput 4:4:4 16 Intra", - 5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5 }, + 5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 }, }; @@ -231,14 +231,14 @@ const H265LevelDescriptor *ff_h265_guess_level(const H265RawProfileTierLevel *pt if (bitrate > (int64_t)profile->cpb_nal_factor * hbr_factor * max_br) continue; - if (pic_size < (level->max_luma_ps >> 2)) - max_dpb_size = 16; - else if (pic_size < (level->max_luma_ps >> 1)) - max_dpb_size = 14; - else if (pic_size < (3 * level->max_luma_ps >> 2)) - max_dpb_size = 9; + if (pic_size <= (level->max_luma_ps >> 2)) + max_dpb_size = FFMIN(4 * profile->max_dpb_pic_buf, 16); + else if (pic_size <= (level->max_luma_ps >> 1)) + max_dpb_size = FFMIN(2 * profile->max_dpb_pic_buf, 16); + else if (pic_size <= (3 * level->max_luma_ps >> 2)) + max_dpb_size = FFMIN(4 * profile->max_dpb_pic_buf / 3, 16); else - max_dpb_size = 7; + max_dpb_size = profile->max_dpb_pic_buf; if (max_dec_pic_buffering > max_dpb_size) continue; diff --git a/libavcodec/h265_profile_level.h b/libavcodec/h265_profile_level.h index 12c00f0077..2d5bebaecd 100644 --- a/libavcodec/h265_profile_level.h +++ b/libavcodec/h265_profile_level.h @@ -66,6 +66,7 @@ typedef struct H265ProfileDescriptor { uint16_t cpb_nal_factor; float format_capability_factor; float min_cr_scale_factor; + uint8_t max_dpb_pic_buf; } H265ProfileDescriptor;