[FFmpeg-devel] [PATCH] add top video filter

Mark Himsley mark at mdsh.com
Tue Mar 29 23:02:53 CEST 2011


On 29/03/11 17:50, Stefano Sabatini wrote:
> On date Monday 2011-03-28 14:47:20 +0100, Mark Himsley encoded:

[...]

>> +
>> +static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
>> +{
>> +    AVFilterContext *ctx = link->dst;
>> +    TopContext *top      = ctx->priv;
>> +
>> +    AVFilterBufferRef *inpic = link->cur_buf;
>> +    AVFilterBufferRef *outpic = link->dst->outputs[0]->out_buf;
>> +    int i, plane;
>> +    uint8_t *cpy_dst;
>> +
>> +    if (inpic->video->interlaced) {
>> +        if (inpic->video->top_field_first != top->dst_tff) {
>
>> +            av_log(ctx, AV_LOG_DEBUG,
>> +                    "picture will move %s one line\n",
>> +                    top->dst_tff ? "up" : "down");
>
> av_dlog(ctx, "...", ) or this will spam the log with -loglevel debug
>
> (and put a /* #define DEBUG */ at the top of the file)
>
>> +            for (plane = 0; plane<  4&&  outpic->data[plane]; plane++) {
>> +                cpy_dst = outpic->data[plane] + y * outpic->linesize[plane];
>> +                if (top->dst_tff) {
>> +                    for (i = 0; i<  h; i++) {
>> +                        if (1 + y + i<  outpic->video->h) {
>> +                            memcpy(cpy_dst, cpy_dst + outpic->linesize[plane], outpic->linesize[plane]);
>
> You're copying more than it is required, outpic->linesize[plane] ->  line_step[plane] * w;

Am I?
I want to copy a whole line, from line+1 to line.
Where does w some from BTW?

>
>> +                        } else {
>> +                            memcpy(cpy_dst, cpy_dst - 2 * outpic->linesize[plane], outpic->linesize[plane]);
>> +                        }
>
> If I'm correct this is copy the line which is tow lines up the current
> one, that is:
> ...
> line N-2
> line N-1
> line N-2
>
> Can you confirm this is the standard behavior? (also it should be
> possibly documented).
>
>> +                        cpy_dst += outpic->linesize[plane];
>> +                    }
>> +                } else {
>> +                    cpy_dst += (h -1) * outpic->linesize[plane];
>> +                    for (i = h -1; i>= 0 ; i--) {
>> +                        if ( y + i>  0) {
>> +                            memcpy( cpy_dst, cpy_dst - outpic->linesize[plane], outpic->linesize[plane] );
>> +                        } else {
>> +                            memcpy( cpy_dst, cpy_dst + 2 * outpic->linesize[plane], outpic->linesize[plane] );
>> +                        }
>> +                        cpy_dst -= outpic->linesize[plane];
>> +                    }
>> +                }
>> +            }
>
>> +        } else {
>
>> +            av_log(ctx, AV_LOG_DEBUG,
>> +                    "field order already correct\n");
>
> av_dlog()
>
>> +        }
>> +    }
>> +
>> +    avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir);
>> +}


More information about the ffmpeg-devel mailing list