summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorAndreas Öman <andreas@olebyn.nu>2007-09-05 16:18:15 +0000
committerGuillaume Poirier <gpoirier@mplayerhq.hu>2007-09-05 16:18:15 +0000
commitafebe2f7cac1e23ea5b198cfe5bfabf5e7f1105f (patch)
treef60825730d3f0d4a625928812b5ef9651d3e302d /libavcodec/mpegvideo.c
parente146ce521f03b1cd472a61880a9438f55369d9d4 (diff)
Add slice-based parallel H.264 decoding
Patch by Andreas Öman % andreas A olebyn P nu % NB: depends on having a thread library activated at config time, and on having a source encoded with multiple slices Original threads: date: May 18, 2007 11:00 PM subject: [FFmpeg-devel] Parallelized h264 proof-of-concept date: Jun 15, 2007 10:10 PM subject: [FFmpeg-devel] [PATCH] h264 parallelized, (was: Parallelized h264 proof-of-concept) date: Jun 25, 2007 7:02 PM subject: Re: [FFmpeg-devel] [PATCH] h264 parallelized Originally committed as revision 10407 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 66339bb618..2e6d1d8b27 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -418,7 +418,7 @@ void MPV_decode_defaults(MpegEncContext *s){
*/
int MPV_common_init(MpegEncContext *s)
{
- int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
+ int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y, threads;
s->mb_height = (s->height + 15) / 16;
@@ -587,12 +587,16 @@ int MPV_common_init(MpegEncContext *s)
s->context_initialized = 1;
s->thread_context[0]= s;
- for(i=1; i<s->avctx->thread_count; i++){
+ /* h264 does thread context setup itself, but it needs context[0]
+ * to be fully initialized for the error resilience code */
+ threads = s->codec_id == CODEC_ID_H264 ? 1 : s->avctx->thread_count;
+
+ for(i=1; i<threads; i++){
s->thread_context[i]= av_malloc(sizeof(MpegEncContext));
memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
}
- for(i=0; i<s->avctx->thread_count; i++){
+ for(i=0; i<threads; i++){
if(init_duplicate_context(s->thread_context[i], s) < 0)
goto fail;
s->thread_context[i]->start_mb_y= (s->mb_height*(i ) + s->avctx->thread_count/2) / s->avctx->thread_count;