FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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_st = s->streams[i];
216  swf->video_enc = enc;
217  } else {
218  av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV1 and MJPEG\n");
219  return -1;
220  }
221  }
222  }
223 
224  if (!swf->video_enc) {
225  /* currently, cannot work correctly if audio only */
226  width = 320;
227  height = 200;
228  rate = 10;
229  rate_base= 1;
230  } else {
231  width = swf->video_enc->width;
232  height = swf->video_enc->height;
233  // TODO: should be avg_frame_rate
234  rate = swf->video_st->time_base.den;
235  rate_base = swf->video_st->time_base.num;
236  }
237 
238  if (!swf->audio_enc)
239  swf->samples_per_frame = (44100LL * rate_base) / rate;
240  else
241  swf->samples_per_frame = (swf->audio_enc->sample_rate * rate_base) / rate;
242 
243  avio_write(pb, "FWS", 3);
244 
245  if (!strcmp("avm2", s->oformat->name))
246  version = 9;
247  else if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_VP6F)
248  version = 8; /* version 8 and above support VP6 codec */
249  else if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_FLV1)
250  version = 6; /* version 6 and above support FLV1 codec */
251  else
252  version = 4; /* version 4 for mpeg audio support */
253  avio_w8(pb, version);
254 
255  avio_wl32(pb, DUMMY_FILE_SIZE); /* dummy size
256  (will be patched if not streamed) */
257 
258  put_swf_rect(pb, 0, width * 20, 0, height * 20);
259  if ((rate * 256LL) / rate_base >= (1<<16)) {
260  av_log(s, AV_LOG_ERROR, "Invalid (too large) frame rate %d/%d\n", rate, rate_base);
261  return AVERROR(EINVAL);
262  }
263  avio_wl16(pb, (rate * 256) / rate_base); /* frame rate */
264  swf->duration_pos = avio_tell(pb);
265  avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
266 
267  /* avm2/swf v9 (also v8?) files require a file attribute tag */
268  if (version == 9) {
270  avio_wl32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
271  put_swf_end_tag(s);
272  }
273 
274  /* define a shape with the jpeg inside */
275  if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_MJPEG) {
277 
278  avio_wl16(pb, SHAPE_ID); /* ID of shape */
279  /* bounding rectangle */
280  put_swf_rect(pb, 0, width, 0, height);
281  /* style info */
282  avio_w8(pb, 1); /* one fill style */
283  avio_w8(pb, 0x41); /* clipped bitmap fill */
284  avio_wl16(pb, BITMAP_ID); /* bitmap ID */
285  /* position of the bitmap */
286  put_swf_matrix(pb, 1 << FRAC_BITS, 0,
287  0, 1 << FRAC_BITS, 0, 0);
288  avio_w8(pb, 0); /* no line style */
289 
290  /* shape drawing */
291  init_put_bits(&p, buf1, sizeof(buf1));
292  put_bits(&p, 4, 1); /* one fill bit */
293  put_bits(&p, 4, 0); /* zero line bit */
294 
295  put_bits(&p, 1, 0); /* not an edge */
297  put_bits(&p, 5, 1); /* nbits */
298  put_bits(&p, 1, 0); /* X */
299  put_bits(&p, 1, 0); /* Y */
300  put_bits(&p, 1, 1); /* set fill style 1 */
301 
302  /* draw the rectangle ! */
303  put_swf_line_edge(&p, width, 0);
304  put_swf_line_edge(&p, 0, height);
305  put_swf_line_edge(&p, -width, 0);
306  put_swf_line_edge(&p, 0, -height);
307 
308  /* end of shape */
309  put_bits(&p, 1, 0); /* not an edge */
310  put_bits(&p, 5, 0);
311 
312  flush_put_bits(&p);
313  avio_write(pb, buf1, put_bits_ptr(&p) - p.buf);
314 
315  put_swf_end_tag(s);
316  }
317 
318  if (swf->audio_enc && swf->audio_enc->codec_id == AV_CODEC_ID_MP3) {
319  int v = 0;
320 
321  /* start sound */
323  switch(swf->audio_enc->sample_rate) {
324  case 11025: v |= 1 << 2; break;
325  case 22050: v |= 2 << 2; break;
326  case 44100: v |= 3 << 2; break;
327  default:
328  /* not supported */
329  av_log(s, AV_LOG_ERROR, "swf does not support that sample rate, choose from (44100, 22050, 11025).\n");
330  return -1;
331  }
332  v |= 0x02; /* 16 bit playback */
333  if (swf->audio_enc->channels == 2)
334  v |= 0x01; /* stereo playback */
335  avio_w8(s->pb, v);
336  v |= 0x20; /* mp3 compressed */
337  avio_w8(s->pb, v);
338  avio_wl16(s->pb, swf->samples_per_frame); /* avg samples per frame */
339  avio_wl16(s->pb, 0);
340 
341  put_swf_end_tag(s);
342  }
343 
344  avio_flush(s->pb);
345  return 0;
346 }
347 
349  AVCodecContext *enc, const uint8_t *buf, int size)
350 {
351  SWFContext *swf = s->priv_data;
352  AVIOContext *pb = s->pb;
353 
354  /* Flash Player limit */
355  if (swf->swf_frame_number == 16000)
356  av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
357 
358  if (enc->codec_id == AV_CODEC_ID_VP6F ||
359  enc->codec_id == AV_CODEC_ID_FLV1) {
360  if (swf->video_frame_number == 0) {
361  /* create a new video object */
363  avio_wl16(pb, VIDEO_ID);
364  swf->vframes_pos = avio_tell(pb);
365  avio_wl16(pb, 15000); /* hard flash player limit */
366  avio_wl16(pb, enc->width);
367  avio_wl16(pb, enc->height);
368  avio_w8(pb, 0);
370  put_swf_end_tag(s);
371 
372  /* place the video object for the first time */
374  avio_w8(pb, 0x36);
375  avio_wl16(pb, 1);
376  avio_wl16(pb, VIDEO_ID);
377  put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
378  avio_wl16(pb, swf->video_frame_number);
379  avio_write(pb, "video", 5);
380  avio_w8(pb, 0x00);
381  put_swf_end_tag(s);
382  } else {
383  /* mark the character for update */
385  avio_w8(pb, 0x11);
386  avio_wl16(pb, 1);
387  avio_wl16(pb, swf->video_frame_number);
388  put_swf_end_tag(s);
389  }
390 
391  /* set video frame data */
393  avio_wl16(pb, VIDEO_ID);
394  avio_wl16(pb, swf->video_frame_number++);
395  avio_write(pb, buf, size);
396  put_swf_end_tag(s);
397  } else if (enc->codec_id == AV_CODEC_ID_MJPEG) {
398  if (swf->swf_frame_number > 0) {
399  /* remove the shape */
401  avio_wl16(pb, SHAPE_ID); /* shape ID */
402  avio_wl16(pb, 1); /* depth */
403  put_swf_end_tag(s);
404 
405  /* free the bitmap */
407  avio_wl16(pb, BITMAP_ID);
408  put_swf_end_tag(s);
409  }
410 
412 
413  avio_wl16(pb, BITMAP_ID); /* ID of the image */
414 
415  /* a dummy jpeg header seems to be required */
416  avio_wb32(pb, 0xffd8ffd9);
417  /* write the jpeg image */
418  avio_write(pb, buf, size);
419 
420  put_swf_end_tag(s);
421 
422  /* draw the shape */
423 
425  avio_wl16(pb, SHAPE_ID); /* shape ID */
426  avio_wl16(pb, 1); /* depth */
427  put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0);
428  put_swf_end_tag(s);
429  }
430 
431  swf->swf_frame_number++;
432 
433  /* streaming sound always should be placed just before showframe tags */
434  if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
435  int frame_size = av_fifo_size(swf->audio_fifo);
437  avio_wl16(pb, swf->sound_samples);
438  avio_wl16(pb, 0); // seek samples
439  av_fifo_generic_read(swf->audio_fifo, pb, frame_size, (void*)avio_write);
440  put_swf_end_tag(s);
441 
442  /* update FIFO */
443  swf->sound_samples = 0;
444  }
445 
446  /* output the frame */
448  put_swf_end_tag(s);
449 
450  return 0;
451 }
452 
454  AVCodecContext *enc, uint8_t *buf, int size)
455 {
456  SWFContext *swf = s->priv_data;
457 
458  /* Flash Player limit */
459  if (swf->swf_frame_number == 16000)
460  av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
461 
462  if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
463  av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
464  return -1;
465  }
466 
467  av_fifo_generic_write(swf->audio_fifo, buf, size, NULL);
468  swf->sound_samples += enc->frame_size;
469 
470  /* if audio only stream make sure we add swf frames */
471  if (!swf->video_enc)
472  swf_write_video(s, enc, 0, 0);
473 
474  return 0;
475 }
476 
478 {
479  AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
480  if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
481  return swf_write_audio(s, codec, pkt->data, pkt->size);
482  else
483  return swf_write_video(s, codec, pkt->data, pkt->size);
484 }
485 
487 {
488  SWFContext *swf = s->priv_data;
489  AVIOContext *pb = s->pb;
490  AVCodecContext *enc, *video_enc;
491  int file_size, i;
492 
493  video_enc = NULL;
494  for(i=0;i<s->nb_streams;i++) {
495  enc = s->streams[i]->codec;
496  if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
497  video_enc = enc;
498  else {
499  av_fifo_freep(&swf->audio_fifo);
500  }
501  }
502 
503  put_swf_tag(s, TAG_END);
504  put_swf_end_tag(s);
505 
506  /* patch file size and number of frames if not streamed */
507  if (s->pb->seekable && video_enc) {
508  file_size = avio_tell(pb);
509  avio_seek(pb, 4, SEEK_SET);
510  avio_wl32(pb, file_size);
511  avio_seek(pb, swf->duration_pos, SEEK_SET);
512  avio_wl16(pb, swf->video_frame_number);
513  if (swf->vframes_pos) {
514  avio_seek(pb, swf->vframes_pos, SEEK_SET);
515  avio_wl16(pb, swf->video_frame_number);
516  }
517  avio_seek(pb, file_size, SEEK_SET);
518  }
519  return 0;
520 }
521 
522 #if CONFIG_SWF_MUXER
523 AVOutputFormat ff_swf_muxer = {
524  .name = "swf",
525  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash)"),
526  .mime_type = "application/x-shockwave-flash",
527  .extensions = "swf",
528  .priv_data_size = sizeof(SWFContext),
529  .audio_codec = AV_CODEC_ID_MP3,
530  .video_codec = AV_CODEC_ID_FLV1,
535 };
536 #endif
537 #if CONFIG_AVM2_MUXER
538 AVOutputFormat ff_avm2_muxer = {
539  .name = "avm2",
540  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash) (AVM2)"),
541  .mime_type = "application/x-shockwave-flash",
542  .priv_data_size = sizeof(SWFContext),
543  .audio_codec = AV_CODEC_ID_MP3,
544  .video_codec = AV_CODEC_ID_FLV1,
549 };
550 #endif
#define SHAPE_ID
Definition: swf.h:121
const AVCodecTag ff_swf_codec_tags[]
Definition: swf.c:25
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:634
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:424
const char * s
Definition: avisynth_c.h:631
Bytestream IO Context.
Definition: avio.h:111
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:168
#define VIDEO_ID
Definition: mpeg.h:42
AVStream * video_st
Definition: swf.h:135
int num
numerator
Definition: rational.h:44
int size
Definition: avcodec.h:1468
const char * b
Definition: vf_curves.c:109
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:208
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
Definition: utils.c:2811
int version
Definition: avisynth_c.h:629
static AVPacket pkt
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:495
#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.
Definition: fifo.c:122
Format I/O context.
Definition: avformat.h:1314
#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:324
uint8_t
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1382
static void put_swf_rect(AVIOContext *pb, int xmin, int xmax, int ymin, int ymax)
Definition: swfenc.c:82
uint8_t * data
Definition: avcodec.h:1467
#define BITMAP_ID
Definition: swf.h:119
uint32_t tag
Definition: movenc.c:1348
int swf_frame_number
Definition: swf.h:129
ptrdiff_t size
Definition: opengl_enc.c:101
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:442
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:182
#define av_log(a,...)
static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
Definition: swfenc.c:109
struct AVOutputFormat * oformat
The output container format.
Definition: avformat.h:1333
static int swf_write_video(AVFormatContext *s, AVCodecContext *enc, const uint8_t *buf, int size)
Definition: swfenc.c:348
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
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:227
int video_frame_number
Definition: swf.h:130
static const uint16_t mask[17]
Definition: lzw.c:38
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
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
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: avcodec.h:420
uint8_t * buf
Definition: put_bits.h:38
simple assert() macros that are a bit more flexible than ISO C assert().
int sound_samples
Definition: swf.h:128
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:896
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1370
int samples_per_frame
Definition: swf.h:127
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:207
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:202
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:453
int width
picture width / height.
Definition: avcodec.h:1711
#define DUMMY_FILE_SIZE
Definition: swf.h:38
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:94
#define FLAG_SETFILL0
Definition: swf.h:113
const char * name
Definition: avformat.h:523
Definition: swf.h:62
int n
Definition: avisynth_c.h:547
AVCodecContext * audio_enc
Definition: swf.h:134
static int swf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: swfenc.c:477
int frame_size
Number of samples per channel in an audio frame.
Definition: avcodec.h:2307
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
static int swf_write_header(AVFormatContext *s)
Definition: swfenc.c:174
int frame_size
Definition: mxfenc.c:1821
enum AVMediaType codec_type
Definition: avcodec.h:1540
enum AVCodecID codec_id
Definition: avcodec.h:1549
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
int sample_rate
samples per second
Definition: avcodec.h:2287
AVIOContext * pb
I/O context.
Definition: avformat.h:1356
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:160
main external API structure.
Definition: avcodec.h:1532
void * buf
Definition: avisynth_c.h:553
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
AVCodecContext * video_enc
Definition: swf.h:134
#define FRAC_BITS
Definition: swfenc.c:136
int64_t vframes_pos
Definition: swf.h:126
static int flags
Definition: cpu.c:47
#define TAG_LONG
Definition: swf.h:109
Main libavformat public API header.
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:101
static double c[64]
int64_t tag_pos
Definition: swf.h:125
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:48
int den
denominator
Definition: rational.h:45
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
int channels
number of audio channels
Definition: avcodec.h:2288
void * priv_data
Format private data.
Definition: avformat.h:1342
#define AUDIO_FIFO_SIZE
Definition: swf.h:116
int tag
Definition: swf.h:132
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:497
Definition: swf.h:42
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:332
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
Definition: fifo.c:63
int stream_index
Definition: avcodec.h:1469
AVFifoBuffer * audio_fifo
Definition: swf.h:133
static int swf_write_trailer(AVFormatContext *s)
Definition: swfenc.c:486
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:919
int64_t duration_pos
Definition: swf.h:124
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.
Definition: avcodec.h:1444
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: v4l2enc.c:86
#define FLAG_MOVETO
Definition: swf.h:112
static int width
bitstream writer API