[FFmpeg-devel] [PATCH] avfitler/vf_perspective: support slice threading

Paul B Mahol onemda at gmail.com
Tue Aug 12 17:12:43 CEST 2014


On 8/12/14, Clement Boesch <u at pkh.me> wrote:
> On Tue, Aug 12, 2014 at 11:32:20AM +0000, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavfilter/vf_perspective.c | 69
>> +++++++++++++++++++++++++++++++++-----------
>>  1 file changed, 52 insertions(+), 17 deletions(-)
>>
>> diff --git a/libavfilter/vf_perspective.c b/libavfilter/vf_perspective.c
>> index f433226..c5471b0 100644
>> --- a/libavfilter/vf_perspective.c
>> +++ b/libavfilter/vf_perspective.c
>> @@ -47,10 +47,8 @@ typedef struct PerspectiveContext {
>>      int hsub, vsub;
>>      int nb_planes;
>>
>> -    void (*perspective)(struct PerspectiveContext *s,
>> -                        uint8_t *dst, int dst_linesize,
>> -                        uint8_t *src, int src_linesize,
>> -                        int w, int h, int hsub, int vsub);
>> +    int (*perspective)(AVFilterContext *ctx,
>> +                       void *arg, int job, int nb_jobs);
>>  } PerspectiveContext;
>>
>>  #define OFFSET(x) offsetof(PerspectiveContext, x)
>> @@ -193,15 +191,34 @@ static int config_input(AVFilterLink *inlink)
>>      return 0;
>>  }
>>
>> -static void resample_cubic(PerspectiveContext *s,
>> -                           uint8_t *dst, int dst_linesize,
>> -                           uint8_t *src, int src_linesize,
>> -                           int w, int h, int hsub, int vsub)
>> +typedef struct ThreadData {
>> +    uint8_t *dst;
>> +    int dst_linesize;
>> +    uint8_t *src;
>> +    int src_linesize;
>> +    int w, h;
>> +    int hsub, vsub;
>> +} ThreadData;
>> +
>> +static int resample_cubic(AVFilterContext *ctx, void *arg,
>> +                          int job, int nb_jobs)
>>  {
>> +    PerspectiveContext *s = ctx->priv;
>> +    ThreadData *td = arg;
>> +    uint8_t *dst = td->dst;
>> +    int dst_linesize = td->dst_linesize;
>> +    uint8_t *src = td->src;
>> +    int src_linesize = td->src_linesize;
>> +    int w = td->w;
>> +    int h = td->h;
>> +    int hsub = td->hsub;
>> +    int vsub = td->vsub;
>> +    int start = (h * job) / nb_jobs;
>> +    int end   = (h * (job+1)) / nb_jobs;
>
> I would guess this doesn't work unless you src += start * src_linesize
> (same for dst)
I do not think so. You can try it.


More information about the ffmpeg-devel mailing list