[FFmpeg-devel] [PATCH] libavcodec/lpc.c: Fix warning about uninitialized variable
Justin Ruggles
justin.ruggles
Wed Feb 11 12:25:01 CET 2009
Patrik Kullman wrote:
> On Tue, 2009-02-10 at 21:05 -0500, Justin Ruggles wrote:
>> Jai Menon wrote:
>>> On Tue, Feb 10, 2009 at 2:38 PM, Patrik Kullman <patrik at yes.nu> wrote:
>>>> On Tue, 2009-02-10 at 14:29 +0530, Jai Menon wrote:
>>>>> On Tue, Feb 10, 2009 at 2:14 PM, Jai Menon <jmenon86 at gmail.com> wrote:
>>>>>> On Tue, Feb 10, 2009 at 2:08 PM, Patrik Kullman <patrik at yes.nu> wrote:
>>>>>>> If use_lpc < 1 and max_order > 0, weight would be uninitialized.
>>>>>> since a use_lpc of 0 was never intended, maybe an assert could be used....
>>>>> to clarify, i meant an assert on use_lpc == 0
>>>> Well, a negative value in use_lpc wouldn't initialize weight either.
>>>> Are negative values intended?
>>> Justin could probably comment but semantically it makes no sense.
>>> also, this is supposed to be used internally so asserting should be ok.
>>> anyhow, please wait for others to comment/approve/disapprove.
>> Adding "assert(use_lpc > 0);" sounds like a good idea. Perhaps that
>> parameter should have better documentation as well.
>> 0 = LPC with fixed pre-defined coeffs
>> 1 = LPC with coeffs determined by Levinson-Durbin recursion
>> 2+ = LPC with coeffs determined by Cholesky factorization using
>> (use_lpc-1) passes.
>>
>> Therefore, ff_lpc_calc_coefs() should not be called with use_lpc<=0.
>>
>> -Justin
>
> So how about I add the documentation in the patch?
>
>
> Index: libavcodec/lpc.c
> ===================================================================
> --- libavcodec/lpc.c (revision 17149)
> +++ libavcodec/lpc.c (working copy)
> @@ -94,6 +94,11 @@
>
> /**
> * Calculate LPC coefficients for multiple orders
> + *
> + * use_lpc:
> + * 0 = LPC with fixed pre-defined coeffs
> + * 1 = LPC with coeffs determined by Levinson-Durbin recursion
> + * 2+ = LPC with coeffs determined by Cholesky factorization using (use_lpc-1) passes.
> */
Please make this a Doxygen comment.
> int ff_lpc_calc_coefs(DSPContext *s,
> const int32_t *samples, int blocksize, int min_order,
> @@ -107,7 +112,7 @@
> int i, j, pass;
> int opt_order;
>
> - assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER);
> + assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && use_lpc > 0);
>
> if(use_lpc == 1){
> s->flac_compute_autocorr(samples, blocksize, max_order, autoc);
> @@ -118,7 +123,7 @@
> ref[i] = fabs(lpc[i][i]);
> }else{
> LLSModel m[2];
> - double var[MAX_LPC_ORDER+1], weight;
> + double var[MAX_LPC_ORDER+1], av_uninit(weight);
>
> for(pass=0; pass<use_lpc-1; pass++){
> av_init_lls(&m[pass&1], max_order);
These 3 changes should probably be in 3 separate commits.
-Justin
More information about the ffmpeg-devel
mailing list