Mercurial > libavcodec.hg
diff utils.c @ 10386:98501365c3aa libavcodec
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.
author | reimar |
---|---|
date | Mon, 12 Oct 2009 11:35:35 +0000 |
parents | 294c444866f7 |
children | 11b685acd280 |
line wrap: on
line diff
--- a/utils.c Sun Oct 11 16:16:08 2009 +0000 +++ b/utils.c Mon Oct 12 11:35:35 2009 +0000 @@ -414,6 +414,16 @@ 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;