[FFmpeg-devel] [PATCH] Add a G.722 encoder
Michael Niedermayer
michaelni
Thu Sep 23 22:54:33 CEST 2010
On Fri, Sep 17, 2010 at 09:31:15AM +0300, Martin Storsj? wrote:
[...]
> +static inline int encode_high(G722Context *c, int xhigh)
[...]
> +static inline int encode_low(const struct G722Band* state, int xlow)
creepily inconsistant both should be G722Band if possible
> +{
> + int diff = av_clip_int16(xlow - state->s_predictor);
> + /* = diff >= 0 ? diff : -(diff + 1) */
> + int limit = diff ^ (diff >> (sizeof(diff)*8-1));
> + int i = 0;
> + limit = limit + 1 << 10;
> + if (limit > low_quant[8] * state->scale_factor)
> + i = 9;
> + while (i < 29 && limit > low_quant[i] * state->scale_factor)
> + i++;
> + return (diff < 0 ? (i < 2 ? 63 : 33) : 61) - i;
> +}
> +
> +static int g722_encode_frame(AVCodecContext *avctx,
> + uint8_t *dst, int buf_size, void *data)
> +{
> + G722Context *c = avctx->priv_data;
> + const int16_t *samples = data;
> + int i;
> +
> + for (i = 0; i < buf_size >> 1; i++) {
> + int xlow, xhigh, ihigh, ilow;
> + filter_samples(c, &samples[2*i], &xlow, &xhigh);
> + ihigh = encode_high(c, xhigh);
> + ilow = encode_low(&c->band[0], xlow);
> + update_low_predictor(&c->band[0], ilow >> 2);
update_* is also inconsistantly called
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100923/d0626ae9/attachment.pgp>
More information about the ffmpeg-devel
mailing list