Commit 236bb275 authored by attila's avatar attila

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.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@20668 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent fe4a8dd1
...@@ -85,6 +85,9 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) ...@@ -85,6 +85,9 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands); c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands);
c->frames_to_skip = 0; c->frames_to_skip = 0;
avctx->sample_fmt = SAMPLE_FMT_S16;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
if(vlc_initialized) return 0; if(vlc_initialized) return 0;
av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
scfi_vlc.table = scfi_table; scfi_vlc.table = scfi_table;
...@@ -124,8 +127,6 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) ...@@ -124,8 +127,6 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
} }
} }
vlc_initialized = 1; vlc_initialized = 1;
avctx->sample_fmt = SAMPLE_FMT_S16;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
return 0; return 0;
} }
......
...@@ -129,6 +129,9 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) ...@@ -129,6 +129,9 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
c->MSS = get_bits1(&gb); c->MSS = get_bits1(&gb);
c->frames = 1 << (get_bits(&gb, 3) * 2); c->frames = 1 << (get_bits(&gb, 3) * 2);
avctx->sample_fmt = SAMPLE_FMT_S16;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
if(vlc_initialized) return 0; if(vlc_initialized) return 0;
av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
...@@ -219,8 +222,6 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) ...@@ -219,8 +222,6 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
&mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); &mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
} }
vlc_initialized = 1; vlc_initialized = 1;
avctx->sample_fmt = SAMPLE_FMT_S16;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment