[FFmpeg-devel] [PATCH] Common ACELP code & G.729 [2/7] - pitch lag decoding
Michael Niedermayer
michaelni
Fri May 2 20:44:01 CEST 2008
On Fri, May 02, 2008 at 06:36:34PM +0700, Vladimir Voroshilov wrote:
> This patch contains pitch lag decoding routines (according to different
> encoding schemes).
>
> Routines returns packed (multiplied by 3int+frac+1 or 6int+frac+2)
> pitch lag value.
> This made them much simple.
[...]
> +/**
> + * \brief decode pitch lag of the first subframe encoded by 8 bits with 1/3
> + * resolution
> + * \param ac_index adaptive codebook index (8 bits)
> + *
> + * \return 3*pitch_lag+1
> + *
> + * Pitch delay is coded:
> + *
> + * 1 2
> + * [19 ---; 84 ---] - with 1/3 resolution
> + * 3 3
> + *
> + * [85; 143] - integers only
> + */
> +static int decode_lag3_1st_8_bits(int ac_index)
> +{
> + ac_index += 59;
> + if(ac_index > 255)
> + ac_index = 3 * ac_index - 512;
> + return ac_index;
> +}
> +
> +int ff_acelp_decode_lag3_8_4_bits(
> + int ac_index,
> + int subframeno,
> + int pitch_lag_min)
> +{
> + // (4.1.3 of G.729 and 5.6.1 of AMR)
> + if (!subframeno)
> + return decode_lag3_1st_8_bits(ac_index);
> + else
> + {
> + ac_index &= 0xf;
> +
> + if(ac_index < 4)
> + return 3*(ac_index + pitch_lag_min) + 1;
> + else if(ac_index < 12)
> + return 3*pitch_lag_min + ac_index + 7;
> + else
> + return 3*(ac_index + pitch_lag_min) - 17;
> + }
> +}
> +
> +int ff_acelp_decode_lag3_8_56_bits(
> + int ac_index,
> + int subframeno,
> + int pitch_lag_min)
> +{
> + // (4.1.3 of G.729 and 5.6.1 of AMR)
> + if (!subframeno)
> + return decode_lag3_1st_8_bits(ac_index);
> + else
> + return 3*pitch_lag_min + ac_index - 1;
> +}
It seems as if it would be simpler to do the if (!subframeno) check outside
after all its always doing the same, this would also avoid having to pass
subframeno as argument.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- 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/20080502/46619129/attachment.pgp>
More information about the ffmpeg-devel
mailing list