[FFmpeg-devel] lavfi noise generator

Vitor Sessak vitor1001
Mon Dec 29 16:27:04 CET 2008


Stefano Sabatini wrote:
> On date Monday 2008-12-29 12:06:20 +0100, Vitor Sessak encoded:
>> Hi, and thank you for working with lavfi!
>>
>> Stefano Sabatini wrote:
>>> On date Monday 2008-12-29 00:52:18 +0100, Michael Niedermayer encoded:
>>>> On Mon, Dec 29, 2008 at 12:25:02AM +0100, Stefano Sabatini wrote:
>>>>> Hi all,
>>>>>
>>>>> no Michael I'm not posting it for you or others to review it, I'm just
>>>> no but i reject it anyway
>>>> your code is crap, sorry
>>>>
>>>> People didnt want to port libmpcodecs when i suggested it, i dont mind
>>>> this at all, libmpcodecs has its serious issues but this does not mean i
>>>> will accept code that is inferrior than it.
>>>>
>>>> vf_noise.c should be MUCH faster than your code.
>>> I'm aware of the speed issues, but that wasn't the point of it, I
>>> didn't intended it as something ready for production use either
>>> inclusion in SVN, but just as a working example, since we currently
>>> lack examples besides the other things and the noise generator is
>>> a good candidate due to its intrinsic simplicity.
>> Indeed, we are lacking good examples of filters in the SoC tree. But 
>> exactly for this reason, I think vf_noise.c should fill one slice at a 
>> time to give the good example. After this is done, IMO it is welcome to 
>> soc svn, at least to serve as a template.
> 
> Hi Vitor, vsrc_noise.c is a *source* rather than a filter, so I don't
> think it is possible to use the the draw_slice() API.

Indeed, it should not be possible, at least not with the current svn 
code. See my attached patch.

> What I'm
> currently doing is:
> 
> static int request_frame(AVFilterLink *link)
> {
>     NoiseContext *ctx = link->src->priv;
>     AVFilterPicRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE);
> 
>     fill_picture(ctx, picref);
>     picref->pts = av_rescale_q(ctx->pts++, (AVRational){ ctx->frame_rate.den, ctx->frame_rate.num }, AV_TIME_BASE_Q);
> 
>     avfilter_start_frame(link, avfilter_ref_pic(picref, ~0));
>     avfilter_draw_slice(link, 0, picref->h);
>     avfilter_end_frame(link);
> 
>     avfilter_unref_pic(picref);
> 
>     return 0;
> }

Could something like the following work?

#define SLICE_SIZE 32

static int request_frame(AVFilterLink *link)
{
     NoiseContext *ctx = link->src->priv;
     AVFilterPicRef *picref = avfilter_get_video_buffer(link, 
AV_PERM_WRITE);
     int h;

     picref->pts = av_rescale_q(ctx->pts++, (AVRational) { 
ctx->frame_rate.den, ctx->frame_rate.num }, AV_TIME_BASE_Q);

     avfilter_start_frame(link, avfilter_ref_pic(picref, ~0));
     for(h=0; h < ctx->h; h += SLICE_SIZE) {
        fill_picture(ctx, picref, h, FFMIN(h+SLICE_SIZE, ctx->h));
        avfilter_draw_slice(link, h, FFMIN(h+SLICE_SIZE, ctx->h));
     }
     avfilter_end_frame(link);

     avfilter_unref_pic(picref);

     return 0;
}

But maybe an even cleaner solution would be to use draw_slice() and 
change the function avfilter_request_frame() as in the completely 
untested attached patch.

-Vitor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: untested.diff
Type: text/x-diff
Size: 879 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081229/1c1aca88/attachment.diff>



More information about the ffmpeg-devel mailing list