00001 /* 00002 * MLP codec common header file 00003 * Copyright (c) 2007-2008 Ian Caulfield 00004 * 00005 * This file is part of FFmpeg. 00006 * 00007 * FFmpeg is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * FFmpeg is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with FFmpeg; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef AVCODEC_MLP_H 00023 #define AVCODEC_MLP_H 00024 00025 #include <stdint.h> 00026 00027 #include "avcodec.h" 00028 00030 #define MAX_CHANNELS 16 00031 00035 #define MAX_MATRICES 15 00036 00040 #define MAX_SUBSTREAMS 2 00041 00043 #define MAX_SAMPLERATE 192000 00044 00046 #define MAX_BLOCKSIZE (40 * (MAX_SAMPLERATE / 48000)) 00047 00048 #define MAX_BLOCKSIZE_POW2 (64 * (MAX_SAMPLERATE / 48000)) 00049 00051 #define NUM_FILTERS 2 00052 00057 #define MAX_FILTER_ORDER 8 00058 00060 #define END_OF_STREAM 0xd234d234 00061 00062 #define FIR 0 00063 #define IIR 1 00064 00066 typedef struct { 00067 uint8_t order; 00068 uint8_t shift; 00069 00070 int32_t coeff[MAX_FILTER_ORDER]; 00071 int32_t state[MAX_FILTER_ORDER]; 00072 } FilterParams; 00073 00075 typedef struct { 00076 FilterParams filter_params[NUM_FILTERS]; 00077 00078 int16_t huff_offset; 00079 int32_t sign_huff_offset; 00080 uint8_t codebook; 00081 uint8_t huff_lsbs; 00082 } ChannelParams; 00083 00089 extern const uint8_t ff_mlp_huffman_tables[3][18][2]; 00090 00096 uint8_t ff_mlp_checksum8 (const uint8_t *buf, unsigned int buf_size); 00097 uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size); 00098 00102 uint8_t ff_mlp_restart_checksum(const uint8_t *buf, unsigned int bit_size); 00103 00107 uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size); 00108 00109 void ff_mlp_init_crc(void); 00110 00112 static inline uint8_t xor_32_to_8(uint32_t value) 00113 { 00114 value ^= value >> 16; 00115 value ^= value >> 8; 00116 return value; 00117 } 00118 00119 #endif /* AVCODEC_MLP_H */