[FFmpeg-devel] [PATCH] Add scale filter

Stefano Sabatini stefano.sabatini-lala
Mon Nov 2 01:23:01 CET 2009


On date Saturday 2009-10-31 00:46:31 +0100, Michael Niedermayer encoded:
> On Fri, Oct 30, 2009 at 11:44:13AM +0100, Stefano Sabatini wrote:
[...]
> > +static void draw_slice(AVFilterLink *link, int y, int h)
> > +{
> > +    ScaleContext *scale = link->dst->priv;
> > +    int out_h;
> > +    AVFilterPicRef *cur_pic = link->cur_pic;
> > +    uint8_t *data[4];
> > +
> > +    if (!scale->slice_dir) {
> > +        if (y != 0 && y + h != link->h) {
> > +            av_log(scale, AV_LOG_ERROR, "Slices start in the middle!\n");
> > +            return;
> > +        }
> > +        scale->slice_dir = y ?                       -1 : 1;
> > +        scale->slice_y   = y ? link->dst->outputs[0]->h : y;
> > +    }
> > +
> > +    data[0] = cur_pic->data[0] +  y               * cur_pic->linesize[0];
> 
> > +    data[1] = link->format == PIX_FMT_PAL8 ?
> > +              cur_pic->data[1] :
> > +              cur_pic->data[1] + (y>>scale->vsub) * cur_pic->linesize[1];
> 
> the PAL8 check is insufficient, other 8bit formats can also have a fixed
> palette in there

swscale.c has this macro:

#define usePal(x)           (       \
           (x)==PIX_FMT_PAL8        \
        || (x)==PIX_FMT_BGR4_BYTE   \
        || (x)==PIX_FMT_RGB4_BYTE   \
        || (x)==PIX_FMT_BGR8        \
        || (x)==PIX_FMT_RGB8        \
     )

And in pixfmt.h there is:

 * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like
 * for pal8. This palette is filled in automatically by the function
 * allocating the picture.

BTW, why RGB4/BGR4 is not amongst them? It's not an 8bit format,
nonetheless looks like it would make sense to expect a palette for it
too.

Also it appears that the more sane way to export this information to
lavfi is through pixdesc, which would also allow to simplify many
filters.

Regards.
-- 
FFmpeg = Foolish & Freak Multimedia Patchable Emblematic Gargoyle



More information about the ffmpeg-devel mailing list