aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2017-01-19 12:29:41 +0100
committerPaul B Mahol <onemda@gmail.com>2017-01-19 12:33:14 +0100
commit1daa08bd96991d798ab883e049ef9177001efa98 (patch)
treeffecc69b647b4ec2ef005001deeb5ecd6076d25b
parente5ac554ba7d6c0298a2504f9dc2411a81e1a6d96 (diff)
downloadffmpeg-1daa08bd96991d798ab883e049ef9177001efa98.tar.gz
avcodec/wmapro: redone stream selection for XMA1/2
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r--libavcodec/wmaprodec.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index a53c64c1d3..b0d3edeb9a 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1635,7 +1635,7 @@ static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s,
num_bits_prev_frame);
/** check for packet loss */
- if (avctx->codec_id != AV_CODEC_ID_XMA2 && !s->packet_loss &&
+ if (avctx->codec_id == AV_CODEC_ID_WMAPRO && !s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
s->packet_loss = 1;
av_log(avctx, AV_LOG_ERROR,
@@ -1764,19 +1764,32 @@ static int xma_decode_packet(AVCodecContext *avctx, void *data,
s->xma[s->current_stream].packet_loss) {
int bret;
- if (s->xma[0].skip_packets == 0) {
+ if (s->xma[s->current_stream].skip_packets == 0) {
+ ;
+ } else if (s->xma[0].skip_packets == 0 && avctx->channels >= 2) {
s->current_stream = 0;
- } else if (s->xma[1].skip_packets == 0) {
+ } else if (s->xma[1].skip_packets == 0 && avctx->channels >= 4) {
s->current_stream = 1;
- } else if (s->xma[2].skip_packets == 0) {
+ } else if (s->xma[2].skip_packets == 0 && avctx->channels >= 6) {
s->current_stream = 2;
- } else if (s->xma[3].skip_packets == 0) {
+ } else if (s->xma[3].skip_packets == 0 && avctx->channels == 8) {
s->current_stream = 3;
} else {
- s->current_stream++;
- if (s->current_stream >= avctx->channels / 2)
- s->current_stream = 0;
+ int min[2];
+
+ min[0] = s->xma[0].skip_packets;
+ min[1] = i = 0;
+
+ for (i = 1; i < avctx->channels / 2; i++) {
+ if (s->xma[i].skip_packets < min[0]) {
+ min[1] = i;
+ min[0] = s->xma[i].skip_packets;
+ }
+ }
+
+ s->current_stream = min[1];
}
+
for (i = 0; i < avctx->channels / 2; i++) {
s->xma[i].skip_packets = FFMAX(0, s->xma[i].skip_packets - 1);
}