FFmpeg
flacdec.c
Go to the documentation of this file.
1 /*
2  * Raw FLAC demuxer
3  * Copyright (c) 2001 Fabrice Bellard
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 
23 #include "libavcodec/avcodec.h"
24 #include "libavcodec/bytestream.h"
25 #include "libavcodec/flac.h"
26 #include "avformat.h"
27 #include "demux.h"
28 #include "flac_picture.h"
29 #include "internal.h"
30 #include "rawdec.h"
31 #include "oggdec.h"
32 #include "replaygain.h"
33 
34 #define SEEKPOINT_SIZE 18
35 
36 typedef struct FLACDecContext {
39 
42 
43 static void reset_index_position(int64_t metadata_head_size, AVStream *st)
44 {
45  FFStream *const sti = ffstream(st);
46  /* the real seek index offset should be the size of metadata blocks with the offset in the frame blocks */
47  for (int i = 0; i < sti->nb_index_entries; i++)
48  sti->index_entries[i].pos += metadata_head_size;
49 }
50 
51 static const uint16_t sr_table[16] = {
52  0, 1764, 3528, 3840, 160, 320, 441, 480, 640, 882, 960, 1920, 0, 0, 0, 0
53 };
54 
56 {
57  int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0;
58  uint8_t header[4];
59  uint8_t *buffer=NULL;
60  uint32_t marker;
61  FLACDecContext *flac = s->priv_data;
63  if (!st)
64  return AVERROR(ENOMEM);
68  /* the parameters will be extracted from the compressed bitstream */
69 
70  /* if fLaC marker is not found, assume there is no header */
71  marker = avio_rl32(s->pb);
72  if (marker != MKTAG('f','L','a','C')) {
73  const int sample_rate = 50 * sr_table[(marker >> 16) & 0xF];
74  if (sample_rate)
75  avpriv_set_pts_info(st, 64, 1, sample_rate);
76  avio_seek(s->pb, -4, SEEK_CUR);
77  return 0;
78  }
79 
80  /* process metadata blocks */
81  while (!avio_feof(s->pb) && !metadata_last) {
82  if (avio_read(s->pb, header, 4) != 4)
83  return AVERROR_INVALIDDATA;
84  flac_parse_block_header(header, &metadata_last, &metadata_type,
85  &metadata_size);
86  switch (metadata_type) {
87  /* allocate and read metadata block for supported types */
94  if (!buffer) {
95  return AVERROR(ENOMEM);
96  }
97  if (avio_read(s->pb, buffer, metadata_size) != metadata_size) {
98  RETURN_ERROR(AVERROR(EIO));
99  }
100  break;
101  /* skip metadata block for unsupported types */
102  default:
103  ret = avio_skip(s->pb, metadata_size);
104  if (ret < 0)
105  return ret;
106  }
107 
108  if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) {
109  uint32_t samplerate;
110  uint64_t samples;
111 
112  /* STREAMINFO can only occur once */
113  if (found_streaminfo) {
115  }
116  if (metadata_size != FLAC_STREAMINFO_SIZE) {
118  }
119  found_streaminfo = 1;
120  st->codecpar->extradata = buffer;
121  st->codecpar->extradata_size = metadata_size;
122  buffer = NULL;
123 
124  /* get sample rate and sample count from STREAMINFO header;
125  * other parameters will be extracted by the parser */
126  samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
127  samples = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);
128 
129  /* set time base and duration */
130  if (samplerate > 0) {
131  avpriv_set_pts_info(st, 64, 1, samplerate);
132  if (samples > 0)
133  st->duration = samples;
134  }
135  } else if (metadata_type == FLAC_METADATA_TYPE_CUESHEET) {
136  uint8_t isrc[13];
137  uint64_t start;
138  const uint8_t *offset;
139  int i, chapters, track, ti;
140  if (metadata_size < 431)
142  offset = buffer + 395;
143  chapters = bytestream_get_byte(&offset) - 1;
144  if (chapters <= 0)
146  for (i = 0; i < chapters; i++) {
147  if (offset + 36 - buffer > metadata_size)
149  start = bytestream_get_be64(&offset);
150  track = bytestream_get_byte(&offset);
151  bytestream_get_buffer(&offset, isrc, 12);
152  isrc[12] = 0;
153  offset += 14;
154  ti = bytestream_get_byte(&offset);
155  if (ti <= 0) RETURN_ERROR(AVERROR_INVALIDDATA);
156  offset += ti * 12;
157  avpriv_new_chapter(s, track, st->time_base, start, AV_NOPTS_VALUE, isrc);
158  }
159  av_freep(&buffer);
160  } else if (metadata_type == FLAC_METADATA_TYPE_PICTURE) {
161  ret = ff_flac_parse_picture(s, &buffer, metadata_size, 1);
162  av_freep(&buffer);
163  if (ret < 0) {
164  av_log(s, AV_LOG_ERROR, "Error parsing attached picture.\n");
165  return ret;
166  }
167  } else if (metadata_type == FLAC_METADATA_TYPE_SEEKTABLE) {
168  const uint8_t *seekpoint = buffer;
169  int i, seek_point_count = metadata_size/SEEKPOINT_SIZE;
170  flac->found_seektable = 1;
171  if ((s->flags&AVFMT_FLAG_FAST_SEEK)) {
172  for(i=0; i<seek_point_count; i++) {
173  int64_t timestamp = bytestream_get_be64(&seekpoint);
174  int64_t pos = bytestream_get_be64(&seekpoint);
175  /* skip number of samples */
176  bytestream_get_be16(&seekpoint);
177  av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
178  }
179  }
180  av_freep(&buffer);
181  }
182  else {
183 
184  /* STREAMINFO must be the first block */
185  if (!found_streaminfo) {
187  }
188  /* process supported blocks other than STREAMINFO */
189  if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
190  AVDictionaryEntry *chmask;
191 
192  ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1);
193  if (ret < 0) {
194  av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
195  } else if (ret > 0) {
196  s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
197  }
198 
199  /* parse the channels mask if present */
200  chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
201  if (chmask) {
202  uint64_t mask = strtol(chmask->value, NULL, 0);
203  if (!mask || mask & ~0x3ffffULL) {
205  "Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
206  } else {
208  av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
209  }
210  }
211  }
212  av_freep(&buffer);
213  }
214  }
215 
216  ret = ff_replaygain_export(st, s->metadata);
217  if (ret < 0)
218  return ret;
219 
220  reset_index_position(avio_tell(s->pb), st);
221  return 0;
222 
223 fail:
224  av_free(buffer);
225  return ret;
226 }
227 
228 static int raw_flac_probe(const AVProbeData *p)
229 {
230  if ((p->buf[2] & 0xF0) == 0) // blocksize code invalid
231  return 0;
232  if ((p->buf[2] & 0x0F) == 0x0F) // sample rate code invalid
233  return 0;
234  if ((p->buf[3] & 0xF0) >= FLAC_MAX_CHANNELS + FLAC_CHMODE_MID_SIDE << 4)
235  // channel mode invalid
236  return 0;
237  if ((p->buf[3] & 0x06) == 0x06) // bits per sample code invalid
238  return 0;
239  if ((p->buf[3] & 0x01) == 0x01) // reserved bit set
240  return 0;
241  return AVPROBE_SCORE_EXTENSION / 4 + 1;
242 }
243 
244 static int flac_probe(const AVProbeData *p)
245 {
246  if ((AV_RB16(p->buf) & 0xFFFE) == 0xFFF8)
247  return raw_flac_probe(p);
248 
249  /* file header + metadata header + checked bytes of streaminfo */
250  if (p->buf_size >= 4 + 4 + 13) {
251  int type = p->buf[4] & 0x7f;
252  int size = AV_RB24(p->buf + 5);
253  int min_block_size = AV_RB16(p->buf + 8);
254  int max_block_size = AV_RB16(p->buf + 10);
255  int sample_rate = AV_RB24(p->buf + 18) >> 4;
256 
257  if (memcmp(p->buf, "fLaC", 4))
258  return 0;
261  min_block_size >= 16 &&
262  max_block_size >= min_block_size &&
263  sample_rate && sample_rate <= 655350)
264  return AVPROBE_SCORE_MAX;
266  }
267 
268  return 0;
269 }
270 
271 static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_index,
272  int64_t *ppos, int64_t pos_limit)
273 {
274  FLACDecContext *flac = s->priv_data;
275  FFFormatContext *const si = ffformatcontext(s);
276  AVPacket *const pkt = si->parse_pkt;
277  AVStream *st = s->streams[stream_index];
278  AVCodecParserContext *parser;
279  int ret;
280  int64_t pts = AV_NOPTS_VALUE;
281 
282  if (avio_seek(s->pb, *ppos, SEEK_SET) < 0)
283  return AV_NOPTS_VALUE;
284 
285  parser = av_parser_init(st->codecpar->codec_id);
286  if (!parser){
287  return AV_NOPTS_VALUE;
288  }
289  parser->flags |= PARSER_FLAG_USE_CODEC_TS;
290 
291  if (!flac->parser_dec) {
293  if (!flac->parser_dec)
294  return AV_NOPTS_VALUE;
295 
297  if (ret < 0)
298  return ret;
299  }
300 
301  for (;;){
302  uint8_t *data;
303  int size;
304 
306  if (ret < 0){
307  if (ret == AVERROR(EAGAIN))
308  continue;
309  else {
311  av_assert1(!pkt->size);
312  }
313  }
314  av_parser_parse2(parser, flac->parser_dec,
315  &data, &size, pkt->data, pkt->size,
316  pkt->pts, pkt->dts, *ppos);
317 
319  if (size) {
320  if (parser->pts != AV_NOPTS_VALUE){
321  // seeking may not have started from beginning of a frame
322  // calculate frame start position from next frame backwards
323  *ppos = parser->next_frame_offset - size;
324  pts = parser->pts;
325  break;
326  }
327  } else if (ret < 0)
328  break;
329  }
330  av_parser_close(parser);
331  return pts;
332 }
333 
335 {
336  FLACDecContext *flac = s->priv_data;
337 
339 
340  return 0;
341 }
342 
343 static int flac_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) {
344  AVStream *const st = s->streams[0];
345  FFStream *const sti = ffstream(st);
346  int index;
347  int64_t pos;
348  AVIndexEntry e;
349  FLACDecContext *flac = s->priv_data;
350 
351  if (!flac->found_seektable || !(s->flags&AVFMT_FLAG_FAST_SEEK)) {
352  return -1;
353  }
354 
355  index = av_index_search_timestamp(st, timestamp, flags);
356  if (index < 0 || index >= sti->nb_index_entries)
357  return -1;
358 
359  e = sti->index_entries[index];
360  pos = avio_seek(s->pb, e.pos, SEEK_SET);
361  if (pos >= 0) {
362  return 0;
363  }
364  return -1;
365 }
366 
368  .p.name = "flac",
369  .p.long_name = NULL_IF_CONFIG_SMALL("raw FLAC"),
370  .p.flags = AVFMT_GENERIC_INDEX,
371  .p.extensions = "flac",
372  .p.priv_class = &ff_raw_demuxer_class,
373  .read_probe = flac_probe,
374  .read_header = flac_read_header,
375  .read_close = flac_close,
376  .read_packet = ff_raw_read_partial_packet,
377  .read_seek = flac_seek,
378  .read_timestamp = flac_read_timestamp,
379  .raw_codec_id = AV_CODEC_ID_FLAC,
380  .priv_data_size = sizeof(FLACDecContext),
381 };
avpriv_new_chapter
AVChapter * avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
Definition: demux_utils.c:42
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:427
FLAC_CHMODE_MID_SIDE
@ FLAC_CHMODE_MID_SIDE
Definition: flac.h:42
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
AVCodecParserContext::pts
int64_t pts
Definition: avcodec.h:2726
FLAC_METADATA_TYPE_SEEKTABLE
@ FLAC_METADATA_TYPE_SEEKTABLE
Definition: flac.h:49
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
ffformatcontext
static av_always_inline FFFormatContext * ffformatcontext(AVFormatContext *s)
Definition: internal.h:188
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
ff_replaygain_export
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
Definition: replaygain.c:94
av_unused
#define av_unused
Definition: attributes.h:131
flac_probe
static int flac_probe(const AVProbeData *p)
Definition: flacdec.c:244
AVPacket::data
uint8_t * data
Definition: packet.h:522
data
const char data[16]
Definition: mxf.c:148
FLACDecContext::rawctx
FFRawDemuxerContext rawctx
Definition: flacdec.c:37
AV_CODEC_ID_FLAC
@ AV_CODEC_ID_FLAC
Definition: codec_id.h:452
AVProbeData::buf_size
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:454
flac_read_header
static int flac_read_header(AVFormatContext *s)
Definition: flacdec.c:55
sample_rate
sample_rate
Definition: ffmpeg_filter.c:409
AVIndexEntry
Definition: avformat.h:602
AVINDEX_KEYFRAME
#define AVINDEX_KEYFRAME
Definition: avformat.h:610
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:463
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: avformat.c:853
flac_seek
static int flac_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: flacdec.c:343
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:417
fail
#define fail()
Definition: checkasm.h:179
av_add_index_entry
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
Definition: seek.c:120
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:494
FFRawDemuxerContext
Definition: rawdec.h:37
AVFMT_GENERIC_INDEX
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:480
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
av_parser_init
AVCodecParserContext * av_parser_init(int codec_id)
Definition: parser.c:32
pts
static int64_t pts
Definition: transcode_aac.c:643
SEEKPOINT_SIZE
#define SEEKPOINT_SIZE
Definition: flacdec.c:34
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:802
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
mask
static const uint16_t mask[17]
Definition: lzw.c:38
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:62
ff_raw_read_partial_packet
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
Definition: rawdec.c:33
avcodec_alloc_context3
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition: options.c:149
s
#define s(width, name)
Definition: cbs_vp9.c:198
FLAC_METADATA_TYPE_CUESHEET
@ FLAC_METADATA_TYPE_CUESHEET
Definition: flac.h:51
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:453
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_channel_layout_from_mask
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
Definition: channel_layout.c:242
flac_picture.h
reset_index_position
static void reset_index_position(int64_t metadata_head_size, AVStream *st)
Definition: flacdec.c:43
FLAC_METADATA_TYPE_STREAMINFO
@ FLAC_METADATA_TYPE_STREAMINFO
Definition: flac.h:46
FFFormatContext
Definition: internal.h:64
FFStream::need_parsing
enum AVStreamParseType need_parsing
Definition: internal.h:386
ff_raw_demuxer_class
const AVClass ff_raw_demuxer_class
Definition: rawdec.c:141
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
internal.h
FLACDecContext
Definition: flacdec.c:36
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:766
avcodec_parameters_to_context
int avcodec_parameters_to_context(AVCodecContext *codec, const struct AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
FLAC_METADATA_TYPE_PICTURE
@ FLAC_METADATA_TYPE_PICTURE
Definition: flac.h:52
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:782
NULL
#define NULL
Definition: coverity.c:32
rawdec.h
flac_parse_block_header
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:63
avcodec_free_context
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition: options.c:164
FFStream::nb_index_entries
int nb_index_entries
Definition: internal.h:251
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:451
FLAC_STREAMINFO_SIZE
#define FLAC_STREAMINFO_SIZE
Definition: flac.h:32
AVCodecParserContext::flags
int flags
Definition: avcodec.h:2740
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:180
index
int index
Definition: gxfenc.c:89
AVPROBE_SCORE_EXTENSION
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:461
ff_flac_parse_picture
int ff_flac_parse_picture(AVFormatContext *s, uint8_t **bufp, int buf_size, int truncate_workaround)
Parse a FLAC METADATA_BLOCK_PICTURE.
Definition: flac_picture.c:33
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:73
flac_read_timestamp
static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
Definition: flacdec.c:271
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:729
sr_table
static const uint16_t sr_table[16]
Definition: flacdec.c:51
AVPacket::size
int size
Definition: packet.h:523
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
FFFormatContext::parse_pkt
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
Definition: internal.h:127
FFStream
Definition: internal.h:193
AVCodecParserContext::next_frame_offset
int64_t next_frame_offset
Definition: avcodec.h:2713
size
int size
Definition: twinvq_data.h:10344
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:41
header
static const uint8_t header[24]
Definition: sdr2.c:68
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:521
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
AVFMT_FLAG_FAST_SEEK
#define AVFMT_FLAG_FAST_SEEK
Enable fast, but inaccurate seeks for some formats.
Definition: avformat.h:1425
RETURN_ERROR
#define RETURN_ERROR(code)
Definition: flac_picture.h:27
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
demux.h
avcodec.h
AVCodecParserContext
Definition: avcodec.h:2707
bytestream_get_buffer
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)
Definition: bytestream.h:363
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:743
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:230
FLAC_METADATA_TYPE_VORBIS_COMMENT
@ FLAC_METADATA_TYPE_VORBIS_COMMENT
Definition: flac.h:50
FLACDecContext::found_seektable
int found_seektable
Definition: flacdec.c:38
pos
unsigned int pos
Definition: spdifenc.c:413
avformat.h
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
FLAC_MAX_CHANNELS
#define FLAC_MAX_CHANNELS
Definition: flac.h:33
oggdec.h
AVCodecContext
main external API structure.
Definition: avcodec.h:445
channel_layout.h
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
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:611
PARSER_FLAG_USE_CODEC_TS
#define PARSER_FLAG_USE_CODEC_TS
Definition: avcodec.h:2745
AVIndexEntry::pos
int64_t pos
Definition: avformat.h:603
AVSTREAM_PARSE_FULL_RAW
@ AVSTREAM_PARSE_FULL_RAW
full parsing and repack with timestamp and position generation by parser for raw this assumes that ea...
Definition: avformat.h:597
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:317
FFStream::index_entries
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: internal.h:249
av_parser_parse2
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts, int64_t pos)
Parse a packet.
Definition: parser.c:115
raw_flac_probe
static int raw_flac_probe(const AVProbeData *p)
Definition: flacdec.c:228
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:499
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:88
FFInputFormat
Definition: demux.h:37
bytestream.h
replaygain.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_flac_demuxer
const FFInputFormat ff_flac_demuxer
Definition: flacdec.c:367
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
AVDictionaryEntry::value
char * value
Definition: dict.h:91
flac.h
ff_vorbis_comment
int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size, int parse_picture)
Parse Vorbis comments.
Definition: oggparsevorbis.c:148
AV_RB24
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
Definition: bytestream.h:97
AV_RB64
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
Definition: bytestream.h:95
AVFMT_EVENT_FLAG_METADATA_UPDATED
#define AVFMT_EVENT_FLAG_METADATA_UPDATED
Definition: avformat.h:1632
av_parser_close
void av_parser_close(AVCodecParserContext *s)
Definition: parser.c:193
AV_RB16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:98
av_index_search_timestamp
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: seek.c:243
flac_close
static int flac_close(AVFormatContext *s)
Definition: flacdec.c:334
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:345
FLACDecContext::parser_dec
AVCodecContext * parser_dec
Definition: flacdec.c:40