From patchwork Tue Jun 20 14:16:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42241 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp1427396pzb; Tue, 20 Jun 2023 07:17:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nkMQAur7nSbVN4l5o9QuQLv43aEgBmsFgi7GIdqTjIhuuK7mcehn1nzhw//vZKSM8ng2g X-Received: by 2002:a2e:a175:0:b0:2b1:fda8:e653 with SMTP id u21-20020a2ea175000000b002b1fda8e653mr7880630ljl.27.1687270647703; Tue, 20 Jun 2023 07:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687270647; cv=none; d=google.com; s=arc-20160816; b=LPZgMqBK0CYwux3GEEkYRa4ZUYLzcD2KDFdYbKL7jlDaKpuLjd7WyVRpIyQlBxTd1o WR8Zx6uyuZbVVs053tuStlGDKeThH/2DTEOguYlDPNXYxR9H07qQiIp7cxI8kTlUjmXS ai0IG3vKBn6GRJaInLm7HddMC/4l28CIZUd0Y2+teeKba/Quu4gvd+JqRNPXgvqsPQPq x2Oz5pI9WNsxxGcRgUNNbt7UnPqHvwb4/rTm60XTAYaGDVGBZhzPuiYKf8gtKs+GHiXn HyiIGpZBdK4atlsvC1M5bRg39eT9IyPCRFcNqQcvn1boFIvlt009Imzgsl+NbbI6+fk4 ETLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=lfbezFhwIllMn7pSAj+6xDCtk+daKK0UZeY/m30TQRo=; b=JHrdC3b/We8bIe5ZR29bhMOQoswV+rzAwIacjNBc5vvU/xMYUT9WTNzgA8qPUtMRhM XzrdGXOGYuEWO7Nj58owlW7OW5pocrtJiF+M7fsHOBtlt5HPGy52mN6zobrP1ksaAN1z jMQQn1ys4avH0NewY8PAjA7apwYU8pgDSu+zmy95qeFup/s0N1F2vVw5tUrzGT1uqLNo cLbKUKEnkgV/LzaacR7mbEM2GUGr/+HkcHPYTAid4TwL6hlR50JGqJ3XItfRyg2fosVF 92DXX3Zb65+tXKrgb9ZyWAvgBrC281wqPsZ/7rpFhKjg5Fez0DXtgkIngySgCQFxC8K1 p9nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y10-20020aa7ccca000000b005163c217906si1126102edt.333.2023.06.20.07.17.27; Tue, 20 Jun 2023 07:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6DEDA68C101; Tue, 20 Jun 2023 17:16:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2251568A892 for ; Tue, 20 Jun 2023 17:16:44 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DEFFD2406CA for ; Tue, 20 Jun 2023 16:16:43 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id gui9ekHPi9s6 for ; Tue, 20 Jun 2023 16:16:43 +0200 (CEST) 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 mail0.khirnov.net (Postfix) with ESMTPS id A10622404F5 for ; Tue, 20 Jun 2023 16:16:42 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id AD3793A02F8 for ; Tue, 20 Jun 2023 16:16:36 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Jun 2023 16:16:00 +0200 Message-Id: <20230620141608.31759-1-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/9] lavc: add a header for internal generic-layer APIs 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: osHIZVrqR7yU The goal is to distinguish between APIs provided by the generic layer to individual codecs and APIs internal to the generic layer. Start by moving ff_{decode,encode}_receive_frame() and ff_{decode,encode}_preinit() into this new header, as those functions are called from generic code and should not be visible to individual codecs. --- libavcodec/avcodec.c | 1 + libavcodec/avcodec_internal.h | 53 +++++++++++++++++++++++++++++++++++ libavcodec/decode.c | 1 + libavcodec/decode.h | 11 -------- libavcodec/encode.c | 1 + libavcodec/encode.h | 11 -------- 6 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 libavcodec/avcodec_internal.h diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index db8226f9b3..638cb55146 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -34,6 +34,7 @@ #include "libavutil/opt.h" #include "libavutil/thread.h" #include "avcodec.h" +#include "avcodec_internal.h" #include "bsf.h" #include "codec_internal.h" #include "decode.h" diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h new file mode 100644 index 0000000000..be60a36644 --- /dev/null +++ b/libavcodec/avcodec_internal.h @@ -0,0 +1,53 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * APIs internal to the generic codec layer. + * + * MUST NOT be included by individual encoders or decoders. + */ + +#ifndef AVCODEC_AVCODEC_INTERNAL_H +#define AVCODEC_AVCODEC_INTERNAL_H + +struct AVCodecContext; +struct AVFrame; + +/** + * avcodec_receive_frame() implementation for decoders. + */ +int ff_decode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame); + +/** + * avcodec_receive_frame() implementation for encoders. + */ +int ff_encode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame); + +/* + * Perform encoder initialization and validation. + * Called when opening the encoder, before the FFCodec.init() call. + */ +int ff_encode_preinit(struct AVCodecContext *avctx); + +/** + * Perform decoder initialization and validation. + * Called when opening the decoder, before the FFCodec.init() call. + */ +int ff_decode_preinit(struct AVCodecContext *avctx); + +#endif // AVCODEC_AVCODEC_INTERNAL_H diff --git a/libavcodec/decode.c b/libavcodec/decode.c index a7c130207c..8adb532616 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -41,6 +41,7 @@ #include "libavutil/opt.h" #include "avcodec.h" +#include "avcodec_internal.h" #include "bytestream.h" #include "bsf.h" #include "codec_internal.h" diff --git a/libavcodec/decode.h b/libavcodec/decode.h index aaa29bc7f5..2b9fe59907 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -53,11 +53,6 @@ typedef struct FrameDecodeData { void (*hwaccel_priv_free)(void *priv); } FrameDecodeData; -/** - * avcodec_receive_frame() implementation for decoders. - */ -int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame); - /** * Called by decoders to get the next packet for decoding. * @@ -99,12 +94,6 @@ int ff_attach_decode_data(AVFrame *frame); */ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); -/** - * Perform decoder initialization and validation. - * Called when opening the decoder, before the FFCodec.init() call. - */ -int ff_decode_preinit(AVCodecContext *avctx); - /** * Check that the provided frame dimensions are valid and set them on the codec * context. diff --git a/libavcodec/encode.c b/libavcodec/encode.c index ab5f889615..3a016b14c1 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -27,6 +27,7 @@ #include "libavutil/samplefmt.h" #include "avcodec.h" +#include "avcodec_internal.h" #include "codec_internal.h" #include "encode.h" #include "frame_thread_encoder.h" diff --git a/libavcodec/encode.h b/libavcodec/encode.h index 26a3304045..dfaab7c976 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -26,11 +26,6 @@ #include "avcodec.h" #include "packet.h" -/** - * avcodec_receive_frame() implementation for encoders. - */ -int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame); - /** * Called by encoders to get the next frame for encoding. * @@ -75,12 +70,6 @@ int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); int ff_encode_reordered_opaque(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame); -/* - * Perform encoder initialization and validation. - * Called when opening the encoder, before the FFCodec.init() call. - */ -int ff_encode_preinit(AVCodecContext *avctx); - int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, AVFrame *frame, int *got_packet);