mpc.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Musepack decoder
  3. * Copyright (c) 2006 Konstantin Shishkov
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * Musepack decoder
  24. * MPEG Audio Layer 1/2 -like codec with frames of 1152 samples
  25. * divided into 32 subbands.
  26. */
  27. #ifndef AVCODEC_MPC_H
  28. #define AVCODEC_MPC_H
  29. #include "libavutil/lfg.h"
  30. #include "avcodec.h"
  31. #include "bswapdsp.h"
  32. #include "mpegaudio.h"
  33. #include "mpegaudiodsp.h"
  34. #define BANDS 32
  35. #define SAMPLES_PER_BAND 36
  36. #define MPC_FRAME_SIZE (BANDS * SAMPLES_PER_BAND)
  37. /** Subband structure - hold all variables for each subband */
  38. typedef struct Band {
  39. int msf; ///< mid-stereo flag
  40. int res[2];
  41. int scfi[2];
  42. int scf_idx[2][3];
  43. int Q[2];
  44. }Band;
  45. typedef struct MPCContext {
  46. BswapDSPContext bdsp;
  47. MPADSPContext mpadsp;
  48. int IS, MSS, gapless;
  49. int lastframelen;
  50. int maxbands, last_max_band;
  51. int last_bits_used;
  52. int oldDSCF[2][BANDS];
  53. Band bands[BANDS];
  54. int Q[2][MPC_FRAME_SIZE];
  55. int cur_frame, frames;
  56. uint8_t *bits;
  57. int buf_size;
  58. AVLFG rnd;
  59. int frames_to_skip;
  60. /* for synthesis */
  61. DECLARE_ALIGNED(16, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512*2];
  62. int synth_buf_offset[MPA_MAX_CHANNELS];
  63. DECLARE_ALIGNED(16, int32_t, sb_samples)[MPA_MAX_CHANNELS][36][SBLIMIT];
  64. } MPCContext;
  65. void ff_mpc_init(void);
  66. void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, int16_t **out, int channels);
  67. #endif /* AVCODEC_MPC_H */