- if(s->stereo_in){
- if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
- samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
- else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
- samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
- else
- samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
-
- if (samplecount < 0)
- return -1;
-
- samplecount >>= 1;
- }else{
- const int channel_stride = avctx->channels;
-
- if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
- samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
- else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
- samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
- else
- samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
-
- if (samplecount < 0)
- return -1;
-
- if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){
- int16_t *dst = (int16_t*)samples + 1;
- int16_t *src = (int16_t*)samples;
- int cnt = samplecount;
- while(cnt--){
- *dst = *src;
- src += channel_stride;
- dst += channel_stride;
- }
- }else if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S32){
- int32_t *dst = (int32_t*)samples + 1;
- int32_t *src = (int32_t*)samples;
- int cnt = samplecount;
- while(cnt--){
- *dst = *src;
- src += channel_stride;
- dst += channel_stride;
- }
- }else if(s->stereo){
- float *dst = (float*)samples + 1;
- float *src = (float*)samples;
- int cnt = samplecount;
- while(cnt--){
- *dst = *src;
- src += channel_stride;
- dst += channel_stride;
- }
+ /* get output buffer */
+ frame->nb_samples = s->samples;
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;