[FFmpeg-devel] [PATCH] ALAC Encoder

Michael Niedermayer michaelni
Sun Aug 17 21:17:34 CEST 2008


On Mon, Aug 18, 2008 at 12:01:46AM +0530, Jai Menon wrote:
> Hi,
> 
> On Sunday 17 Aug 2008 6:45:17 pm Michael Niedermayer wrote:
> > On Sun, Aug 17, 2008 at 09:09:00AM +0530, Jai Menon wrote:
> > > Hi,
> > >
> > > On Sunday 17 Aug 2008 8:05:14 am Michael Niedermayer wrote:
> > > > On Sun, Aug 17, 2008 at 04:14:43AM +0530, Jai Menon wrote:
> >
> > [...]
> >
> > > > > +static void alac_stereo_decorrelation(AlacEncodeContext *s)
> > > > > +{
> > > > > +    int32_t *left = s->sample_buf[0], *right = s->sample_buf[1];
> > > > > +    int32_t tmp;
> > > > > +    int i;
> > > > > +
> > > > > +    for(i=0; i<s->avctx->frame_size; i++) {
> > > > > +        tmp = left[i];
> > > > > +        left[i] = (tmp + right[i]) >> 1;
> > > > > +        right[i] = tmp - right[i];
> > > > > +    }
> > > > >
> > > > > +    s->interlacing_leftweight = 1;
> > > > > +    s->interlacing_shift = 1;
> > > >
> > > > i do not belive this is optimal
> > >
> > > It may not be optimal in the sense that I do not adaptively select the
> > > decorrelation scheme, but this is just the first iteration which aims at
> > > getting a basic encoder into svn. And it is better than doing no
> > > deorrelation. I did initially try out an adaptive approach but the
> > > difference in compression wasn't that great. I'm looking into how this
> > > can be done in a better manner. Till then, I was hoping if we could go
> > > with this.
> >
> > see the pca.c/h i posted in a reply to ramiro a few days ago
> > it might be worth a try ... (and dont hesitate to ask if you have no clue
> > on how to use it ...)
> >
> 
> I'd be lying if I said I understood much. The math seems okay but how does 
> this fit in with decorrelation?

Iam seeing now that ALAC does not use (or support) a orthogonal decorrelation
but rather has one axis fixed at <1,-1> and allows the second to vary. This
does not seem to be the right problem for PCA which is limited to orthogonal
decorrelations.

So iam sorry for pointing to the wrong algorithm.
i guess simply calculating the bits for
(left[i] + right[i])>>1
left[i]
right[i]

and picking the best may help for some files.

anyway, just in case you dont know the forward transform (its not in the
encoder) it should be:

b= left
a= right
b -= a;
a += (b * interlacing_leftweight) >> interlacing_shift;
left= a;
right= b;

and weight,shift being 0,2 ; 1,2 ; 2,2
for the 3 examples above

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- 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/20080817/05fa54d1/attachment.pgp>



More information about the ffmpeg-devel mailing list