diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-08-30 22:30:28 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-08-30 22:30:28 +0000 |
commit | 32063c433915b8dddd143a951ad90ae901ac1b38 (patch) | |
tree | 88aaee983b0885b5bb22d870476f7afdaa8a7010 | |
parent | 264633eec589baddfdcd79dde08fd7f1f47fba51 (diff) | |
download | mpv-32063c433915b8dddd143a951ad90ae901ac1b38.tar.bz2 mpv-32063c433915b8dddd143a951ad90ae901ac1b38.tar.xz |
libfaad2 v2.0rc1 imported
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10726 b3059339-0415-0410-9bf9-f77b7e298cf2
96 files changed, 42879 insertions, 0 deletions
diff --git a/libfaad2/Makefile b/libfaad2/Makefile new file mode 100644 index 0000000000..36d7b1ea14 --- /dev/null +++ b/libfaad2/Makefile @@ -0,0 +1,39 @@ + +LIBNAME = libfaad2.a + +include ../config.mak + +SRCS = bits.c cfft.c common.c decoder.c dither.c drc.c error.c filtbank.c hcr.c ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c pulse.c rvlc.c sbr_dct.c sbr_dec.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c specrec.c ssr.c ssr_fb.c ssr_ipqf.c syntax.c tns.c +OBJS = $(SRCS:.c=.o) + +CFLAGS = -I. $(OPTFLAGS) + +.SUFFIXES: .c .o + +# .PHONY: all clean + +.c.o: + $(CC) -c $(CFLAGS) -o $@ $< + +$(LIBNAME): $(OBJS) + $(AR) r $(LIBNAME) $(OBJS) + +all: $(LIBNAME) + +clean: + rm -f *.o *.a *~ + +distclean: + rm -f test *.o *.a *~ .depend + +dep: depend + +depend: + $(CC) -MM $(CFLAGS) $(SRCS) 1>.depend + +# +# include dependency files if they exist +# +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/libfaad2/README b/libfaad2/README new file mode 100644 index 0000000000..5943bdb18c --- /dev/null +++ b/libfaad2/README @@ -0,0 +1 @@ +files from libfaad v2.0rc1 tarball's libfaad/ and include/ subdir diff --git a/libfaad2/analysis.h b/libfaad2/analysis.h new file mode 100644 index 0000000000..f05c876269 --- /dev/null +++ b/libfaad2/analysis.h @@ -0,0 +1,49 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id: analysis.h,v 1.3 2003/07/29 08:20:12 menno Exp $ +**/ + +#ifndef __ANALYSIS_H__ +#define __ANALYSIS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef ANALYSIS +#define DEBUGDEC ,uint8_t print,uint16_t var,uint8_t *dbg +#define DEBUGVAR(A,B,C) ,A,B,C +extern uint16_t dbg_count; +#else +#define DEBUGDEC +#define DEBUGVAR(A,B,C) +#endif + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libfaad2/bits.c b/libfaad2/bits.c new file mode 100644 index 0000000000..00f9ad0090 --- /dev/null +++ b/libfaad2/bits.c @@ -0,0 +1,173 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id: bits.c,v 1.22 2003/07/29 08:20:12 menno Exp $ +**/ + +#include "common.h" +#include "structs.h" + +#include <stdlib.h> +#include <string.h> +#include "bits.h" + +/* initialize buffer, call once before first getbits or showbits */ +void faad_initbits(bitfile *ld, void *_buffer, uint32_t buffer_size) +{ + uint32_t tmp; + + ld->buffer = malloc((buffer_size+12)*sizeof(uint8_t)); + memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t)); + memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t)); + + ld->buffer_size = buffer_size; + + tmp = getdword((uint32_t*)ld->buffer); +#ifndef ARCH_IS_BIG_ENDIAN + BSWAP(tmp); +#endif + ld->bufa = tmp; + + tmp = getdword((uint32_t*)ld->buffer + 1); +#ifndef ARCH_IS_BIG_ENDIAN + BSWAP(tmp); +#endif + ld->bufb = tmp; + + ld->start = (uint32_t*)ld->buffer; + ld->tail = ((uint32_t*)ld->buffer + 2); + + ld->bits_left = 32; + + ld->bytes_used = 0; + ld->no_more_reading = 0; + ld->error = 0; +} + +void faad_endbits(bitfile *ld) +{ + if (ld) + if (ld->buffer) free(ld->buffer); +} + + +uint32_t faad_get_processed_bits(bitfile *ld) +{ + return 8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left); +} + +uint8_t faad_byte_align(bitfile *ld) +{ + uint8_t remainder = (uint8_t)((32 - ld->bits_left) % 8); + + if (remainder) + { + faad_flushbits(ld, 8 - remainder); + return (8 - remainder); + } + return 0; +} + +/* rewind to beginning */ +void faad_rewindbits(bitfile *ld) +{ + uint32_t tmp; + + tmp = ld->start[0]; +#ifndef ARCH_IS_BIG_ENDIAN + BSWAP(tmp); +#endif + ld->bufa = tmp; + + tmp = ld->start[1]; +#ifndef ARCH_IS_BIG_ENDIAN + BSWAP(tmp); +#endif + ld->bufb = tmp; + ld->bits_left = 32; + ld->tail = &ld->start[2]; + ld->bytes_used = 0; + ld->no_more_reading = 0; +} + +uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits + DEBUGDEC) +{ + uint16_t i; + uint8_t temp; + uint16_t bytes = (uint16_t)bits / 8; + uint8_t remainder = (uint8_t)bits % 8; + + uint8_t *buffer = (uint8_t*)malloc((bytes+1)*sizeof(uint8_t)); + + for (i = 0; i < bytes; i++) + { + buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg)); + } + + if (remainder) + { + temp = (uint8_t)faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder); + + buffer[bytes] = temp; + } + + return buffer; +} + +/* reversed bit reading routines, used for RVLC and HCR */ +void faad_initbits_rev(bitfile *ld, void *buffer, + uint32_t bits_in_buffer) +{ + uint32_t tmp; + int32_t index; + + ld->buffer_size = bit2byte(bits_in_buffer); + + index = (bits_in_buffer+31)/32 - 1; + + ld->start = (uint32_t*)buffer + index - 2; + + tmp = getdword((uint32_t*)buffer + index); +#ifndef ARCH_IS_BIG_ENDIAN + BSWAP(tmp); +#endif + ld->bufa = tmp; + + tmp = getdword((uint32_t*)buffer + index - 1); +#ifndef ARCH_IS_BIG_ENDIAN + BSWAP(tmp); +#endif + ld->bufb = tmp; + + ld->tail = (uint32_t*)buffer + index; + + ld->bits_left = bits_in_buffer % 32; + if (ld->bits_left == 0) + ld->bits_left = 32; + + ld->bytes_used = 0; + ld->no_more_reading = 0; + ld->error = 0; +} diff --git a/libfaad2/bits.h b/libfaad2/bits.h new file mode 100644 index 0000000000..fbe2295215 --- /dev/null +++ b/libfaad2/bits.h @@ -0,0 +1,260 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __BITS_H__ +#define __BITS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "analysis.h" +#ifdef ANALYSIS +#include <stdio.h> +#endif + +#define BYTE_NUMBIT 8 +#define bit2byte(a) ((a+7)/BYTE_NUMBIT) + +typedef struct _bitfile +{ + /* bit input */ + uint32_t bufa; + uint32_t bufb; + uint32_t bits_left; + uint32_t buffer_size; /* size of the buffer in bytes */ + uint32_t bytes_used; + uint8_t no_more_reading; + uint8_t error; + uint32_t *tail; + uint32_t *start; + void *buffer; +} bitfile; + + +#if defined (_WIN32) && !defined(_WIN32_WCE) +#define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax +#elif defined(LINUX) || defined(DJGPP) +#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) +#else +#define BSWAP(a) \ + ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) +#endif + +static uint32_t bitmask[] = { + 0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, + 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, + 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, + 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, + 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF +}; + +void faad_initbits(bitfile *ld, void *buffer, uint32_t buffer_size); +void faad_endbits(bitfile *ld); +void faad_initbits_rev(bitfile *ld, void *buffer, + uint32_t bits_in_buffer); |