annotate swfdec.c @ 5102:81c37b782fba libavformat

Use ff_neterrno instead of errno in tcp.c. If ff_neterrno() is checked instead of errno, that's probably what should be used in the return value. As a sideeffect, this gives better compatibility with Windows (CE), where network errors aren't visible in errno.) patch by Martin Storsj, martin martin st
author diego
date Wed, 15 Jul 2009 05:52:49 +0000
parents 33a244b7ca65
children 536e5527c1e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
3357
5f8a6b9d8f87 cosmetics, add demuxer word
bcoudurier
parents: 3304
diff changeset
2 * Flash Compatible Streaming Format demuxer
4251
77e0c7511d41 cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 4201
diff changeset
3 * Copyright (c) 2000 Fabrice Bellard
77e0c7511d41 cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 4201
diff changeset
4 * Copyright (c) 2003 Tinic Uro
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21 */
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 2959
diff changeset
22
4201
7d2f3f1b68d8 Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents: 3424
diff changeset
23 #include "libavutil/intreadwrite.h"
3302
171f5664d129 split swf de/muxer
bcoudurier
parents: 3286
diff changeset
24 #include "swf.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 static int get_swf_tag(ByteIOContext *pb, int *len_ptr)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28 int tag, len;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 858
diff changeset
29
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 if (url_feof(pb))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 tag = get_le16(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34 len = tag & 0x3f;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35 tag = tag >> 6;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36 if (len == 0x3f) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 len = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38 }
806
e1007d19f28d tell the user if compressed swf found
alex
parents: 775
diff changeset
39 // av_log(NULL, AV_LOG_DEBUG, "Tag: %d - Len: %d\n", tag, len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 *len_ptr = len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 return tag;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 static int swf_probe(AVProbeData *p)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 /* check file header */
806
e1007d19f28d tell the user if compressed swf found
alex
parents: 775
diff changeset
48 if ((p->buf[0] == 'F' || p->buf[0] == 'C') && p->buf[1] == 'W' &&
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49 p->buf[2] == 'S')
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 return AVPROBE_SCORE_MAX;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56 {
1641
ea284c26b0f4 priv_data is allocated internally
bcoudurier
parents: 1640
diff changeset
57 SWFContext *swf = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2402
diff changeset
58 ByteIOContext *pb = s->pb;
2310
91a6c2b29b7b remove now useless vars
bcoudurier
parents: 2309
diff changeset
59 int nbits, len, tag;
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
60
806
e1007d19f28d tell the user if compressed swf found
alex
parents: 775
diff changeset
61 tag = get_be32(pb) & 0xffffff00;
e1007d19f28d tell the user if compressed swf found
alex
parents: 775
diff changeset
62
2309
15c426951f7b cosmetics, braces/parenthesis style
bcoudurier
parents: 2308
diff changeset
63 if (tag == MKBETAG('C', 'W', 'S', 0)) {
887
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 885
diff changeset
64 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
65 return AVERROR(EIO);
806
e1007d19f28d tell the user if compressed swf found
alex
parents: 775
diff changeset
66 }
e1007d19f28d tell the user if compressed swf found
alex
parents: 775
diff changeset
67 if (tag != MKBETAG('F', 'W', 'S', 0))
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2164
diff changeset
68 return AVERROR(EIO);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 /* skip rectangle size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 nbits = get_byte(pb) >> 3;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 len = (4 * nbits - 3 + 7) / 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
73 url_fskip(pb, len);
1889
e81bae269ae1 fix pts handling
bcoudurier
parents: 1882
diff changeset
74 swf->frame_rate = get_le16(pb); /* 8.8 fixed */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 get_le16(pb); /* frame count */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 858
diff changeset
76
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
77 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
78 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
79 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
80 }
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
81
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
82 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
83 {
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
84 SWFContext *swf = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2402
diff changeset
85 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
86 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
87 int tag, len, i, frame, v;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 for(;;) {
4707
f153437e1ac0 Set pkt->pos correctly (to the start of header of the packet) in swfdec.
reimar
parents: 4706
diff changeset
90 uint64_t pos = url_ftell(pb);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91 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
92 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
93 return AVERROR(EIO);
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
94 if (tag == TAG_VIDEOSTREAM) {
1637
50bbf9658436 use ch_id as AVStream id and simplify
bcoudurier
parents: 1636
diff changeset
95 int ch_id = get_le16(pb);
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
96 len -= 2;
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
97
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
98 for (i=0; i<s->nb_streams; i++) {
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
99 st = s->streams[i];
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
100 if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id)
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
101 goto skip;
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
102 }
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
103
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
104 get_le16(pb);
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
105 get_le16(pb);
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
106 get_le16(pb);
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
107 get_byte(pb);
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
108 /* Check for FLV1 */
1637
50bbf9658436 use ch_id as AVStream id and simplify
bcoudurier
parents: 1636
diff changeset
109 vst = av_new_stream(s, ch_id);
2913
f05588003063 check av_new_stream return value
bcoudurier
parents: 2771
diff changeset
110 if (!vst)
f05588003063 check av_new_stream return value
bcoudurier
parents: 2771
diff changeset
111 return -1;
1635
59d2c40950ca always export videostreams
bcoudurier
parents: 1623
diff changeset
112 vst->codec->codec_type = CODEC_TYPE_VIDEO;
5058
33a244b7ca65 Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents: 4715
diff changeset
113 vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, get_byte(pb));
4715
2b75450ca0a9 swf timestamps are 16 bits
bcoudurier
parents: 4714
diff changeset
114 av_set_pts_info(vst, 16, 256, swf->frame_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
115 vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
116 len -= 8;
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
117 } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
118 /* streaming found */
1642
8b62e4e73069 simplify
bcoudurier
parents: 1641
diff changeset
119 int sample_rate_code;
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
120
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
121 for (i=0; i<s->nb_streams; i++) {
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
122 st = s->streams[i];
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
123 if (st->codec->codec_type == CODEC_TYPE_AUDIO && st->id == -1)
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
124 goto skip;
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
125 }
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
126
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127 get_byte(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
128 v = get_byte(pb);
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
129 swf->samples_per_frame = get_le16(pb);
1638
0c6b7ac24cd7 swf can contain only one audio track, simplify
bcoudurier
parents: 1637
diff changeset
130 ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */
2913
f05588003063 check av_new_stream return value
bcoudurier
parents: 2771
diff changeset
131 if (!ast)
f05588003063 check av_new_stream return value
bcoudurier
parents: 2771
diff changeset
132 return -1;
1636
783969dab069 always export audiostreams
bcoudurier
parents: 1635
diff changeset
133 ast->codec->channels = 1 + (v&1);
783969dab069 always export audiostreams
bcoudurier
parents: 1635
diff changeset
134 ast->codec->codec_type = CODEC_TYPE_AUDIO;
5058
33a244b7ca65 Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents: 4715
diff changeset
135 ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
2023
a3e79d6e4e3c add an enum for need_parsing
aurel
parents: 2001
diff changeset
136 ast->need_parsing = AVSTREAM_PARSE_FULL;
1642
8b62e4e73069 simplify
bcoudurier
parents: 1641
diff changeset
137 sample_rate_code= (v>>2) & 3;
8b62e4e73069 simplify
bcoudurier
parents: 1641
diff changeset
138 if (!sample_rate_code)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2164
diff changeset
139 return AVERROR(EIO);
1642
8b62e4e73069 simplify
bcoudurier
parents: 1641
diff changeset
140 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
141 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
142 len -= 4;
2308
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
143 } else if (tag == TAG_VIDEOFRAME) {
1637
50bbf9658436 use ch_id as AVStream id and simplify
bcoudurier
parents: 1636
diff changeset
144 int ch_id = get_le16(pb);
1639
4740223bfd8e simplify
bcoudurier
parents: 1638
diff changeset
145 len -= 2;
2309
15c426951f7b cosmetics, braces/parenthesis style
bcoudurier
parents: 2308
diff changeset
146 for(i=0; i<s->nb_streams; i++) {
887
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 885
diff changeset
147 st = s->streams[i];
1637
50bbf9658436 use ch_id as AVStream id and simplify
bcoudurier
parents: 1636
diff changeset
148 if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id) {
50bbf9658436 use ch_id as AVStream id and simplify
bcoudurier
parents: 1636
diff changeset
149 frame = get_le16(pb);
1639
4740223bfd8e simplify
bcoudurier
parents: 1638
diff changeset
150 av_get_packet(pb, pkt, len-2);
4707
f153437e1ac0 Set pkt->pos correctly (to the start of header of the packet) in swfdec.
reimar
parents: 4706
diff changeset
151 pkt->pos = pos;
1889
e81bae269ae1 fix pts handling
bcoudurier
parents: 1882
diff changeset
152 pkt->pts = frame;
1637
50bbf9658436 use ch_id as AVStream id and simplify
bcoudurier
parents: 1636
diff changeset
153 pkt->stream_index = st->index;
50bbf9658436 use ch_id as AVStream id and simplify
bcoudurier
parents: 1636
diff changeset
154 return pkt->size;
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
155 }
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 858
diff changeset
156 }
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
157 } else if (tag == TAG_STREAMBLOCK) {
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
158 for (i = 0; i < s->nb_streams; i++) {
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
159 st = s->streams[i];
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
160 if (st->codec->codec_type == CODEC_TYPE_AUDIO && st->id == -1) {
1638
0c6b7ac24cd7 swf can contain only one audio track, simplify
bcoudurier
parents: 1637
diff changeset
161 if (st->codec->codec_id == CODEC_ID_MP3) {
0c6b7ac24cd7 swf can contain only one audio track, simplify
bcoudurier
parents: 1637
diff changeset
162 url_fskip(pb, 4);
0c6b7ac24cd7 swf can contain only one audio track, simplify
bcoudurier
parents: 1637
diff changeset
163 av_get_packet(pb, pkt, len-4);
1833
09a67819763e support for adpcm swf, pcm
bcoudurier
parents: 1827
diff changeset
164 } else { // ADPCM, PCM
09a67819763e support for adpcm swf, pcm
bcoudurier
parents: 1827
diff changeset
165 av_get_packet(pb, pkt, len);
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
166 }
4707
f153437e1ac0 Set pkt->pos correctly (to the start of header of the packet) in swfdec.
reimar
parents: 4706
diff changeset
167 pkt->pos = pos;
1833
09a67819763e support for adpcm swf, pcm
bcoudurier
parents: 1827
diff changeset
168 pkt->stream_index = st->index;
09a67819763e support for adpcm swf, pcm
bcoudurier
parents: 1827
diff changeset
169 return pkt->size;
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
170 }
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
171 }
1640
ec1236a03504 enable mjpeg in swf
bcoudurier
parents: 1639
diff changeset
172 } else if (tag == TAG_JPEG2) {
ec1236a03504 enable mjpeg in swf
bcoudurier
parents: 1639
diff changeset
173 for (i=0; i<s->nb_streams; i++) {
ec1236a03504 enable mjpeg in swf
bcoudurier
parents: 1639
diff changeset
174 st = s->streams[i];
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
175 if (st->codec->codec_id == CODEC_ID_MJPEG && st->id == -2)
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
176 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
177 }
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
178 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
179 vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */
2913
f05588003063 check av_new_stream return value
bcoudurier
parents: 2771
diff changeset
180 if (!vst)
f05588003063 check av_new_stream return value
bcoudurier
parents: 2771
diff changeset
181 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
182 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
183 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
184 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
185 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
186 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
187 }
2308
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
188 get_le16(pb); /* BITMAP_ID */
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
189 av_new_packet(pkt, len-2);
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
190 get_buffer(pb, pkt->data, 4);
2402
8decf7585a94 support swink created files which have soi/eoi broken tags reversed
bcoudurier
parents: 2310
diff changeset
191 if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
8decf7585a94 support swink created files which have soi/eoi broken tags reversed
bcoudurier
parents: 2310
diff changeset
192 AV_RB32(pkt->data) == 0xffd9ffd8) {
2308
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
193 /* 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
194 /* files created by swink have reversed tag */
2308
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
195 pkt->size -= 4;
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
196 get_buffer(pb, pkt->data, pkt->size);
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
197 } else {
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
198 get_buffer(pb, pkt->data + 4, pkt->size - 4);
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
199 }
4707
f153437e1ac0 Set pkt->pos correctly (to the start of header of the packet) in swfdec.
reimar
parents: 4706
diff changeset
200 pkt->pos = pos;
2308
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
201 pkt->stream_index = st->index;
c12d367e9246 cosmetics, indentation
bcoudurier
parents: 2307
diff changeset
202 return pkt->size;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
203 }
4706
a3f213a1d3a8 fix swf seeking by fixing new stream detection
bcoudurier
parents: 4251
diff changeset
204 skip:
1639
4740223bfd8e simplify
bcoudurier
parents: 1638
diff changeset
205 url_fskip(pb, len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
207 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
208 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
209
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
210 AVInputFormat swf_demuxer = {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
211 "swf",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 3357
diff changeset
212 NULL_IF_CONFIG_SMALL("Flash format"),
359
e9232aa21976 - made --extra-cflags option work on darwin
michael
parents: 325
diff changeset
213 sizeof(SWFContext),
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 swf_probe,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
215 swf_read_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
216 swf_read_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
217 };