History

avcodec/wmaprodec: unbreak XMA mono decoding

Paul B Mahol committed 9 years ago

Commit 96fe4431 parent cab0f3a1 file · +9 −6Browse files

Unified · Split

libavcodec/wmaprodec.c+9−6
@@ -1755,8 +1755,9 @@ static int xma_decode_packet(AVCodecContext *avctx, void *data, · 1754 unmodified lines
17551755 if (got_stream_frame_ptr) {
17561756 memcpy(&s->samples[s->current_stream * 2 + 0][s->offset[s->current_stream] * 512],
17571757 s->frames[s->current_stream]->extended_data[0], 512 * 4);
1758− memcpy(&s->samples[s->current_stream * 2 + 1][s->offset[s->current_stream] * 512],
1759− s->frames[s->current_stream]->extended_data[1], 512 * 4);
1758+ if (avctx->channels > 1)
1759+ memcpy(&s->samples[s->current_stream * 2 + 1][s->offset[s->current_stream] * 512],
1760+ s->frames[s->current_stream]->extended_data[1], 512 * 4);
17601761 s->offset[s->current_stream]++;
17611762 }
17621763
@@ -1794,7 +1795,7 @@ static int xma_decode_packet(AVCodecContext *avctx, void *data, · 31 unmodified lines
17941795 s->xma[i].skip_packets = FFMAX(0, s->xma[i].skip_packets - 1);
17951796 }
17961797
1797− for (i = 0; i < avctx->channels / 2; i++) {
1798+ for (i = 0; i < (avctx->channels + 1) / 2; i++) {
17981799 offset = FFMIN(offset, s->offset[i]);
17991800 }
18001801
@@ -1803,13 +1804,15 @@ static int xma_decode_packet(AVCodecContext *avctx, void *data, · 2 unmodified lines
18031804 if ((bret = ff_get_buffer(avctx, frame, 0)) < 0)
18041805 return bret;
18051806
1806− for (i = 0; i < avctx->channels / 2; i++) {
1807+ for (i = 0; i < (avctx->channels + 1) / 2; i++) {
18071808 memcpy(frame->extended_data[i * 2 + 0], s->samples[i * 2 + 0], frame->nb_samples * 4);
1808− memcpy(frame->extended_data[i * 2 + 1], s->samples[i * 2 + 1], frame->nb_samples * 4);
1809+ if (avctx->channels > 1)
1810+ memcpy(frame->extended_data[i * 2 + 1], s->samples[i * 2 + 1], frame->nb_samples * 4);
18091811 s->offset[i] -= offset;
18101812 if (s->offset[i]) {
18111813 memmove(s->samples[i * 2 + 0], s->samples[i * 2 + 0] + frame->nb_samples, s->offset[i] * 4 * 512);
1812− memmove(s->samples[i * 2 + 1], s->samples[i * 2 + 1] + frame->nb_samples, s->offset[i] * 4 * 512);
1814+ if (avctx->channels > 1)
1815+ memmove(s->samples[i * 2 + 1], s->samples[i * 2 + 1] + frame->nb_samples, s->offset[i] * 4 * 512);
18131816 }
18141817 }
18151818

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t