[FFmpeg-devel] [PATCH] ALAC Encoder

Jai Menon realityman
Tue Aug 19 19:11:17 CEST 2008


Hi,

On Tuesday 19 Aug 2008 9:45:41 pm Michael Niedermayer wrote:
> 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
>

Sure. I got the concept of splitting properly now :-)

> > > [...]
> > >
> > > > @@ -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
>

And applied...
Thanks for the reviews!


Regards,

Jai Menon




More information about the ffmpeg-devel mailing list