Macroize some threading checks.

---
 libavcodec/thread.h |    6 ++++++
 libavcodec/utils.c  |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index 4377d08..b4db18f 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -42,6 +42,9 @@ void ff_await_decode_progress(AVFrame *f, int progress);
 int ff_get_buffer(AVCodecContext *avctx, AVFrame *f);
 void ff_release_buffer(AVFrame *f);
 void ff_delayed_release_buffer(AVCodecContext *avctx, AVFrame *f);
+
+#define USE_FRAME_THREADING(avctx)  ((avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS) && (avctx->thread_count > 1))
+#define USE_AVCODEC_EXECUTE(avctx) (!(avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS) && (avctx->thread_count > 1))
 #else
 static int ff_thread_init(AVCodecContext *avctx) {return 0;}
 static void ff_thread_free(AVCodecContext *avctx) {}
@@ -68,6 +71,9 @@ static void ff_release_buffer(AVFrame *f)
 }
 
 #define ff_delayed_release_buffer(avctx, f) ff_release_buffer(f)
+
+#define USE_FRAME_THREADING(avctx) 0
+#define USE_AVCODEC_EXECUTE(avctx) 0
 #endif
 
 #endif /* FFMPEG_FRAMEPTHREAD_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index fdadc05..fa9f8e5 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -886,7 +886,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
         }
     }
 
-    if (avctx->thread_count > 1 && !(avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS)) {
+    if (USE_AVCODEC_EXECUTE(avctx)) {
         ret = ff_thread_init(avctx, avctx->thread_count);
         if (ret < 0) {
             av_freep(&avctx->priv_data);
@@ -949,7 +949,7 @@ int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *pic
                          const uint8_t *buf, int buf_size)
 {
     int ret;
-    int threaded = (avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS) && avctx->thread_count > 1;
+    int threaded = USE_FRAME_THREADING(avctx);
 
     *got_picture_ptr= 0;
     if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
-- 
1.5.5.1


_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to