[FFmpeg-devel] indeo4/indeo5 inverse quantization

Michael Niedermayer michaelni
Sun May 30 01:12:21 CEST 2010


On Sat, May 29, 2010 at 02:04:25AM +0200, Maxim wrote:
> Hi crews,
> 
> due the fact that quantization schemes of indeo4/indeo5 are quite
> different I & Kostya elaborated an unified version. According to that
> the base quant tables of the existing indeo5 decoder must be upscaled by
> the factor of 2. This let us calculate dequantization factor in the
> common way for both codecs using the following equation:
> 
> q = (base_tab[scan_pos] * scale_tab[q_level]) >> 9;
> 
> Indeo4 doesn't require any scale table so a dummy one is used that
> statisfies the following condition:
> 
> dummy_scale_tab[q_level] = q_level;
> 
> Indeo4 quant tables can be found in the attached "indeo4data.h". Note
> that it's for reference only!
> 
> It would be very appreciated if someone had an idea how that stuff can
> be further optimized/improved. If not - I'll commit it after some time...
> 
> Best regards
> Maxim

> Index: libavcodec/ivi_common.c
> ===================================================================
> --- libavcodec/ivi_common.c	(Revision 23369)
> +++ libavcodec/ivi_common.c	(Arbeitskopie)
> @@ -338,7 +338,8 @@
>      RVMapDesc   *rvmap = band->rv_map;
>      void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
>      void (*mc_no_delta_func)  (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
> -    const uint8_t   *base_tab, *scale_tab;
> +    const uint16_t  *base_tab;
> +    const uint8_t   *scale_tab;
>  
>      prev_dc = 0; /* init intra prediction for the DC coefficient */
>  
> @@ -414,7 +415,7 @@
>                      if (IVI_DEBUG && !val)
>                          av_log(NULL, AV_LOG_ERROR, "Val = 0 encountered!\n");
>  
> -                    q = (base_tab[pos] * scale_tab[quant]) >> 8;
> +                    q = (base_tab[pos] * scale_tab[quant]) >> 9;
>                      if (q > 1)
>                          val = val * q + FFSIGN(val) * ((q >> 1) - (q & 1));

((q >> 1) - (q & 1))
could be replaced by

((q^1)-1)>>1

also val could be kept in absolute value + sign form and onl be changed
to normal c style int afterwards this would avoid the need for FFSIGN()

and quant changes per mb not per block thus scale_tab[quant] can be calculated
outside the loop

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- 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/20100530/6838abcd/attachment.pgp>



More information about the ffmpeg-devel mailing list