History

lavc/thread: move generic-layer API to avcodec_internal.h

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.

Anton Khirnov committed 2 years ago

Commit d94cfd41 parent 8d5efc24 files · +26 −32Browse files

Showing the changes to libavcodec (4 of 4 files). Show all

Unified · Split

4 files
  1. libavcodec/avcodec_internal.h +24 −0
  2. libavcodec/pthread.c +1 −0
  3. libavcodec/thread.h +1 −24
  4. libavcodec/utils.c +0 −8
libavcodec/avcodec_internal.h+24−0
@@ -72,4 +72,28 @@ struct AVCodecInternal *ff_encode_internal_alloc(void); · 71 unmodified lines
7272
7373 void ff_codec_close(struct AVCodecContext *avctx);
7474
75+int ff_thread_init(struct AVCodecContext *s);
76+void ff_thread_free(struct AVCodecContext *s);
77+
78+/**
79+ * Wait for decoding threads to finish and reset internal state.
80+ * Called by avcodec_flush_buffers().
81+ *
82+ * @param avctx The context.
83+ */
84+void ff_thread_flush(struct AVCodecContext *avctx);
85+
86+/**
87+ * Submit a new frame to a decoding thread.
88+ * Returns the next available frame in picture. *got_picture_ptr
89+ * will be 0 if none is available.
90+ * The return value on success is the size of the consumed packet for
91+ * compatibility with FFCodec.decode. This means the decoder
92+ * has to consume the full packet.
93+ *
94+ * Parameters are the same as FFCodec.decode.
95+ */
96+int ff_thread_decode_frame(struct AVCodecContext *avctx, struct AVFrame *frame,
97+ int *got_picture_ptr, struct AVPacket *avpkt);
98+
7599 #endif // AVCODEC_AVCODEC_INTERNAL_H
libavcodec/pthread.c+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/thread.h"
3333
3434 #include "avcodec.h"
35+#include "avcodec_internal.h"
3536 #include "codec_internal.h"
3637 #include "pthread_internal.h"
3738 #include "thread.h"
libavcodec/thread.h+1−24
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020
2121 /**
2222 * @file
23− * Multithreading support functions
23+ * Multithreading API for decoders
2424 * @author Alexander Strange <astrange@ithinksw.com>
2525 */
2626
@@ -31,27 +31,6 @@ · 4 unmodified lines
3131
3232 #include "avcodec.h"
3333
34−/**
35− * Wait for decoding threads to finish and reset internal state.
36− * Called by avcodec_flush_buffers().
37− *
38− * @param avctx The context.
39− */
40−void ff_thread_flush(AVCodecContext *avctx);
41−
42−/**
43− * Submit a new frame to a decoding thread.
44− * Returns the next available frame in picture. *got_picture_ptr
45− * will be 0 if none is available.
46− * The return value on success is the size of the consumed packet for
47− * compatibility with FFCodec.decode. This means the decoder
48− * has to consume the full packet.
49− *
50− * Parameters are the same as FFCodec.decode.
51− */
52−int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
53− int *got_picture_ptr, AVPacket *avpkt);
54−
5534 int ff_thread_can_start_frame(AVCodecContext *avctx);
5635
5736 /**
@@ -74,11 +53,9 @@ void ff_thread_finish_setup(AVCodecContext *avctx); · 16 unmodified lines
7453 */
7554 int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags);
7655
77−int ff_thread_init(AVCodecContext *s);
7856 int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx,
7957 int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr),
8058 int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count);
81−void ff_thread_free(AVCodecContext *s);
8259 int ff_slice_thread_allocz_entries(AVCodecContext *avctx, int count);
8360 int ff_slice_thread_init_progress(AVCodecContext *avctx);
8461 void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n);
libavcodec/utils.c+0−8
@@ -809,14 +809,6 @@ int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes) · 808 unmodified lines
809809 return FFMAX(0, duration);
810810 }
811811
812−#if !HAVE_THREADS
813−int ff_thread_init(AVCodecContext *s)
814−{
815− return -1;
816−}
817−
818−#endif
819−
820812 unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
821813 {
822814 unsigned int n = 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t