From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id BA92643DBE
	for <ffmpegdev@gitmailbox.com>; Sat, 10 Dec 2022 00:01:25 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A237B68BD43;
	Sat, 10 Dec 2022 02:01:23 +0200 (EET)
Received: from btbn.de (btbn.de [136.243.74.85])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 20D8B68BC30
 for <ffmpeg-devel@ffmpeg.org>; Sat, 10 Dec 2022 02:01:17 +0200 (EET)
Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 8A3792563D9
 for <ffmpeg-devel@ffmpeg.org>; Sat, 10 Dec 2022 01:01:14 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org;
 s=mail; t=1670630474;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=h+QMwE8qpkHv0nPbHKPb8gz2e/pEo5UDp56y0drwac0=;
 b=YX1n2uvPkMsboUjQn6C63z1qpP7UotXnELmIogPfD0McSw4nKPxzTUvCxRMMQsu7Do3/f/
 +uvFnVXmpa4xcp/a15g+ErmwftU7l3RvTBl66PXF2KeBEKvSSgvy87xX3ghsEETg/htrk2
 nh6dgbRwGYfZ2Cy9qaoLmHxkNzJXTZVqj3qUIKUbcJx/q9CtEX8DAEYgN2viPn5KQAFcXT
 KAgRDyv8tfssB+dowGfeprxmKybNQpv7ONqsgb+eeZNH6kJBsr6LLp8y2lKynWrA4UouL4
 vvpbwCzTGvp8wXReUHQEjPoC3khO3UC9MwHk0P7n7J2EdjsFFTPyBQ3OIfW3NQ==
Message-ID: <f18d46ec-80bb-a89c-646e-ea6fa3e21057@rothenpieler.org>
Date: Sat, 10 Dec 2022 01:01:14 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.5.1
To: ffmpeg-devel@ffmpeg.org
References: <20221205222559.107006-1-timo@rothenpieler.org>
 <20221209141617.13641-1-timo@rothenpieler.org>
 <20221209141617.13641-2-timo@rothenpieler.org>
 <20221209112024.63cdb3b9@fido7>
Content-Language: en-US
From: Timo Rothenpieler <timo@rothenpieler.org>
In-Reply-To: <20221209112024.63cdb3b9@fido7>
Subject: Re: [FFmpeg-devel] [PATCH v2 2/2] avcodec/nvdec: make explicit copy
 of frames unless user requested otherwise
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/f18d46ec-80bb-a89c-646e-ea6fa3e21057@rothenpieler.org/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

On 09.12.2022 20:20, Philip Langdale wrote:
> On Fri,  9 Dec 2022 15:16:17 +0100
> Timo Rothenpieler <timo@rothenpieler.org> wrote:
> 
>> ---
>>   libavcodec/nvdec.c | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
>> index fbaedf0b6b..a477449d14 100644
>> --- a/libavcodec/nvdec.c
>> +++ b/libavcodec/nvdec.c
>> @@ -51,6 +51,8 @@ typedef struct NVDECDecoder {
>>   
>>       CudaFunctions *cudl;
>>       CuvidFunctions *cvdl;
>> +
>> +    int unsafe_output;
>>   } NVDECDecoder;
>>   
>>   typedef struct NVDECFramePool {
>> @@ -344,6 +346,8 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
>>       int cuvid_codec_type, cuvid_chroma_format, chroma_444;
>>       int ret = 0;
>>   
>> +    int unsafe_output = !!(avctx->hwaccel_flags &
>> AV_HWACCEL_FLAG_UNSAFE_OUTPUT); +
>>       sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
>>       if (!sw_desc)
>>           return AVERROR_BUG;
>> @@ -402,7 +406,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
>>       params.CodecType           = cuvid_codec_type;
>>       params.ChromaFormat        = cuvid_chroma_format;
>>       params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size;
>> -    params.ulNumOutputSurfaces = frames_ctx->initial_pool_size;
>> +    params.ulNumOutputSurfaces = unsafe_output ?
>> frames_ctx->initial_pool_size : 1;
>>       ret = nvdec_decoder_create(&ctx->decoder_ref,
>> frames_ctx->device_ref, &params, avctx); if (ret < 0) {
>> @@ -417,6 +421,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
>>       }
>>   
>>       decoder = (NVDECDecoder*)ctx->decoder_ref->data;
>> +    decoder->unsafe_output = unsafe_output;
>>       decoder->real_hw_frames_ref = real_hw_frames_ref;
>>       real_hw_frames_ref = NULL;
>>   
>> @@ -554,7 +559,11 @@ copy_fail:
>>   
>>   finish:
>>       CHECK_CU(decoder->cudl->cuCtxPopCurrent(&dummy));
>> -    return ret;
>> +
>> +    if (ret < 0 || decoder->unsafe_output)
>> +        return ret;
>> +
>> +    return av_frame_make_writable(frame);
>>   }
>>   
>>   int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)
> 
> LGTM
> 
> 

applied
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".