FFmpeg
flac_parse.h
Go to the documentation of this file.
1 /*
2  * FLAC (Free Lossless Audio Codec) decoder/parser 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
24  * FLAC (Free Lossless Audio Codec) decoder/parser common functions
25  */
26 
27 #ifndef AVCODEC_FLAC_PARSE_H
28 #define AVCODEC_FLAC_PARSE_H
29 
30 #include "avcodec.h"
31 #include "get_bits.h"
32 
33 typedef struct FLACStreaminfo {
34  int samplerate; /**< sample rate */
35  int channels; /**< number of channels */
36  int bps; /**< bits-per-sample */
37  int max_blocksize; /**< maximum block size, in samples */
38  int max_framesize; /**< maximum frame size, in bytes */
39  int64_t samples; /**< total number of samples */
41 
42 typedef struct FLACFrameInfo {
43  int samplerate; /**< sample rate */
44  int channels; /**< number of channels */
45  int bps; /**< bits-per-sample */
46  int blocksize; /**< block size of the frame */
47  int ch_mode; /**< channel decorrelation mode */
48  int64_t frame_or_sample_num; /**< frame number or sample number */
49  int is_var_size; /**< specifies if the stream uses variable
50  block sizes or a fixed block size;
51  also determines the meaning of
52  frame_or_sample_num */
54 
55 /**
56  * Parse the Streaminfo metadata block
57  * @param[out] avctx codec context to set basic stream parameters
58  * @param[out] s where parsed information is stored
59  * @param[in] buffer pointer to start of 34-byte streaminfo data
60  *
61  * @return negative error code on faiure or >= 0 on success
62  */
64  const uint8_t *buffer);
65 
66 /**
67  * Validate the FLAC extradata.
68  * @param[in] avctx codec context containing the extradata.
69  * @param[out] format extradata format.
70  * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
71  * @return 1 if valid, 0 if not valid.
72  */
74  uint8_t **streaminfo_start);
75 
76 /**
77  * Validate and decode a frame header.
78  * @param logctx context for logging
79  * @param gb GetBitContext from which to read frame header
80  * @param[out] fi frame information
81  * @param log_level_offset log level offset. can be used to silence error messages.
82  * @return non-zero on error, 0 if ok
83  */
84 int ff_flac_decode_frame_header(void *logctx, GetBitContext *gb,
85  FLACFrameInfo *fi, int log_level_offset);
86 
88 
89 #endif /* AVCODEC_FLAC_PARSE_H */
FLACStreaminfo::max_blocksize
int max_blocksize
maximum block size, in samples
Definition: flac_parse.h:37
FLACFrameInfo::frame_or_sample_num
int64_t frame_or_sample_num
frame number or sample number
Definition: flac_parse.h:48
FLACFrameInfo::is_var_size
int is_var_size
specifies if the stream uses variable block sizes or a fixed block size; also determines the meaning ...
Definition: flac_parse.h:49
GetBitContext
Definition: get_bits.h:108
FLACStreaminfo::channels
int channels
number of channels
Definition: flac_parse.h:35
FLACFrameInfo::channels
int channels
number of channels
Definition: flac_parse.h:44
FLACStreaminfo
Definition: flac_parse.h:33
s
#define s(width, name)
Definition: cbs_vp9.c:198
FLACFrameInfo::blocksize
int blocksize
block size of the frame
Definition: flac_parse.h:46
channels
channels
Definition: aptx.h:31
get_bits.h
FLACStreaminfo::samples
int64_t samples
total number of samples
Definition: flac_parse.h:39
FLACStreaminfo::bps
int bps
bits-per-sample
Definition: flac_parse.h:36
ff_flac_parse_streaminfo
int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer)
Parse the Streaminfo metadata block.
Definition: flac.c:187
FLACFrameInfo
Definition: flac_parse.h:42
FLACStreaminfo::max_framesize
int max_framesize
maximum frame size, in bytes
Definition: flac_parse.h:38
ff_flac_is_extradata_valid
int ff_flac_is_extradata_valid(AVCodecContext *avctx, uint8_t **streaminfo_start)
Validate the FLAC extradata.
Definition: flac.c:149
FLACStreaminfo::samplerate
int samplerate
sample rate
Definition: flac_parse.h:34
FLACFrameInfo::ch_mode
int ch_mode
channel decorrelation mode
Definition: flac_parse.h:47
FLACFrameInfo::samplerate
int samplerate
sample rate
Definition: flac_parse.h:43
avcodec.h
AVCodecContext
main external API structure.
Definition: avcodec.h:445
ff_flac_set_channel_layout
void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels)
Definition: flac.c:173
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
ff_flac_decode_frame_header
int ff_flac_decode_frame_header(void *logctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset)
Validate and decode a frame header.
Definition: flac.c:51
FLACFrameInfo::bps
int bps
bits-per-sample
Definition: flac_parse.h:45