[Ffmpeg-devel] [PATCH] Swscaler multithreading

Haruhiko Yamagata h.yamagata
Thu Aug 17 15:15:48 CEST 2006

Hello. Thank you for your great product swscaler. I implemented multithreading of swscaler for ffdshow port and posted patch on 
April 2006. Since then I debuged and now I would like to port back. I didn't have Linux running PC, so I thought it should be very 
hard to port back, but Cygwin allowed me to do it easier. Some OS dependent functions are not implemented. Please help me to 

[Tested environment]
 Mingw32+mplayer, Cygwin+mplayer are tested.
 Native posix systems are not tested.
 I think it's probably OK on posix, because pthread.c works on Cygwin.
 OS2 and BeOS are not tested at all, though os2thread.c
 and beosthread.c are included.

[How to compile multithreaded version]
 On posix system(including Cygwin), default configuration is multithreaded.
  Please implement GetCPUCount - pthread.c.

 Mingw32 : There is no option for configure as far as I know.
   Add "#define HAVE_THREADS" to config.h.
   Add "HAVE_W32THREADS = yes" to config.mak.

 OS2 :
   Add "#define HAVE_THREADS" to config.h.
   Add "HAVE_OS2THREADS = yes" to config.mak.
   Please implement GetCPUCount - os2thread.c.
   Please degug.

 BeOS :
   Add "#define HAVE_THREADS" to config.h.
   Add "HAVE_BEOSTHREADS = yes" to config.mak.
   Please implement GetCPUCount - beosthread.c.
   Please degug.

[How to use]
 To specify the number of threads, use sws_getContextEx.
 sws_getContextEx has parameter for threadCount.

 * @param threadCount : number of threads. Set threadCount=0 to GetCPUCount automatically.
    SwsContext *sws_getContextEx(int srcW,
                int srcH,
                int origSrcFormat,
                int dstW,
                int dstH,
                int origDstFormat,
                int flags,
                SwsFilter *srcFilter,
                SwsFilter *dstFilter,
                double *param,
                int threadCount

 sws_getContextEx calls GetCPUCount to get threadCount, if threadCount==0.

 Multithreading should be avoided if the output buffer
 is the video RAM(It's much slower).

 GetCPUCount is expected to return number of system processors.
 If the processor is Pentium4-HT it is counted 1,
 because multithreading on P4HT is not faster at all.
 It depends on OS and I couldn't implement except for Mingw32.
 Please help me.

[Overview of implementation]
 SwsContext is copied for each thread.
 Picture is simply divided by the number of threads.
 Asymmetric division is long term TODO.

[About MPlayer]
 I don't know why and where it is called from, but MPlayer divids
 picture to pieces(16lines/call). In this setting, swscaler
 multithreading cannot take effect at all. Whole picture should
 be given at once to see effect of multithreading.

[How to contact me in the mailing list]
 I can't catch up the high traffic of this mailing list because of
 my poor English. Please be sure to include "swscale" in the title.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libswscale_multithread20060817.patch
Type: application/octet-stream
Size: 40093 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060817/e76c197b/attachment.obj>

More information about the ffmpeg-devel mailing list