summaryrefslogtreecommitdiffstats
path: root/libhb/hb.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-06-08 21:20:08 +0000
committerjstebbins <[email protected]>2011-06-08 21:20:08 +0000
commitc3c5052550c010732b5ca31acf563ea1e3349d88 (patch)
tree5bc011e81849ed9eb94e189de0a6312e99c3386d /libhb/hb.c
parent925b90ee9ee13afdc8efbf1bb3e46d564a67bb7e (diff)
libhb: Enable multi-threaded decode in ffmpeg
Enable both slice and frame based mutli-threaded decode in ffmpeg. Uses cpu_count/2 + 1 threads. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4034 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb.c')
-rw-r--r--libhb/hb.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index 1e3686cf2..b1050e0e0 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -99,9 +99,19 @@ void hb_avcodec_init()
av_register_all();
}
-int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec)
+int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, int thread_count)
{
int ret;
+
+ if ( ( thread_count == HB_FFMPEG_THREADS_AUTO || thread_count > 0 ) &&
+ ( codec->type == AVMEDIA_TYPE_VIDEO ) )
+ {
+ avctx->thread_count = ( thread_count == HB_FFMPEG_THREADS_AUTO ) ?
+ hb_get_cpu_count() / 2 + 1 : thread_count;
+ avctx->thread_type = FF_THREAD_FRAME|FF_THREAD_SLICE;
+ avctx->thread_safe_callbacks = 1;
+ }
+
ret = avcodec_open(avctx, codec);
return ret;
}