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.
Showing the changes to libavcodec (4 of 4 files). Show all
Unified · Split
| @@ -72,4 +72,28 @@ struct AVCodecInternal *ff_encode_internal_alloc(void); · 71 unmodified lines | ||
| 72 | 72 | |
| 73 | 73 | void ff_codec_close(struct AVCodecContext *avctx); |
| 74 | 74 | |
| 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 | + | |
| 75 | 99 | #endif // AVCODEC_AVCODEC_INTERNAL_H |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "libavutil/thread.h" |
| 33 | 33 | |
| 34 | 34 | #include "avcodec.h" |
| 35 | +#include "avcodec_internal.h" | |
| 35 | 36 | #include "codec_internal.h" |
| 36 | 37 | #include "pthread_internal.h" |
| 37 | 38 | #include "thread.h" |
| @@ -20,7 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * @file |
| 23 | − * Multithreading support functions | |
| 23 | + * Multithreading API for decoders | |
| 24 | 24 | * @author Alexander Strange <astrange@ithinksw.com> |
| 25 | 25 | */ |
| 26 | 26 | |
| @@ -31,27 +31,6 @@ · 4 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | #include "avcodec.h" |
| 33 | 33 | |
| 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 | − | |
| 55 | 34 | int ff_thread_can_start_frame(AVCodecContext *avctx); |
| 56 | 35 | |
| 57 | 36 | /** |
| @@ -74,11 +53,9 @@ void ff_thread_finish_setup(AVCodecContext *avctx); · 16 unmodified lines | ||
| 74 | 53 | */ |
| 75 | 54 | int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags); |
| 76 | 55 | |
| 77 | −int ff_thread_init(AVCodecContext *s); | |
| 78 | 56 | int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, |
| 79 | 57 | int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr), |
| 80 | 58 | int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count); |
| 81 | −void ff_thread_free(AVCodecContext *s); | |
| 82 | 59 | int ff_slice_thread_allocz_entries(AVCodecContext *avctx, int count); |
| 83 | 60 | int ff_slice_thread_init_progress(AVCodecContext *avctx); |
| 84 | 61 | void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n); |
| @@ -809,14 +809,6 @@ int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes) · 808 unmodified lines | ||
| 809 | 809 | return FFMAX(0, duration); |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | −#if !HAVE_THREADS | |
| 813 | −int ff_thread_init(AVCodecContext *s) | |
| 814 | −{ | |
| 815 | − return -1; | |
| 816 | −} | |
| 817 | − | |
| 818 | −#endif | |
| 819 | − | |
| 820 | 812 | unsigned int av_xiphlacing(unsigned char *s, unsigned int v) |
| 821 | 813 | { |
| 822 | 814 | unsigned int n = 0; |