Re: Re: Help needed

Michael Niedermayer <[email protected]> Thu, 8 Sep 2005 00:21:47 +0200
Newsgroups gmane.comp.video.xine.codec.devel
Message-ID <[email protected]>
Hi

On Mon, Sep 05, 2005 at 07:08:00PM +0300, Kostya wrote:
> I've more or less understood their logic. Their intra blocks follow such 
> scheme:
>            LAST 4 ELEMENTS
>             V       V       V      V
> D0 -> +d00 +d10 +d20 +d30 -> D0
> D1 -> +d01 +d11 +d21 +d31 -> D1
> D2 -> +d02 +d12 +d22 +d32 -> D2
> D3 -> +d03 +d13 +d23 +d33 -> D3
>             V       V       V      V
>           LAST 4 ELEMENTS
> where D0-D3 - saved deltas, dxy - new delta for position x,y (note that 
> +d00 +d10 means D0 += d00; D0 += d10; and the same for LAST 4 ELEMENTS)
> 
> Inter blocks (still, motion, update) also update deltas D0-D3 and LAST4, 
> but somehow in another way.
> 
> Now my decoder decodes file tm20.avi from MPlayer samples repository 
> with artifacts and in grayscale only, but nevertheless close to original.
> 
> Can somebody review this code and suggest how to correct and/or some 
> optimise it?

well, i just took a quick look at the code (didnt compile or test it ...)
here is what i noticed


get_bits() is limited to a max of MIN_CACHE_BITS which is 25 with the
default bitstream reader and may be as low as 17 with others, i saw
some cases which read more, they should use get_bits_long()

the comments for structure fields should be in doxygen compatible format
(/** ... */ before or ///< after the field, or see the doxy manual there
are other variants too)


>     toks = BE_32(buf); buf += 4; cur += 4;
[...]
>     toks >>= 1;
>     ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
[...]
> 	for(i = 0; i < toks; i++)
>     	    ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);

looks bad, toks * sizeof(int) can overflow so that the allocated memory is
too small for the later for loop

[...]

-- 
Michael


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf