[FFmpeg-devel] [PATCH] Common code for Indeo interactive

Maxim max_pole
Wed Mar 25 12:16:05 CET 2009


Kostya schrieb:
> On Tue, Mar 24, 2009 at 04:27:56PM +0100, Maxim wrote:
>   
>> Michael Niedermayer schrieb:
>>     
>>> On Thu, Mar 19, 2009 at 11:12:40PM +0100, Maxim wrote:
>>>   
>>>       
>>>> Hello guys,
>>>>
>>>> here is the 1st part of my patch making FFmpeg decode Indeo interactive
>>>> (indeo4/indeo5) streams. Both codecs are very similar but use abit
>>>> different bitstream formats, so I decided myself to put all common
>>>> functions and tables together and submit them as a separate patch.
>>>> The 2nd part will be the long-awaited indeo5 decoder...
>>>> Please review!
>>>>     
>>>>         
>>>   
>>>       
>>>   
>>>       
>>>> {
>>>>     int         result, pos, i, j, codes_per_row, prefix, last_row;
>>>>     uint16_t    codewords[256]; /* FIXME: move this temporal storage out here? */
>>>>     uint8_t     bits[256];
>>>>
>>>>     pos = 0; /* current position = 0 */
>>>>
>>>>     for (i = 0; i < cb->num_rows; i++) {
>>>>         codes_per_row = 1 << cb->xbits[i];
>>>>         last_row = (i - cb->num_rows + 1) != 0; /* = 0 for the last row */
>>>>         prefix = ((1 << i) - 1) << (cb->xbits[i] + last_row);
>>>>
>>>>         for (j = 0; j < codes_per_row; j++) {
>>>>             if(pos >= 256)  /* some indeo5 codebooks can have more as 256 elements */
>>>>                 break;      /* but only 256 codes are allowed! */
>>>>
>>>>             bits[pos] = i + cb->xbits[i] + last_row;
>>>>             if (bits[pos] > IVI_VLC_BITS)
>>>>                 return -1; /* invalid descriptor */
>>>>
>>>>             codewords[pos] = ivi_inv_bits((prefix | j), bits[pos]);
>>>>             if (bits[pos] == 0)
>>>>                 bits[pos] = 1;
>>>>
>>>>             pos++;
>>>>         }//for j
>>>>     }//for i
>>>>
>>>>     /* number of codewords = pos */
>>>>     result = init_vlc(pOut, IVI_VLC_BITS, pos, &bits[0], 1, 1, &codewords[0], 2, 2, (flag & INIT_VLC_USE_STATIC) | INIT_VLC_LE);
>>>>     
>>>>         
>>> #define INIT_VLC_USE_STATIC 1 ///< VERY strongly deprecated and forbidden
>>>   
>>>       
>> What should be used instead? Changing INIT_VLC_USE_STATIC to
>> INIT_VLC_USE_NEW_STATIC causes a crash. Am I doing smth wrong?
>>     
>
> That flag requires setting table pointer in VLC struct to static array before init -
> look at macro INIT_VLC_STATIC in libavcodec/bitstream.h
>   

Ok, I tried to use INIT_VLC_STATIC but it doesn't work (crash) because
the tables are in the little endian format. The only possibility I see
is to add two lines of code doing the same like this:

static VLC_TYPE   huff_tabs[8][8192][2]; ///< space for code/bits tables
static VLC              mb_vlc_tabsvlc[8];

for (t = 0; t < 8; t++) {
    /* build the table here (ommited) */
    huff_vlc[t].table = &huff_tabs[t][0][0];
    huff_vlc[t].table_allocated = 8192;
    init_vlc(&huff_vlc[t], IVI_VLC_BITS, pos, &bits[0], 1, 1,
&codewords[0], 2, 2, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE);
}

Is that ok? I can imagine myself to have a version of the
INIT_VLC_STATIC that allows to init little endian tables...

Sorry for asking around, but I didn't see anything comparable anywhere
in the FFmpeg...

> P.S. I have one disk with files encoded with Indeo 5 beta. Your decoder decodes
> them with motion and other artefacts but picture is mostly OK. Binary decoder
> used to hand my computer completely.
>   

I just looked into it - the sample "AV36_1.AVI" have a strange frame
sequence unknown to me. The decoder core is error-free though...
The problem is that somewhere in this video my decoder choose wrong
prediction frame. I think it's possible to add a fix for it quickly...

Regards
Maxim




More information about the ffmpeg-devel mailing list