[FFmpeg-trac] Bad palette in decoding MPEG2 Subtitle

Emmanuel HOUITTE ehouitte at yacast.fr
Mon Nov 14 13:54:56 CET 2011


Hi,

I'm trying to decode MPEG2 Subtitle in TS MPEG2 file.

There is no problem with an old version (02 december 2008) with rgba_palette code in AVSubtitleRect. rgba_palette was an (uint32_t *) variable.

Since recent version, ffmpeg has included rgba_palette in (uint8_t *) in data[1] table and we have got an 8 bits palette instead of 32 bits.

So, every subtitle are monocolors.

Is there something I have misunderstood or there is really a bug?



This is some code to introduce my problem:



// Main
// Decode subtitle frame
int nRes = avcodec_decode_subtitle(pCodecCtx, pSubtitle, &frameFinished, packet.data, packet.size);

// Did we get a subtitle frame?
if(frameFinished != 0)
{
nSize = pSubtitle->num_rects;
for(i = 0; i < nSize; ++i)
{
int width = pSubtitle->rects[i].w;
int height = pSubtitle->rects[i].h;
SaveFrame(&pSubtitle->rects[i], width, height);
}

}





// Save
static void SaveFrame(AVSubtitleRect* pRect, int width, int height)
{
char szImagename[32];
sprintf(szImagename, "d:\\tmp\\ST\\frame%d.ppm", iFrame);
FILE* pImage=fopen(szImagename, "w");

int x, y, v;
for(y = 0; y < height; y++)
{
for(x = 0; x < width; x++)
{

// 20081202 version:  v is uint32_t
v = pRect->rgba_palette[pRect->bitmap[y * width + x]];

// recent version: v is uint8_t
//v = pRect->pict.data[1][pRect->pict.data[0][y * width + x]];

putc((v >> 16) & 0xff, pImage);
putc((v >> 8) & 0xff, pImage);
putc((v >> 0) & 0xff, pImage);
}
}
}




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://avcodec.org/pipermail/ffmpeg-trac/attachments/20111114/6b676fb3/attachment.html>


More information about the FFmpeg-trac mailing list