[FFmpeg-devel] [PATCH] avfilter/vf_lut3d: add planar rgb support

Paul B Mahol onemda at gmail.com
Thu May 3 21:23:54 EEST 2018


On 5/3/18, James Almer <jamrial at gmail.com> wrote:
> On 5/3/2018 3:08 PM, Paul B Mahol wrote:
>> +#define DEFINE_INTERP_FUNC_PLANAR(name, nbits, depth)
>>                           \
>> +static int interp_##nbits##_##name##_p##depth(AVFilterContext *ctx, void
>> *arg, int jobnr, int nb_jobs)     \
>> +{
>>                           \
>> +    int x, y;
>>                           \
>> +    const LUT3DContext *lut3d = ctx->priv;
>>                           \
>> +    const ThreadData *td = arg;
>>                           \
>> +    const AVFrame *in  = td->in;
>>                           \
>> +    const AVFrame *out = td->out;
>>                           \
>> +    const int direct = out == in;
>>                           \
>> +    const int slice_start = (in->height *  jobnr   ) / nb_jobs;
>>                           \
>> +    const int slice_end   = (in->height * (jobnr+1)) / nb_jobs;
>>                           \
>> +    uint8_t *grow = out->data[0] + slice_start * out->linesize[0];
>>                           \
>> +    uint8_t *brow = out->data[1] + slice_start * out->linesize[1];
>>                           \
>> +    uint8_t *rrow = out->data[2] + slice_start * out->linesize[2];
>>                           \
>> +    uint8_t *arow = out->data[2] + slice_start * out->linesize[2];
>>                           \
>> +    const uint8_t *srcgrow = in->data[0] + slice_start * in->linesize[0];
>>                           \
>> +    const uint8_t *srcbrow = in->data[1] + slice_start * in->linesize[1];
>>                           \
>> +    const uint8_t *srcrrow = in->data[2] + slice_start * in->linesize[2];
>>                           \
>> +    const uint8_t *srcarow = in->data[3] + slice_start * in->linesize[3];
>>                           \
>> +    const float scale = (1. / ((1<<depth) - 1)) * (lut3d->lutsize - 1);
>>                           \
>> +
>>                           \
>> +    for (y = slice_start; y < slice_end; y++) {
>>                           \
>> +        uint##nbits##_t *dstg = (uint##nbits##_t *)grow;
>>                           \
>> +        uint##nbits##_t *dstb = (uint##nbits##_t *)brow;
>>                           \
>> +        uint##nbits##_t *dstr = (uint##nbits##_t *)rrow;
>>                           \
>> +        uint##nbits##_t *dsta = (uint##nbits##_t *)arow;
>>                           \
>> +        const uint##nbits##_t *srcg = (const uint##nbits##_t *)srcgrow;
>>                           \
>> +        const uint##nbits##_t *srcb = (const uint##nbits##_t *)srcbrow;
>>                           \
>> +        const uint##nbits##_t *srcr = (const uint##nbits##_t *)srcrrow;
>>                           \
>> +        const uint##nbits##_t *srca = (const uint##nbits##_t *)srcarow;
>>                           \
>> +        for (x = 0; x < in->width; x++) {
>>                           \
>> +            const struct rgbvec scaled_rgb = {srcr[x] * scale,
>>                           \
>> +                                              srcg[x] * scale,
>>                           \
>> +                                              srcb[x] * scale};
>>                           \
>> +            struct rgbvec vec = interp_##name(lut3d, &scaled_rgb);
>>                           \
>> +            dstr[x] = av_clip(vec.r * (float)((1<<depth) - 1), 0,
>> (1<<depth) - 1);                  \
>> +            dstg[x] = av_clip(vec.g * (float)((1<<depth) - 1), 0,
>> (1<<depth) - 1);                  \
>> +            dstb[x] = av_clip(vec.b * (float)((1<<depth) - 1), 0,
>> (1<<depth) - 1);                  \
>
> av_clip_uintp2(vec.r * (float)((1<<depth) - 1), depth);
> av_clip_uintp2(vec.g * (float)((1<<depth) - 1), depth);
> av_clip_uintp2(vec.b * (float)((1<<depth) - 1), depth);
>

changed locally.


More information about the ffmpeg-devel mailing list