Commit 1a345903 authored by Justin Ruggles's avatar Justin Ruggles

mpc7/8: use planar sample format

parent 3fca0d72
...@@ -43,28 +43,24 @@ void ff_mpc_init(void) ...@@ -43,28 +43,24 @@ void ff_mpc_init(void)
/** /**
* Process decoded Musepack data and produce PCM * Process decoded Musepack data and produce PCM
*/ */
static void mpc_synth(MPCContext *c, int16_t *out, int channels) static void mpc_synth(MPCContext *c, int16_t **out, int channels)
{ {
int dither_state = 0; int dither_state = 0;
int i, ch; int i, ch;
OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr;
for(ch = 0; ch < channels; ch++){ for(ch = 0; ch < channels; ch++){
samples_ptr = samples + ch;
for(i = 0; i < SAMPLES_PER_BAND; i++) { for(i = 0; i < SAMPLES_PER_BAND; i++) {
ff_mpa_synth_filter_fixed(&c->mpadsp, ff_mpa_synth_filter_fixed(&c->mpadsp,
c->synth_buf[ch], &(c->synth_buf_offset[ch]), c->synth_buf[ch], &(c->synth_buf_offset[ch]),
ff_mpa_synth_window_fixed, &dither_state, ff_mpa_synth_window_fixed, &dither_state,
samples_ptr, channels, out[ch] + 32 * i, 1,
c->sb_samples[ch][i]); c->sb_samples[ch][i]);
samples_ptr += 32 * channels;
} }
} }
for(i = 0; i < MPC_FRAME_SIZE*channels; i++)
*out++=samples[i];
} }
void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels) void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, int16_t **out,
int channels)
{ {
int i, j, ch; int i, j, ch;
Band *bands = c->bands; Band *bands = c->bands;
...@@ -100,5 +96,5 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int ch ...@@ -100,5 +96,5 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int ch
} }
} }
mpc_synth(c, data, channels); mpc_synth(c, out, channels);
} }
...@@ -73,6 +73,6 @@ typedef struct { ...@@ -73,6 +73,6 @@ typedef struct {
} MPCContext; } MPCContext;
void ff_mpc_init(void); void ff_mpc_init(void);
void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, void *dst, int channels); void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, int16_t **out, int channels);
#endif /* AVCODEC_MPC_H */ #endif /* AVCODEC_MPC_H */
...@@ -94,7 +94,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) ...@@ -94,7 +94,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands); c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands);
c->frames_to_skip = 0; c->frames_to_skip = 0;
avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
avctx->channel_layout = AV_CH_LAYOUT_STEREO; avctx->channel_layout = AV_CH_LAYOUT_STEREO;
if(vlc_initialized) return 0; if(vlc_initialized) return 0;
...@@ -293,7 +293,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data, ...@@ -293,7 +293,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
for(ch = 0; ch < 2; ch++) for(ch = 0; ch < 2; ch++)
idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off); idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2); ff_mpc_dequantize_and_synth(c, mb, (int16_t **)c->frame.extended_data, 2);
bits_used = get_bits_count(&gb); bits_used = get_bits_count(&gb);
bits_avail = buf_size * 8; bits_avail = buf_size * 8;
...@@ -340,4 +340,6 @@ AVCodec ff_mpc7_decoder = { ...@@ -340,4 +340,6 @@ AVCodec ff_mpc7_decoder = {
.flush = mpc7_decode_flush, .flush = mpc7_decode_flush,
.capabilities = CODEC_CAP_DR1, .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"), .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE },
}; };
...@@ -135,7 +135,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) ...@@ -135,7 +135,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
c->MSS = get_bits1(&gb); c->MSS = get_bits1(&gb);
c->frames = 1 << (get_bits(&gb, 3) * 2); c->frames = 1 << (get_bits(&gb, 3) * 2);
avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
if(vlc_initialized) return 0; if(vlc_initialized) return 0;
...@@ -405,7 +405,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data, ...@@ -405,7 +405,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
} }
} }
ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0], ff_mpc_dequantize_and_synth(c, maxband - 1,
(int16_t **)c->frame.extended_data,
avctx->channels); avctx->channels);
c->cur_frame++; c->cur_frame++;
...@@ -438,4 +439,6 @@ AVCodec ff_mpc8_decoder = { ...@@ -438,4 +439,6 @@ AVCodec ff_mpc8_decoder = {
.flush = mpc8_decode_flush, .flush = mpc8_decode_flush,
.capabilities = CODEC_CAP_DR1, .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"), .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE },
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment