Statistics
| Branch: | Revision:

ffmpeg / libavcodec / flac.h @ d1d9945f

History | View | Annotate | Download (3.79 KB)

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

    
22
/**
23
 * @file libavcodec/flac.h
24
 * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
25
 */
26

    
27
#ifndef AVCODEC_FLAC_H
28
#define AVCODEC_FLAC_H
29

    
30
#include "avcodec.h"
31

    
32
#define FLAC_STREAMINFO_SIZE   34
33
#define FLAC_MAX_CHANNELS       8
34
#define FLAC_MIN_BLOCKSIZE     16
35
#define FLAC_MAX_BLOCKSIZE  65535
36

    
37
enum {
38
    FLAC_CHMODE_INDEPENDENT =  0,
39
    FLAC_CHMODE_LEFT_SIDE   =  8,
40
    FLAC_CHMODE_RIGHT_SIDE  =  9,
41
    FLAC_CHMODE_MID_SIDE    = 10,
42
};
43

    
44
enum {
45
    FLAC_METADATA_TYPE_STREAMINFO = 0,
46
    FLAC_METADATA_TYPE_PADDING,
47
    FLAC_METADATA_TYPE_APPLICATION,
48
    FLAC_METADATA_TYPE_SEEKTABLE,
49
    FLAC_METADATA_TYPE_VORBIS_COMMENT,
50
    FLAC_METADATA_TYPE_CUESHEET,
51
    FLAC_METADATA_TYPE_PICTURE,
52
    FLAC_METADATA_TYPE_INVALID = 127
53
};
54

    
55
enum FLACExtradataFormat {
56
    FLAC_EXTRADATA_FORMAT_STREAMINFO  = 0,
57
    FLAC_EXTRADATA_FORMAT_FULL_HEADER = 1
58
};
59

    
60
/**
61
 * Data needed from the Streaminfo header for use by the raw FLAC demuxer
62
 * and/or the FLAC decoder.
63
 */
64
#define FLACSTREAMINFO \
65
    int max_blocksize;      /**< maximum block size, in samples          */\
66
    int max_framesize;      /**< maximum frame size, in bytes            */\
67
    int samplerate;         /**< sample rate                             */\
68
    int channels;           /**< number of channels                      */\
69
    int bps;                /**< bits-per-sample                         */\
70
    int64_t samples;        /**< total number of samples                 */\
71

    
72
typedef struct FLACStreaminfo {
73
    FLACSTREAMINFO
74
} FLACStreaminfo;
75

    
76
/**
77
 * Parse the Streaminfo metadata block
78
 * @param[out] avctx   codec context to set basic stream parameters
79
 * @param[out] s       where parsed information is stored
80
 * @param[in]  buffer  pointer to start of 34-byte streaminfo data
81
 */
82
void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
83
                              const uint8_t *buffer);
84

    
85
/**
86
 * Validate the FLAC extradata.
87
 * @param[in]  avctx codec context containing the extradata.
88
 * @param[out] format extradata format.
89
 * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
90
 * @return 1 if valid, 0 if not valid.
91
 */
92
int ff_flac_is_extradata_valid(AVCodecContext *avctx,
93
                               enum FLACExtradataFormat *format,
94
                               uint8_t **streaminfo_start);
95

    
96
/**
97
 * Parse the metadata block parameters from the header.
98
 * @param[in]  block_header header data, at least 4 bytes
99
 * @param[out] last indicator for last metadata block
100
 * @param[out] type metadata block type
101
 * @param[out] size metadata block size
102
 */
103
void ff_flac_parse_block_header(const uint8_t *block_header,
104
                                int *last, int *type, int *size);
105

    
106
/**
107
 * Calculate an estimate for the maximum frame size based on verbatim mode.
108
 * @param blocksize block size, in samples
109
 * @param ch number of channels
110
 * @param bps bits-per-sample
111
 */
112
int ff_flac_get_max_frame_size(int blocksize, int ch, int bps);
113

    
114
#endif /* AVCODEC_FLAC_H */