Libav
flac.h
Go to the documentation of this file.
1 /*
2  * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
3  * Copyright (c) 2008 Justin Ruggles
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
27 #ifndef AVCODEC_FLAC_H
28 #define AVCODEC_FLAC_H
29 
30 #include "avcodec.h"
31 #include "bytestream.h"
32 #include "get_bits.h"
33 
34 #define FLAC_STREAMINFO_SIZE 34
35 #define FLAC_MAX_CHANNELS 8
36 #define FLAC_MIN_BLOCKSIZE 16
37 #define FLAC_MAX_BLOCKSIZE 65535
38 #define FLAC_MIN_FRAME_SIZE 11
39 
40 enum {
45 };
46 
47 enum {
56 };
57 
61 };
62 
63 #define FLACCOMMONINFO \
64  int samplerate; \
65  int channels; \
66  int bps; \
67 
68 
72 #define FLACSTREAMINFO \
73  FLACCOMMONINFO \
74  int max_blocksize; \
75  int max_framesize; \
76  int64_t samples; \
77 
78 typedef struct FLACStreaminfo {
81 
82 typedef struct FLACFrameInfo {
84  int blocksize;
85  int ch_mode;
92 
100  const uint8_t *buffer);
101 
110  enum FLACExtradataFormat *format,
111  uint8_t **streaminfo_start);
112 
119 int ff_flac_get_max_frame_size(int blocksize, int ch, int bps);
120 
130  FLACFrameInfo *fi, int log_level_offset);
131 
133 
141 static av_always_inline void flac_parse_block_header(const uint8_t *block_header,
142  int *last, int *type, int *size)
143 {
144  int tmp = bytestream_get_byte(&block_header);
145  if (last)
146  *last = tmp & 0x80;
147  if (type)
148  *type = tmp & 0x7F;
149  if (size)
150  *size = bytestream_get_be24(&block_header);
151 }
152 
153 #endif /* AVCODEC_FLAC_H */
int size
#define av_always_inline
Definition: attributes.h:40
int64_t frame_or_sample_num
frame number or sample number
Definition: flac.h:88
FLACCOMMONINFO int blocksize
block size of the frame
Definition: flac.h:86
int ff_flac_get_max_frame_size(int blocksize, int ch, int bps)
Calculate an estimate for the maximum frame size based on verbatim mode.
Definition: flac.c:148
uint8_t
void ff_flac_set_channel_layout(AVCodecContext *avctx)
Definition: flac.c:196
bitstream reader API header.
int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset)
Validate and decode a frame header.
Definition: flac.c:50
FLACExtradataFormat
Definition: flac.h:58
int ch_mode
channel decorrelation mode
Definition: flac.h:87
#define FLACCOMMONINFO
bits-per-sample
Definition: flac.h:63
#define FLACSTREAMINFO
Data needed from the Streaminfo header for use by the raw FLAC demuxer and/or the FLAC decoder...
Definition: flac.h:73
Libavcodec external API header.
void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer)
Parse the Streaminfo metadata block.
Definition: flac.c:204
int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start)
Validate the FLAC extradata.
Definition: flac.c:169
static char buffer[20]
Definition: seek-test.c:31
main external API structure.
Definition: avcodec.h:1050
static av_always_inline void flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size)
Parse the metadata block parameters from the header.
Definition: flac.h:143
unsigned bps
Definition: movenc.c:845
int is_var_size
specifies if the stream uses variable block sizes or a fixed block size; also determines the meaning ...
Definition: flac.h:89