[Ffmpeg-devel] [PATCH] fix ffmpeg crash when thread_count is zero
Limin Wang
lance.lmwang
Tue Feb 27 12:21:09 CET 2007
Hi,
After inputing "-threads auto" option for ffmpeg as x264, mencode by mistaken.
I got ffmpeg crashed. After checking, I got the reason is ffmpeg get
thread_count to zero in case of this usage.
The attached patch will check and restrict the thread_count range from 1 to
FF_THREAD_MAX. Maybe it's better to support auto option like x264?
Thanks,
Limin
-------------- next part --------------
Index: ffmpeg.c
===================================================================
--- ffmpeg.c (revision 8140)
+++ ffmpeg.c (working copy)
@@ -2323,6 +2323,8 @@
static void opt_thread_count(const char *arg)
{
thread_count= atoi(arg);
+
+ thread_count = av_clip( thread_count, 1, FF_THREAD_MAX );
#if !defined(HAVE_THREADS)
if (verbose >= 0)
fprintf(stderr, "Warning: not compiled with thread support, using thread emulation\n");
Index: libavutil/common.h
===================================================================
--- libavutil/common.h (revision 8140)
+++ libavutil/common.h (working copy)
@@ -75,6 +75,8 @@
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
+#define FF_THREAD_MAX 16
+
/* misc math functions */
extern const uint8_t ff_log2_tab[256];
More information about the ffmpeg-devel
mailing list