diff mbox series

[FFmpeg-devel,1/3] lavc/thread: move generic-layer API to avcodec_internal.h

Message ID 20240308082749.20028-1-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,1/3] lavc/thread: move generic-layer API to avcodec_internal.h | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 8, 2024, 8:27 a.m. UTC
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(-)

Comments

Michael Niedermayer March 9, 2024, 11:26 p.m. UTC | #1
On Fri, Mar 08, 2024 at 09:27:47AM +0100, Anton Khirnov wrote:
> 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(-)

breaks ppc build

make -j32 -k
CC	libavcodec/utils.o
src/libavcodec/utils.c:810:5: error: no previous prototype for ‘ff_thread_init’ [-Werror=missing-prototypes]
 int ff_thread_init(AVCodecContext *s)
     ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
src/ffbuild/common.mak:81: recipe for target 'libavcodec/utils.o' failed
make: *** [libavcodec/utils.o] Error 1
make: Target 'all' not remade because of errors.


[...]
diff mbox series

Patch

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 <astrange@ithinksw.com>
  */
 
@@ -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);