[FFmpeg-devel] [PATCH 2/6] Deprecate avcodec_thread_init()
Alexander Strange
astrange
Mon Nov 15 14:37:02 CET 2010
As a side effect of the last commit, avcodec_open() now calls it automatically,
so there is no longer any need for clients to call it.
Instead they should set AVCodecContext.thread_count.
avcodec_thread_free() will be removed from avcodec.h at the same time; there
is no need to mark it deprecated as clients already had no reason to call it.
---
doc/APIchanges | 4 ++++
ffmpeg.c | 11 +++--------
ffplay.c | 2 +-
libavcodec/avcodec.h | 6 ++++++
libavcodec/thread.h | 5 +++++
5 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index c8892d9..5df6bcb 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2009-03-08
API changes, most recent first:
+2010-11-XX - rX - lavc 52.xx.0 - avcodec_thread_init API
+ Deprecate avcodec_thread_init/avcodec_thread_free; instead
+ set thread_count before calling avcodec_open.
+
2010-11-XX - rX - lavc 52.xx.0 - threading API
Add CODEC_CAP_FRAME_THREADS with new restrictions on get_buffer()/
release_buffer()/draw_horiz_band() callbacks for appropriate codecs.
diff --git a/ffmpeg.c b/ffmpeg.c
index 1eac3cd..d511417 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -706,11 +706,6 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename)
choose_pixel_fmt(st, codec);
}
- if(!st->codec->thread_count)
- st->codec->thread_count = 1;
- if(st->codec->thread_count>1)
- avcodec_thread_init(st->codec, st->codec->thread_count);
-
if(st->codec->flags & CODEC_FLAG_BITEXACT)
nopts = 1;
@@ -3210,7 +3205,7 @@ static void opt_input_file(const char *filename)
for(i=0;i<ic->nb_streams;i++) {
AVStream *st = ic->streams[i];
AVCodecContext *dec = st->codec;
- avcodec_thread_init(dec, thread_count);
+ dec->thread_count = thread_count;
input_codecs = grow_array(input_codecs, sizeof(*input_codecs), &nb_input_codecs, nb_input_codecs + 1);
switch (dec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -3366,7 +3361,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
ost->bitstream_filters = video_bitstream_filters;
video_bitstream_filters= NULL;
- avcodec_thread_init(st->codec, thread_count);
+ st->codec->thread_count= thread_count;
video_enc = st->codec;
@@ -3513,7 +3508,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx)
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
- avcodec_thread_init(st->codec, thread_count);
+ st->codec->thread_count= thread_count;
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
diff --git a/ffplay.c b/ffplay.c
index d478bcb..aa61440 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2246,7 +2246,7 @@ static int stream_component_open(VideoState *is, int stream_index)
avctx->skip_loop_filter= skip_loop_filter;
avctx->error_recognition= error_recognition;
avctx->error_concealment= error_concealment;
- avcodec_thread_init(avctx, thread_count);
+ avctx->thread_count= thread_count;
set_context_opts(avctx, avcodec_opts[avctx->codec_type], 0, codec);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e35e77d..afa2440 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3544,8 +3544,14 @@ int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
+#if LIBAVCODEC_VERSION_MAJOR < 53
+/**
+ * @deprecated Set s->thread_count before calling avcodec_open() instead of calling this.
+ */
+attribute_deprecated
int avcodec_thread_init(AVCodecContext *s, int thread_count);
void avcodec_thread_free(AVCodecContext *s);
+#endif
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
//FIXME func typedef
diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index ac370bd..0267c6f 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -95,4 +95,9 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f);
*/
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f);
+#if LIBAVCODEC_VERSION_MAJOR >= 53
+int avcodec_thread_init(AVCodecContext *s, int thread_count);
+void avcodec_thread_free(AVCodecContext *s);
+#endif
+
#endif /* AVCODEC_THREAD_H */
--
1.7.3.1
More information about the ffmpeg-devel
mailing list