[FFmpeg-devel] [RFC] AAC Encoder

Michael Niedermayer michaelni
Tue Aug 12 19:48:59 CEST 2008


On Tue, Aug 12, 2008 at 08:09:36PM +0300, Kostya wrote:
> On Tue, Aug 12, 2008 at 02:14:20PM +0200, Michael Niedermayer wrote:
> > On Tue, Aug 12, 2008 at 08:33:15AM +0300, Kostya wrote:
> > > On Mon, Aug 11, 2008 at 08:03:49PM +0200, Michael Niedermayer wrote:
> > > > On Mon, Aug 11, 2008 at 12:18:03PM +0300, Kostya wrote:
> > > > > Here's my implementation of AAC encoder.
> > > > > 
> > > > > Since AAC decoder is not fully in SVN yet, I'm omitting data structures
> > > > > and declarations used from it, I'll sort it after decoder commit.
> > > > > The main difference is that psy model fills data structures and encoder
> > > > > writes bitstream with them, so several structures have additional members.
> > > > > 
> > > > > I've also stripped out model based on 3GPP 26.403 to make review easier.
> > > > 
> > [...]
> > > [...]
> > > > > +            }while(w < cpe->ch[channel].ics.num_windows && cpe->ch[channel].ics.group_len[w]);
> > > > > +        }
> > > > > +        if(score < best){
> > > > > +            best = score;
> > > > > +            bestcb = cb;
> > > > > +        }
> > > > > +    }
> > > > > +    return bestcb;
> > > > > +}
> > > > 
> > > > This code does not seem to consider the distortion
> > > > please use rate distortion not just the number of bits!
> > >  
> > > Umm, why?
> > > By this point psy model produced coefficients to encode and encoder
> > > tries to write them in a minimum number of bits.
> > > It's lossless operation.
> > 
> > We have a problem here, because this isnt optimal
> > It seems we agree that each bit counts the same no matter what psy says.
> > Maybe a example will best show the problem
> > lets assume we have a coeff of 11.5, the psy model decides that a change
> > to 10 would be ok for the given audio quality/bitrate and thus outputs 10
> > let us assume that storing a coefficient of 10 and one of 11 both take
> > 7 bit, the decission to store 10 clearly was bad. OTOH it could have
> > been that storing 11 requires twice as many bits in which case the
> > decission would have been good. One simply cannot quantize values optimally
> > without considering the number of bits they need. This is even more true
> > for vector quantization based codecs than it is for scalar quantization.
> > it may very well be that psy thinks that both {-1,1} and {-2,0} are an
> > equally good representation of the exact {-1.5,0.5} but its not until
> > the encoding that it becomes known which of the two need fewer bits.
> > 
> > Id say the psy model should return an array of perceptual weights W[i]
> > and the bitstream encode should choose the (global) minimum of
> > bits[i] + distortion(W[i], coeff[i]-stored[i])
> > where distortion is a appropriate function whos output matches how audible
> > a change is, this may be a simple W[i]*(coeff[i]-stored[i])^2 but iam no
> > psychoacoustic expert so there may be better choices.
> > 
> > And of course the suggested system above needs to be compared to what you
> > have currenty so that we can be sure it really does sound better.
> 
> I understand what you mean but I suspect that is of complexity O("shaving piglets").
> 
> I followed 3GPP TS26.403 which relies on perceptual entropy which more
> or less corresponds to the number of bits needed to code it since it's easier.
> Anyway, it would be easy to implement psy model that will consider
> real coding cost vs. distortion.

if you do not want to implement this then i will have to investigate if it
is doable or not and why, could you provide me with some more elaborate
explanation of where the problem is?

[...]

-- 
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/20080812/16079ac7/attachment.pgp>



More information about the ffmpeg-devel mailing list