On Fri, Mar 02, 2012 at 05:21:01PM +0100, Diego Biurrun wrote:
> On Fri, Mar 02, 2012 at 01:03:38AM +0100, Diego Biurrun wrote:
> > On Thu, Mar 01, 2012 at 05:43:00AM -0800, Mashiat Sarker Shakkhar wrote:
> > > 
> > > --- /dev/null
> > > +++ b/libavcodec/wmalosslessdec.c
> > > @@ -0,0 +1,1288 @@
> > > +static void clear_codec_buffers(WmallDecodeCtx *s)
> > > +{
> > > +    int ich, ilms;
> > > +
> > > +    memset(s->acfilter_coeffs, 0, 16 * sizeof(s->acfilter_coeffs[0]));
> > > +    memset(s->acfilter_prevvalues, 0, 16 * 2 * 
> > > sizeof(s->acfilter_prevvalues[0]));
> > > +    memset(s->lpc_coefs, 0, 40 * 2 * sizeof(s->lpc_coefs[0]));
> > > +
> > > +    memset(s->mclms_coeffs, 0, 128 * sizeof(s->mclms_coeffs[0]));
> > > +    memset(s->mclms_coeffs_cur, 0, 4 * sizeof(s->mclms_coeffs_cur[0]));
> > > +    memset(s->mclms_prevvalues, 0, 64 * sizeof(s->mclms_prevvalues[0]));
> > > +    memset(s->mclms_updates, 0, 64 * sizeof(s->mclms_updates[0]));
> > > +
> > > +    for (ich = 0; ich < s->num_channels; ich++) {
> > > +        for (ilms = 0; ilms < s->cdlms_ttl[ich]; ilms++) {
> > > +            memset(s->cdlms[ich][ilms].coefs, 0,
> > > +                   256 * sizeof(s->cdlms[ich][ilms].coefs[0]));
> > > +            memset(s->cdlms[ich][ilms].lms_prevvalues, 0,
> > > +                   512 * sizeof(s->cdlms[ich][ilms].lms_prevvalues[0]));
> > > +            memset(s->cdlms[ich][ilms].lms_updates, 0,
> > > +                   512 * sizeof(s->cdlms[ich][ilms].lms_updates[0]));
> > > +        }
> > 
> > Using [0] instead of * here is equivalent but uncommon.  So uncommon
> > that grep cannot find a single instance of it in Libav.  This should
> > therefore be adapted to the more usual style.
> 
> Also, hardcoding the array sizes in the memset call here is brittle and
> somewhat ugly.  We have the FF_ARRAY_ELEMS macro in libavutil/common.h
> for that.
> 
>   memset(s->acfilter_coeffs, 0, 16 * sizeof(s->acfilter_coeffs[0]));
> 
> --->
> 
>   memset(s->acfilter_coeffs, 0,
>          FF_ARRAY_ELEMS(s->acfilter_coeffs) * sizeof(*s->acfilter_coeffs));

Or even less nonsensy:

  memset(s->acfilter_coeffs, 0, sizeof(s->acfilter_coeffs));

Diego
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to