if (got_stream_frame_ptr) {
memcpy(&s->samples[s->current_stream * 2 + 0][s->offset[s->current_stream] * 512],
s->frames[s->current_stream]->extended_data[0], 512 * 4);
- memcpy(&s->samples[s->current_stream * 2 + 1][s->offset[s->current_stream] * 512],
- s->frames[s->current_stream]->extended_data[1], 512 * 4);
+ if (avctx->channels > 1)
+ memcpy(&s->samples[s->current_stream * 2 + 1][s->offset[s->current_stream] * 512],
+ s->frames[s->current_stream]->extended_data[1], 512 * 4);
s->offset[s->current_stream]++;
}
s->xma[i].skip_packets = FFMAX(0, s->xma[i].skip_packets - 1);
}
- for (i = 0; i < avctx->channels / 2; i++) {
+ for (i = 0; i < (avctx->channels + 1) / 2; i++) {
offset = FFMIN(offset, s->offset[i]);
}
if ((bret = ff_get_buffer(avctx, frame, 0)) < 0)
return bret;
- for (i = 0; i < avctx->channels / 2; i++) {
+ for (i = 0; i < (avctx->channels + 1) / 2; i++) {
memcpy(frame->extended_data[i * 2 + 0], s->samples[i * 2 + 0], frame->nb_samples * 4);
- memcpy(frame->extended_data[i * 2 + 1], s->samples[i * 2 + 1], frame->nb_samples * 4);
+ if (avctx->channels > 1)
+ memcpy(frame->extended_data[i * 2 + 1], s->samples[i * 2 + 1], frame->nb_samples * 4);
s->offset[i] -= offset;
if (s->offset[i]) {
memmove(s->samples[i * 2 + 0], s->samples[i * 2 + 0] + frame->nb_samples, s->offset[i] * 4 * 512);
- memmove(s->samples[i * 2 + 1], s->samples[i * 2 + 1] + frame->nb_samples, s->offset[i] * 4 * 512);
+ if (avctx->channels > 1)
+ memmove(s->samples[i * 2 + 1], s->samples[i * 2 + 1] + frame->nb_samples, s->offset[i] * 4 * 512);
}
}
return 0;
}
-/**
- *@brief Clear decoder buffers (for seeking).
- *@param avctx codec context
- */
-static void flush(AVCodecContext *avctx)
+static void flush(WMAProDecodeCtx *s)
{
- WMAProDecodeCtx *s = avctx->priv_data;
int i;
/** reset output buffer as a part of it is used during the windowing of a
new frame */
memset(s->channel[i].out, 0, s->samples_per_frame *
sizeof(*s->channel[i].out));
s->packet_loss = 1;
+ s->skip_packets = 0;
+}
+
+
+/**
+ *@brief Clear decoder buffers (for seeking).
+ *@param avctx codec context
+ */
+static void wmapro_flush(AVCodecContext *avctx)
+{
+ WMAProDecodeCtx *s = avctx->priv_data;
+
+ flush(s);
+}
+
+static void xma_flush(AVCodecContext *avctx)
+{
+ XMADecodeCtx *s = avctx->priv_data;
+ int i;
+ for (i = 0; i < (avctx->channels + 1) / 2; i++)
+ flush(&s->xma[i]);
+
+ memset(s->offset, 0, sizeof(s->offset));
+ s->current_stream = 0;
}
.close = wmapro_decode_end,
.decode = wmapro_decode_packet,
.capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1,
- .flush = flush,
+ .flush = wmapro_flush,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
};
.init = xma_decode_init,
.close = xma_decode_end,
.decode = xma_decode_packet,
+ .flush = xma_flush,
.capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },