From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 633D04359D for ; Mon, 18 Jul 2022 12:35:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DEB3E68B88F; Mon, 18 Jul 2022 15:35:36 +0300 (EEST) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5195068B78C for ; Mon, 18 Jul 2022 15:35:30 +0300 (EEST) Received: by mail-ot1-f45.google.com with SMTP id br15-20020a056830390f00b0061c9d73b8bdso2920433otb.6 for ; Mon, 18 Jul 2022 05:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=nsY7VnHWvsoo5r36nmbUZrwR65vGtppyFQkk58sTIko=; b=eYVvn9nztIhipicm125b2AFPktEno8x62E3c1wLbanA/RwcvhwyhQu+1EIbWebH9XF n8cU7y3Y+vU1hxRWUt3g780O8rx5Y0QIOzbJMknTqkAdnw0Te52oX24m5bKMpBybepl0 duJYw6b47CWNQTqOnbFNycRDK/eaLoGI1pAZ9W+nEiqOi6dgwLrZxm4cpFSaHWTg6yEu zQj8ndf52LfQ1ccqS9fZ3wbopituH48kMlbn+UZz2n4EFitAdnKCwcr+uiR4Ta4lyzNd lZlp8VQWkVR1FoQQru7Od/iCSvvlVWcG/3o5qeL/I3a4YaQYt1MErAqT0oWgnSRrhvY8 nYdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=nsY7VnHWvsoo5r36nmbUZrwR65vGtppyFQkk58sTIko=; b=Abs02k2UwcymGJGxRuf1Yyx+zsRZL7KY8PBpoZJM2TFwJZiN6vLYNylahkKXZ8ncnx d5Qp6JlN1rerOKFSc/PiXSAyM6ZNFAcIqaKeGYAnmq7wv88VH6d36j6cP1Lq5vlU22LX Y2zq3jKy1FYffMyVwNdnHYPjAQPvzCt/y4ZSiOGMcm54fIdwshmNcB7P7nX7IBmOT1yB PxSRR0XuFKv+IilvkHyYkrg9I1mxfDhqmnynOBQ1VoG/hEdG/K7SoOeWsgJE0NzMfj3c XgaACrHANSHd5Nu+q0Q213R65Ryxw4fogjsQwJ2pEqWvoF9Ywmiu8ckwdPnFC2uKyf20 7VBQ== X-Gm-Message-State: AJIora8LklL87Eh/Yiwa/9gsq3zUQvesUmCCtAw/BynyB0D7RZzBySpi iRVZSKag+8v7HooOZsuYp3G/Fnlnvtwc9A== X-Google-Smtp-Source: AGRyM1vToMQPUJUQkZX3LKT4UxmjIANP+EoOvPF63u7JQinQ5H0p4zRUmwT0T89AqwPmF3vBY+3HfA== X-Received: by 2002:a05:6830:40ca:b0:60c:2a46:a4b1 with SMTP id h10-20020a05683040ca00b0060c2a46a4b1mr10807284otu.215.1658147728091; Mon, 18 Jul 2022 05:35:28 -0700 (PDT) Received: from [192.168.0.13] ([186.136.131.204]) by smtp.gmail.com with ESMTPSA id n3-20020a0568080a0300b0033a76d3ad29sm932859oij.47.2022.07.18.05.35.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Jul 2022 05:35:27 -0700 (PDT) Message-ID: <7132588d-a8c2-6d23-4c9e-ac7539866cdb@gmail.com> Date: Mon, 18 Jul 2022 09:35:30 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220717192700.1077-1-anton@khirnov.net> <20220717192700.1077-2-anton@khirnov.net> From: James Almer In-Reply-To: <20220717192700.1077-2-anton@khirnov.net> Subject: Re: [FFmpeg-devel] [PATCH 2/4] lavc: add API for exporting reconstructed frames from encoders X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 7/17/2022 4:26 PM, Anton Khirnov wrote: > diff --git a/libavcodec/encode.c b/libavcodec/encode.c > index 1f39ab1a2f..f15309ce09 100644 > --- a/libavcodec/encode.c > +++ b/libavcodec/encode.c > @@ -594,6 +594,18 @@ int ff_encode_preinit(AVCodecContext *avctx) > return AVERROR(ENOMEM); > } > > + if ((avctx->flags & AV_CODEC_FLAG_RECON_FRAME)) { > + if (!(avctx->codec->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME)) { > + av_log(avctx, AV_LOG_ERROR, "Reconstructed frame output requested " > + "from an encoder not supporting it\n"); > + return AVERROR(ENOSYS); > + } > + > + avci->recon_frame = av_frame_alloc(); > + if (!avci->recon_frame) > + return AVERROR(ENOMEM); > + } > + > return 0; > } > > @@ -630,3 +642,16 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame) > > return 0; > } > + > +int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame) > +{ > + AVCodecInternal *avci = avctx->internal; > + > + if (!avci->recon_frame) > + return AVERROR(EINVAL); > + if (!avci->recon_frame->buf[0]) > + return avci->draining_done ? AVERROR_EOF : AVERROR(EAGAIN); > + > + av_frame_move_ref(frame, avci->recon_frame); The API for avcodec_receive_frame() mentions frame will be unref'd first thing, so you should do that before even the recon_frame checks. > + return 0; > +} _______________________________________________ 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".