changeset 2913:cc55bc1f8d92 libavcodec

QDM2 compatible decoder
author rtognimp
date Tue, 18 Oct 2005 20:16:43 +0000
parents 4b3626936f09
children 4a52affac0e0
files Makefile allcodecs.c avcodec.h mpegaudio.c mpegaudio.h mpegaudiodec.c
diffstat 6 files changed, 41 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Oct 16 13:56:52 2005 +0000
+++ b/Makefile	Tue Oct 18 20:16:43 2005 +0000
@@ -18,7 +18,7 @@
       fft.o mdct.o raw.o golomb.o cabac.o\
       dpcm.o adx.o faandct.o parser.o g726.o \
       vp3dsp.o h264idct.o rangecoder.o pnm.o h263.o msmpeg4.o h263dec.o dvdsub.o dvbsub.o dvbsubdec.o\
-      opt.o truemotion2.o
+      opt.o qdm2.o truemotion2.o
 
 ifeq ($(CONFIG_AASC_DECODER),yes)
     OBJS+= aasc.o
--- a/allcodecs.c	Sun Oct 16 13:56:52 2005 +0000
+++ b/allcodecs.c	Tue Oct 18 20:16:43 2005 +0000
@@ -491,6 +491,9 @@
 #ifdef CONFIG_LIBGSM
     register_avcodec(&libgsm_decoder);
 #endif //CONFIG_LIBGSM
+#ifdef CONFIG_QDM2_DECODER
+    register_avcodec(&qdm2_decoder);
+#endif //CONFIG_QDM2_DECODER
 #endif /* CONFIG_DECODERS */
 
 #ifdef AMR_NB
--- a/avcodec.h	Sun Oct 16 13:56:52 2005 +0000
+++ b/avcodec.h	Tue Oct 18 20:16:43 2005 +0000
@@ -185,6 +185,7 @@
     CODEC_ID_ALAC,
     CODEC_ID_WESTWOOD_SND1,
     CODEC_ID_GSM,    
+    CODEC_ID_QDM2,
     
     CODEC_ID_OGGTHEORA= 0x16000, 
 
@@ -2000,6 +2001,7 @@
 extern AVCodec mp3_decoder;
 extern AVCodec mp3adu_decoder;
 extern AVCodec mp3on4_decoder;
+extern AVCodec qdm2_decoder;
 extern AVCodec mace3_decoder;
 extern AVCodec mace6_decoder;
 extern AVCodec huffyuv_decoder;
--- a/mpegaudio.c	Sun Oct 16 13:56:52 2005 +0000
+++ b/mpegaudio.c	Tue Oct 18 20:16:43 2005 +0000
@@ -28,8 +28,6 @@
 
 /* currently, cannot change these constants (need to modify
    quantization stage) */
-#define FRAC_BITS 15
-#define WFRAC_BITS  14
 #define MUL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)
 #define FIX(a)   ((int)((a) * (1 << FRAC_BITS)))
 
--- a/mpegaudio.h	Sun Oct 16 13:56:52 2005 +0000
+++ b/mpegaudio.h	Tue Oct 18 20:16:43 2005 +0000
@@ -22,8 +22,42 @@
 #define SAME_HEADER_MASK \
    (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
 
+/* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg
+   audio decoder */
+
+#ifdef USE_HIGHPRECISION
+#define FRAC_BITS   23   /* fractional bits for sb_samples and dct */
+#define WFRAC_BITS  16   /* fractional bits for window */
+#else
+#define FRAC_BITS   15   /* fractional bits for sb_samples and dct */
+#define WFRAC_BITS  14   /* fractional bits for window */
+#endif
+
+#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
+typedef int32_t OUT_INT;
+#define OUT_MAX INT32_MAX
+#define OUT_MIN INT32_MIN
+#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
+#else
+typedef int16_t OUT_INT;
+#define OUT_MAX INT16_MAX
+#define OUT_MIN INT16_MIN
+#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
+#endif
+
+#if FRAC_BITS <= 15
+typedef int16_t MPA_INT;
+#else
+typedef int32_t MPA_INT;
+#endif
+
 int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
 int mpa_decode_header(AVCodecContext *avctx, uint32_t head);
+void ff_mpa_synth_init(MPA_INT *window);
+void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
+			 MPA_INT *window, int *dither_state,
+                         OUT_INT *samples, int incr,
+                         int32_t sb_samples[SBLIMIT]);
 
 extern const uint16_t mpa_bitrate_tab[2][3][15];
 extern const uint16_t mpa_freq_tab[3];
--- a/mpegaudiodec.c	Sun Oct 16 13:56:52 2005 +0000
+++ b/mpegaudiodec.c	Tue Oct 18 20:16:43 2005 +0000
@@ -25,7 +25,6 @@
 //#define DEBUG
 #include "avcodec.h"
 #include "bitstream.h"
-#include "mpegaudio.h"
 #include "dsputil.h"
 
 /*
@@ -40,25 +39,7 @@
 #define USE_HIGHPRECISION
 #endif
 
-#ifdef USE_HIGHPRECISION
-#define FRAC_BITS   23   /* fractional bits for sb_samples and dct */
-#define WFRAC_BITS  16   /* fractional bits for window */
-#else
-#define FRAC_BITS   15   /* fractional bits for sb_samples and dct */
-#define WFRAC_BITS  14   /* fractional bits for window */
-#endif
-
-#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
-typedef int32_t OUT_INT;
-#define OUT_MAX INT32_MAX
-#define OUT_MIN INT32_MIN
-#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
-#else
-typedef int16_t OUT_INT;
-#define OUT_MAX INT16_MAX
-#define OUT_MIN INT16_MIN
-#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
-#endif
+#include "mpegaudio.h"
 
 #define FRAC_ONE    (1 << FRAC_BITS)
 
@@ -75,12 +56,6 @@
     return ((int64_t)(a) * (int64_t)(b))>>32;
 }
 
-#if FRAC_BITS <= 15
-typedef int16_t MPA_INT;
-#else
-typedef int32_t MPA_INT;
-#endif
-
 /****************/
 
 #define HEADER_SIZE 4