From patchwork Fri Mar 8 08:27:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46894 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c995:b0:1a1:738b:6bc0 with SMTP id gy21csp798186pzb; Fri, 8 Mar 2024 00:28:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW2Q8slfb02AuLFE1k5EJGg04qySdu4k3DMItZX/p45YLE9hsTMtQ2qSTHIfaja/qklX/ozga536HEo8Ll8P12M92U3usrWcXEICg== X-Google-Smtp-Source: AGHT+IExm9VLkujQge0F1q88s0KSnWxGVTLh3QNHa20Npd7WGjNiyEQYMCC6K0fpP4PGCEbn5u8l X-Received: by 2002:a17:906:5909:b0:a3f:50f0:7a0a with SMTP id h9-20020a170906590900b00a3f50f07a0amr2462356ejq.20.1709886484050; Fri, 08 Mar 2024 00:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709886484; cv=none; d=google.com; s=arc-20160816; b=WyPB0jQ3p6uB8evxXyCQkc31+90GaMnonLp0VbaU3Z9bqZjsOG0dLY7awFdQaOoiUA t347YXd/hIzuUT2FhKOQtbNzhF7cfHD0IeQkne/27wVQA1uhvLuyVqU6wO2Ijv0La90P ix7MLw09ATL7U8Fwsl2OVFKIbp4BPX4ZbjXQYgQyoE4GOju/VUPzYBtwquMIQiYMdKjU +GcNjTeNRcxUnZXpjcWV7/xp5rzQR+ZKAiNXmhPvZNbZWfCasfwSAASUviykeyJOiMst ZivXhlTsiZRM0NkjOcmAvqzLmcSnVe2qD5EQcZ+zpDL96jdfvEm9TZHDTOhXTgX09CYj XLdA== 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 :dkim-signature:delivered-to; bh=UFz4Je02ivUJqGMJ/Lkr/nEzEkNwEmAoW3J+jdQPX30=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=js0QgdY0w+sjzcgvU0/zUmEB4aHFRdnrVO7LFTi4Uq/IPOh3QCndQBVxdV9wE+RAqo nL+uw56QR/EfBneb3hGH60gYhuLbri/0P7VoE+llB4/VKIbppuUEaMfRqHQ9TGJeyGOK yq/Kf0hkeUzjkqK7c5s/VeN3ufcTqPGjKeTcab2KaURXWnzfCJuMj/SmKq9S/2mR8r6u WijReIWRZ3BIo7iF43LYRBf6cyZwwDANk0vPBUNv9Yt5L6DlmzSiFlcsDYsmPBo07kmF z1mSqMVUTBUvO2llS1CgPHUhmDfvDDj3YOPDgLq11o6CJJtYJ0wBbfpMmZdCX4JwjIug wlAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=MmfrWPhY; 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 mj6-20020a170906af8600b00a3e6c5fa398si7472054ejb.304.2024.03.08.00.28.03; Fri, 08 Mar 2024 00:28:04 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=MmfrWPhY; 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 A5D1368CBED; Fri, 8 Mar 2024 10:28:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 83D1468C7DA for ; Fri, 8 Mar 2024 10:27:53 +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=MmfrWPhY; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id E27AE4D4C for ; Fri, 8 Mar 2024 09:27:52 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id gESGq15OykwM for ; Fri, 8 Mar 2024 09:27:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709886471; bh=NEeXQEdPQ716ZhuZk9BuV6jS/rW1ktDoyYVUv2MWLOs=; h=From:To:Subject:Date:From; b=MmfrWPhYM/9xeVHCsiA9WJpel6l7+yzHOfNUEHa8vLJIVsKQNTy0u3pwQbg/YIL9i JobuafjjN/oZB6wHHs39dONspODcyFVCoqw3SSLjZmYa1EejHRFTrzRDNovl35DflZ TXWa/jt1dGaOXPhYDByC03xKPBOPmK925ZZtS0XGzprUJjytIEAzKxvlFacvLIG3uU g+CU/LFKHV2sQOfrrxLKotKn9GsvEOB5jFBMXdjgN6ZVT9axOtGL/x/RYaX0kMT5Tn wPm7knPrYJYw1x8ASl7E8u8AqYtsD8P53Yz31o/UbnB0R1MPloCtZ4Ej9BK3Z/wSZW nED0D2UOy9Y5w== 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 9112B4496 for ; Fri, 8 Mar 2024 09:27:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5BB2C3A0357 for ; Fri, 8 Mar 2024 09:27:51 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Mar 2024 09:27:47 +0100 Message-ID: <20240308082749.20028-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] lavc/thread: move generic-layer API to avcodec_internal.h 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: VrbInXh61xId thread.h currently contains both API for decoder use and functions internal to lavc generic layer. Move the latter to avcodec_internal.h, which is a more appropriate place for them. --- libavcodec/avcodec_internal.h | 24 ++++++++++++++++++++++++ libavcodec/pthread.c | 1 + libavcodec/thread.h | 25 +------------------------ 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h index 4d1cb3a314..e7a229dee9 100644 --- a/libavcodec/avcodec_internal.h +++ b/libavcodec/avcodec_internal.h @@ -58,4 +58,28 @@ struct AVCodecInternal *ff_encode_internal_alloc(void); void ff_codec_close(struct AVCodecContext *avctx); +int ff_thread_init(struct AVCodecContext *s); +void ff_thread_free(struct AVCodecContext *s); + +/** + * Wait for decoding threads to finish and reset internal state. + * Called by avcodec_flush_buffers(). + * + * @param avctx The context. + */ +void ff_thread_flush(struct AVCodecContext *avctx); + +/** + * Submit a new frame to a decoding thread. + * Returns the next available frame in picture. *got_picture_ptr + * will be 0 if none is available. + * The return value on success is the size of the consumed packet for + * compatibility with FFCodec.decode. This means the decoder + * has to consume the full packet. + * + * Parameters are the same as FFCodec.decode. + */ +int ff_thread_decode_frame(struct AVCodecContext *avctx, struct AVFrame *frame, + int *got_picture_ptr, struct AVPacket *avpkt); + #endif // AVCODEC_AVCODEC_INTERNAL_H diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index ca84b81391..d32e56de0d 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -32,6 +32,7 @@ #include "libavutil/thread.h" #include "avcodec.h" +#include "avcodec_internal.h" #include "codec_internal.h" #include "pthread_internal.h" #include "thread.h" diff --git a/libavcodec/thread.h b/libavcodec/thread.h index f772d7ff18..4272fd87d4 100644 --- a/libavcodec/thread.h +++ b/libavcodec/thread.h @@ -20,7 +20,7 @@ /** * @file - * Multithreading support functions + * Multithreading API for decoders * @author Alexander Strange */ @@ -31,27 +31,6 @@ #include "avcodec.h" -/** - * Wait for decoding threads to finish and reset internal state. - * Called by avcodec_flush_buffers(). - * - * @param avctx The context. - */ -void ff_thread_flush(AVCodecContext *avctx); - -/** - * Submit a new frame to a decoding thread. - * Returns the next available frame in picture. *got_picture_ptr - * will be 0 if none is available. - * The return value on success is the size of the consumed packet for - * compatibility with FFCodec.decode. This means the decoder - * has to consume the full packet. - * - * Parameters are the same as FFCodec.decode. - */ -int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, AVPacket *avpkt); - int ff_thread_can_start_frame(AVCodecContext *avctx); /** @@ -74,11 +53,9 @@ void ff_thread_finish_setup(AVCodecContext *avctx); */ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags); -int ff_thread_init(AVCodecContext *s); int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr), int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count); -void ff_thread_free(AVCodecContext *s); int ff_slice_thread_allocz_entries(AVCodecContext *avctx, int count); int ff_slice_thread_init_progress(AVCodecContext *avctx); void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n);