FFmpeg
swfenc.c
Go to the documentation of this file.
1 /*
2  * Flash Compatible Streaming Format muxer
3  * Copyright (c) 2000 Fabrice Bellard
4  * Copyright (c) 2003 Tinic Uro
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "libavcodec/put_bits.h"
24 #include "libavutil/avassert.h"
25 #include "avformat.h"
26 #include "swf.h"
27 
28 static void put_swf_tag(AVFormatContext *s, int tag)
29 {
30  SWFContext *swf = s->priv_data;
31  AVIOContext *pb = s->pb;
32 
33  swf->tag_pos = avio_tell(pb);
34  swf->tag = tag;
35  /* reserve some room for the tag */
36  if (tag & TAG_LONG) {
37  avio_wl16(pb, 0);
38  avio_wl32(pb, 0);
39  } else {
40  avio_wl16(pb, 0);
41  }
42 }
43 
45 {
46  SWFContext *swf = s->priv_data;
47  AVIOContext *pb = s->pb;
48  int64_t pos;
49  int tag_len, tag;
50 
51  pos = avio_tell(pb);
52  tag_len = pos - swf->tag_pos - 2;
53  tag = swf->tag;
54  avio_seek(pb, swf->tag_pos, SEEK_SET);
55  if (tag & TAG_LONG) {
56  tag &= ~TAG_LONG;
57  avio_wl16(pb, (tag << 6) | 0x3f);
58  avio_wl32(pb, tag_len - 4);
59  } else {
60  av_assert0(tag_len < 0x3f);
61  avio_wl16(pb, (tag << 6) | tag_len);
62  }
63  avio_seek(pb, pos, SEEK_SET);
64 }
65 
66 static inline void max_nbits(int *nbits_ptr, int val)
67 {
68  int n;
69 
70  if (val == 0)
71  return;
72  val = FFABS(val);
73  n = 1;
74  while (val != 0) {
75  n++;
76  val >>= 1;
77  }
78  if (n > *nbits_ptr)
79  *nbits_ptr = n;
80 }
81 
82 static void put_swf_rect(AVIOContext *pb,
83  int xmin, int xmax, int ymin, int ymax)
84 {
85  PutBitContext p;
86  uint8_t buf[256];
87  int nbits, mask;
88 
89  init_put_bits(&p, buf, sizeof(buf));
90 
91  nbits = 0;
92  max_nbits(&nbits, xmin);
93  max_nbits(&nbits, xmax);
94  max_nbits(&nbits, ymin);
95  max_nbits(&nbits, ymax);
96  mask = (1 << nbits) - 1;
97 
98  /* rectangle info */
99  put_bits(&p, 5, nbits);
100  put_bits(&p, nbits, xmin & mask);
101  put_bits(&p, nbits, xmax & mask);
102  put_bits(&p, nbits, ymin & mask);
103  put_bits(&p, nbits, ymax & mask);
104 
105  flush_put_bits(&p);
106  avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
107 }
108 
109 static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
110 {
111  int nbits, mask;
112 
113  put_bits(pb, 1, 1); /* edge */
114  put_bits(pb, 1, 1); /* line select */
115  nbits = 2;
116  max_nbits(&nbits, dx);
117  max_nbits(&nbits, dy);
118 
119  mask = (1 << nbits) - 1;
120  put_bits(pb, 4, nbits - 2); /* 16 bits precision */
121  if (dx == 0) {
122  put_bits(pb, 1, 0);
123  put_bits(pb, 1, 1);
124  put_bits(pb, nbits, dy & mask);
125  } else if (dy == 0) {
126  put_bits(pb, 1, 0);
127  put_bits(pb, 1, 0);
128  put_bits(pb, nbits, dx & mask);
129  } else {
130  put_bits(pb, 1, 1);
131  put_bits(pb, nbits, dx & mask);
132  put_bits(pb, nbits, dy & mask);
133  }
134 }
135 
136 #define FRAC_BITS 16
137 
138 static void put_swf_matrix(AVIOContext *pb,
139  int a, int b, int c, int d, int tx, int ty)
140 {
141  PutBitContext p;
142  uint8_t buf[256];
143  int nbits;
144 
145  init_put_bits(&p, buf, sizeof(buf));
146 
147  put_bits(&p, 1, 1); /* a, d present */
148  nbits = 1;
149  max_nbits(&nbits, a);
150  max_nbits(&nbits, d);
151  put_bits(&p, 5, nbits); /* nb bits */
152  put_bits(&p, nbits, a);
153  put_bits(&p, nbits, d);
154 
155  put_bits(&p, 1, 1); /* b, c present */
156  nbits = 1;
157  max_nbits(&nbits, c);
158  max_nbits(&nbits, b);
159  put_bits(&p, 5, nbits); /* nb bits */
160  put_bits(&p, nbits, c);
161  put_bits(&p, nbits, b);
162 
163  nbits = 1;
164  max_nbits(&nbits, tx);
165  max_nbits(&nbits, ty);
166  put_bits(&p, 5, nbits); /* nb bits */
167  put_bits(&p, nbits, tx);
168  put_bits(&p, nbits, ty);
169 
170  flush_put_bits(&p);
171  avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
172 }
173 
175 {
176  SWFContext *swf = s->priv_data;
177  AVIOContext *pb = s->pb;
178  PutBitContext p;
179  uint8_t buf1[256];
180  int i, width, height, rate, rate_base;
181  int version;
182 
183  swf->sound_samples = 0;
184  swf->swf_frame_number = 0;
185  swf->video_frame_number = 0;
186 
187  for(i=0;i<s->nb_streams;i++) {
188  AVCodecParameters *par = s->streams[i]->codecpar;
189  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
190  if (swf->audio_par) {
191  av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 audio stream\n");
192  return AVERROR_INVALIDDATA;
193  }
194  if (par->codec_id == AV_CODEC_ID_MP3) {
195  swf->audio_par = par;
197  if (!swf->audio_fifo)
198  return AVERROR(ENOMEM);
199  } else {
200  av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
201  return -1;
202  }
203  } else {
204  if (swf->video_par) {
205  av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 video stream\n");
206  return AVERROR_INVALIDDATA;
207  }
208  if (par->codec_id == AV_CODEC_ID_VP6F ||
209  par->codec_id == AV_CODEC_ID_FLV1 ||
210  par->codec_id == AV_CODEC_ID_MJPEG) {
211  swf->video_st = s->streams[i];
212  swf->video_par = par;
213  } else {
214  av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV1 and MJPEG\n");
215  return -1;
216  }
217  }
218  }
219 
220  if (!swf->video_par) {
221  /* currently, cannot work correctly if audio only */
222  width = 320;
223  height = 200;
224  rate = 10;
225  rate_base= 1;
226  } else {
227  width = swf->video_par->width;
228  height = swf->video_par->height;
229  // TODO: should be avg_frame_rate
230  rate = swf->video_st->time_base.den;
231  rate_base = swf->video_st->time_base.num;
232  }
233 
234  if (!swf->audio_par)
235  swf->samples_per_frame = (44100LL * rate_base) / rate;
236  else
237  swf->samples_per_frame = (swf->audio_par->sample_rate * rate_base) / rate;
238 
239  avio_write(pb, "FWS", 3);
240 
241  if (!strcmp("avm2", s->oformat->name))
242  version = 9;
243  else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_VP6F)
244  version = 8; /* version 8 and above support VP6 codec */
245  else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_FLV1)
246  version = 6; /* version 6 and above support FLV1 codec */
247  else
248  version = 4; /* version 4 for mpeg audio support */
249  avio_w8(pb, version);
250 
251  avio_wl32(pb, DUMMY_FILE_SIZE); /* dummy size
252  (will be patched if not streamed) */
253 
254  put_swf_rect(pb, 0, width * 20, 0, height * 20);
255  if ((rate * 256LL) / rate_base >= (1<<16)) {
256  av_log(s, AV_LOG_ERROR, "Invalid (too large) frame rate %d/%d\n", rate, rate_base);
257  return AVERROR(EINVAL);
258  }
259  avio_wl16(pb, (rate * 256LL) / rate_base); /* frame rate */
260  swf->duration_pos = avio_tell(pb);
261  avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
262 
263  /* avm2/swf v9 (also v8?) files require a file attribute tag */
264  if (version == 9) {
266  avio_wl32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
268  }
269 
270  /* define a shape with the jpeg inside */
271  if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_MJPEG) {
273 
274  avio_wl16(pb, SHAPE_ID); /* ID of shape */
275  /* bounding rectangle */
276  put_swf_rect(pb, 0, width, 0, height);
277  /* style info */
278  avio_w8(pb, 1); /* one fill style */
279  avio_w8(pb, 0x41); /* clipped bitmap fill */
280  avio_wl16(pb, BITMAP_ID); /* bitmap ID */
281  /* position of the bitmap */
282  put_swf_matrix(pb, 1 << FRAC_BITS, 0,
283  0, 1 << FRAC_BITS, 0, 0);
284  avio_w8(pb, 0); /* no line style */
285 
286  /* shape drawing */
287  init_put_bits(&p, buf1, sizeof(buf1));
288  put_bits(&p, 4, 1); /* one fill bit */
289  put_bits(&p, 4, 0); /* zero line bit */
290 
291  put_bits(&p, 1, 0); /* not an edge */
293  put_bits(&p, 5, 1); /* nbits */
294  put_bits(&p, 1, 0); /* X */
295  put_bits(&p, 1, 0); /* Y */
296  put_bits(&p, 1, 1); /* set fill style 1 */
297 
298  /* draw the rectangle ! */
299  put_swf_line_edge(&p, width, 0);
300  put_swf_line_edge(&p, 0, height);
301  put_swf_line_edge(&p, -width, 0);
302  put_swf_line_edge(&p, 0, -height);
303 
304  /* end of shape */
305  put_bits(&p, 1, 0); /* not an edge */
306  put_bits(&p, 5, 0);
307 
308  flush_put_bits(&p);
309  avio_write(pb, buf1, put_bits_ptr(&p) - p.buf);
310 
312  }
313 
314  if (swf->audio_par && swf->audio_par->codec_id == AV_CODEC_ID_MP3) {
315  int v = 0;
316 
317  /* start sound */
319  switch(swf->audio_par->sample_rate) {
320  case 11025: v |= 1 << 2; break;
321  case 22050: v |= 2 << 2; break;
322  case 44100: v |= 3 << 2; break;
323  default:
324  /* not supported */
325  av_log(s, AV_LOG_ERROR, "swf does not support that sample rate, choose from (44100, 22050, 11025).\n");
326  return -1;
327  }
328  v |= 0x02; /* 16 bit playback */
329  if (swf->audio_par->channels == 2)
330  v |= 0x01; /* stereo playback */
331  avio_w8(s->pb, v);
332  v |= 0x20; /* mp3 compressed */
333  avio_w8(s->pb, v);
334  avio_wl16(s->pb, swf->samples_per_frame); /* avg samples per frame */
335  avio_wl16(s->pb, 0);
336 
338  }
339 
340  return 0;
341 }
342 
344  AVCodecParameters *par, const uint8_t *buf, int size)
345 {
346  SWFContext *swf = s->priv_data;
347  AVIOContext *pb = s->pb;
348 
349  /* Flash Player limit */
350  if (swf->swf_frame_number == 16000)
351  av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
352 
353  if (par->codec_id == AV_CODEC_ID_VP6F ||
354  par->codec_id == AV_CODEC_ID_FLV1) {
355  if (swf->video_frame_number == 0) {
356  /* create a new video object */
358  avio_wl16(pb, VIDEO_ID);
359  swf->vframes_pos = avio_tell(pb);
360  avio_wl16(pb, 15000); /* hard flash player limit */
361  avio_wl16(pb, par->width);
362  avio_wl16(pb, par->height);
363  avio_w8(pb, 0);
366 
367  /* place the video object for the first time */
369  avio_w8(pb, 0x36);
370  avio_wl16(pb, 1);
371  avio_wl16(pb, VIDEO_ID);
372  put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
373  avio_wl16(pb, swf->video_frame_number);
374  avio_write(pb, "video", 5);
375  avio_w8(pb, 0x00);
377  } else {
378  /* mark the character for update */
380  avio_w8(pb, 0x11);
381  avio_wl16(pb, 1);
382  avio_wl16(pb, swf->video_frame_number);
384  }
385 
386  /* set video frame data */
388  avio_wl16(pb, VIDEO_ID);
389  avio_wl16(pb, swf->video_frame_number++);
390  avio_write(pb, buf, size);
392  } else if (par->codec_id == AV_CODEC_ID_MJPEG) {
393  if (swf->swf_frame_number > 0) {
394  /* remove the shape */
396  avio_wl16(pb, SHAPE_ID); /* shape ID */
397  avio_wl16(pb, 1); /* depth */
399 
400  /* free the bitmap */
402  avio_wl16(pb, BITMAP_ID);
404  }
405 
407 
408  avio_wl16(pb, BITMAP_ID); /* ID of the image */
409 
410  /* a dummy jpeg header seems to be required */
411  avio_wb32(pb, 0xffd8ffd9);
412  /* write the jpeg image */
413  avio_write(pb, buf, size);
414 
416 
417  /* draw the shape */
418 
420  avio_wl16(pb, SHAPE_ID); /* shape ID */
421  avio_wl16(pb, 1); /* depth */
422  put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0);
424  }
425 
426  swf->swf_frame_number++;
427 
428  /* streaming sound always should be placed just before showframe tags */
429  if (swf->audio_par && av_fifo_size(swf->audio_fifo)) {
430  int frame_size = av_fifo_size(swf->audio_fifo);
432  avio_wl16(pb, swf->sound_samples);
433  avio_wl16(pb, 0); // seek samples
436 
437  /* update FIFO */
438  swf->sound_samples = 0;
439  }
440 
441  /* output the frame */
444 
445  return 0;
446 }
447 
449  AVCodecParameters *par, uint8_t *buf, int size)
450 {
451  SWFContext *swf = s->priv_data;
452 
453  /* Flash Player limit */
454  if (swf->swf_frame_number == 16000)
455  av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
456 
458  av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
459  return -1;
460  }
461 
464 
465  /* if audio only stream make sure we add swf frames */
466  if (!swf->video_par)
467  swf_write_video(s, par, 0, 0);
468 
469  return 0;
470 }
471 
473 {
474  AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
475  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
476  return swf_write_audio(s, par, pkt->data, pkt->size);
477  else
478  return swf_write_video(s, par, pkt->data, pkt->size);
479 }
480 
482 {
483  SWFContext *swf = s->priv_data;
484  AVIOContext *pb = s->pb;
485  int file_size;
486 
489 
490  /* patch file size and number of frames if not streamed */
491  if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && swf->video_par) {
492  file_size = avio_tell(pb);
493  avio_seek(pb, 4, SEEK_SET);
494  avio_wl32(pb, file_size);
495  avio_seek(pb, swf->duration_pos, SEEK_SET);
496  avio_wl16(pb, swf->video_frame_number);
497  if (swf->vframes_pos) {
498  avio_seek(pb, swf->vframes_pos, SEEK_SET);
499  avio_wl16(pb, swf->video_frame_number);
500  }
501  avio_seek(pb, file_size, SEEK_SET);
502  }
503  return 0;
504 }
505 
507 {
508  SWFContext *swf = s->priv_data;
509 
510  av_fifo_freep(&swf->audio_fifo);
511 }
512 
513 #if CONFIG_SWF_MUXER
515  .name = "swf",
516  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash)"),
517  .mime_type = "application/x-shockwave-flash",
518  .extensions = "swf",
519  .priv_data_size = sizeof(SWFContext),
520  .audio_codec = AV_CODEC_ID_MP3,
521  .video_codec = AV_CODEC_ID_FLV1,
525  .deinit = swf_deinit,
527 };
528 #endif
529 #if CONFIG_AVM2_MUXER
531  .name = "avm2",
532  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash) (AVM2)"),
533  .mime_type = "application/x-shockwave-flash",
534  .priv_data_size = sizeof(SWFContext),
535  .audio_codec = AV_CODEC_ID_MP3,
536  .video_codec = AV_CODEC_ID_FLV1,
540  .deinit = swf_deinit,
542 };
543 #endif
SWFContext::video_frame_number
int video_frame_number
Definition: swf.h:130
AV_CODEC_ID_VP6F
@ AV_CODEC_ID_VP6F
Definition: codec_id.h:141
AVOutputFormat::name
const char * name
Definition: avformat.h:491
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
SWFContext
Definition: swf.h:123
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
max_nbits
static void max_nbits(int *nbits_ptr, int val)
Definition: swfenc.c:66
TAG_END
@ TAG_END
Definition: swf.h:42
av_fifo_generic_write
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
Definition: fifo.c:122
swf_write_audio
static int swf_write_audio(AVFormatContext *s, AVCodecParameters *par, uint8_t *buf, int size)
Definition: swfenc.c:448
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
swf_write_header
static int swf_write_header(AVFormatContext *s)
Definition: swfenc.c:174
put_swf_end_tag
static void put_swf_end_tag(AVFormatContext *s)
Definition: swfenc.c:44
SWFContext::duration_pos
int64_t duration_pos
Definition: swf.h:124
SWFContext::sound_samples
int sound_samples
Definition: swf.h:128
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:48
SWFContext::video_par
AVCodecParameters * video_par
Definition: swf.h:134
DUMMY_FILE_SIZE
#define DUMMY_FILE_SIZE
Definition: swf.h:38
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
AVPacket::data
uint8_t * data
Definition: packet.h:355
b
#define b
Definition: input.c:41
TAG_DEFINESHAPE
@ TAG_DEFINESHAPE
Definition: swf.h:44
av_fifo_generic_read
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
Definition: fifo.c:213
swf_deinit
static void swf_deinit(AVFormatContext *s)
Definition: swfenc.c:506
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:447
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
swf_write_video
static int swf_write_video(AVFormatContext *s, AVCodecParameters *par, const uint8_t *buf, int size)
Definition: swfenc.c:343
SHAPE_ID
#define SHAPE_ID
Definition: swf.h:121
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
SWFContext::vframes_pos
int64_t vframes_pos
Definition: swf.h:126
val
static double val(void *priv, double ch)
Definition: aeval.c:76
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:411
AVRational::num
int num
Numerator.
Definition: rational.h:59
FLAG_SETFILL0
#define FLAG_SETFILL0
Definition: swf.h:113
avassert.h
put_swf_matrix
static void put_swf_matrix(AVIOContext *pb, int a, int b, int c, int d, int tx, int ty)
Definition: swfenc.c:138
ff_avm2_muxer
AVOutputFormat ff_avm2_muxer
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
swf.h
mask
static const uint16_t mask[17]
Definition: lzw.c:38
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:257
ff_swf_codec_tags
const AVCodecTag ff_swf_codec_tags[]
Definition: swf.c:25
frame_size
int frame_size
Definition: mxfenc.c:2137
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
TAG_REMOVEOBJECT
@ TAG_REMOVEOBJECT
Definition: swf.h:47
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
DUMMY_DURATION
#define DUMMY_DURATION
Definition: swf.h:39
AUDIO_FIFO_SIZE
#define AUDIO_FIFO_SIZE
Definition: swf.h:116
swf_write_trailer
static int swf_write_trailer(AVFormatContext *s)
Definition: swfenc.c:481
PutBitContext
Definition: put_bits.h:35
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
AVFormatContext
Format I/O context.
Definition: avformat.h:1335
TAG_STREAMHEAD2
@ TAG_STREAMHEAD2
Definition: swf.h:76
TAG_FREECHARACTER
@ TAG_FREECHARACTER
Definition: swf.h:45
PutBitContext::buf
uint8_t * buf
Definition: put_bits.h:38
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:894
NULL
#define NULL
Definition: coverity.c:32
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:98
SWFContext::audio_par
AVCodecParameters * audio_par
Definition: swf.h:134
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:191
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
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
BITMAP_ID
#define BITMAP_ID
Definition: swf.h:119
FLAG_MOVETO
#define FLAG_MOVETO
Definition: swf.h:112
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
TAG_FILEATTRIBUTES
@ TAG_FILEATTRIBUTES
Definition: swf.h:89
AVPacket::size
int size
Definition: packet.h:356
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:188
SWFContext::video_st
AVStream * video_st
Definition: swf.h:135
SWFContext::tag
int tag
Definition: swf.h:132
size
int size
Definition: twinvq_data.h:11134
TAG_JPEG2
@ TAG_JPEG2
Definition: swf.h:62
TAG_LONG
#define TAG_LONG
Definition: swf.h:109
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:213
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:375
height
#define height
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:367
SWFContext::swf_frame_number
int swf_frame_number
Definition: swf.h:129
version
version
Definition: libkvazaar.c:292
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:702
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:56
AVOutputFormat
Definition: avformat.h:490
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
TAG_VIDEOSTREAM
@ TAG_VIDEOSTREAM
Definition: swf.h:83
TAG_PLACEOBJECT
@ TAG_PLACEOBJECT
Definition: swf.h:46
AVCodecParameters::height
int height
Definition: codec_par.h:127
uint8_t
uint8_t
Definition: audio_convert.c:194
TAG_PLACEOBJECT2
@ TAG_PLACEOBJECT2
Definition: swf.h:66
TAG_SHOWFRAME
@ TAG_SHOWFRAME
Definition: swf.h:43
swf_write_packet
static int swf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: swfenc.c:472
AVFMT_TS_NONSTRICT
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:472
tag
uint32_t tag
Definition: movenc.c:1532
put_swf_rect
static void put_swf_rect(AVIOContext *pb, int xmin, int xmax, int ymin, int ymax)
Definition: swfenc.c:82
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:241
ff_swf_muxer
AVOutputFormat ff_swf_muxer
pos
unsigned int pos
Definition: spdifenc.c:412
avformat.h
VIDEO_ID
#define VIDEO_ID
Definition: mpeg.h:42
SWFContext::samples_per_frame
int samples_per_frame
Definition: swf.h:127
put_bits_ptr
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
Definition: put_bits.h:324
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
TAG_STREAMBLOCK
@ TAG_STREAMBLOCK
Definition: swf.h:60
AVRational::den
int den
Denominator.
Definition: rational.h:60
ff_codec_get_tag
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
Definition: utils.c:3155
av_get_audio_frame_duration2
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
Definition: utils.c:1809
AVPacket::stream_index
int stream_index
Definition: packet.h:357
TAG_VIDEOFRAME
@ TAG_VIDEOFRAME
Definition: swf.h:84
av_fifo_size
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
Definition: fifo.c:77
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:101
av_fifo_freep
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
Definition: fifo.c:63
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:332
put_swf_line_edge
static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
Definition: swfenc.c:109
av_fifo_alloc
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
SWFContext::tag_pos
int64_t tag_pos
Definition: swf.h:125
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:346
AV_CODEC_ID_FLV1
@ AV_CODEC_ID_FLV1
Definition: codec_id.h:70
put_bits.h
SWFContext::audio_fifo
AVFifoBuffer * audio_fifo
Definition: swf.h:133
put_swf_tag
static void put_swf_tag(AVFormatContext *s, int tag)
Definition: swfenc.c:28
FRAC_BITS
#define FRAC_BITS
Definition: swfenc.c:136