Mercurial > libavcodec.hg
comparison mpc.c @ 4330:0663caaf573c libavcodec
Decode previous 32 frames to avoid seeking artifacts in MPC
author | kostya |
---|---|
date | Mon, 01 Jan 2007 05:32:27 +0000 |
parents | a0cfbd6679c0 |
children | a188a94e1b61 |
comparison
equal
deleted
inserted
replaced
4329:356483de0c13 | 4330:0663caaf573c |
---|---|
49 DSPContext dsp; | 49 DSPContext dsp; |
50 int IS, MSS, gapless; | 50 int IS, MSS, gapless; |
51 int lastframelen, bands; | 51 int lastframelen, bands; |
52 int oldDSCF[2][BANDS]; | 52 int oldDSCF[2][BANDS]; |
53 int rnd; | 53 int rnd; |
54 int frames_to_skip; | |
54 /* for synthesis */ | 55 /* for synthesis */ |
55 DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]); | 56 DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]); |
56 int synth_buf_offset[MPA_MAX_CHANNELS]; | 57 int synth_buf_offset[MPA_MAX_CHANNELS]; |
57 DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]); | 58 DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]); |
58 } MPCContext; | 59 } MPCContext; |
96 skip_bits(&gb, 88); | 97 skip_bits(&gb, 88); |
97 c->gapless = get_bits1(&gb); | 98 c->gapless = get_bits1(&gb); |
98 c->lastframelen = get_bits(&gb, 11); | 99 c->lastframelen = get_bits(&gb, 11); |
99 av_log(avctx, AV_LOG_DEBUG, "IS: %d, MSS: %d, TG: %d, LFL: %d, bands: %d\n", | 100 av_log(avctx, AV_LOG_DEBUG, "IS: %d, MSS: %d, TG: %d, LFL: %d, bands: %d\n", |
100 c->IS, c->MSS, c->gapless, c->lastframelen, c->bands); | 101 c->IS, c->MSS, c->gapless, c->lastframelen, c->bands); |
102 c->frames_to_skip = 0; | |
101 | 103 |
102 if(vlc_inited) return 0; | 104 if(vlc_inited) return 0; |
103 av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); | 105 av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); |
104 if(init_vlc(&scfi_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, | 106 if(init_vlc(&scfi_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, |
105 &mpc7_scfi[1], 2, 1, | 107 &mpc7_scfi[1], 2, 1, |
326 bits_avail = (buf_size - 4) * 8; | 328 bits_avail = (buf_size - 4) * 8; |
327 if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){ | 329 if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){ |
328 av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail); | 330 av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail); |
329 return -1; | 331 return -1; |
330 } | 332 } |
333 if(c->frames_to_skip){ | |
334 c->frames_to_skip--; | |
335 *data_size = 0; | |
336 return buf_size; | |
337 } | |
331 *data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4; | 338 *data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4; |
332 | 339 |
333 return buf_size; | 340 return buf_size; |
334 } | 341 } |
335 | 342 |
343 static void mpc7_decode_flush(AVCodecContext *avctx) | |
344 { | |
345 MPCContext *c = avctx->priv_data; | |
346 | |
347 memset(c->oldDSCF, 0, sizeof(c->oldDSCF)); | |
348 c->frames_to_skip = 32; | |
349 } | |
336 | 350 |
337 AVCodec mpc7_decoder = { | 351 AVCodec mpc7_decoder = { |
338 "mpc sv7", | 352 "mpc sv7", |
339 CODEC_TYPE_AUDIO, | 353 CODEC_TYPE_AUDIO, |
340 CODEC_ID_MUSEPACK7, | 354 CODEC_ID_MUSEPACK7, |
341 sizeof(MPCContext), | 355 sizeof(MPCContext), |
342 mpc7_decode_init, | 356 mpc7_decode_init, |
343 NULL, | 357 NULL, |
344 NULL, | 358 NULL, |
345 mpc7_decode_frame, | 359 mpc7_decode_frame, |
360 .flush = mpc7_decode_flush, | |
346 }; | 361 }; |