[FFmpeg-devel] [PATCH] lavfi test pattern generator

Michael Niedermayer michaelni
Fri Jan 2 02:51:44 CET 2009


On Fri, Jan 02, 2009 at 01:20:42AM +0100, Stefano Sabatini wrote:
> On date Sunday 2008-12-28 19:51:36 +0100, Stefano Sabatini encoded:
> > Hi all,
> > 
> > useful for testing, it is based on the test pattern generator by
> > Nicolas George:
> > http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-October/036838.html
> > 
> > basically I just stripped the audio signal generator and adapted few
> > things to the lavfi framework, so most credit goes to Nicolas.
> > 
> > And it would plenty cool to find some way to get ffmpeg/ffplay take as
> > input such a generator, but I still can't see how to do that.
> > 
> > What I can do now is to take as input /dev/null, then overlay the
> > test_pattern over it, but this is rather ugly.
> 
> New improved version which avoids an unnecessary memcpy and with misc
> cleanups, also rename it to test_src (better name suggestions are
> welcome, 

> I think the suffix "_src" is needed to avoid clashes with the
> filters namespace, for example "noise" versus "noise_src").

agree


[...]

> static int init(AVFilterContext *filt_ctx, const char *args, void *opaque)
> {
>     TestContext *ctx= filt_ctx->priv;
> 
>     if(!args) {
>         ctx->frame_rate = (AVRational) {25, 1};
>     } else {
>         sscanf(args, "%d:%d:%d:%d", &ctx->w, &ctx->h, &ctx->frame_rate.num, &ctx->frame_rate.den);
>     }
> 
>     /* todo: add more checks */
>     if (ctx->frame_rate.den <= 0 || ctx->frame_rate.num <= 0) {
>         av_log(filt_ctx, AV_LOG_ERROR, "Invalid frame rate value: %d/%d\n", ctx->frame_rate.num, ctx->frame_rate.den);
>         return -1;
>     }
> 
>     ctx->frame_nb = 0;
>     ctx->pts = 0;
> 
>     /* fill the frame */
>     {
>         unsigned int frame_size = avpicture_get_size(PIX_FMT_RGB24, ctx->w, ctx->h);

>         uint8_t* frame_data = (uint8_t*)av_malloc(frame_size);

useless cast


>         avpicture_fill((AVPicture*)(&ctx->frame), frame_data,
>                        PIX_FMT_RGB24, ctx->w, ctx->h);
>     }
> 
>     return 0;
> }
> 
> static int config_props(AVFilterLink *link)
> {
>     TestContext *ctx  = link->src->priv;
> 
>     link->w = ctx->w;
>     link->h = ctx->h;
> 
>     return 0;
> }
> 

> static void draw_rectangle(unsigned val, unsigned char *p, unsigned stride,
>     unsigned sw, unsigned x, unsigned y, unsigned w, unsigned h)
> {

id rename sw to some english word


>     unsigned i;
> 
>     p += sw * (3 * x + y * stride);
>     w *= 3 * sw;
>     h *= sw;
>     for(i = 0; i < h; i++) {
>         memset(p, val, w);
>         p += stride;
>     }
> }
> 
> static void draw_digit(int digit, unsigned char *p0, unsigned stride,
>     unsigned sw)
> {
>     static const unsigned char masks[10] = {
>         0x7D, 0x50, 0x37, 0x57, 0x5A, 0x4F, 0x6F, 0x51, 0x7F, 0x5F
>     };
>     unsigned mask = masks[digit];
> 
>     draw_rectangle(0, p0, stride, sw, 0, 0, 8, 13);
>     if(mask & 1)
>         draw_rectangle(255, p0, stride, sw, 1, 0, 5, 1);
>     if(mask & 2)
>         draw_rectangle(255, p0, stride, sw, 1, 6, 5, 1);
>     if(mask & 4)
>         draw_rectangle(255, p0, stride, sw, 1, 12, 5, 1);
>     if(mask & 8)
>         draw_rectangle(255, p0, stride, sw, 0, 1, 1, 5);
>     if(mask & 16)
>         draw_rectangle(255, p0, stride, sw, 6, 1, 1, 5);
>     if(mask & 32)
>         draw_rectangle(255, p0, stride, sw, 0, 7, 1, 5);
>     if(mask & 64)
>         draw_rectangle(255, p0, stride, sw, 6, 7, 1, 5);
> }

why not write a simple text renderer with fixed width ASCII bitmap font
mplayer contains a tool to make these bitmaps ...
... we could use this for subtitles as well and it is easy :)


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090102/1ee6ac4d/attachment.pgp>



More information about the ffmpeg-devel mailing list