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 = abs(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  AVCodecContext *enc = s->streams[i]->codec;
189  if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
190  if (swf->audio_enc) {
191  av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 audio stream\n");
192  return AVERROR_INVALIDDATA;
193  }
194  if (enc->codec_id == AV_CODEC_ID_MP3) {
195  if (!enc->frame_size) {
196  av_log(s, AV_LOG_ERROR, "audio frame size not set\n");
197  return -1;
198  }
199  swf->audio_enc = enc;
201  if (!swf->audio_fifo)
202  return AVERROR(ENOMEM);
203  } else {
204  av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
205  return -1;
206  }
207  } else {
208  if (swf->video_enc) {
209  av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 video stream\n");
210  return AVERROR_INVALIDDATA;
211  }
212  if (enc->codec_id == AV_CODEC_ID_VP6F ||
213  enc->codec_id == AV_CODEC_ID_FLV1 ||
214  enc->codec_id == AV_CODEC_ID_MJPEG) {
215  swf->video_enc = enc;
216  } else {
217  av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV1 and MJPEG\n");
218  return -1;
219  }
220  }
221  }
222 
223  if (!swf->video_enc) {
224  /* currently, cannot work correctly if audio only */
225  width = 320;
226  height = 200;
227  rate = 10;
228  rate_base= 1;
229  } else {
230  width = swf->video_enc->width;
231  height = swf->video_enc->height;
232  rate = swf->video_enc->time_base.den;
233  rate_base = swf->video_enc->time_base.num;
234  }
235 
236  if (!swf->audio_enc)
237  swf->samples_per_frame = (44100. * rate_base) / rate;
238  else
239  swf->samples_per_frame = (swf->audio_enc->sample_rate * rate_base) / rate;
240 
241  avio_write(pb, "FWS", 3);
242 
243  if (!strcmp("avm2", s->oformat->name))
244  version = 9;
245  else if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_VP6F)
246  version = 8; /* version 8 and above support VP6 codec */
247  else if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_FLV1)
248  version = 6; /* version 6 and above support FLV1 codec */
249  else
250  version = 4; /* version 4 for mpeg audio support */
251  avio_w8(pb, version);
252 
253  avio_wl32(pb, DUMMY_FILE_SIZE); /* dummy size
254  (will be patched if not streamed) */
255 
256  put_swf_rect(pb, 0, width * 20, 0, height * 20);
257  avio_wl16(pb, (rate * 256) / rate_base); /* frame rate */
258  swf->duration_pos = avio_tell(pb);
259  avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
260 
261  /* avm2/swf v9 (also v8?) files require a file attribute tag */
262  if (version == 9) {
264  avio_wl32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
265  put_swf_end_tag(s);
266  }
267 
268  /* define a shape with the jpeg inside */
269  if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_MJPEG) {
271 
272  avio_wl16(pb, SHAPE_ID); /* ID of shape */
273  /* bounding rectangle */
274  put_swf_rect(pb, 0, width, 0, height);
275  /* style info */
276  avio_w8(pb, 1); /* one fill style */
277  avio_w8(pb, 0x41); /* clipped bitmap fill */
278  avio_wl16(pb, BITMAP_ID); /* bitmap ID */
279  /* position of the bitmap */
280  put_swf_matrix(pb, (int)(1.0 * (1 << FRAC_BITS)), 0,
281  0, (int)(1.0 * (1 << FRAC_BITS)), 0, 0);
282  avio_w8(pb, 0); /* no line style */
283 
284  /* shape drawing */
285  init_put_bits(&p, buf1, sizeof(buf1));
286  put_bits(&p, 4, 1); /* one fill bit */
287  put_bits(&p, 4, 0); /* zero line bit */
288 
289  put_bits(&p, 1, 0); /* not an edge */
291  put_bits(&p, 5, 1); /* nbits */
292  put_bits(&p, 1, 0); /* X */
293  put_bits(&p, 1, 0); /* Y */
294  put_bits(&p, 1, 1); /* set fill style 1 */
295 
296  /* draw the rectangle ! */
297  put_swf_line_edge(&p, width, 0);
298  put_swf_line_edge(&p, 0, height);
299  put_swf_line_edge(&p, -width, 0);
300  put_swf_line_edge(&p, 0, -height);
301 
302  /* end of shape */
303  put_bits(&p, 1, 0); /* not an edge */
304  put_bits(&p, 5, 0);
305 
306  flush_put_bits(&p);
307  avio_write(pb, buf1, put_bits_ptr(&p) - p.buf);
308 
309  put_swf_end_tag(s);
310  }
311 
312  if (swf->audio_enc && swf->audio_enc->codec_id == AV_CODEC_ID_MP3) {
313  int v = 0;
314 
315  /* start sound */
317  switch(swf->audio_enc->sample_rate) {
318  case 11025: v |= 1 << 2; break;
319  case 22050: v |= 2 << 2; break;
320  case 44100: v |= 3 << 2; break;
321  default:
322  /* not supported */
323  av_log(s, AV_LOG_ERROR, "swf does not support that sample rate, choose from (44100, 22050, 11025).\n");
324  return -1;
325  }
326  v |= 0x02; /* 16 bit playback */
327  if (swf->audio_enc->channels == 2)
328  v |= 0x01; /* stereo playback */
329  avio_w8(s->pb, v);
330  v |= 0x20; /* mp3 compressed */
331  avio_w8(s->pb, v);
332  avio_wl16(s->pb, swf->samples_per_frame); /* avg samples per frame */
333  avio_wl16(s->pb, 0);
334 
335  put_swf_end_tag(s);
336  }
337 
338  avio_flush(s->pb);
339  return 0;
340 }
341 
343  AVCodecContext *enc, const uint8_t *buf, int size)
344 {
345  SWFContext *swf = s->priv_data;
346  AVIOContext *pb = s->pb;
347 
348  /* Flash Player limit */
349  if (swf->swf_frame_number == 16000)
350  av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
351 
352  if (enc->codec_id == AV_CODEC_ID_VP6F ||
353  enc->codec_id == AV_CODEC_ID_FLV1) {
354  if (swf->video_frame_number == 0) {
355  /* create a new video object */
357  avio_wl16(pb, VIDEO_ID);
358  swf->vframes_pos = avio_tell(pb);
359  avio_wl16(pb, 15000); /* hard flash player limit */
360  avio_wl16(pb, enc->width);
361  avio_wl16(pb, enc->height);
362  avio_w8(pb, 0);
364  put_swf_end_tag(s);
365 
366  /* place the video object for the first time */
368  avio_w8(pb, 0x36);
369  avio_wl16(pb, 1);
370  avio_wl16(pb, VIDEO_ID);
371  put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
372  avio_wl16(pb, swf->video_frame_number);
373  avio_write(pb, "video", 5);
374  avio_w8(pb, 0x00);
375  put_swf_end_tag(s);
376  } else {
377  /* mark the character for update */
379  avio_w8(pb, 0x11);
380  avio_wl16(pb, 1);
381  avio_wl16(pb, swf->video_frame_number);
382  put_swf_end_tag(s);
383  }
384 
385  /* set video frame data */
387  avio_wl16(pb, VIDEO_ID);
388  avio_wl16(pb, swf->video_frame_number++);
389  avio_write(pb, buf, size);
390  put_swf_end_tag(s);
391  } else if (enc->codec_id == AV_CODEC_ID_MJPEG) {
392  if (swf->swf_frame_number > 0) {
393  /* remove the shape */
395  avio_wl16(pb, SHAPE_ID); /* shape ID */
396  avio_wl16(pb, 1); /* depth */
397  put_swf_end_tag(s);
398 
399  /* free the bitmap */
401  avio_wl16(pb, BITMAP_ID);
402  put_swf_end_tag(s);
403  }
404 
406 
407  avio_wl16(pb, BITMAP_ID); /* ID of the image */
408 
409  /* a dummy jpeg header seems to be required */
410  avio_wb32(pb, 0xffd8ffd9);
411  /* write the jpeg image */
412  avio_write(pb, buf, size);
413 
414  put_swf_end_tag(s);
415 
416  /* draw the shape */
417 
419  avio_wl16(pb, SHAPE_ID); /* shape ID */
420  avio_wl16(pb, 1); /* depth */
421  put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0);
422  put_swf_end_tag(s);
423  }
424 
425  swf->swf_frame_number++;
426 
427  /* streaming sound always should be placed just before showframe tags */
428  if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
429  int frame_size = av_fifo_size(swf->audio_fifo);
431  avio_wl16(pb, swf->sound_samples);
432  avio_wl16(pb, 0); // seek samples
433  av_fifo_generic_read(swf->audio_fifo, pb, frame_size, (void*)avio_write);
434  put_swf_end_tag(s);
435 
436  /* update FIFO */
437  swf->sound_samples = 0;
438  }
439 
440  /* output the frame */
442  put_swf_end_tag(s);
443 
444  return 0;
445 }
446 
448  AVCodecContext *enc, uint8_t *buf, int size)
449 {
450  SWFContext *swf = s->priv_data;
451 
452  /* Flash Player limit */
453  if (swf->swf_frame_number == 16000)
454  av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
455 
456  if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
457  av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
458  return -1;
459  }
460 
461  av_fifo_generic_write(swf->audio_fifo, buf, size, NULL);
462  swf->sound_samples += enc->frame_size;
463 
464  /* if audio only stream make sure we add swf frames */
465  if (!swf->video_enc)
466  swf_write_video(s, enc, 0, 0);
467 
468  return 0;
469 }
470 
472 {
473  AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
474  if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
475  return swf_write_audio(s, codec, pkt->data, pkt->size);
476  else
477  return swf_write_video(s, codec, pkt->data, pkt->size);
478 }
479 
481 {
482  SWFContext *swf = s->priv_data;
483  AVIOContext *pb = s->pb;
484  AVCodecContext *enc, *video_enc;
485  int file_size, i;
486 
487  video_enc = NULL;
488  for(i=0;i<s->nb_streams;i++) {
489  enc = s->streams[i]->codec;
490  if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
491  video_enc = enc;
492  else {
493  av_fifo_free(swf->audio_fifo);
494  swf->audio_fifo = NULL;
495  }
496  }
497 
498  put_swf_tag(s, TAG_END);
499  put_swf_end_tag(s);
500 
501  /* patch file size and number of frames if not streamed */
502  if (s->pb->seekable && video_enc) {
503  file_size = avio_tell(pb);
504  avio_seek(pb, 4, SEEK_SET);
505  avio_wl32(pb, file_size);
506  avio_seek(pb, swf->duration_pos, SEEK_SET);
507  avio_wl16(pb, swf->video_frame_number);
508  if (swf->vframes_pos) {
509  avio_seek(pb, swf->vframes_pos, SEEK_SET);
510  avio_wl16(pb, swf->video_frame_number);
511  }
512  avio_seek(pb, file_size, SEEK_SET);
513  }
514  return 0;
515 }
516 
517 #if CONFIG_SWF_MUXER
518 AVOutputFormat ff_swf_muxer = {
519  .name = "swf",
520  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash)"),
521  .mime_type = "application/x-shockwave-flash",
522  .extensions = "swf",
523  .priv_data_size = sizeof(SWFContext),
524  .audio_codec = AV_CODEC_ID_MP3,
525  .video_codec = AV_CODEC_ID_FLV1,
530 };
531 #endif
532 #if CONFIG_AVM2_MUXER
533 AVOutputFormat ff_avm2_muxer = {
534  .name = "avm2",
535  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash) (AVM2)"),
536  .mime_type = "application/x-shockwave-flash",
537  .priv_data_size = sizeof(SWFContext),
538  .audio_codec = AV_CODEC_ID_MP3,
539  .video_codec = AV_CODEC_ID_FLV1,
544 };
545 #endif
#define SHAPE_ID
Definition: swf.h:121
const AVCodecTag ff_swf_codec_tags[]
Definition: swf.c:25
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:367
Definition: swf.h:42
float v
const char * s
Definition: avisynth_c.h:668
Bytestream IO Context.
Definition: avio.h:68
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define VIDEO_ID
Definition: mpeg.h:42
static int write_packet(AVFormatContext *s, AVPacket *pkt)
int num
numerator
Definition: rational.h:44
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:199
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
int version
Definition: avisynth_c.h:666
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:363
#define DUMMY_DURATION
Definition: swf.h:39
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.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
set threshold d
Format I/O context.
Definition: avformat.h:944
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:291
uint8_t
static AVPacket pkt
Definition: demuxing.c:56
#define b
Definition: input.c:42
AVStream ** streams
Definition: avformat.h:992
static void put_swf_rect(AVIOContext *pb, int xmin, int xmax, int ymin, int ymax)
Definition: swfenc.c:82
uint8_t * data
#define BITMAP_ID
Definition: swf.h:119
uint32_t tag
Definition: movenc.c:894
int swf_frame_number
Definition: swf.h:132
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:248
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:173
static int write_trailer(AVFormatContext *s)
static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
Definition: swfenc.c:109
struct AVOutputFormat * oformat
Definition: avformat.h:958
static const uint8_t frame_size[4]
Definition: g723_1_data.h:58
static int swf_write_video(AVFormatContext *s, AVCodecContext *enc, const uint8_t *buf, int size)
Definition: swfenc.c:342
Definition: swf.h:62
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:199
int video_frame_number
Definition: swf.h:133
static const uint16_t mask[17]
Definition: lzw.c:37
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
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.
preferred ID for decoding MPEG audio layer 1, 2 or 3
uint8_t * buf
Definition: put_bits.h:44
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
static void put_bits(J2kEncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:160
int sound_samples
Definition: swf.h:131
int size
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:662
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:991
int samples_per_frame
Definition: swf.h:130
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:117
int void avio_flush(AVIOContext *s)
Force flushing of buffered data to the output s.
Definition: aviobuf.c:193
struct SWFContext SWFContext
static void put_swf_tag(AVFormatContext *s, int tag)
Definition: swfenc.c:28
static void max_nbits(int *nbits_ptr, int val)
Definition: swfenc.c:66
static int swf_write_audio(AVFormatContext *s, AVCodecContext *enc, uint8_t *buf, int size)
Definition: swfenc.c:447
int width
picture width / height.
#define DUMMY_FILE_SIZE
Definition: swf.h:38
#define FLAG_SETFILL0
Definition: swf.h:113
const char * name
Definition: avformat.h:378
AVCodecContext * audio_enc
Definition: swf.h:137
static int swf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: swfenc.c:471
int frame_size
Number of samples per channel in an audio frame.
NULL
Definition: eval.c:55
static int width
Definition: tests/utils.c:158
static int swf_write_header(AVFormatContext *s)
Definition: swfenc.c:174
enum AVMediaType codec_type
enum AVCodecID codec_id
int sample_rate
samples per second
AVIOContext * pb
I/O context.
Definition: avformat.h:977
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:151
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
void * buf
Definition: avisynth_c.h:594
BYTE int const BYTE int int int height
Definition: avisynth_c.h:713
synthesis window for stochastic i
AVCodecContext * video_enc
Definition: swf.h:137
#define FRAC_BITS
Definition: swfenc.c:136
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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.Buffer references ownership and permissions
int64_t vframes_pos
Definition: swf.h:129
static int flags
Definition: cpu.c:23
#define TAG_LONG
Definition: swf.h:109
Main libavformat public API header.
int av_fifo_size(AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
static void put_swf_end_tag(AVFormatContext *s)
Definition: swfenc.c:44
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:81
static double c[64]
int64_t tag_pos
Definition: swf.h:128
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:54
int den
denominator
Definition: rational.h:45
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
int channels
number of audio channels
void * priv_data
Format private data.
Definition: avformat.h:964
#define AUDIO_FIFO_SIZE
Definition: swf.h:116
int tag
Definition: swf.h:135
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:470
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:299
#define AV_LOG_INFO
Definition: log.h:156
AVFifoBuffer * audio_fifo
Definition: swf.h:136
static int swf_write_trailer(AVFormatContext *s)
Definition: swfenc.c:480
int64_t duration_pos
Definition: swf.h:127
static void put_swf_matrix(AVIOContext *pb, int a, int b, int c, int d, int tx, int ty)
Definition: swfenc.c:138
This structure stores compressed data.
#define FLAG_MOVETO
Definition: swf.h:112
bitstream writer API