annotate flac.h @ 12248:121272849def libavcodec

VP8: always_inline some things to force gcc to do the right thing Mostly seems to help in the MC code, which gets a hundred cycles faster.
author darkshikari
date Fri, 23 Jul 2010 21:36:21 +0000
parents 7dd2a45249a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6728
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
1 /*
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
2 * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
3 * Copyright (c) 2008 Justin Ruggles
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
4 *
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
5 * This file is part of FFmpeg.
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
6 *
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
11 *
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
15 * Lesser General Public License for more details.
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
16 *
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
20 */
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
21
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
22 /**
11644
7dd2a45249a9 Remove explicit filename from Doxygen @file commands.
diego
parents: 9254
diff changeset
23 * @file
6728
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
24 * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
25 */
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
26
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 6732
diff changeset
27 #ifndef AVCODEC_FLAC_H
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 6732
diff changeset
28 #define AVCODEC_FLAC_H
6728
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
29
6732
dc4f5c55af40 include avcodec.h
jbr
parents: 6729
diff changeset
30 #include "avcodec.h"
dc4f5c55af40 include avcodec.h
jbr
parents: 6729
diff changeset
31
9231
e150ca8d7f91 cosmetics: vertical alignment
jbr
parents: 9216
diff changeset
32 #define FLAC_STREAMINFO_SIZE 34
9188
f534d0cca450 share some constants between the FLAC encoder and FLAC decoder
jbr
parents: 9146
diff changeset
33 #define FLAC_MAX_CHANNELS 8
f534d0cca450 share some constants between the FLAC encoder and FLAC decoder
jbr
parents: 9146
diff changeset
34 #define FLAC_MIN_BLOCKSIZE 16
f534d0cca450 share some constants between the FLAC encoder and FLAC decoder
jbr
parents: 9146
diff changeset
35 #define FLAC_MAX_BLOCKSIZE 65535
8660
4f1525c698e9 move FLAC_STREAMINFO_SIZE to flac.h
jbr
parents: 8659
diff changeset
36
8659
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
37 enum {
9208
443f056ba7e7 share channel mode constants between the FLAC decoder and FLAC encoder
jbr
parents: 9188
diff changeset
38 FLAC_CHMODE_INDEPENDENT = 0,
443f056ba7e7 share channel mode constants between the FLAC decoder and FLAC encoder
jbr
parents: 9188
diff changeset
39 FLAC_CHMODE_LEFT_SIDE = 8,
443f056ba7e7 share channel mode constants between the FLAC decoder and FLAC encoder
jbr
parents: 9188
diff changeset
40 FLAC_CHMODE_RIGHT_SIDE = 9,
443f056ba7e7 share channel mode constants between the FLAC decoder and FLAC encoder
jbr
parents: 9188
diff changeset
41 FLAC_CHMODE_MID_SIDE = 10,
443f056ba7e7 share channel mode constants between the FLAC decoder and FLAC encoder
jbr
parents: 9188
diff changeset
42 };
443f056ba7e7 share channel mode constants between the FLAC decoder and FLAC encoder
jbr
parents: 9188
diff changeset
43
443f056ba7e7 share channel mode constants between the FLAC decoder and FLAC encoder
jbr
parents: 9188
diff changeset
44 enum {
8659
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
45 FLAC_METADATA_TYPE_STREAMINFO = 0,
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
46 FLAC_METADATA_TYPE_PADDING,
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
47 FLAC_METADATA_TYPE_APPLICATION,
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
48 FLAC_METADATA_TYPE_SEEKTABLE,
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
49 FLAC_METADATA_TYPE_VORBIS_COMMENT,
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
50 FLAC_METADATA_TYPE_CUESHEET,
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
51 FLAC_METADATA_TYPE_PICTURE,
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
52 FLAC_METADATA_TYPE_INVALID = 127
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
53 };
61ae841cd13e define FLAC metadata types in flac.h
jbr
parents: 7760
diff changeset
54
9054
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
55 enum FLACExtradataFormat {
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
56 FLAC_EXTRADATA_FORMAT_STREAMINFO = 0,
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
57 FLAC_EXTRADATA_FORMAT_FULL_HEADER = 1
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
58 };
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
59
9254
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
60 #define FLACCOMMONINFO \
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
61 int samplerate; /**< sample rate */\
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
62 int channels; /**< number of channels */\
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
63 int bps; /**< bits-per-sample */\
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
64
6728
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
65 /**
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
66 * Data needed from the Streaminfo header for use by the raw FLAC demuxer
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
67 * and/or the FLAC decoder.
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
68 */
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
69 #define FLACSTREAMINFO \
9254
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
70 FLACCOMMONINFO \
6728
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
71 int max_blocksize; /**< maximum block size, in samples */\
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
72 int max_framesize; /**< maximum frame size, in bytes */\
8661
94f7aca055d5 flacdec: get total number of samples from STREAMINFO
jbr
parents: 8660
diff changeset
73 int64_t samples; /**< total number of samples */\
6728
56c5bbd0996f split out some decoder context params to a shared macro
jbr
parents:
diff changeset
74
6729
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
75 typedef struct FLACStreaminfo {
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
76 FLACSTREAMINFO
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
77 } FLACStreaminfo;
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
78
9254
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
79 typedef struct FLACFrameInfo {
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
80 FLACCOMMONINFO
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
81 int blocksize; /**< block size of the frame */
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
82 int ch_mode; /**< channel decorrelation mode */
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
83 } FLACFrameInfo;
8d570fb097f8 flacdec: split frame header decoding and validation into a separate
jbr
parents: 9231
diff changeset
84
6729
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
85 /**
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
86 * Parse the Streaminfo metadata block
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
87 * @param[out] avctx codec context to set basic stream parameters
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
88 * @param[out] s where parsed information is stored
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
89 * @param[in] buffer pointer to start of 34-byte streaminfo data
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
90 */
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
91 void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
92 const uint8_t *buffer);
071888974d8a share streaminfo parsing function
jbr
parents: 6728
diff changeset
93
9054
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
94 /**
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
95 * Validate the FLAC extradata.
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
96 * @param[in] avctx codec context containing the extradata.
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
97 * @param[out] format extradata format.
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
98 * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
99 * @return 1 if valid, 0 if not valid.
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
100 */
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
101 int ff_flac_is_extradata_valid(AVCodecContext *avctx,
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
102 enum FLACExtradataFormat *format,
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
103 uint8_t **streaminfo_start);
7eedb5796dd8 Use a shared function to validate FLAC extradata.
jbr
parents: 8718
diff changeset
104
9146
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
105 /**
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
106 * Parse the metadata block parameters from the header.
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
107 * @param[in] block_header header data, at least 4 bytes
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
108 * @param[out] last indicator for last metadata block
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
109 * @param[out] type metadata block type
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
110 * @param[out] size metadata block size
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
111 */
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
112 void ff_flac_parse_block_header(const uint8_t *block_header,
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
113 int *last, int *type, int *size);
b980183eb831 flacdec: Add a shared function for parsing a FLAC metadata block header.
jbr
parents: 9106
diff changeset
114
9216
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
115 /**
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
116 * Calculate an estimate for the maximum frame size based on verbatim mode.
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
117 * @param blocksize block size, in samples
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
118 * @param ch number of channels
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
119 * @param bps bits-per-sample
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
120 */
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
121 int ff_flac_get_max_frame_size(int blocksize, int ch, int bps);
64246d9e583a add a function to calculate a more accurate estimate for maximum FLAC
jbr
parents: 9208
diff changeset
122
7760
c4a4495715dd Globally rename the header inclusion guard names.
stefano
parents: 6732
diff changeset
123 #endif /* AVCODEC_FLAC_H */