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_MATRIX_CHANNEL_MLP 5 00031 #define MAX_MATRIX_CHANNEL_TRUEHD 7 00032 00036 #define MAX_CHANNELS 8 00037 00041 #define MAX_MATRICES_MLP 6 00042 #define MAX_MATRICES_TRUEHD 8 00043 #define MAX_MATRICES 8 00044 00048 #define MAX_SUBSTREAMS 3 00049 00051 #define MAX_RATEFACTOR 4 00052 00053 #define MAX_SAMPLERATE (MAX_RATEFACTOR * 48000) 00054 00056 #define MAX_BLOCKSIZE (40 * MAX_RATEFACTOR) 00057 00058 #define MAX_BLOCKSIZE_POW2 (64 * MAX_RATEFACTOR) 00059 00061 #define NUM_FILTERS 2 00062 00064 #define MAX_FIR_ORDER 8 00065 #define MAX_IIR_ORDER 4 00066 00068 #define END_OF_STREAM 0xd234d234 00069 00070 #define FIR 0 00071 #define IIR 1 00072 00074 typedef struct { 00075 uint8_t order; 00076 uint8_t shift; 00077 00078 int32_t state[MAX_FIR_ORDER]; 00079 } FilterParams; 00080 00082 typedef struct { 00083 FilterParams filter_params[NUM_FILTERS]; 00084 int32_t coeff[NUM_FILTERS][MAX_FIR_ORDER]; 00085 00086 int16_t huff_offset; 00087 int32_t sign_huff_offset; 00088 uint8_t codebook; 00089 uint8_t huff_lsbs; 00090 } ChannelParams; 00091 00097 extern const uint8_t ff_mlp_huffman_tables[3][18][2]; 00098 00104 uint8_t ff_mlp_checksum8 (const uint8_t *buf, unsigned int buf_size); 00105 uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size); 00106 00110 uint8_t ff_mlp_restart_checksum(const uint8_t *buf, unsigned int bit_size); 00111 00115 uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size); 00116 00117 void ff_mlp_init_crc(void); 00118 00120 static inline uint8_t xor_32_to_8(uint32_t value) 00121 { 00122 value ^= value >> 16; 00123 value ^= value >> 8; 00124 return value; 00125 } 00126 00127 #endif /* AVCODEC_MLP_H */