adx.h 2.28 KB
Newer Older
1 2 3 4
/*
 * ADX ADPCM codecs
 * Copyright (c) 2001,2003 BERO
 *
5
 * This file is part of Libav.
6
 *
7
 * Libav is free software; you can redistribute it and/or
8 9 10 11
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
12
 * Libav is distributed in the hope that it will be useful,
13 14 15 16 17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with Libav; if not, write to the Free Software
19 20 21 22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/**
23
 * @file
24 25 26 27 28 29 30
 * SEGA CRI adx codecs.
 *
 * Reference documents:
 * http://ku-www.ss.titech.ac.jp/~yatsushi/adx.html
 * adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/
 */

31 32
#ifndef AVCODEC_ADX_H
#define AVCODEC_ADX_H
33

34 35 36 37
#include <stdint.h>

#include "avcodec.h"

38
typedef struct ADXChannelState {
39
    int s1,s2;
40
} ADXChannelState;
41

42
typedef struct ADXContext {
43
    int channels;
44
    ADXChannelState prev[2];
45
    int header_parsed;
Justin Ruggles's avatar
Justin Ruggles committed
46
    int eof;
47 48
    int cutoff;
    int coeff[2];
49 50
} ADXContext;

51
#define COEFF_BITS  12
52

53 54 55
#define BLOCK_SIZE      18
#define BLOCK_SAMPLES   32

56 57 58 59 60 61 62 63 64
/**
 * Calculate LPC coefficients based on cutoff frequency and sample rate.
 *
 * @param cutoff       cutoff frequency
 * @param sample_rate  sample rate
 * @param bits         number of bits used to quantize coefficients
 * @param[out] coeff   2 quantized LPC coefficients
 */
void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff);
65

66 67 68 69 70 71 72 73 74 75 76
/**
 * Decode ADX stream header.
 * Sets avctx->channels and avctx->sample_rate.
 *
 * @param      avctx        codec context
 * @param      buf          header data
 * @param      bufsize      data size, should be at least 24 bytes
 * @param[out] header_size  size of ADX header
 * @param[out] coeff        2 LPC coefficients, can be NULL
 * @return data offset or negative error code if header is invalid
 */
77 78 79
int ff_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
                         int bufsize, int *header_size, int *coeff);

80
#endif /* AVCODEC_ADX_H */