FFmpeg
flacenc.c
Go to the documentation of this file.
1 /*
2  * raw FLAC muxer
3  * Copyright (c) 2006-2009 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 #include "libavutil/avstring.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 #include "libavcodec/flac.h"
28 #include "avformat.h"
29 #include "avio_internal.h"
30 #include "flacenc.h"
31 #include "id3v2.h"
32 #include "internal.h"
33 #include "mux.h"
34 #include "version.h"
35 #include "vorbiscomment.h"
36 
37 
38 typedef struct FlacMuxerContext {
39  const AVClass *class;
41 
44  /* audio packets are queued here until we get all the attached pictures */
46 
47  /* updated streaminfo sent by the encoder at the end */
50 
51  unsigned attached_types;
53 
54 static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes,
55  int last_block)
56 {
57  avio_w8(pb, last_block ? 0x81 : 0x01);
58  avio_wb24(pb, n_padding_bytes);
59  ffio_fill(pb, 0, n_padding_bytes);
60  return 0;
61 }
62 
64  int last_block, int bitexact)
65 {
66  const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
67  int64_t len;
68 
70 
71  len = ff_vorbiscomment_length(*m, vendor, NULL, 0);
72  if (len >= ((1<<24) - 4))
73  return AVERROR(EINVAL);
74 
75  avio_w8(pb, last_block ? 0x84 : 0x04);
76  avio_wb24(pb, len);
77  ff_vorbiscomment_write(pb, *m, vendor, NULL, 0);
78 
79  return 0;
80 }
81 
83 {
84  FlacMuxerContext *c = s->priv_data;
85  AVIOContext *pb = s->pb;
86  const AVPixFmtDescriptor *pixdesc;
87  const CodecMime *mime = ff_id3v2_mime_tags;
89  const char *mimetype = NULL, *desc = "";
90  const AVStream *st = s->streams[pkt->stream_index];
91  int i, mimelen, desclen, type = 0, blocklen;
92 
93  if (!pkt->data)
94  return 0;
95 
96  while (mime->id != AV_CODEC_ID_NONE) {
97  if (mime->id == st->codecpar->codec_id) {
98  mimetype = mime->str;
99  break;
100  }
101  mime++;
102  }
103  if (!mimetype) {
104  av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot "
105  "write an attached picture.\n", st->index);
106  return AVERROR(EINVAL);
107  }
108  mimelen = strlen(mimetype);
109 
110  /* get the picture type */
111  e = av_dict_get(st->metadata, "comment", NULL, 0);
112  for (i = 0; e && i < FF_ARRAY_ELEMS(ff_id3v2_picture_types); i++) {
114  type = i;
115  break;
116  }
117  }
118 
119  if ((c->attached_types & (1 << type)) & 0x6) {
120  av_log(s, AV_LOG_ERROR, "Duplicate attachment for type '%s'\n", ff_id3v2_picture_types[type]);
121  return AVERROR(EINVAL);
122  }
123 
124  if (type == 1 && (st->codecpar->codec_id != AV_CODEC_ID_PNG ||
125  st->codecpar->width != 32 ||
126  st->codecpar->height != 32)) {
127  av_log(s, AV_LOG_ERROR, "File icon attachment must be a 32x32 PNG");
128  return AVERROR(EINVAL);
129  }
130 
131  c->attached_types |= (1 << type);
132 
133  /* get the description */
134  if ((e = av_dict_get(st->metadata, "title", NULL, 0)))
135  desc = e->value;
136  desclen = strlen(desc);
137 
138  blocklen = 4 + 4 + mimelen + 4 + desclen + 4 + 4 + 4 + 4 + 4 + pkt->size;
139  if (blocklen >= 1<<24) {
140  av_log(s, AV_LOG_ERROR, "Picture block too big %d >= %d\n", blocklen, 1<<24);
141  return AVERROR(EINVAL);
142  }
143 
144  avio_w8(pb, 0x06);
145  avio_wb24(pb, blocklen);
146 
147  avio_wb32(pb, type);
148 
149  avio_wb32(pb, mimelen);
150  avio_write(pb, mimetype, mimelen);
151 
152  avio_wb32(pb, desclen);
153  avio_write(pb, desc, desclen);
154 
155  avio_wb32(pb, st->codecpar->width);
156  avio_wb32(pb, st->codecpar->height);
157  if ((pixdesc = av_pix_fmt_desc_get(st->codecpar->format)))
158  avio_wb32(pb, av_get_bits_per_pixel(pixdesc));
159  else
160  avio_wb32(pb, 0);
161  avio_wb32(pb, 0);
162 
163  avio_wb32(pb, pkt->size);
164  avio_write(pb, pkt->data, pkt->size);
165  return 0;
166 }
167 
169 {
170  int i, ret, padding = s->metadata_header_padding;
171  if (padding < 0)
172  padding = 8192;
173  /* The FLAC specification states that 24 bits are used to represent the
174  * size of a metadata block so we must clip this value to 2^24-1. */
175  padding = av_clip_uintp2(padding, 24);
176 
177  for (i = 0; i < s->nb_streams; i++) {
178  AVStream *st = s->streams[i];
179  AVPacket *pkt = st->priv_data;
180  if (!pkt)
181  continue;
184  if (ret < 0 && (s->error_recognition & AV_EF_EXPLODE))
185  return ret;
186  }
187 
188  ret = flac_write_block_comment(s->pb, &s->metadata, !padding,
189  s->flags & AVFMT_FLAG_BITEXACT);
190  if (ret)
191  return ret;
192 
193  /* The command line flac encoder defaults to placing a seekpoint
194  * every 10s. So one might add padding to allow that later
195  * but there seems to be no simple way to get the duration here.
196  * So just add the amount requested by the user. */
197  if (padding)
198  flac_write_block_padding(s->pb, padding, 1);
199 
200  return 0;
201 }
202 
203 static int flac_init(struct AVFormatContext *s)
204 {
205  AVCodecParameters *par;
206  FlacMuxerContext *c = s->priv_data;
207  int i;
208 
209  c->audio_stream_idx = -1;
210  for (i = 0; i < s->nb_streams; i++) {
211  AVStream *st = s->streams[i];
212  if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
213  if (c->audio_stream_idx >= 0 || st->codecpar->codec_id != AV_CODEC_ID_FLAC) {
214  av_log(s, AV_LOG_ERROR, "Invalid audio stream. Exactly one FLAC "
215  "audio stream is required.\n");
216  return AVERROR(EINVAL);
217  }
218  par = s->streams[i]->codecpar;
219  c->audio_stream_idx = i;
220  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
222  av_log(s, AV_LOG_WARNING, "Video stream #%d is not an attached picture. Ignoring\n", i);
223  continue;
224  } else if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
225  av_log(s, AV_LOG_ERROR, "GIF image support is not implemented.\n");
226  return AVERROR_PATCHWELCOME;
227  } else if (!c->write_header) {
228  av_log(s, AV_LOG_ERROR, "Can't write attached pictures without a header.\n");
229  return AVERROR(EINVAL);
230  }
231  c->waiting_pics++;
232  } else {
233  av_log(s, AV_LOG_ERROR, "Only audio streams and pictures are allowed in FLAC.\n");
234  return AVERROR(EINVAL);
235  }
236  }
237  if (c->audio_stream_idx < 0) {
238  av_log(s, AV_LOG_ERROR, "No audio stream present.\n");
239  return AVERROR(EINVAL);
240  }
241 
242  /* add the channel layout tag */
244  !(par->ch_layout.u.mask & ~0x3ffffULL) &&
246  AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
247  NULL, 0);
248 
249  if (chmask) {
250  av_log(s, AV_LOG_WARNING, "A WAVEFORMATEXTENSIBLE_CHANNEL_MASK is "
251  "already present, this muxer will not overwrite it.\n");
252  } else {
253  uint8_t buf[32];
254  snprintf(buf, sizeof(buf), "0x%"PRIx64, par->ch_layout.u.mask);
255  av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
256  }
257  }
258 
259  return 0;
260 }
261 
263 {
264  FlacMuxerContext *c = s->priv_data;
265  AVCodecParameters *par = s->streams[c->audio_stream_idx]->codecpar;
266  int ret;
267 
268  if (!c->write_header)
269  return 0;
270 
271  ret = ff_flac_write_header(s->pb, par->extradata,
272  par->extradata_size, 0);
273  if (ret < 0)
274  return ret;
275 
276  if (!c->waiting_pics)
278 
279  return ret;
280 }
281 
283 {
284  FlacMuxerContext *c = s->priv_data;
285  uint8_t *streaminfo;
286  size_t streaminfo_size;
287 
288  /* check for updated streaminfo */
290  &streaminfo_size);
291  if (streaminfo && streaminfo_size == FLAC_STREAMINFO_SIZE) {
292  memcpy(c->streaminfo, streaminfo, FLAC_STREAMINFO_SIZE);
293  c->updated_streaminfo = 1;
294  }
295 
296  if (pkt->size)
297  avio_write(s->pb, pkt->data, pkt->size);
298  return 0;
299 }
300 
302 {
303  FlacMuxerContext *c = s->priv_data;
304  AVPacket *const pkt = ffformatcontext(s)->pkt;
305  int ret, write = 1;
306 
308  if (ret < 0)
309  write = 0;
310 
311  while (c->queue.head) {
312  avpriv_packet_list_get(&c->queue, pkt);
313  if (write && (ret = flac_write_audio_packet(s, pkt)) < 0)
314  write = 0;
316  }
317  return ret;
318 }
319 
321 {
322  AVIOContext *pb = s->pb;
323  int64_t file_size;
324  FlacMuxerContext *c = s->priv_data;
325 
326  if (c->waiting_pics) {
327  av_log(s, AV_LOG_WARNING, "No packets were sent for some of the "
328  "attached pictures.\n");
330  }
331 
332  if (!c->write_header || !c->updated_streaminfo)
333  return 0;
334 
335  if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
336  /* rewrite the STREAMINFO header block data */
337  file_size = avio_tell(pb);
338  avio_seek(pb, 8, SEEK_SET);
339  avio_write(pb, c->streaminfo, FLAC_STREAMINFO_SIZE);
340  avio_seek(pb, file_size, SEEK_SET);
341  } else {
342  av_log(s, AV_LOG_WARNING, "unable to rewrite FLAC header.\n");
343  }
344 
345  return 0;
346 }
347 
348 static void flac_deinit(struct AVFormatContext *s)
349 {
350  FlacMuxerContext *c = s->priv_data;
351 
352  avpriv_packet_list_free(&c->queue);
353  for (unsigned i = 0; i < s->nb_streams; i++)
354  av_packet_free((AVPacket **)&s->streams[i]->priv_data);
355 }
356 
358 {
359  FlacMuxerContext *c = s->priv_data;
360  int ret;
361 
362  if (pkt->stream_index == c->audio_stream_idx) {
363  if (c->waiting_pics) {
364  /* buffer audio packets until we get all the pictures */
365  ret = avpriv_packet_list_put(&c->queue, pkt, NULL, 0);
366  if (ret < 0) {
367  av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n");
368  c->waiting_pics = 0;
370  if (ret < 0)
371  return ret;
372  return flac_write_audio_packet(s, pkt);
373  }
374  } else
375  return flac_write_audio_packet(s, pkt);
376  } else {
377  AVStream *st = s->streams[pkt->stream_index];
378 
379  if (!c->waiting_pics ||
381  return 0;
382 
383  /* warn only once for each stream */
384  if (st->nb_frames == 1) {
385  av_log(s, AV_LOG_WARNING, "Got more than one picture in stream %d,"
386  " ignoring.\n", pkt->stream_index);
387  }
388  if (st->nb_frames >= 1)
389  return 0;
390 
392  if (!st->priv_data)
393  av_log(s, AV_LOG_ERROR, "Out of memory queueing an attached picture; skipping\n");
394  c->waiting_pics--;
395 
396  /* flush the buffered audio packets */
397  if (!c->waiting_pics &&
398  (ret = flac_queue_flush(s)) < 0)
399  return ret;
400  }
401 
402  return 0;
403 }
404 
405 static const AVOption flacenc_options[] = {
406  { "write_header", "Write the file header", offsetof(FlacMuxerContext, write_header), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
407  { NULL },
408 };
409 
410 static const AVClass flac_muxer_class = {
411  .class_name = "flac muxer",
412  .item_name = av_default_item_name,
413  .option = flacenc_options,
414  .version = LIBAVUTIL_VERSION_INT,
415 };
416 
418  .p.name = "flac",
419  .p.long_name = NULL_IF_CONFIG_SMALL("raw FLAC"),
420  .priv_data_size = sizeof(FlacMuxerContext),
421  .p.mime_type = "audio/x-flac",
422  .p.extensions = "flac",
423  .p.audio_codec = AV_CODEC_ID_FLAC,
424  .p.video_codec = AV_CODEC_ID_PNG,
425  .init = flac_init,
426  .write_header = flac_write_header,
427  .write_packet = flac_write_packet,
428  .write_trailer = flac_write_trailer,
429  .deinit = flac_deinit,
430  .p.flags = AVFMT_NOTIMESTAMPS,
431  .p.priv_class = &flac_muxer_class,
432 };
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:423
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
avpriv_packet_list_put
int avpriv_packet_list_put(PacketList *packet_buffer, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
Append an AVPacket to the list.
Definition: avpacket.c:537
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
LIBAVFORMAT_IDENT
#define LIBAVFORMAT_IDENT
Definition: version.h:45
avpriv_packet_list_get
int avpriv_packet_list_get(PacketList *pkt_buffer, AVPacket *pkt)
Remove the oldest AVPacket in the list and return it.
Definition: avpacket.c:576
AV_EF_EXPLODE
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition: defs.h:51
flac_init
static int flac_init(struct AVFormatContext *s)
Definition: flacenc.c:203
AVOutputFormat::name
const char * name
Definition: avformat.h:511
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
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
FlacMuxerContext::queue
PacketList queue
Definition: flacenc.c:45
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
ffformatcontext
static av_always_inline FFFormatContext * ffformatcontext(AVFormatContext *s)
Definition: internal.h:194
AV_PKT_DATA_NEW_EXTRADATA
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Definition: packet.h:56
AVStream::priv_data
void * priv_data
Definition: avformat.h:866
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2964
AV_DISPOSITION_ATTACHED_PIC
#define AV_DISPOSITION_ATTACHED_PIC
The stream is stored in the file as an attached picture/"cover art" (e.g.
Definition: avformat.h:772
av_clip_uintp2
#define av_clip_uintp2
Definition: common.h:120
AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:480
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:207
id3v2.h
ff_metadata_conv
void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv)
Definition: metadata.c:26
pixdesc.h
flac_write_header
static int flac_write_header(struct AVFormatContext *s)
Definition: flacenc.c:262
AVPacket::data
uint8_t * data
Definition: packet.h:491
vorbiscomment.h
AVOption
AVOption.
Definition: opt.h:251
PacketList
Definition: packet_internal.h:33
flacenc.h
av_get_bits_per_pixel
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:2916
AVDictionary
Definition: dict.c:34
AV_CODEC_ID_FLAC
@ AV_CODEC_ID_FLAC
Definition: codec_id.h:454
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:312
AVChannelLayout::mask
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
Definition: channel_layout.h:339
ff_flac_is_native_layout
int ff_flac_is_native_layout(uint64_t channel_layout)
Definition: flacenc_header.c:50
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:74
FFOutputFormat::p
AVOutputFormat p
The public AVOutputFormat.
Definition: mux.h:36
CodecMime
Definition: internal.h:53
flac_finish_header
static int flac_finish_header(struct AVFormatContext *s)
Definition: flacenc.c:168
flac_write_audio_packet
static int flac_write_audio_packet(struct AVFormatContext *s, AVPacket *pkt)
Definition: flacenc.c:282
ff_vorbiscomment_write
int ff_vorbiscomment_write(AVIOContext *pb, const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters)
Write a VorbisComment into an AVIOContext.
Definition: vorbiscomment.c:65
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:513
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
AVChannelLayout::u
union AVChannelLayout::@332 u
Details about which channels are present in this layout.
flac_deinit
static void flac_deinit(struct AVFormatContext *s)
Definition: flacenc.c:348
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
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
flac_muxer_class
static const AVClass flac_muxer_class
Definition: flacenc.c:410
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
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:281
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:121
ff_flac_muxer
const FFOutputFormat ff_flac_muxer
Definition: flacenc.c:417
ff_vorbiscomment_metadata_conv
const AVMetadataConv ff_vorbiscomment_metadata_conv[]
VorbisComment metadata conversion mapping.
Definition: vorbiscomment.c:33
FlacMuxerContext::attached_types
unsigned attached_types
Definition: flacenc.c:51
FlacMuxerContext::updated_streaminfo
int updated_streaminfo
Definition: flacenc.c:49
AV_CODEC_ID_PNG
@ AV_CODEC_ID_PNG
Definition: codec_id.h:113
flac_write_packet
static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
Definition: flacenc.c:357
AVFormatContext
Format I/O context.
Definition: avformat.h:1115
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:864
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
flac_write_picture
static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt)
Definition: flacenc.c:82
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:921
FLAC_STREAMINFO_SIZE
#define FLAC_STREAMINFO_SIZE
Definition: flac.h:32
FFOutputFormat
Definition: mux.h:32
flac_write_block_padding
static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes, int last_block)
Definition: flacenc.c:54
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:226
ffio_fill
void ffio_fill(AVIOContext *s, int b, int64_t count)
Definition: aviobuf.c:234
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:206
ff_id3v2_picture_types
const char *const ff_id3v2_picture_types[21]
Definition: id3v2.c:108
ff_vorbiscomment_length
int64_t ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters)
Calculate the length in bytes of a VorbisComment.
Definition: vorbiscomment.c:41
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ff_id3v2_mime_tags
const CodecMime ff_id3v2_mime_tags[]
Definition: id3v2.c:132
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:902
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:73
FlacMuxerContext::write_header
int write_header
Definition: flacenc.c:40
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
AVPacket::size
int size
Definition: packet.h:492
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
AVIOContext::seekable
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:271
avpriv_packet_list_free
void avpriv_packet_list_free(PacketList *pkt_buf)
Wipe the list and unref all the packets in it.
Definition: avpacket.c:590
flac_write_block_comment
static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m, int last_block, int bitexact)
Definition: flacenc.c:63
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:248
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:412
flac_queue_flush
static int flac_queue_flush(AVFormatContext *s)
Definition: flacenc.c:301
AV_CHANNEL_ORDER_NATIVE
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
Definition: channel_layout.h:118
AV_CODEC_ID_GIF
@ AV_CODEC_ID_GIF
Definition: codec_id.h:149
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
avio_internal.h
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Definition: avpacket.c:252
AVCodecParameters::height
int height
Definition: codec_par.h:122
FlacMuxerContext::streaminfo
uint8_t streaminfo[FLAC_STREAMINFO_SIZE]
Definition: flacenc.c:48
flacenc_options
static const AVOption flacenc_options[]
Definition: flacenc.c:405
len
int len
Definition: vorbis_enc_data.h:426
FlacMuxerContext::audio_stream_idx
int audio_stream_idx
Definition: flacenc.c:42
version.h
AVStream::disposition
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
Definition: avformat.h:910
AVFMT_FLAG_BITEXACT
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1250
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:841
FlacMuxerContext::waiting_pics
int waiting_pics
Definition: flacenc.c:43
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:278
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
avformat.h
FlacMuxerContext
Definition: flacenc.c:38
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:847
channel_layout.h
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:41
ff_flac_write_header
int ff_flac_write_header(AVIOContext *pb, const uint8_t *extradata, int extradata_size, int last_block)
Definition: flacenc_header.c:29
AVPacket::stream_index
int stream_index
Definition: packet.h:493
CodecMime::str
char str[32]
Definition: internal.h:54
CodecMime::id
enum AVCodecID id
Definition: internal.h:55
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
packet_internal.h
FFFormatContext::pkt
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
Definition: internal.h:140
AVCodecParameters::format
int format
Definition: codec_par.h:79
flac_write_trailer
static int flac_write_trailer(struct AVFormatContext *s)
Definition: flacenc.c:320
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
avio_wb24
void avio_wb24(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:502
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:468
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
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
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVDictionaryEntry::value
char * value
Definition: dict.h:91
avstring.h
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:346
flac.h
snprintf
#define snprintf
Definition: snprintf.h:34
av_packet_clone
AVPacket * av_packet_clone(const AVPacket *src)
Create a new packet that references the same data as src.
Definition: avpacket.c:467
mux.h