From patchwork Sat Nov 24 01:44:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 11133 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 2267244DA8E for ; Sat, 24 Nov 2018 03:45:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9219D68A2AF; Sat, 24 Nov 2018 03:45:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [5.9.118.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB5F168A1F2 for ; Sat, 24 Nov 2018 03:44:54 +0200 (EET) Received: from localhost.localdomain (200116b864f44b005542f295cde90382.dip.versatel-1u1.de [IPv6:2001:16b8:64f4:4b00:5542:f295:cde9:382]) by btbn.de (Postfix) with ESMTPSA id CD5391A72CD; Sat, 24 Nov 2018 02:44:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1543023897; bh=sh0IciHYTOb2fd5LuuxZoUoPiNWWSgaHXE+swlfw0fs=; h=From:To:Cc:Subject:Date; b=EaxJjdBfTAHiiIorALfrfdn93veAKwWBoYngpF8mPVsxpNQ/Pdzx7R3FIbQfdOw5E 43HRRDObywJtteSFp6UJW9Wbx8ahJu/bTLIoZfa48Bt2QrA7DRhv98WkXiD/N9yN5w ss3Cs7xZKAQZQPnK5lTPJvW/HM0Nl7G6ZeDMMS62PPCrtJUHBKXECyYdCehGOgVVLw r1BR9f4YLZzDztRoKDq/lP/HjpFJ3FAEoEait53jeuDNS/KZFBQC5J1g1bAX1obObX 4el/sw7vz5tfJUW5sRN7aYE7w4FeMFliyXinu1UnaPHncNrVbB5yiQ9ZvQfpwL1NcQ hjzO73AwrXekw== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Nov 2018 02:44:45 +0100 Message-Id: <20181124014445.30148-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.17.0 Subject: [FFmpeg-devel] [PATCH] lavc/decode: allow users to shrink the hw frames pool size, if they so desire. 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: Timo Rothenpieler MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/decode.c | 9 +++++---- libavcodec/options_table.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index c89c77c43a..08ae8788a2 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1256,10 +1256,11 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx, AVHWFramesContext *frames_ctx = (AVHWFramesContext*)frames_ref->data; if (frames_ctx->initial_pool_size) { - // If the user has requested that extra output surfaces be - // available then add them here. - if (avctx->extra_hw_frames > 0) - frames_ctx->initial_pool_size += avctx->extra_hw_frames; + // If the user has requested extra/fewer output surfaces be + // available then add/substract them here. + frames_ctx->initial_pool_size += avctx->extra_hw_frames; + if (avctx->extra_hw_frames < 0) + av_log(avctx, AV_LOG_WARNING, "Decreasing hwaccel frame pool size!\n"); // If frame threading is enabled then an extra surface per thread // is also required. diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 099261e168..af0ab1cfe0 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -478,7 +478,7 @@ static const AVOption avcodec_options[] = { {"ignore_level", "ignore level even if the codec level used is unknown or higher than the maximum supported level reported by the hardware driver", 0, AV_OPT_TYPE_CONST, { .i64 = AV_HWACCEL_FLAG_IGNORE_LEVEL }, INT_MIN, INT_MAX, V | D, "hwaccel_flags" }, {"allow_high_depth", "allow to output YUV pixel formats with a different chroma sampling than 4:2:0 and/or other than 8 bits per component", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"}, {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, INT_MAX, V | D, "hwaccel_flags"}, -{"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, +{"extra_hw_frames", "Number of extra hardware frames to allocate for the user, negative values are supported at own risk", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, V|D }, {NULL}, };