FFmpeg  4.4
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 "libavutil/fifo.h"
26 #include "avformat.h"
27 #include "flv.h"
28 #include "swf.h"
29 
30 #define AUDIO_FIFO_SIZE 65536
31 
32 typedef struct SWFEncContext {
33  int64_t duration_pos;
34  int64_t tag_pos;
35  int64_t vframes_pos;
40  int tag;
45 
46 static void put_swf_tag(AVFormatContext *s, int tag)
47 {
48  SWFEncContext *swf = s->priv_data;
49  AVIOContext *pb = s->pb;
50 
51  swf->tag_pos = avio_tell(pb);
52  swf->tag = tag;
53  /* reserve some room for the tag */
54  if (tag & TAG_LONG) {
55  avio_wl16(pb, 0);
56  avio_wl32(pb, 0);
57  } else {
58  avio_wl16(pb, 0);
59  }
60 }
61 
63 {
64  SWFEncContext *swf = s->priv_data;
65  AVIOContext *pb = s->pb;
66  int64_t pos;
67  int tag_len, tag;
68 
69  pos = avio_tell(pb);
70  tag_len = pos - swf->tag_pos - 2;
71  tag = swf->tag;
72  avio_seek(pb, swf->tag_pos, SEEK_SET);
73  if (tag & TAG_LONG) {
74  tag &= ~TAG_LONG;
75  avio_wl16(pb, (tag << 6) | 0x3f);
76  avio_wl32(pb, tag_len - 4);
77  } else {
78  av_assert0(tag_len < 0x3f);
79  avio_wl16(pb, (tag << 6) | tag_len);
80  }
81  avio_seek(pb, pos, SEEK_SET);
82 }
83 
84 static inline void max_nbits(int *nbits_ptr, int val)
85 {
86  int n;
87 
88  if (val == 0)
89  return;
90  val = FFABS(val);
91  n = 1;
92  while (val != 0) {
93  n++;
94  val >>= 1;
95  }
96  if (n > *nbits_ptr)
97  *nbits_ptr = n;
98 }
99 
100 static void put_swf_rect(AVIOContext *pb,
101  int xmin, int xmax, int ymin, int ymax)
102 {
103  PutBitContext p;
104  uint8_t buf[256];
105  int nbits, mask;
106 
107  init_put_bits(&p, buf, sizeof(buf));
108 
109  nbits = 0;
110  max_nbits(&nbits, xmin);
111  max_nbits(&nbits, xmax);
112  max_nbits(&nbits, ymin);
113  max_nbits(&nbits, ymax);
114  mask = (1 << nbits) - 1;
115 
116  /* rectangle info */
117  put_bits(&p, 5, nbits);
118  put_bits(&p, nbits, xmin & mask);
119  put_bits(&p, nbits, xmax & mask);
120  put_bits(&p, nbits, ymin & mask);
121  put_bits(&p, nbits, ymax & mask);
122 
123  flush_put_bits(&p);
124  avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
125 }
126 
127 static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
128 {
129  int nbits, mask;
130 
131  put_bits(pb, 1, 1); /* edge */
132  put_bits(pb, 1, 1); /* line select */
133  nbits = 2;
134  max_nbits(&nbits, dx);
135  max_nbits(&nbits, dy);
136 
137  mask = (1 << nbits) - 1;
138  put_bits(pb, 4, nbits - 2); /* 16 bits precision */
139  if (dx == 0) {
140  put_bits(pb, 1, 0);
141  put_bits(pb, 1, 1);
142  put_bits(pb, nbits, dy & mask);
143  } else if (dy == 0) {
144  put_bits(pb, 1, 0);
145  put_bits(pb, 1, 0);
146  put_bits(pb, nbits, dx & mask);
147  } else {
148  put_bits(pb, 1, 1);
149  put_bits(pb, nbits, dx & mask);
150  put_bits(pb, nbits, dy & mask);
151  }
152 }
153 
154 #define FRAC_BITS 16
155 
156 static void put_swf_matrix(AVIOContext *pb,
157  int a, int b, int c, int d, int tx, int ty)
158 {
159  PutBitContext p;
160  uint8_t buf[256];
161  int nbits;
162 
163  init_put_bits(&p, buf, sizeof(buf));
164 
165  put_bits(&p, 1, 1); /* a, d present */
166  nbits = 1;
167  max_nbits(&nbits, a);
168  max_nbits(&nbits, d);
169  put_bits(&p, 5, nbits); /* nb bits */
170  put_bits(&p, nbits, a);
171  put_bits(&p, nbits, d);
172 
173  put_bits(&p, 1, 1); /* b, c present */
174  nbits = 1;
175  max_nbits(&nbits, c);
176  max_nbits(&nbits, b);
177  put_bits(&p, 5, nbits); /* nb bits */
178  put_bits(&p, nbits, c);
179  put_bits(&p, nbits, b);
180 
181  nbits = 1;
182  max_nbits(&nbits, tx);
183  max_nbits(&nbits, ty);
184  put_bits(&p, 5, nbits); /* nb bits */
185  put_bits(&p, nbits, tx);
186  put_bits(&p, nbits, ty);
187 
188  flush_put_bits(&p);
189  avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
190 }
191 
193 {
194  SWFEncContext *swf = s->priv_data;
195  AVIOContext *pb = s->pb;
196  PutBitContext p;
197  uint8_t buf1[256];
198  int i, width, height, rate, rate_base;
199  int version;
200 
201  swf->sound_samples = 0;
202  swf->swf_frame_number = 0;
203  swf->video_frame_number = 0;
204 
205  for(i=0;i<s->nb_streams;i++) {
206  AVCodecParameters *par = s->streams[i]->codecpar;
207  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
208  if (swf->audio_par) {
209  av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 audio stream\n");
210  return AVERROR_INVALIDDATA;
211  }
212  if (par->codec_id == AV_CODEC_ID_MP3) {
213  swf->audio_par = par;
215  if (!swf->audio_fifo)
216  return AVERROR(ENOMEM);
217  } else {
218  av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
219  return -1;
220  }
221  } else {
222  if (swf->video_par) {
223  av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 video stream\n");
224  return AVERROR_INVALIDDATA;
225  }
227  par->codec_id == AV_CODEC_ID_PNG ||
228  par->codec_id == AV_CODEC_ID_MJPEG) {
229  swf->video_st = s->streams[i];
230  swf->video_par = par;
231  } else {
232  av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV, Flash Screen Video, PNG and MJPEG\n");
233  return -1;
234  }
235  }
236  }
237 
238  if (!swf->video_par) {
239  /* currently, cannot work correctly if audio only */
240  width = 320;
241  height = 200;
242  rate = 10;
243  rate_base= 1;
244  } else {
245  width = swf->video_par->width;
246  height = swf->video_par->height;
247  // TODO: should be avg_frame_rate
248  rate = swf->video_st->time_base.den;
249  rate_base = swf->video_st->time_base.num;
250  }
251 
252  if (!swf->audio_par)
253  swf->samples_per_frame = (44100LL * rate_base) / rate;
254  else
255  swf->samples_per_frame = (swf->audio_par->sample_rate * rate_base) / rate;
256 
257  avio_write(pb, "FWS", 3);
258 
259  if (!strcmp("avm2", s->oformat->name))
260  version = 9;
261  else if (swf->video_par && (swf->video_par->codec_id == AV_CODEC_ID_VP6A ||
264  version = 8; /* version 8 and above support VP6 and PNG codec */
265  else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_FLASHSV)
266  version = 7; /* version 7 and above support Flash Screen Video codec */
267  else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_FLV1)
268  version = 6; /* version 6 and above support FLV1 codec */
269  else
270  version = 4; /* version 4 for mpeg audio support */
271  avio_w8(pb, version);
272 
273  avio_wl32(pb, DUMMY_FILE_SIZE); /* dummy size
274  (will be patched if not streamed) */
275 
276  put_swf_rect(pb, 0, width * 20, 0, height * 20);
277  if ((rate * 256LL) / rate_base >= (1<<16)) {
278  av_log(s, AV_LOG_ERROR, "Invalid (too large) frame rate %d/%d\n", rate, rate_base);
279  return AVERROR(EINVAL);
280  }
281  avio_wl16(pb, (rate * 256LL) / rate_base); /* frame rate */
282  swf->duration_pos = avio_tell(pb);
283  avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
284 
285  /* swf v8 and later files require a file attribute tag */
286  if (version >= 8) {
288  avio_wl32(pb, (version >= 9) << 3); /* set ActionScript v3/AVM2 flag */
290  }
291 
292  /* define a shape with the jpeg inside */
293  if (swf->video_par && (swf->video_par->codec_id == AV_CODEC_ID_MJPEG || swf->video_par->codec_id == AV_CODEC_ID_PNG)) {
295 
296  avio_wl16(pb, SHAPE_ID); /* ID of shape */
297  /* bounding rectangle */
298  put_swf_rect(pb, 0, width, 0, height);
299  /* style info */
300  avio_w8(pb, 1); /* one fill style */
301  avio_w8(pb, 0x41); /* clipped bitmap fill */
302  avio_wl16(pb, BITMAP_ID); /* bitmap ID */
303  /* position of the bitmap */
304  put_swf_matrix(pb, 1 << FRAC_BITS, 0,
305  0, 1 << FRAC_BITS, 0, 0);
306  avio_w8(pb, 0); /* no line style */
307 
308  /* shape drawing */
309  init_put_bits(&p, buf1, sizeof(buf1));
310  put_bits(&p, 4, 1); /* one fill bit */
311  put_bits(&p, 4, 0); /* zero line bit */
312 
313  put_bits(&p, 1, 0); /* not an edge */
315  put_bits(&p, 5, 1); /* nbits */
316  put_bits(&p, 1, 0); /* X */
317  put_bits(&p, 1, 0); /* Y */
318  put_bits(&p, 1, 1); /* set fill style 1 */
319 
320  /* draw the rectangle ! */
321  put_swf_line_edge(&p, width, 0);
322  put_swf_line_edge(&p, 0, height);
323  put_swf_line_edge(&p, -width, 0);
324  put_swf_line_edge(&p, 0, -height);
325 
326  /* end of shape */
327  put_bits(&p, 1, 0); /* not an edge */
328  put_bits(&p, 5, 0);
329 
330  flush_put_bits(&p);
331  avio_write(pb, buf1, put_bits_ptr(&p) - p.buf);
332 
334  }
335 
336  if (swf->audio_par && swf->audio_par->codec_id == AV_CODEC_ID_MP3) {
337  int v = 0;
338 
339  /* start sound */
341  switch(swf->audio_par->sample_rate) {
342  case 11025: v |= 1 << 2; break;
343  case 22050: v |= 2 << 2; break;
344  case 44100: v |= 3 << 2; break;
345  default:
346  /* not supported */
347  av_log(s, AV_LOG_ERROR, "swf does not support that sample rate, choose from (44100, 22050, 11025).\n");
348  return -1;
349  }
350  v |= 0x02; /* 16 bit playback */
351  if (swf->audio_par->channels == 2)
352  v |= 0x01; /* stereo playback */
353  avio_w8(s->pb, v);
354  v |= 0x20; /* mp3 compressed */
355  avio_w8(s->pb, v);
356  avio_wl16(s->pb, swf->samples_per_frame); /* avg samples per frame */
357  avio_wl16(s->pb, 0);
358 
360  }
361 
362  return 0;
363 }
364 
366  AVCodecParameters *par, const uint8_t *buf, int size, unsigned pkt_flags)
367 {
368  SWFEncContext *swf = s->priv_data;
369  AVIOContext *pb = s->pb;
370  unsigned codec_tag = ff_codec_get_tag(ff_swf_codec_tags, par->codec_id);
371 
372  /* Flash Player limit */
373  if (swf->swf_frame_number == 16000)
374  av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
375 
376  if (codec_tag) {
377  if (swf->video_frame_number == 0) {
378  /* create a new video object */
380  avio_wl16(pb, VIDEO_ID);
381  swf->vframes_pos = avio_tell(pb);
382  avio_wl16(pb, 15000); /* hard flash player limit */
383  avio_wl16(pb, par->width);
384  avio_wl16(pb, par->height);
385  avio_w8(pb, 0);
386  avio_w8(pb, codec_tag);
388 
389  /* place the video object for the first time */
391  avio_w8(pb, 0x36);
392  avio_wl16(pb, 1);
393  avio_wl16(pb, VIDEO_ID);
394  put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
395  avio_wl16(pb, swf->video_frame_number);
396  avio_write(pb, "video", 5);
397  avio_w8(pb, 0x00);
399  } else {
400  /* mark the character for update */
402  avio_w8(pb, 0x11);
403  avio_wl16(pb, 1);
404  avio_wl16(pb, swf->video_frame_number);
406  }
407 
408  /* set video frame data */
410  avio_wl16(pb, VIDEO_ID);
411  avio_wl16(pb, swf->video_frame_number++);
412  if (par->codec_id == AV_CODEC_ID_FLASHSV) {
413  /* FrameType and CodecId is needed here even if it is not documented correctly in the SWF specs */
414  int flags = codec_tag | (pkt_flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER);
415  avio_w8(pb, flags);
416  }
417  avio_write(pb, buf, size);
419  } else if (par->codec_id == AV_CODEC_ID_MJPEG || par->codec_id == AV_CODEC_ID_PNG) {
420  if (swf->swf_frame_number > 0) {
421  /* remove the shape */
423  avio_wl16(pb, SHAPE_ID); /* shape ID */
424  avio_wl16(pb, 1); /* depth */
426 
427  /* free the bitmap */
429  avio_wl16(pb, BITMAP_ID);
431  }
432 
434 
435  avio_wl16(pb, BITMAP_ID); /* ID of the image */
436 
437  /* a dummy jpeg header seems to be required */
438  if (par->codec_id == AV_CODEC_ID_MJPEG)
439  avio_wb32(pb, 0xffd8ffd9);
440  /* write the jpeg/png image */
441  avio_write(pb, buf, size);
442 
444 
445  /* draw the shape */
446 
448  avio_wl16(pb, SHAPE_ID); /* shape ID */
449  avio_wl16(pb, 1); /* depth */
450  put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0);
452  }
453 
454  swf->swf_frame_number++;
455 
456  /* streaming sound always should be placed just before showframe tags */
457  if (swf->audio_par && av_fifo_size(swf->audio_fifo)) {
458  int frame_size = av_fifo_size(swf->audio_fifo);
460  avio_wl16(pb, swf->sound_samples);
461  avio_wl16(pb, 0); // seek samples
464 
465  /* update FIFO */
466  swf->sound_samples = 0;
467  }
468 
469  /* output the frame */
472 
473  return 0;
474 }
475 
477  AVCodecParameters *par, uint8_t *buf, int size)
478 {
479  SWFEncContext *swf = s->priv_data;
480 
481  /* Flash Player limit */
482  if (swf->swf_frame_number == 16000)
483  av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
484 
486  av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
487  return -1;
488  }
489 
492 
493  /* if audio only stream make sure we add swf frames */
494  if (!swf->video_par)
495  swf_write_video(s, par, 0, 0, 0);
496 
497  return 0;
498 }
499 
501 {
502  AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
503  if (par->codec_type == AVMEDIA_TYPE_AUDIO)
504  return swf_write_audio(s, par, pkt->data, pkt->size);
505  else
506  return swf_write_video(s, par, pkt->data, pkt->size, pkt->flags);
507 }
508 
510 {
511  SWFEncContext *swf = s->priv_data;
512  AVIOContext *pb = s->pb;
513  int file_size;
514 
517 
518  /* patch file size and number of frames if not streamed */
519  if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && swf->video_par) {
520  file_size = avio_tell(pb);
521  avio_seek(pb, 4, SEEK_SET);
522  avio_wl32(pb, file_size);
523  avio_seek(pb, swf->duration_pos, SEEK_SET);
524  avio_wl16(pb, swf->video_frame_number);
525  if (swf->vframes_pos) {
526  avio_seek(pb, swf->vframes_pos, SEEK_SET);
527  avio_wl16(pb, swf->video_frame_number);
528  }
529  avio_seek(pb, file_size, SEEK_SET);
530  }
531  return 0;
532 }
533 
535 {
536  SWFEncContext *swf = s->priv_data;
537 
538  av_fifo_freep(&swf->audio_fifo);
539 }
540 
541 #if CONFIG_SWF_MUXER
543  .name = "swf",
544  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash)"),
545  .mime_type = "application/x-shockwave-flash",
546  .extensions = "swf",
547  .priv_data_size = sizeof(SWFEncContext),
548  .audio_codec = AV_CODEC_ID_MP3,
549  .video_codec = AV_CODEC_ID_FLV1,
553  .deinit = swf_deinit,
555 };
556 #endif
557 #if CONFIG_AVM2_MUXER
559  .name = "avm2",
560  .long_name = NULL_IF_CONFIG_SMALL("SWF (ShockWave Flash) (AVM2)"),
561  .mime_type = "application/x-shockwave-flash",
562  .priv_data_size = sizeof(SWFEncContext),
563  .audio_codec = AV_CODEC_ID_MP3,
564  .video_codec = AV_CODEC_ID_FLV1,
568  .deinit = swf_deinit,
570 };
571 #endif
static double val(void *priv, double ch)
Definition: aeval.c:76
AVOutputFormat ff_swf_muxer
AVOutputFormat ff_avm2_muxer
uint8_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
Main libavformat public API header.
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:472
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:253
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:375
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:455
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:203
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:383
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:225
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define s(width, name)
Definition: cbs_vp9.c:257
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define NULL
Definition: coverity.c:32
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:729
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:346
a very simple circular buffer FIFO implementation
@ AV_CODEC_ID_FLV1
Definition: codec_id.h:70
@ AV_CODEC_ID_PNG
Definition: codec_id.h:110
@ AV_CODEC_ID_VP6F
Definition: codec_id.h:141
@ AV_CODEC_ID_VP6A
Definition: codec_id.h:155
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:56
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:425
@ AV_CODEC_ID_FLASHSV
Definition: codec_id.h:135
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:835
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:410
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_INFO
Standard information.
Definition: log.h:205
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
int i
Definition: input.c:407
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:218
FLV common header.
@ FLV_FRAME_INTER
inter frame (for AVC, a non-seekable frame)
Definition: flv.h:117
@ FLV_FRAME_KEY
key frame (for AVC, a seekable frame)
Definition: flv.h:116
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
Definition: utils.c:3119
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
Definition: fifo.c:63
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 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
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
version
Definition: libkvazaar.c:320
static const uint16_t mask[17]
Definition: lzw.c:38
uint32_t tag
Definition: movenc.c:1600
#define VIDEO_ID
Definition: mpeg.h:42
int frame_size
Definition: mxfenc.c:2206
bitstream writer API
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:57
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:342
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:110
unsigned int pos
Definition: spdifenc.c:412
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
int channels
Audio only.
Definition: codec_par.h:166
int width
Video only.
Definition: codec_par.h:126
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
int sample_rate
Audio only.
Definition: codec_par.h:170
Format I/O context.
Definition: avformat.h:1232
Bytestream IO Context.
Definition: avio.h:161
const char * name
Definition: avformat.h:491
This structure stores compressed data.
Definition: packet.h:346
int stream_index
Definition: packet.h:371
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:375
int size
Definition: packet.h:370
uint8_t * data
Definition: packet.h:369
int num
Numerator.
Definition: rational.h:59
int den
Denominator.
Definition: rational.h:60
Stream structure.
Definition: avformat.h:873
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:902
uint8_t * buf
Definition: put_bits.h:47
int64_t duration_pos
Definition: swfenc.c:33
AVCodecParameters * video_par
Definition: swfenc.c:42
AVStream * video_st
Definition: swfenc.c:43
int sound_samples
Definition: swfenc.c:37
int video_frame_number
Definition: swfenc.c:39
AVCodecParameters * audio_par
Definition: swfenc.c:42
int64_t tag_pos
Definition: swfenc.c:34
int samples_per_frame
Definition: swfenc.c:36
AVFifoBuffer * audio_fifo
Definition: swfenc.c:41
int swf_frame_number
Definition: swfenc.c:38
int64_t vframes_pos
Definition: swfenc.c:35
const AVCodecTag ff_swf_codec_tags[]
Definition: swf.c:25
#define DUMMY_FILE_SIZE
Definition: swf.h:29
#define TAG_LONG
Definition: swf.h:100
#define BITMAP_ID
Definition: swf.h:108
@ TAG_PLACEOBJECT
Definition: swf.h:37
@ TAG_FREECHARACTER
Definition: swf.h:36
@ TAG_STREAMHEAD2
Definition: swf.h:67
@ TAG_FILEATTRIBUTES
Definition: swf.h:80
@ TAG_REMOVEOBJECT
Definition: swf.h:38
@ TAG_STREAMBLOCK
Definition: swf.h:51
@ TAG_VIDEOSTREAM
Definition: swf.h:74
@ TAG_JPEG2
Definition: swf.h:53
@ TAG_DEFINESHAPE
Definition: swf.h:35
@ TAG_VIDEOFRAME
Definition: swf.h:75
@ TAG_END
Definition: swf.h:33
@ TAG_PLACEOBJECT2
Definition: swf.h:57
@ TAG_SHOWFRAME
Definition: swf.h:34
#define SHAPE_ID
Definition: swf.h:110
#define DUMMY_DURATION
Definition: swf.h:30
#define FLAG_MOVETO
Definition: swf.h:103
#define FLAG_SETFILL0
Definition: swf.h:104
static void swf_deinit(AVFormatContext *s)
Definition: swfenc.c:534
static int swf_write_audio(AVFormatContext *s, AVCodecParameters *par, uint8_t *buf, int size)
Definition: swfenc.c:476
#define FRAC_BITS
Definition: swfenc.c:154
static void put_swf_tag(AVFormatContext *s, int tag)
Definition: swfenc.c:46
#define AUDIO_FIFO_SIZE
Definition: swfenc.c:30
static int swf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: swfenc.c:500
static int swf_write_trailer(AVFormatContext *s)
Definition: swfenc.c:509
static void put_swf_matrix(AVIOContext *pb, int a, int b, int c, int d, int tx, int ty)
Definition: swfenc.c:156
static int swf_write_header(AVFormatContext *s)
Definition: swfenc.c:192
static void put_swf_end_tag(AVFormatContext *s)
Definition: swfenc.c:62
static void max_nbits(int *nbits_ptr, int val)
Definition: swfenc.c:84
static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
Definition: swfenc.c:127
static int swf_write_video(AVFormatContext *s, AVCodecParameters *par, const uint8_t *buf, int size, unsigned pkt_flags)
Definition: swfenc.c:365
static void put_swf_rect(AVIOContext *pb, int xmin, int xmax, int ymin, int ymax)
Definition: swfenc.c:100
#define av_log(a,...)
AVPacket * pkt
Definition: movenc.c:59
#define height
#define width
int size
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:98
const char * b
Definition: vf_curves.c:118
static double c[64]