comparison mpc8.c @ 10602:987373501407 libavcodec

Fix an issue uncovered by commit 20623: The init functions of mpc7 and mpc8 check whether the vlc has been initialized already and return early if this is the case (eg by calling init a second time). But avctx->sample_fmt and channel_layout is set after the vlc initialization, causing it not to be set on the second call of init. Move all manipulations of avctx before the initialization of the vlc, so that it is always set.
author attila
date Mon, 30 Nov 2009 10:25:20 +0000
parents d1119c095555
children 8a4984c5cacc
comparison
equal deleted inserted replaced
10601:5bf8c18a9907 10602:987373501407
127 c->maxbands = get_bits(&gb, 5) + 1; 127 c->maxbands = get_bits(&gb, 5) + 1;
128 skip_bits(&gb, 4);//channels 128 skip_bits(&gb, 4);//channels
129 c->MSS = get_bits1(&gb); 129 c->MSS = get_bits1(&gb);
130 c->frames = 1 << (get_bits(&gb, 3) * 2); 130 c->frames = 1 << (get_bits(&gb, 3) * 2);
131 131
132 avctx->sample_fmt = SAMPLE_FMT_S16;
133 avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
134
132 if(vlc_initialized) return 0; 135 if(vlc_initialized) return 0;
133 av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); 136 av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
134 137
135 band_vlc.table = band_table; 138 band_vlc.table = band_table;
136 band_vlc.table_allocated = 542; 139 band_vlc.table_allocated = 542;
217 init_vlc(&quant_vlc[3][i], MPC8_Q8_BITS, MPC8_Q8_SIZE, 220 init_vlc(&quant_vlc[3][i], MPC8_Q8_BITS, MPC8_Q8_SIZE,
218 &mpc8_q8_bits[i], 1, 1, 221 &mpc8_q8_bits[i], 1, 1,
219 &mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); 222 &mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
220 } 223 }
221 vlc_initialized = 1; 224 vlc_initialized = 1;
222 avctx->sample_fmt = SAMPLE_FMT_S16;
223 avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
224 return 0; 225 return 0;
225 } 226 }
226 227
227 static int mpc8_decode_frame(AVCodecContext * avctx, 228 static int mpc8_decode_frame(AVCodecContext * avctx,
228 void *data, int *data_size, 229 void *data, int *data_size,