diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-10-12 11:35:35 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-10-12 11:35:35 +0000 |
commit | 8d23a86f3346121f64b1ce80c3e0740e05fd2b29 (patch) | |
tree | 6645c63f8ca4ca4a97da7325b758cb4a7724aee0 /libavcodec/utils.c | |
parent | febd1c90a64c1df2d72600d0fe1f020e88d10953 (diff) | |
download | ffmpeg-8d23a86f3346121f64b1ce80c3e0740e05fd2b29.tar.gz |
Add an execute2 function that is more flexible and allows to use parallel
processing with jobs > threads without wasting too much memory.
It also avoids needing a separate int array when the only additional data
the jobs needs is a single int running from 0 to count-1.
Originally committed as revision 20210 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index c3df903f1e..1077fd7fc7 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -414,6 +414,16 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v return 0; } +int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr),void *arg, int *ret, int count){ + int i; + + for(i=0; i<count; i++){ + int r= func(c, arg, i, 0); + if(ret) ret[i]= r; + } + return 0; +} + enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt){ while (*fmt != PIX_FMT_NONE && ff_is_hwaccel_pix_fmt(*fmt)) ++fmt; |