[FFmpeg-devel] [PATCH] Electronic Arts TGQ decoder

Michael Niedermayer michaelni
Sat Oct 4 03:19:50 CEST 2008


On Fri, Oct 03, 2008 at 09:43:51PM +1000, Peter Ross wrote:
> On Sat, Sep 27, 2008 at 08:07:05PM +1000, Peter Ross wrote:
> > On Sat, Sep 27, 2008 at 10:12:34AM +1000, Peter Ross wrote:
> > > Patches enclosed.
> > > 
> > > Info: http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TGQ
> > > Samples: http://samples.mplayerhq.hu/game-formats/ea-tgq-uv/
> > 
> > Thanks for the prompt feedback. Round two enclosed.
> 
> Round three. (See earlier posts for inv_aanscales.diff and eatgq-demux-r1.diff.)
> 
> -- Peter
> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

> Index: libavcodec/dsputil.c
> ===================================================================
> --- libavcodec/dsputil.c	(revision 15532)
> +++ libavcodec/dsputil.c	(working copy)
> @@ -4137,6 +4137,64 @@
>      dest[0] = cm[dest[0] + ((block[0] + 4)>>3)];
>  }
>  
> +/* Electronic Arts TGQ/TQI/MAD IDCT algorithm */
> +#define A4 1.3065630f
> +#define A2 0.5411961f
> +#define A5 0.3826834f
> +#define IDCT_TRANSFORM(dest,s0,s1,s2,s3,s4,s5,s6,s7,d0,d1,d2,d3,d4,d5,d6,d7,munge,src) {\

I think this should be in a seperate file, dsputil is already rather bloated


[...]
> +static void tgq_decode_block(TgqContext *s, DCTELEM block[64], GetBitContext *gb){
> +    uint8_t *perm = s->scantable.permutated;
> +    int i,j,value;
> +    block[0] = get_sbits(gb,8) * s->qtable[0];
> +    for(i=1; i<64; ) {
> +        switch(show_bits(gb,3)) {
> +        case 4:
> +            block[perm[i++]] = 0;
> +        case 0:
> +            block[perm[i++]] = 0;
> +            skip_bits(gb,3);
> +            break;

> +        case 5:
> +            block[perm[i++]] = 0;
> +        case 1:
> +            skip_bits(gb,3);
> +            value = 2*get_bits(gb,5);

isnt this the same as
case 5:
case 1:
    skip_bits(gb,2);
    value = get_bits(gb,6);
?


> +            for(j=0; j<value; j++)
> +                block[perm[i++]] = 0;
> +            break;
> +        case 6:
> +            skip_bits(gb,3);

> +            block[perm[i]] = -(s->qtable[perm[i]]);

superflous ()


> +            i++;
> +            break;
> +        case 2:
> +            skip_bits(gb,3);
> +            block[perm[i]] = s->qtable[perm[i]];
> +            i++;
> +            break;
> +        case 7: // 111b
> +        case 3: // 011b
> +            skip_bits(gb,2);
> +            if (show_bits(gb,6)==0x3F) {
> +                skip_bits(gb, 6);
> +                block[perm[i]] = get_sbits(gb,8)*s->qtable[perm[i]];
> +            }else{
> +                block[perm[i]] = get_sbits(gb,6)*s->qtable[perm[i]];
> +            }
> +            i++;
> +            break;
> +        }
> +    }
> +    block[0] += 128<<4;
> +}
[...]
> +static inline void tgq_dconly(TgqContext *s, unsigned char *dst, int dst_stride, int dc){
> +    int level = av_clip_uint8(128 + ((dc*s->qtable[0] + 8)>>4));

av_clip_uint8((dc*s->qtable[0] + 2056)>>4);


[...]
> +    if (!s->frame.data[0]) {
> +        s->frame.key_frame = 1;
> +        s->frame.pict_type = FF_I_TYPE;

> +        s->frame.reference = 1;

this is not strictly correct, is there any problem if its removed?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081004/a7d68fd7/attachment.pgp>



More information about the ffmpeg-devel mailing list