comparison mpegaudio.h @ 11707:eb9e142ea51f libavcodec

float based mp1/mp2/mp3 decoders.
author michael
date Tue, 11 May 2010 19:52:42 +0000
parents 7dd2a45249a9
children 0e777af9160a
comparison
equal deleted inserted replaced
11706:15e7486e5c7a 11707:eb9e142ea51f
23 * mpeg audio declarations for both encoder and decoder. 23 * mpeg audio declarations for both encoder and decoder.
24 */ 24 */
25 25
26 #ifndef AVCODEC_MPEGAUDIO_H 26 #ifndef AVCODEC_MPEGAUDIO_H
27 #define AVCODEC_MPEGAUDIO_H 27 #define AVCODEC_MPEGAUDIO_H
28
29 #ifndef CONFIG_FLOAT
30 # define CONFIG_FLOAT 0
31 #endif
28 32
29 #include "avcodec.h" 33 #include "avcodec.h"
30 #include "get_bits.h" 34 #include "get_bits.h"
31 #include "dsputil.h" 35 #include "dsputil.h"
32 36
63 67
64 #define FRAC_ONE (1 << FRAC_BITS) 68 #define FRAC_ONE (1 << FRAC_BITS)
65 69
66 #define FIX(a) ((int)((a) * FRAC_ONE)) 70 #define FIX(a) ((int)((a) * FRAC_ONE))
67 71
68 #if CONFIG_MPEGAUDIO_HP && CONFIG_AUDIO_NONSHORT 72 #if CONFIG_FLOAT
73 typedef float OUT_INT;
74 #define OUT_FMT SAMPLE_FMT_FLT
75 #elif CONFIG_MPEGAUDIO_HP && CONFIG_AUDIO_NONSHORT
69 typedef int32_t OUT_INT; 76 typedef int32_t OUT_INT;
70 #define OUT_MAX INT32_MAX 77 #define OUT_MAX INT32_MAX
71 #define OUT_MIN INT32_MIN 78 #define OUT_MIN INT32_MIN
72 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31) 79 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
73 #define OUT_FMT SAMPLE_FMT_S32 80 #define OUT_FMT SAMPLE_FMT_S32
77 #define OUT_MIN INT16_MIN 84 #define OUT_MIN INT16_MIN
78 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) 85 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
79 #define OUT_FMT SAMPLE_FMT_S16 86 #define OUT_FMT SAMPLE_FMT_S16
80 #endif 87 #endif
81 88
82 #if FRAC_BITS <= 15 89 #if CONFIG_FLOAT
90 # define INTFLOAT float
91 typedef float MPA_INT;
92 #elif FRAC_BITS <= 15
93 # define INTFLOAT int
83 typedef int16_t MPA_INT; 94 typedef int16_t MPA_INT;
84 #else 95 #else
96 # define INTFLOAT int
85 typedef int32_t MPA_INT; 97 typedef int32_t MPA_INT;
86 #endif 98 #endif
87 99
88 #define BACKSTEP_SIZE 512 100 #define BACKSTEP_SIZE 512
89 #define EXTRABYTES 24 101 #define EXTRABYTES 24
103 uint8_t count1table_select; 115 uint8_t count1table_select;
104 int region_size[3]; /* number of huffman codes in each region */ 116 int region_size[3]; /* number of huffman codes in each region */
105 int preflag; 117 int preflag;
106 int short_start, long_end; /* long/short band indexes */ 118 int short_start, long_end; /* long/short band indexes */
107 uint8_t scale_factors[40]; 119 uint8_t scale_factors[40];
108 int32_t sb_hybrid[SBLIMIT * 18]; /* 576 samples */ 120 INTFLOAT sb_hybrid[SBLIMIT * 18]; /* 576 samples */
109 } GranuleDef; 121 } GranuleDef;
110 122
111 #define MPA_DECODE_HEADER \ 123 #define MPA_DECODE_HEADER \
112 int frame_size; \ 124 int frame_size; \
113 int error_protection; \ 125 int error_protection; \
132 uint32_t free_format_next_header; 144 uint32_t free_format_next_header;
133 GetBitContext gb; 145 GetBitContext gb;
134 GetBitContext in_gb; 146 GetBitContext in_gb;
135 DECLARE_ALIGNED(16, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512 * 2]; 147 DECLARE_ALIGNED(16, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512 * 2];
136 int synth_buf_offset[MPA_MAX_CHANNELS]; 148 int synth_buf_offset[MPA_MAX_CHANNELS];
137 DECLARE_ALIGNED(16, int32_t, sb_samples)[MPA_MAX_CHANNELS][36][SBLIMIT]; 149 DECLARE_ALIGNED(16, INTFLOAT, sb_samples)[MPA_MAX_CHANNELS][36][SBLIMIT];
138 int32_t mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */ 150 INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */
139 GranuleDef granules[2][2]; /* Used in Layer 3 */ 151 GranuleDef granules[2][2]; /* Used in Layer 3 */
140 #ifdef DEBUG 152 #ifdef DEBUG
141 int frame_count; 153 int frame_count;
142 #endif 154 #endif
143 void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g);
144 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 155 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3
145 int dither_state; 156 int dither_state;
146 int error_recognition; 157 int error_recognition;
147 AVCodecContext* avctx; 158 AVCodecContext* avctx;
148 } MPADecodeContext; 159 } MPADecodeContext;
159 extern MPA_INT ff_mpa_synth_window[]; 170 extern MPA_INT ff_mpa_synth_window[];
160 void ff_mpa_synth_init(MPA_INT *window); 171 void ff_mpa_synth_init(MPA_INT *window);
161 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, 172 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
162 MPA_INT *window, int *dither_state, 173 MPA_INT *window, int *dither_state,
163 OUT_INT *samples, int incr, 174 OUT_INT *samples, int incr,
164 int32_t sb_samples[SBLIMIT]); 175 INTFLOAT sb_samples[SBLIMIT]);
176
177 void ff_mpa_synth_init_float(MPA_INT *window);
178 void ff_mpa_synth_filter_float(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
179 MPA_INT *window, int *dither_state,
180 OUT_INT *samples, int incr,
181 INTFLOAT sb_samples[SBLIMIT]);
165 182
166 /* fast header check for resync */ 183 /* fast header check for resync */
167 static inline int ff_mpa_check_header(uint32_t header){ 184 static inline int ff_mpa_check_header(uint32_t header){
168 /* header */ 185 /* header */
169 if ((header & 0xffe00000) != 0xffe00000) 186 if ((header & 0xffe00000) != 0xffe00000)