[FFmpeg-devel] [PATCH] ALAC Encoder
Michael Niedermayer
michaelni
Tue Aug 19 18:15:41 CEST 2008
On Tue, Aug 19, 2008 at 08:48:09PM +0530, Jai Menon wrote:
> Hi,
>
> On Tuesday 19 Aug 2008 2:08:32 am Michael Niedermayer wrote:
> > On Tue, Aug 19, 2008 at 01:09:07AM +0530, Jai Menon wrote:
[...]
> >
> > > + sum >>= lpc.lpc_quant;
> > > + sum += samples[0];
> > > + residual[i] = samples[lpc.lpc_order+1] - sum;
> > > + res_val = residual[i];
> > > +
> > >
> > > + if(res_val) {
> > > + int index = lpc.lpc_order - 1;
> > > + int neg = (res_val < 0);
> > > +
> > > + while(index >= 0 && (neg ? (res_val < 0):(res_val > 0)))
> > > { + int val = samples[0] - samples[lpc.lpc_order -
> > > index]; + int sign = (val ? FFSIGN(val) : 0);
> > > +
> > > + if(neg)
> > > + sign*=-1;
> > > +
> > > + lpc.lpc_coeff[index] -= sign;
> > > + val *= sign;
> > > + res_val -= ((val >> lpc.lpc_quant) *
> > > + (lpc.lpc_order - index));
> > > + index--;
> > > + }
> > > + }
> >
> > this part is also used in the decoder, thus could be factorized into
> > a common function
> > alac_entropy_coder() also has some common code with the decoder but it
> > is maybe too much interleaved with non-common code to factorize.
> >
>
> I feel that the code in the encoder is cleaner. So when this is committed,
> I'll see if I can split this code out from the encoder rather than the
> decoder. But then we'll have to rename alac.c to alacdec.c and have a
> separate file just for this one hunk ;-)
yes and dont forget to use svn mv / cp as needed
>
> >
> > [...]
> >
> > > @@ -226,6 +404,32 @@
> > > AV_WB8(alac_extradata+20, s->rc.k_modifier);
> > > }
> > >
> > > + if(avctx->min_prediction_order >= 0) {
> > > + if(avctx->min_prediction_order < MIN_LPC_ORDER ||
> > > + avctx->min_prediction_order > MAX_LPC_ORDER) {
> > > + av_log(avctx, AV_LOG_ERROR, "invalid min prediction order:
> > > %d\n", avctx->min_prediction_order); + return -1;
> > > + }
> > > +
> > > + s->min_prediction_order = avctx->min_prediction_order;
> > > + }
> > > +
> > > + if(avctx->max_prediction_order >= 0) {
> > > + if(avctx->max_prediction_order < MIN_LPC_ORDER ||
> > > + avctx->max_prediction_order > MAX_LPC_ORDER) {
> > > + av_log(avctx, AV_LOG_ERROR, "invalid max prediction order:
> > > %d\n", avctx->max_prediction_order); + return -1;
> > > + }
> > > +
> > > + s->max_prediction_order = avctx->max_prediction_order;
> > > + }
> > > +
> > > + if(s->max_prediction_order < s->min_prediction_order) {
> > > + av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d
> > > max=%d\n", + s->min_prediction_order,
> > > s->max_prediction_order); + return -1;
> > > + }
> > > +
> > > avctx->extradata = alac_extradata;
> > > avctx->extradata_size = ALAC_EXTRADATA_SIZE;
> > >
> > > @@ -255,6 +459,9 @@
> > > return -1;
> > > }
> > >
> > > +verbatim:
> > > + init_put_bits(pb, frame, buf_size);
> > > +
> > > if((s->compression_level == 0) || verbatim_flag) {
> > > // Verbatim mode
> > > int16_t *samples = data;
> >
> > ok
> >
> > btw, if you want a svn write account, send diego your wanted username
> > and password (GPG encrypted!)
> > Assuming that you agree to our svn policy and are willing to maintain your
> > encoder after SOC.
> >
>
> I have replied to this separately.
>
> Sadly, nobody was around to commit the previous stuff. The attached patch
> addresses the issues.
patch ok
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Frequently ignored awnser#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- 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/20080819/1d807ba2/attachment.pgp>
More information about the ffmpeg-devel
mailing list