[Ffmpeg-devel] [PATCH] fix ffmpeg crash when thread_count is zero

Limin Wang lance.lmwang
Fri Mar 2 05:02:01 CET 2007


Hi,

Last patch is bug, please review the new patch, it has pass
"make test". Or we check the thread_count and never permit
it zero.

Thanks,
Limin
-------------- next part --------------
Index: libavcodec/mpegvideo.c
===================================================================
--- libavcodec/mpegvideo.c	(revision 8182)
+++ libavcodec/mpegvideo.c	(working copy)
@@ -825,7 +825,17 @@
         memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
     }
 
-    for(i=0; i<s->avctx->thread_count; i++){
+    if(init_duplicate_context(s->thread_context[0], s) < 0)
+        goto fail;
+    if( s->avctx->thread_count == 0 ) {
+        s->thread_context[0]->start_mb_y= 0;
+        s->thread_context[0]->end_mb_y  = s->mb_height;
+    } else {
+        s->thread_context[0]->start_mb_y= (s->avctx->thread_count/2) / s->avctx->thread_count;
+        s->thread_context[0]->end_mb_y  = (s->mb_height + s->avctx->thread_count/2) / s->avctx->thread_count;
+    }
+
+    for(i=1; i<s->avctx->thread_count; 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070302/04ddf583/attachment.pgp>



More information about the ffmpeg-devel mailing list