Revision 7d3829a8

View differences:

libavcodec/mpc.c
42 42
/**
43 43
 * Process decoded Musepack data and produce PCM
44 44
 */
45
static void mpc_synth(MPCContext *c, int16_t *out)
45
static void mpc_synth(MPCContext *c, int16_t *out, int channels)
46 46
{
47 47
    int dither_state = 0;
48 48
    int i, ch;
49 49
    OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr;
50 50

  
51
    for(ch = 0;  ch < 2; ch++){
51
    for(ch = 0;  ch < channels; ch++){
52 52
        samples_ptr = samples + ch;
53 53
        for(i = 0; i < SAMPLES_PER_BAND; i++) {
54 54
            ff_mpa_synth_filter(c->synth_buf[ch], &(c->synth_buf_offset[ch]),
55 55
                                ff_mpa_synth_window, &dither_state,
56
                                samples_ptr, 2,
56
                                samples_ptr, channels,
57 57
                                c->sb_samples[ch][i]);
58
            samples_ptr += 64;
58
            samples_ptr += 32 * channels;
59 59
        }
60 60
    }
61
    for(i = 0; i < MPC_FRAME_SIZE*2; i++)
61
    for(i = 0; i < MPC_FRAME_SIZE*channels; i++)
62 62
        *out++=samples[i];
63 63
}
64 64

  
65
void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data)
65
void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels)
66 66
{
67 67
    int i, j, ch;
68 68
    Band *bands = c->bands;
......
98 98
        }
99 99
    }
100 100

  
101
    mpc_synth(c, data);
101
    mpc_synth(c, data, channels);
102 102
}
libavcodec/mpc.h
72 72
} MPCContext;
73 73

  
74 74
void ff_mpc_init(void);
75
void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, void *dst);
75
void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, void *dst, int channels);
76 76

  
77 77
#endif /* AVCODEC_MPC_H */
libavcodec/mpc7.c
260 260
        for(ch = 0; ch < 2; ch++)
261 261
            idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
262 262

  
263
    ff_mpc_dequantize_and_synth(c, mb, data);
263
    ff_mpc_dequantize_and_synth(c, mb, data, 2);
264 264

  
265 265
    av_free(bits);
266 266

  
libavcodec/mpc8.c
99 99
    MPCContext *c = avctx->priv_data;
100 100
    GetBitContext gb;
101 101
    static int vlc_initialized = 0;
102
    int channels;
102 103

  
103 104
    static VLC_TYPE band_table[542][2];
104 105
    static VLC_TYPE q1_table[520][2];
......
125 126

  
126 127
    skip_bits(&gb, 3);//sample rate
127 128
    c->maxbands = get_bits(&gb, 5) + 1;
128
    skip_bits(&gb, 4);//channels
129
    channels = get_bits(&gb, 4) + 1;
130
    if (channels > 2) {
131
        av_log_missing_feature(avctx, "Multichannel MPC SV8", 1);
132
        return -1;
133
    }
129 134
    c->MSS = get_bits1(&gb);
130 135
    c->frames = 1 << (get_bits(&gb, 3) * 2);
131 136

  
......
387 392
        }
388 393
    }
389 394

  
390
    ff_mpc_dequantize_and_synth(c, maxband, data);
395
    ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels);
391 396

  
392 397
    c->cur_frame++;
393 398

  
394 399
    c->last_bits_used = get_bits_count(gb);
395 400
    if(c->cur_frame >= c->frames)
396 401
        c->cur_frame = 0;
397
    *data_size =  MPC_FRAME_SIZE * 4;
402
    *data_size =  MPC_FRAME_SIZE * 2 * avctx->channels;
398 403

  
399 404
    return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
400 405
}

Also available in: Unified diff