[FFmpeg-devel] [PATCH] Yet another stab at RGB48 support

Kostya kostya.shishkov
Sat May 16 08:18:09 CEST 2009


On Fri, May 15, 2009 at 04:14:37PM +0200, Michael Niedermayer wrote:
> On Fri, May 15, 2009 at 08:56:28AM +0300, Kostya wrote:
> > On Wed, May 13, 2009 at 01:59:19AM +0200, Michael Niedermayer wrote:
> > > On Sun, May 10, 2009 at 03:21:23PM +0300, Kostya wrote:
[...]
> > > > +SwsRGBFunc sws_hires_getRGBFunc(SwsContext *c)
> > > > +{
> > > > +    const enum PixelFormat srcFormat = c->srcFormat;
> > > > +    const enum PixelFormat dstFormat = c->dstFormat;
> > > > +    const int srcCbe = srcFormat==PIX_FMT_RGB48BE; /* components big-endian */
> > > > +    const int dstCbe = dstFormat==PIX_FMT_RGB48BE;
> > > > +    const int srcBpp = (fmt_depth(srcFormat) + 7) >> 3;
> > > > +    const int dstBpp = (fmt_depth(dstFormat) + 7) >> 3;
> > > > +    const int srcId = (fmt_depth(srcFormat) >> 2) - (srcBpp > 4); /* 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8, 48:11 */
> > > > +    const int dstId = (fmt_depth(dstFormat) >> 2) - (dstBpp > 4);
> > > > +    SwsRGBFunc conv = NULL;
> > > > +
> > > > +    if (  (isBGR(srcFormat) && isBGR(dstFormat))
> > > > +       || (isRGB(srcFormat) && isRGB(dstFormat))) {
> > > > +        switch(srcId | (dstId<<4) | (srcCbe<<8) | (dstCbe<<12)){
> > > > +        case 0x013B: conv = rgb48beto15; break;
> > > > +        case 0x003B: conv = rgb48leto15; break;
> > > > +        case 0x014B: conv = rgb48beto16; break;
> > > > +        case 0x004B: conv = rgb48leto16; break;
> > > > +        case 0x016B: conv = rgb48beto24; break;
> > > > +        case 0x006B: conv = rgb48leto24; break;
> > > > +        case 0x018B: conv = rgb48beto32; break;
> > > > +        case 0x008B: conv = rgb48leto32; break;
> > > > +        case 0x10B3: conv = rgb15to48be; break;
> > > > +        case 0x00B3: conv = rgb15to48le; break;
> > > > +        case 0x10B4: conv = rgb16to48be; break;
> > > > +        case 0x00B4: conv = rgb16to48le; break;
> > > > +        case 0x10B6:
> > > > +        case 0x00B6: conv = rgb24to48; break;
> > > > +        case 0x10B8:
> > > > +        case 0x00B8: conv = rgb32to48; break;
> > > > +        case 0x10BB:
> > > > +        case 0x01BB: conv = rgb48to48; break;
> > > > +        default: av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > > > +                        sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
> > > > +        }
> > > > +    } else if (  (isBGR(srcFormat) && isRGB(dstFormat))
> > > > +             || (isRGB(srcFormat) && isBGR(dstFormat))) {
> > > > +        switch(srcId | (dstId<<4) | (srcCbe<<8) | (dstCbe<<12)){
> > > > +        case 0x013B: conv = rgb48betobgr15; break;
> > > > +        case 0x003B: conv = rgb48letobgr15; break;
> > > > +        case 0x014B: conv = rgb48betobgr16; break;
> > > > +        case 0x004B: conv = rgb48letobgr16; break;
> > > > +        case 0x016B: conv = rgb48betobgr24; break;
> > > > +        case 0x006B: conv = rgb48letobgr24; break;
> > > > +        case 0x018B: conv = rgb48betobgr32; break;
> > > > +        case 0x008B: conv = rgb48letobgr32; break;
> > > > +        case 0x10B3: conv = bgr15torgb48be; break;
> > > > +        case 0x00B3: conv = bgr15torgb48le; break;
> > > > +        case 0x10B4: conv = bgr16torgb48be; break;
> > > > +        case 0x00B4: conv = bgr16torgb48le; break;
> > > > +        case 0x10B6:
> > > > +        case 0x00B6: conv = bgr24torgb48; break;
> > > > +        case 0x10B8:
> > > > +        case 0x00B8: conv = bgr32torgb48; break;
> > > > +        default: av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > > > +                        sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
> > > > +        }
> > > > +    } else {
> > > > +        av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > > > +               sws_format_name(srcFormat), sws_format_name(dstFormat));
> > > > +    }
> > > > +
> > > > +    return conv;
> > > > +}
> > > 
> > > code duplication
> > 
> > hmm? 
> 
> there aleady is a function that does rgb<->rgb adding another duplicates
> parts of its code

This one is called from it specifically for handling hi-res conversion.
I thought it would be better this way than to export a lot of conversion
functions.
 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB



More information about the ffmpeg-devel mailing list