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 38D7148C9E for ; Wed, 24 Jan 2024 08:19:06 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 28E6168D142; Wed, 24 Jan 2024 10:17:38 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2703E68C99B for ; Wed, 24 Jan 2024 10:17:27 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=kTt/HXHO; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 19A671A31 for ; Wed, 24 Jan 2024 09:17:23 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id M_Uv95fDY7b1 for ; Wed, 24 Jan 2024 09:17:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706084239; bh=wieDiuN1R+wBNOnb87ryG+OMSyD8LIpMh/PFa7349Ps=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kTt/HXHO1KZLtXNFA3zD1OeWtj+U8haE8pTU/gudU4ZL0vuTql+iThrc1F+eI411m es+aSQhYGgrmbbzRcwzfMUvdPd644Ozry67jfJe/gnogiBmeXAfN7ZlduaTegOq+Dp +zW1y+st7w2pU/rVTJ5D8JY6EgS56UVQ0dFFOTANGXc88Z5Yd9l7OKWWFJGPw71+x2 UcnWKUcbVKel0tDgB21qdY/Qg18p5/ASZPzojhw/j3pTcDwf+0maww8Z77cl4MwsQW Di+l1sX9XCDo9XmW9FtQyhXC1sASnkQWgOFhJ9Rl5imSlNFFsYJLu7ruZkHlrU3+qU 4uqmYPW1hT3Xw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id D33FB1A3F for ; Wed, 24 Jan 2024 09:17:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C67673A054A for ; Wed, 24 Jan 2024 09:17:19 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jan 2024 09:16:45 +0100 Message-ID: <20240124081702.4759-15-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240124081702.4759-1-anton@khirnov.net> References: <20240124081702.4759-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/31] fftools/ffmpeg: move hwaccel_retrieve_data() from ffmpeg_hw to ffmpeg_dec 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This function is decoding-only and has no interaction with the rest of ffmpeg_hw. It thus belongs more properly in ffmpeg_dec. --- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_dec.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fftools/ffmpeg_hw.c | 42 ------------------------------------------ 3 files changed, 42 insertions(+), 44 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index e87af70698..80c09d1662 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -731,8 +731,6 @@ void hw_device_free_all(void); */ AVBufferRef *hw_device_for_filter(void); -int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input); - /** * @param dec_opts Dictionary filled with decoder options. Its ownership * is transferred to the decoder. diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index f647db3611..f65857bea3 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -265,6 +265,48 @@ static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *fr return FFMAX(dp->last_frame_duration_est, 1); } +static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input) +{ + InputStream *ist = avctx->opaque; + AVFrame *output = NULL; + enum AVPixelFormat output_format = ist->hwaccel_output_format; + int err; + + if (input->format == output_format) { + // Nothing to do. + return 0; + } + + output = av_frame_alloc(); + if (!output) + return AVERROR(ENOMEM); + + output->format = output_format; + + err = av_hwframe_transfer_data(output, input, 0); + if (err < 0) { + av_log(avctx, AV_LOG_ERROR, "Failed to transfer data to " + "output frame: %d.\n", err); + goto fail; + } + + err = av_frame_copy_props(output, input); + if (err < 0) { + av_frame_unref(output); + goto fail; + } + + av_frame_unref(input); + av_frame_move_ref(input, output); + av_frame_free(&output); + + return 0; + +fail: + av_frame_free(&output); + return err; +} + static int video_frame_process(InputStream *ist, AVFrame *frame) { DecoderPriv *dp = dp_from_dec(ist->decoder); diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 46bc7e39c2..8608d24517 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -297,48 +297,6 @@ void hw_device_free_all(void) nb_hw_devices = 0; } -int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input) -{ - InputStream *ist = avctx->opaque; - AVFrame *output = NULL; - enum AVPixelFormat output_format = ist->hwaccel_output_format; - int err; - - if (input->format == output_format) { - // Nothing to do. - return 0; - } - - output = av_frame_alloc(); - if (!output) - return AVERROR(ENOMEM); - - output->format = output_format; - - err = av_hwframe_transfer_data(output, input, 0); - if (err < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to transfer data to " - "output frame: %d.\n", err); - goto fail; - } - - err = av_frame_copy_props(output, input); - if (err < 0) { - av_frame_unref(output); - goto fail; - } - - av_frame_unref(input); - av_frame_move_ref(input, output); - av_frame_free(&output); - - return 0; - -fail: - av_frame_free(&output); - return err; -} - AVBufferRef *hw_device_for_filter(void) { // Pick the last hardware device if the user doesn't pick the device for -- 2.42.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".