Mercurial > libavformat.hg
annotate swf.c @ 3287:8570df039c75 libavformat
Fix type of dest_addr_len to respect return value of udp_set_url.
Patch by Luca Abeni.
author | cehoyos |
---|---|
date | Sun, 11 May 2008 10:53:21 +0000 |
parents | 6f61c3b36632 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * Flash Compatible Streaming Format | |
3 * Copyright (c) 2000 Fabrice Bellard. | |
359 | 4 * Copyright (c) 2003 Tinic Uro. |
0 | 5 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1305
diff
changeset
|
6 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1305
diff
changeset
|
7 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1305
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
0 | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1305
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
0 | 12 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1305
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
0 | 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 | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1305
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 21 */ |
3286 | 22 |
23 #include "libavcodec/bitstream.h" | |
0 | 24 #include "avformat.h" |
1305 | 25 #include "riff.h" /* for CodecTag */ |
0 | 26 |
27 /* should have a generic way to indicate probable size */ | |
28 #define DUMMY_FILE_SIZE (100 * 1024 * 1024) | |
29 #define DUMMY_DURATION 600 /* in seconds */ | |
30 | |
31 #define TAG_END 0 | |
32 #define TAG_SHOWFRAME 1 | |
33 #define TAG_DEFINESHAPE 2 | |
34 #define TAG_FREECHARACTER 3 | |
35 #define TAG_PLACEOBJECT 4 | |
36 #define TAG_REMOVEOBJECT 5 | |
807 | 37 #define TAG_STREAMHEAD 18 |
0 | 38 #define TAG_STREAMBLOCK 19 |
39 #define TAG_JPEG2 21 | |
359 | 40 #define TAG_PLACEOBJECT2 26 |
41 #define TAG_STREAMHEAD2 45 | |
887 | 42 #define TAG_VIDEOSTREAM 60 |
359 | 43 #define TAG_VIDEOFRAME 61 |
2955
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
44 #define TAG_FILEATTRIBUTES 69 |
0 | 45 |
46 #define TAG_LONG 0x100 | |
47 | |
48 /* flags for shape definition */ | |
49 #define FLAG_MOVETO 0x01 | |
50 #define FLAG_SETFILL0 0x02 | |
51 #define FLAG_SETFILL1 0x04 | |
52 | |
359 | 53 #define AUDIO_FIFO_SIZE 65536 |
54 | |
0 | 55 /* character id used */ |
56 #define BITMAP_ID 0 | |
359 | 57 #define VIDEO_ID 0 |
0 | 58 #define SHAPE_ID 1 |
59 | |
516 | 60 #undef NDEBUG |
61 #include <assert.h> | |
359 | 62 |
0 | 63 typedef struct { |
1638 | 64 int audio_stream_index; |
0 | 65 offset_t duration_pos; |
66 offset_t tag_pos; | |
885 | 67 |
359 | 68 int samples_per_frame; |
69 int sound_samples; | |
70 int swf_frame_number; | |
71 int video_frame_number; | |
1889 | 72 int frame_rate; |
0 | 73 int tag; |
359 | 74 |
1854 | 75 uint8_t audio_fifo[AUDIO_FIFO_SIZE]; |
359 | 76 int audio_in_pos; |
77 | |
78 int video_type; | |
79 int audio_type; | |
0 | 80 } SWFContext; |
81 | |
1677
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1673
diff
changeset
|
82 static const AVCodecTag swf_codec_tags[] = { |
1305 | 83 {CODEC_ID_FLV1, 0x02}, |
84 {CODEC_ID_VP6F, 0x04}, | |
85 {0, 0}, | |
86 }; | |
87 | |
1833 | 88 static const AVCodecTag swf_audio_codec_tags[] = { |
89 {CODEC_ID_PCM_S16LE, 0x00}, | |
90 {CODEC_ID_ADPCM_SWF, 0x01}, | |
91 {CODEC_ID_MP3, 0x02}, | |
92 {CODEC_ID_PCM_S16LE, 0x03}, | |
93 //{CODEC_ID_NELLYMOSER, 0x06}, | |
94 {0, 0}, | |
95 }; | |
96 | |
858
66cc656ea404
Replace CONFIG_ENCODERS/CONFIG_DECODERS with CONFIG_MUXERS/CONFIG_DEMUXERS
diego
parents:
820
diff
changeset
|
97 #ifdef CONFIG_MUXERS |
0 | 98 static void put_swf_tag(AVFormatContext *s, int tag) |
99 { | |
100 SWFContext *swf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
101 ByteIOContext *pb = s->pb; |
0 | 102 |
103 swf->tag_pos = url_ftell(pb); | |
104 swf->tag = tag; | |
105 /* reserve some room for the tag */ | |
106 if (tag & TAG_LONG) { | |
107 put_le16(pb, 0); | |
108 put_le32(pb, 0); | |
109 } else { | |
110 put_le16(pb, 0); | |
111 } | |
112 } | |
113 | |
114 static void put_swf_end_tag(AVFormatContext *s) | |
115 { | |
116 SWFContext *swf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
117 ByteIOContext *pb = s->pb; |
0 | 118 offset_t pos; |
119 int tag_len, tag; | |
120 | |
121 pos = url_ftell(pb); | |
122 tag_len = pos - swf->tag_pos - 2; | |
123 tag = swf->tag; | |
124 url_fseek(pb, swf->tag_pos, SEEK_SET); | |
125 if (tag & TAG_LONG) { | |
126 tag &= ~TAG_LONG; | |
127 put_le16(pb, (tag << 6) | 0x3f); | |
128 put_le32(pb, tag_len - 4); | |
129 } else { | |
130 assert(tag_len < 0x3f); | |
131 put_le16(pb, (tag << 6) | tag_len); | |
132 } | |
133 url_fseek(pb, pos, SEEK_SET); | |
134 } | |
135 | |
136 static inline void max_nbits(int *nbits_ptr, int val) | |
137 { | |
138 int n; | |
139 | |
140 if (val == 0) | |
141 return; | |
142 val = abs(val); | |
143 n = 1; | |
144 while (val != 0) { | |
145 n++; | |
146 val >>= 1; | |
147 } | |
148 if (n > *nbits_ptr) | |
149 *nbits_ptr = n; | |
150 } | |
151 | |
885 | 152 static void put_swf_rect(ByteIOContext *pb, |
0 | 153 int xmin, int xmax, int ymin, int ymax) |
154 { | |
155 PutBitContext p; | |
65 | 156 uint8_t buf[256]; |
0 | 157 int nbits, mask; |
158 | |
276 | 159 init_put_bits(&p, buf, sizeof(buf)); |
885 | 160 |
0 | 161 nbits = 0; |
162 max_nbits(&nbits, xmin); | |
163 max_nbits(&nbits, xmax); | |
164 max_nbits(&nbits, ymin); | |
165 max_nbits(&nbits, ymax); | |
166 mask = (1 << nbits) - 1; | |
167 | |
168 /* rectangle info */ | |
169 put_bits(&p, 5, nbits); | |
170 put_bits(&p, nbits, xmin & mask); | |
171 put_bits(&p, nbits, xmax & mask); | |
172 put_bits(&p, nbits, ymin & mask); | |
173 put_bits(&p, nbits, ymax & mask); | |
885 | 174 |
0 | 175 flush_put_bits(&p); |
176 put_buffer(pb, buf, pbBufPtr(&p) - p.buf); | |
177 } | |
178 | |
179 static void put_swf_line_edge(PutBitContext *pb, int dx, int dy) | |
180 { | |
181 int nbits, mask; | |
182 | |
183 put_bits(pb, 1, 1); /* edge */ | |
184 put_bits(pb, 1, 1); /* line select */ | |
185 nbits = 2; | |
186 max_nbits(&nbits, dx); | |
187 max_nbits(&nbits, dy); | |
188 | |
189 mask = (1 << nbits) - 1; | |
190 put_bits(pb, 4, nbits - 2); /* 16 bits precision */ | |
191 if (dx == 0) { | |
2308 | 192 put_bits(pb, 1, 0); |
193 put_bits(pb, 1, 1); | |
194 put_bits(pb, nbits, dy & mask); | |
0 | 195 } else if (dy == 0) { |
2308 | 196 put_bits(pb, 1, 0); |
197 put_bits(pb, 1, 0); | |
198 put_bits(pb, nbits, dx & mask); | |
0 | 199 } else { |
2308 | 200 put_bits(pb, 1, 1); |
201 put_bits(pb, nbits, dx & mask); | |
202 put_bits(pb, nbits, dy & mask); | |
0 | 203 } |
204 } | |
205 | |
206 #define FRAC_BITS 16 | |
207 | |
359 | 208 /* put matrix */ |
0 | 209 static void put_swf_matrix(ByteIOContext *pb, |
210 int a, int b, int c, int d, int tx, int ty) | |
211 { | |
212 PutBitContext p; | |
65 | 213 uint8_t buf[256]; |
359 | 214 int nbits; |
0 | 215 |
276 | 216 init_put_bits(&p, buf, sizeof(buf)); |
885 | 217 |
0 | 218 put_bits(&p, 1, 1); /* a, d present */ |
359 | 219 nbits = 1; |
220 max_nbits(&nbits, a); | |
221 max_nbits(&nbits, d); | |
222 put_bits(&p, 5, nbits); /* nb bits */ | |
223 put_bits(&p, nbits, a); | |
224 put_bits(&p, nbits, d); | |
885 | 225 |
0 | 226 put_bits(&p, 1, 1); /* b, c present */ |
359 | 227 nbits = 1; |
228 max_nbits(&nbits, c); | |
229 max_nbits(&nbits, b); | |
230 put_bits(&p, 5, nbits); /* nb bits */ | |
231 put_bits(&p, nbits, c); | |
232 put_bits(&p, nbits, b); | |
0 | 233 |
359 | 234 nbits = 1; |
235 max_nbits(&nbits, tx); | |
236 max_nbits(&nbits, ty); | |
237 put_bits(&p, 5, nbits); /* nb bits */ | |
238 put_bits(&p, nbits, tx); | |
239 put_bits(&p, nbits, ty); | |
0 | 240 |
241 flush_put_bits(&p); | |
242 put_buffer(pb, buf, pbBufPtr(&p) - p.buf); | |
243 } | |
244 | |
359 | 245 /* */ |
0 | 246 static int swf_write_header(AVFormatContext *s) |
247 { | |
1623 | 248 SWFContext *swf = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
249 ByteIOContext *pb = s->pb; |
0 | 250 AVCodecContext *enc, *audio_enc, *video_enc; |
251 PutBitContext p; | |
65 | 252 uint8_t buf1[256]; |
85
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
253 int i, width, height, rate, rate_base; |
2955
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
254 int is_avm2; |
0 | 255 |
359 | 256 swf->audio_in_pos = 0; |
257 swf->sound_samples = 0; | |
258 swf->swf_frame_number = 0; | |
259 swf->video_frame_number = 0; | |
260 | |
0 | 261 video_enc = NULL; |
262 audio_enc = NULL; | |
263 for(i=0;i<s->nb_streams;i++) { | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
807
diff
changeset
|
264 enc = s->streams[i]->codec; |
1854 | 265 if (enc->codec_type == CODEC_TYPE_AUDIO) { |
266 if (enc->codec_id == CODEC_ID_MP3) { | |
267 if (!enc->frame_size) { | |
268 av_log(s, AV_LOG_ERROR, "audio frame size not set\n"); | |
269 return -1; | |
270 } | |
271 audio_enc = enc; | |
272 } else { | |
1865 | 273 av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n"); |
1854 | 274 return -1; |
275 } | |
276 } else { | |
2309 | 277 if (enc->codec_id == CODEC_ID_VP6F || |
278 enc->codec_id == CODEC_ID_FLV1 || | |
279 enc->codec_id == CODEC_ID_MJPEG) { | |
359 | 280 video_enc = enc; |
281 } else { | |
1865 | 282 av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV1 and MJPEG\n"); |
359 | 283 return -1; |
284 } | |
285 } | |
0 | 286 } |
287 | |
288 if (!video_enc) { | |
2289 | 289 /* currently, cannot work correctly if audio only */ |
359 | 290 swf->video_type = 0; |
0 | 291 width = 320; |
292 height = 200; | |
85
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
293 rate = 10; |
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
294 rate_base= 1; |
0 | 295 } else { |
359 | 296 swf->video_type = video_enc->codec_id; |
0 | 297 width = video_enc->width; |
298 height = video_enc->height; | |
743 | 299 rate = video_enc->time_base.den; |
300 rate_base = video_enc->time_base.num; | |
0 | 301 } |
302 | |
2309 | 303 if (!audio_enc) { |
359 | 304 swf->audio_type = 0; |
2309 | 305 swf->samples_per_frame = (44100. * rate_base) / rate; |
359 | 306 } else { |
307 swf->audio_type = audio_enc->codec_id; | |
2309 | 308 swf->samples_per_frame = (audio_enc->sample_rate * rate_base) / rate; |
359 | 309 } |
310 | |
2955
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
311 is_avm2 = !strcmp("avm2", s->oformat->name); |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
312 |
0 | 313 put_tag(pb, "FWS"); |
2955
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
314 if (is_avm2) { |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
315 put_byte(pb, 9); |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
316 } else if (video_enc && video_enc->codec_id == CODEC_ID_VP6F) { |
1305 | 317 put_byte(pb, 8); /* version (version 8 and above support VP6 codec) */ |
2309 | 318 } else if (video_enc && video_enc->codec_id == CODEC_ID_FLV1) { |
359 | 319 put_byte(pb, 6); /* version (version 6 and above support FLV1 codec) */ |
320 } else { | |
321 put_byte(pb, 4); /* version (should use 4 for mpeg audio support) */ | |
322 } | |
885 | 323 put_le32(pb, DUMMY_FILE_SIZE); /* dummy size |
324 (will be patched if not streamed) */ | |
0 | 325 |
359 | 326 put_swf_rect(pb, 0, width * 20, 0, height * 20); |
85
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
327 put_le16(pb, (rate * 256) / rate_base); /* frame rate */ |
0 | 328 swf->duration_pos = url_ftell(pb); |
85
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
329 put_le16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */ |
885 | 330 |
2955
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
331 /* avm2/swf v9 (also v8?) files require a file attribute tag */ |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
332 if (is_avm2) { |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
333 put_swf_tag(s, TAG_FILEATTRIBUTES); |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
334 put_le32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */ |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
335 put_swf_end_tag(s); |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
336 } |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
337 |
0 | 338 /* define a shape with the jpeg inside */ |
2309 | 339 if (video_enc && (video_enc->codec_id == CODEC_ID_VP6F || |
340 video_enc->codec_id == CODEC_ID_FLV1)) { | |
341 } else if (video_enc && video_enc->codec_id == CODEC_ID_MJPEG) { | |
359 | 342 put_swf_tag(s, TAG_DEFINESHAPE); |
0 | 343 |
359 | 344 put_le16(pb, SHAPE_ID); /* ID of shape */ |
345 /* bounding rectangle */ | |
346 put_swf_rect(pb, 0, width, 0, height); | |
347 /* style info */ | |
348 put_byte(pb, 1); /* one fill style */ | |
349 put_byte(pb, 0x41); /* clipped bitmap fill */ | |
350 put_le16(pb, BITMAP_ID); /* bitmap ID */ | |
351 /* position of the bitmap */ | |
885 | 352 put_swf_matrix(pb, (int)(1.0 * (1 << FRAC_BITS)), 0, |
2308 | 353 0, (int)(1.0 * (1 << FRAC_BITS)), 0, 0); |
359 | 354 put_byte(pb, 0); /* no line style */ |
885 | 355 |
359 | 356 /* shape drawing */ |
357 init_put_bits(&p, buf1, sizeof(buf1)); | |
358 put_bits(&p, 4, 1); /* one fill bit */ | |
359 put_bits(&p, 4, 0); /* zero line bit */ | |
885 | 360 |
359 | 361 put_bits(&p, 1, 0); /* not an edge */ |
362 put_bits(&p, 5, FLAG_MOVETO | FLAG_SETFILL0); | |
363 put_bits(&p, 5, 1); /* nbits */ | |
364 put_bits(&p, 1, 0); /* X */ | |
365 put_bits(&p, 1, 0); /* Y */ | |
366 put_bits(&p, 1, 1); /* set fill style 1 */ | |
885 | 367 |
359 | 368 /* draw the rectangle ! */ |
369 put_swf_line_edge(&p, width, 0); | |
370 put_swf_line_edge(&p, 0, height); | |
371 put_swf_line_edge(&p, -width, 0); | |
372 put_swf_line_edge(&p, 0, -height); | |
885 | 373 |
359 | 374 /* end of shape */ |
375 put_bits(&p, 1, 0); /* not an edge */ | |
376 put_bits(&p, 5, 0); | |
0 | 377 |
359 | 378 flush_put_bits(&p); |
379 put_buffer(pb, buf1, pbBufPtr(&p) - p.buf); | |
0 | 380 |
359 | 381 put_swf_end_tag(s); |
382 } | |
885 | 383 |
2309 | 384 if (audio_enc && audio_enc->codec_id == CODEC_ID_MP3) { |
0 | 385 int v; |
386 | |
387 /* start sound */ | |
359 | 388 put_swf_tag(s, TAG_STREAMHEAD2); |
0 | 389 |
390 v = 0; | |
391 switch(audio_enc->sample_rate) { | |
392 case 11025: | |
393 v |= 1 << 2; | |
394 break; | |
395 case 22050: | |
396 v |= 2 << 2; | |
397 break; | |
398 case 44100: | |
399 v |= 3 << 2; | |
400 break; | |
401 default: | |
402 /* not supported */ | |
2164 | 403 av_log(s, AV_LOG_ERROR, "swf does not support that sample rate, choose from (44100, 22050, 11025).\n"); |
0 | 404 return -1; |
405 } | |
359 | 406 v |= 0x02; /* 16 bit playback */ |
0 | 407 if (audio_enc->channels == 2) |
359 | 408 v |= 0x01; /* stereo playback */ |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
409 put_byte(s->pb, v); |
0 | 410 v |= 0x20; /* mp3 compressed */ |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
411 put_byte(s->pb, v); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
412 put_le16(s->pb, swf->samples_per_frame); /* avg samples per frame */ |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
413 put_le16(s->pb, 0); |
885 | 414 |
0 | 415 put_swf_end_tag(s); |
416 } | |
417 | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
418 put_flush_packet(s->pb); |
0 | 419 return 0; |
420 } | |
421 | |
885 | 422 static int swf_write_video(AVFormatContext *s, |
241 | 423 AVCodecContext *enc, const uint8_t *buf, int size) |
0 | 424 { |
359 | 425 SWFContext *swf = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
426 ByteIOContext *pb = s->pb; |
885 | 427 |
359 | 428 /* Flash Player limit */ |
2309 | 429 if (swf->swf_frame_number == 16000) { |
370
845f9de2c883
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
360
diff
changeset
|
430 av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n"); |
359 | 431 } |
0 | 432 |
2309 | 433 if (swf->video_type == CODEC_ID_VP6F || |
434 swf->video_type == CODEC_ID_FLV1) { | |
435 if (swf->video_frame_number == 0) { | |
2308 | 436 /* create a new video object */ |
437 put_swf_tag(s, TAG_VIDEOSTREAM); | |
438 put_le16(pb, VIDEO_ID); | |
2309 | 439 put_le16(pb, 15000); /* hard flash player limit */ |
2308 | 440 put_le16(pb, enc->width); |
441 put_le16(pb, enc->height); | |
442 put_byte(pb, 0); | |
443 put_byte(pb,codec_get_tag(swf_codec_tags,swf->video_type)); | |
444 put_swf_end_tag(s); | |
885 | 445 |
2308 | 446 /* place the video object for the first time */ |
447 put_swf_tag(s, TAG_PLACEOBJECT2); | |
448 put_byte(pb, 0x36); | |
449 put_le16(pb, 1); | |
450 put_le16(pb, VIDEO_ID); | |
451 put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0); | |
2309 | 452 put_le16(pb, swf->video_frame_number); |
2308 | 453 put_byte(pb, 'v'); |
454 put_byte(pb, 'i'); | |
455 put_byte(pb, 'd'); | |
456 put_byte(pb, 'e'); | |
457 put_byte(pb, 'o'); | |
458 put_byte(pb, 0x00); | |
459 put_swf_end_tag(s); | |
460 } else { | |
461 /* mark the character for update */ | |
462 put_swf_tag(s, TAG_PLACEOBJECT2); | |
463 put_byte(pb, 0x11); | |
464 put_le16(pb, 1); | |
2309 | 465 put_le16(pb, swf->video_frame_number); |
2308 | 466 put_swf_end_tag(s); |
467 } | |
885 | 468 |
2308 | 469 /* set video frame data */ |
470 put_swf_tag(s, TAG_VIDEOFRAME | TAG_LONG); | |
471 put_le16(pb, VIDEO_ID); | |
2309 | 472 put_le16(pb, swf->video_frame_number++); |
2308 | 473 put_buffer(pb, buf, size); |
474 put_swf_end_tag(s); | |
2309 | 475 } else if (swf->video_type == CODEC_ID_MJPEG) { |
2308 | 476 if (swf->swf_frame_number > 0) { |
477 /* remove the shape */ | |
478 put_swf_tag(s, TAG_REMOVEOBJECT); | |
479 put_le16(pb, SHAPE_ID); /* shape ID */ | |
480 put_le16(pb, 1); /* depth */ | |
481 put_swf_end_tag(s); | |
885 | 482 |
2308 | 483 /* free the bitmap */ |
484 put_swf_tag(s, TAG_FREECHARACTER); | |
485 put_le16(pb, BITMAP_ID); | |
486 put_swf_end_tag(s); | |
487 } | |
885 | 488 |
2308 | 489 put_swf_tag(s, TAG_JPEG2 | TAG_LONG); |
885 | 490 |
2308 | 491 put_le16(pb, BITMAP_ID); /* ID of the image */ |
885 | 492 |
2308 | 493 /* a dummy jpeg header seems to be required */ |
494 put_byte(pb, 0xff); | |
495 put_byte(pb, 0xd8); | |
496 put_byte(pb, 0xff); | |
497 put_byte(pb, 0xd9); | |
498 /* write the jpeg image */ | |
499 put_buffer(pb, buf, size); | |
885 | 500 |
2308 | 501 put_swf_end_tag(s); |
885 | 502 |
2308 | 503 /* draw the shape */ |
885 | 504 |
2308 | 505 put_swf_tag(s, TAG_PLACEOBJECT); |
506 put_le16(pb, SHAPE_ID); /* shape ID */ | |
507 put_le16(pb, 1); /* depth */ | |
508 put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0); | |
509 put_swf_end_tag(s); | |
510 } else { | |
511 /* invalid codec */ | |
512 } | |
885 | 513 |
2308 | 514 swf->swf_frame_number ++; |
0 | 515 |
359 | 516 /* streaming sound always should be placed just before showframe tags */ |
1854 | 517 if (swf->audio_type && swf->audio_in_pos) { |
359 | 518 put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG); |
1854 | 519 put_le16(pb, swf->sound_samples); |
520 put_le16(pb, 0); // seek samples | |
521 put_buffer(pb, swf->audio_fifo, swf->audio_in_pos); | |
359 | 522 put_swf_end_tag(s); |
885 | 523 |
359 | 524 /* update FIFO */ |
1854 | 525 swf->sound_samples = 0; |
526 swf->audio_in_pos = 0; | |
359 | 527 } |
528 | |
0 | 529 /* output the frame */ |
530 put_swf_tag(s, TAG_SHOWFRAME); | |
531 put_swf_end_tag(s); | |
885 | 532 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
533 put_flush_packet(s->pb); |
885 | 534 |
0 | 535 return 0; |
536 } | |
537 | |
885 | 538 static int swf_write_audio(AVFormatContext *s, |
359 | 539 AVCodecContext *enc, const uint8_t *buf, int size) |
0 | 540 { |
359 | 541 SWFContext *swf = s->priv_data; |
542 | |
543 /* Flash Player limit */ | |
2309 | 544 if (swf->swf_frame_number == 16000) { |
370
845f9de2c883
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
360
diff
changeset
|
545 av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n"); |
359 | 546 } |
0 | 547 |
1854 | 548 if (swf->audio_in_pos + size >= AUDIO_FIFO_SIZE) { |
549 av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n"); | |
550 return -1; | |
359 | 551 } |
0 | 552 |
1854 | 553 memcpy(swf->audio_fifo + swf->audio_in_pos, buf, size); |
554 swf->audio_in_pos += size; | |
555 swf->sound_samples += enc->frame_size; | |
556 | |
359 | 557 /* if audio only stream make sure we add swf frames */ |
2309 | 558 if (swf->video_type == 0) { |
359 | 559 swf_write_video(s, enc, 0, 0); |
560 } | |
561 | |
0 | 562 return 0; |
563 } | |
564 | |
468 | 565 static int swf_write_packet(AVFormatContext *s, AVPacket *pkt) |
0 | 566 { |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
807
diff
changeset
|
567 AVCodecContext *codec = s->streams[pkt->stream_index]->codec; |
0 | 568 if (codec->codec_type == CODEC_TYPE_AUDIO) |
468 | 569 return swf_write_audio(s, codec, pkt->data, pkt->size); |
0 | 570 else |
468 | 571 return swf_write_video(s, codec, pkt->data, pkt->size); |
0 | 572 } |
573 | |
574 static int swf_write_trailer(AVFormatContext *s) | |
575 { | |
576 SWFContext *swf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
577 ByteIOContext *pb = s->pb; |
0 | 578 AVCodecContext *enc, *video_enc; |
579 int file_size, i; | |
580 | |
581 video_enc = NULL; | |
582 for(i=0;i<s->nb_streams;i++) { | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
807
diff
changeset
|
583 enc = s->streams[i]->codec; |
0 | 584 if (enc->codec_type == CODEC_TYPE_VIDEO) |
585 video_enc = enc; | |
586 } | |
587 | |
588 put_swf_tag(s, TAG_END); | |
589 put_swf_end_tag(s); | |
885 | 590 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
591 put_flush_packet(s->pb); |
0 | 592 |
593 /* patch file size and number of frames if not streamed */ | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
594 if (!url_is_streamed(s->pb) && video_enc) { |
0 | 595 file_size = url_ftell(pb); |
596 url_fseek(pb, 4, SEEK_SET); | |
597 put_le32(pb, file_size); | |
598 url_fseek(pb, swf->duration_pos, SEEK_SET); | |
599 put_le16(pb, video_enc->frame_number); | |
1643
20c25a594c49
seek back at the end of file after updating header
bcoudurier
parents:
1642
diff
changeset
|
600 url_fseek(pb, file_size, SEEK_SET); |
0 | 601 } |
602 return 0; | |
603 } | |
858
66cc656ea404
Replace CONFIG_ENCODERS/CONFIG_DECODERS with CONFIG_MUXERS/CONFIG_DEMUXERS
diego
parents:
820
diff
changeset
|
604 #endif //CONFIG_MUXERS |
0 | 605 |
359 | 606 /*********************************************/ |
607 /* Extract FLV encoded frame and MP3 from swf | |
608 Note that the detection of the real frame | |
609 is inaccurate at this point as it can be | |
885 | 610 quite tricky to determine, you almost certainly |
359 | 611 will get a bad audio/video sync */ |
0 | 612 |
613 static int get_swf_tag(ByteIOContext *pb, int *len_ptr) | |
614 { | |
615 int tag, len; | |
885 | 616 |
0 | 617 if (url_feof(pb)) |
618 return -1; | |
619 | |
620 tag = get_le16(pb); | |
621 len = tag & 0x3f; | |
622 tag = tag >> 6; | |
623 if (len == 0x3f) { | |
624 len = get_le32(pb); | |
625 } | |
806 | 626 // av_log(NULL, AV_LOG_DEBUG, "Tag: %d - Len: %d\n", tag, len); |
0 | 627 *len_ptr = len; |
628 return tag; | |
629 } | |
630 | |
631 | |
632 static int swf_probe(AVProbeData *p) | |
633 { | |
634 /* check file header */ | |
806 | 635 if ((p->buf[0] == 'F' || p->buf[0] == 'C') && p->buf[1] == 'W' && |
0 | 636 p->buf[2] == 'S') |
637 return AVPROBE_SCORE_MAX; | |
638 else | |
639 return 0; | |
640 } | |
641 | |
642 static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) | |
643 { | |
1641 | 644 SWFContext *swf = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
645 ByteIOContext *pb = s->pb; |
2310 | 646 int nbits, len, tag; |
359 | 647 |
806 | 648 tag = get_be32(pb) & 0xffffff00; |
649 | |
2309 | 650 if (tag == MKBETAG('C', 'W', 'S', 0)) { |
887 | 651 av_log(s, AV_LOG_ERROR, "Compressed SWF format not supported\n"); |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2164
diff
changeset
|
652 return AVERROR(EIO); |
806 | 653 } |
654 if (tag != MKBETAG('F', 'W', 'S', 0)) | |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2164
diff
changeset
|
655 return AVERROR(EIO); |
0 | 656 get_le32(pb); |
657 /* skip rectangle size */ | |
658 nbits = get_byte(pb) >> 3; | |
659 len = (4 * nbits - 3 + 7) / 8; | |
660 url_fskip(pb, len); | |
1889 | 661 swf->frame_rate = get_le16(pb); /* 8.8 fixed */ |
0 | 662 get_le16(pb); /* frame count */ |
885 | 663 |
359 | 664 swf->samples_per_frame = 0; |
2307
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
665 s->ctx_flags |= AVFMTCTX_NOHEADER; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
666 return 0; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
667 } |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
668 |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
669 static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
670 { |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
671 SWFContext *swf = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2402
diff
changeset
|
672 ByteIOContext *pb = s->pb; |
2307
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
673 AVStream *vst = NULL, *ast = NULL, *st = 0; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
674 int tag, len, i, frame, v; |
0 | 675 |
676 for(;;) { | |
677 tag = get_swf_tag(pb, &len); | |
2307
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
678 if (tag < 0) |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
679 return AVERROR(EIO); |
2309 | 680 if (tag == TAG_VIDEOSTREAM && !vst) { |
1637 | 681 int ch_id = get_le16(pb); |
359 | 682 get_le16(pb); |
683 get_le16(pb); | |
684 get_le16(pb); | |
685 get_byte(pb); | |
686 /* Check for FLV1 */ | |
1637 | 687 vst = av_new_stream(s, ch_id); |
2913 | 688 if (!vst) |
689 return -1; | |
1635 | 690 vst->codec->codec_type = CODEC_TYPE_VIDEO; |
691 vst->codec->codec_id = codec_get_id(swf_codec_tags, get_byte(pb)); | |
2307
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
692 av_set_pts_info(vst, 64, 256, swf->frame_rate); |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
693 vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
694 len -= 10; |
2309 | 695 } else if ((tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) && !ast) { |
0 | 696 /* streaming found */ |
1642 | 697 int sample_rate_code; |
0 | 698 get_byte(pb); |
699 v = get_byte(pb); | |
359 | 700 swf->samples_per_frame = get_le16(pb); |
1638 | 701 ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */ |
2913 | 702 if (!ast) |
703 return -1; | |
1638 | 704 swf->audio_stream_index = ast->index; |
1636 | 705 ast->codec->channels = 1 + (v&1); |
706 ast->codec->codec_type = CODEC_TYPE_AUDIO; | |
1833 | 707 ast->codec->codec_id = codec_get_id(swf_audio_codec_tags, (v>>4) & 15); |
2023 | 708 ast->need_parsing = AVSTREAM_PARSE_FULL; |
1642 | 709 sample_rate_code= (v>>2) & 3; |
710 if (!sample_rate_code) | |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2164
diff
changeset
|
711 return AVERROR(EIO); |
1642 | 712 ast->codec->sample_rate = 11025 << (sample_rate_code-1); |
1890
04f9a3ae30af
seems safer to set pts timebase to sample rate, fix some mp3
bcoudurier
parents:
1889
diff
changeset
|
713 av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); |
2307
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
714 len -= 4; |
2308 | 715 } else if (tag == TAG_VIDEOFRAME) { |
1637 | 716 int ch_id = get_le16(pb); |
1639 | 717 len -= 2; |
2309 | 718 for(i=0; i<s->nb_streams; i++) { |
887 | 719 st = s->streams[i]; |
1637 | 720 if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id) { |
721 frame = get_le16(pb); | |
1639 | 722 av_get_packet(pb, pkt, len-2); |
1889 | 723 pkt->pts = frame; |
1637 | 724 pkt->stream_index = st->index; |
725 return pkt->size; | |
359 | 726 } |
885 | 727 } |
359 | 728 } else if (tag == TAG_STREAMBLOCK) { |
1638 | 729 st = s->streams[swf->audio_stream_index]; |
730 if (st->codec->codec_id == CODEC_ID_MP3) { | |
731 url_fskip(pb, 4); | |
732 av_get_packet(pb, pkt, len-4); | |
1833 | 733 } else { // ADPCM, PCM |
734 av_get_packet(pb, pkt, len); | |
359 | 735 } |
1833 | 736 pkt->stream_index = st->index; |
737 return pkt->size; | |
1640 | 738 } else if (tag == TAG_JPEG2) { |
739 for (i=0; i<s->nb_streams; i++) { | |
740 st = s->streams[i]; | |
2307
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
741 if (st->id == -2) |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
742 break; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
743 } |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
744 if (i == s->nb_streams) { |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
745 vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */ |
2913 | 746 if (!vst) |
747 return -1; | |
2307
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
748 vst->codec->codec_type = CODEC_TYPE_VIDEO; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
749 vst->codec->codec_id = CODEC_ID_MJPEG; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
750 av_set_pts_info(vst, 64, 256, swf->frame_rate); |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
751 vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
752 st = vst; |
d5508f387614
add streams on the fly, swf is a streaming format and has no real header, correctly detect audio in RamboMJPEGAVP6_112K.swf now
bcoudurier
parents:
2289
diff
changeset
|
753 } |
2308 | 754 get_le16(pb); /* BITMAP_ID */ |
755 av_new_packet(pkt, len-2); | |
756 get_buffer(pb, pkt->data, 4); | |
2402
8decf7585a94
support swink created files which have soi/eoi broken tags reversed
bcoudurier
parents:
2310
diff
changeset
|
757 if (AV_RB32(pkt->data) == 0xffd8ffd9 || |
8decf7585a94
support swink created files which have soi/eoi broken tags reversed
bcoudurier
parents:
2310
diff
changeset
|
758 AV_RB32(pkt->data) == 0xffd9ffd8) { |
2308 | 759 /* old SWF files containing SOI/EOI as data start */ |
2402
8decf7585a94
support swink created files which have soi/eoi broken tags reversed
bcoudurier
parents:
2310
diff
changeset
|
760 /* files created by swink have reversed tag */ |
2308 | 761 pkt->size -= 4; |
762 get_buffer(pb, pkt->data, pkt->size); | |
763 } else { | |
764 get_buffer(pb, pkt->data + 4, pkt->size - 4); | |
765 } | |
766 pkt->stream_index = st->index; | |
767 return pkt->size; | |
0 | 768 } |
1639 | 769 url_fskip(pb, len); |
0 | 770 } |
771 return 0; | |
772 } | |
773 | |
774 static int swf_read_close(AVFormatContext *s) | |
775 { | |
2308 | 776 return 0; |
0 | 777 } |
778 | |
1169 | 779 #ifdef CONFIG_SWF_DEMUXER |
780 AVInputFormat swf_demuxer = { | |
0 | 781 "swf", |
782 "Flash format", | |
359 | 783 sizeof(SWFContext), |
0 | 784 swf_probe, |
785 swf_read_header, | |
786 swf_read_packet, | |
787 swf_read_close, | |
788 }; | |
1169 | 789 #endif |
790 #ifdef CONFIG_SWF_MUXER | |
791 AVOutputFormat swf_muxer = { | |
0 | 792 "swf", |
793 "Flash format", | |
794 "application/x-shockwave-flash", | |
795 "swf", | |
796 sizeof(SWFContext), | |
359 | 797 CODEC_ID_MP3, |
798 CODEC_ID_FLV1, | |
0 | 799 swf_write_header, |
800 swf_write_packet, | |
801 swf_write_trailer, | |
802 }; | |
1169 | 803 #endif |
2955
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
804 #ifdef CONFIG_AVM2_MUXER |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
805 AVOutputFormat avm2_muxer = { |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
806 "avm2", |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
807 "Flash 9 (AVM2) format", |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
808 "application/x-shockwave-flash", |
2959
1b7bf70aab74
unset extension, so code path, and guess format do not choose
bcoudurier
parents:
2955
diff
changeset
|
809 NULL, |
2955
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
810 sizeof(SWFContext), |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
811 CODEC_ID_MP3, |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
812 CODEC_ID_FLV1, |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
813 swf_write_header, |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
814 swf_write_packet, |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
815 swf_write_trailer, |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
816 }; |
b2d1cd7ab383
new avm2 (flash 9) muxer, patch by Paul Egan, paulegan at mail dot com
bcoudurier
parents:
2913
diff
changeset
|
817 #endif |