annotate rm.c @ 1258:558c75bd81a0 libavformat

attribute_deprecated
author michael
date Sun, 20 Aug 2006 10:42:11 +0000
parents d18cc9a1fd02
children 770363b669aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * "Real" compatible mux and demux.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2000, 2001 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 888
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21 /* in ms */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
22 #define BUFFER_DURATION 0
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24 typedef struct {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25 int nb_packets;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 int packet_total_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27 int packet_max_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28 /* codec related output */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 int bit_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 float frame_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 int nb_frames; /* current frame number */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32 int total_frames; /* total number of frames */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 int num;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34 AVCodecContext *enc;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35 } StreamInfo;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 typedef struct {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38 StreamInfo streams[2];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 StreamInfo *audio_stream, *video_stream;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 int data_pos; /* position of the data after the header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 int nb_packets;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
42 int old_format;
609
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
43 int current_stream;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
44 int remaining_len;
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
45 /// Audio descrambling matrix parameters
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
46 uint8_t *audiobuf; ///< place to store reordered audio data
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
47 int64_t audiotimestamp; ///< Audio packet timestamp
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
48 int sub_packet_cnt; // Subpacket counter, used while reading
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
49 int sub_packet_size, sub_packet_h, coded_framesize; ///< Descrambling parameters from container
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
50 int audio_stream_num; ///< Stream number for audio packets
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
51 int audio_pkt_cnt; ///< Output packet counter
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
52 int audio_framesize; /// Audio frame size from container
1105
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
53 int sub_packet_lengths[16]; /// Length of each aac subpacket
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54 } RMContext;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55
858
66cc656ea404 Replace CONFIG_ENCODERS/CONFIG_DECODERS with CONFIG_MUXERS/CONFIG_DEMUXERS
diego
parents: 820
diff changeset
56 #ifdef CONFIG_MUXERS
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57 static void put_str(ByteIOContext *s, const char *tag)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 put_be16(s,strlen(tag));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
60 while (*tag) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 put_byte(s, *tag++);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
63 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
65 static void put_str8(ByteIOContext *s, const char *tag)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
66 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67 put_byte(s, strlen(tag));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 while (*tag) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 put_byte(s, *tag++);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
73 static void rv10_write_header(AVFormatContext *ctx,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
74 int data_size, int index_pos)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
76 RMContext *rm = ctx->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
77 ByteIOContext *s = &ctx->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78 StreamInfo *stream;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79 unsigned char *data_offset_ptr, *start_ptr;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 const char *desc, *mimetype;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81 int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 int bit_rate, v, duration, flags, data_pos;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
83
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84 start_ptr = s->buf_ptr;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86 put_tag(s, ".RMF");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
87 put_be32(s,18); /* header size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88 put_be16(s,0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 put_be32(s,0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 put_be32(s,4 + ctx->nb_streams); /* num headers */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 put_tag(s,"PROP");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93 put_be32(s, 50);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 put_be16(s, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 packet_max_size = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 packet_total_size = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 nb_packets = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
98 bit_rate = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99 duration = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100 for(i=0;i<ctx->nb_streams;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 StreamInfo *stream = &rm->streams[i];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102 bit_rate += stream->bit_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103 if (stream->packet_max_size > packet_max_size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 packet_max_size = stream->packet_max_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105 nb_packets += stream->nb_packets;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
106 packet_total_size += stream->packet_total_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107 /* select maximum duration */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
108 v = (int) (1000.0 * (float)stream->total_frames / stream->frame_rate);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
109 if (v > duration)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
110 duration = v;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
111 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
112 put_be32(s, bit_rate); /* max bit rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
113 put_be32(s, bit_rate); /* avg bit rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
114 put_be32(s, packet_max_size); /* max packet size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
115 if (nb_packets > 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
116 packet_avg_size = packet_total_size / nb_packets;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
117 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
118 packet_avg_size = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
119 put_be32(s, packet_avg_size); /* avg packet size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
120 put_be32(s, nb_packets); /* num packets */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
121 put_be32(s, duration); /* duration */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
122 put_be32(s, BUFFER_DURATION); /* preroll */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
123 put_be32(s, index_pos); /* index offset */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
124 /* computation of data the data offset */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
125 data_offset_ptr = s->buf_ptr;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
126 put_be32(s, 0); /* data offset : will be patched after */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127 put_be16(s, ctx->nb_streams); /* num streams */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
128 flags = 1 | 2; /* save allowed & perfect play */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
129 if (url_is_streamed(s))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
130 flags |= 4; /* live broadcast */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
131 put_be16(s, flags);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
132
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
133 /* comments */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
134
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
135 put_tag(s,"CONT");
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
136 size = strlen(ctx->title) + strlen(ctx->author) + strlen(ctx->copyright) +
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
137 strlen(ctx->comment) + 4 * 2 + 10;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
138 put_be32(s,size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
139 put_be16(s,0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
140 put_str(s, ctx->title);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
141 put_str(s, ctx->author);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
142 put_str(s, ctx->copyright);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
143 put_str(s, ctx->comment);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
144
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
145 for(i=0;i<ctx->nb_streams;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
146 int codec_data_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
147
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
148 stream = &rm->streams[i];
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
149
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
150 if (stream->enc->codec_type == CODEC_TYPE_AUDIO) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
151 desc = "The Audio Stream";
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
152 mimetype = "audio/x-pn-realaudio";
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
153 codec_data_size = 73;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
154 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
155 desc = "The Video Stream";
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
156 mimetype = "video/x-pn-realvideo";
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
157 codec_data_size = 34;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
158 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
159
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
160 put_tag(s,"MDPR");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
161 size = 10 + 9 * 4 + strlen(desc) + strlen(mimetype) + codec_data_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
162 put_be32(s, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
163 put_be16(s, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
164
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
165 put_be16(s, i); /* stream number */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
166 put_be32(s, stream->bit_rate); /* max bit rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
167 put_be32(s, stream->bit_rate); /* avg bit rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
168 put_be32(s, stream->packet_max_size); /* max packet size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
169 if (stream->nb_packets > 0)
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
170 packet_avg_size = stream->packet_total_size /
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
171 stream->nb_packets;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
172 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
173 packet_avg_size = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
174 put_be32(s, packet_avg_size); /* avg packet size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
175 put_be32(s, 0); /* start time */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
176 put_be32(s, BUFFER_DURATION); /* preroll */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
177 /* duration */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
178 if (url_is_streamed(s) || !stream->total_frames)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
179 put_be32(s, (int)(3600 * 1000));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
180 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
181 put_be32(s, (int)(stream->total_frames * 1000 / stream->frame_rate));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
182 put_str8(s, desc);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
183 put_str8(s, mimetype);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
184 put_be32(s, codec_data_size);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
185
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
186 if (stream->enc->codec_type == CODEC_TYPE_AUDIO) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
187 int coded_frame_size, fscode, sample_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
188 sample_rate = stream->enc->sample_rate;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
189 coded_frame_size = (stream->enc->bit_rate *
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
190 stream->enc->frame_size) / (8 * sample_rate);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
191 /* audio codec info */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
192 put_tag(s, ".ra");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
193 put_byte(s, 0xfd);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
194 put_be32(s, 0x00040000); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
195 put_tag(s, ".ra4");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
196 put_be32(s, 0x01b53530); /* stream length */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
197 put_be16(s, 4); /* unknown */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
198 put_be32(s, 0x39); /* header size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
199
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
200 switch(sample_rate) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
201 case 48000:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
202 case 24000:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
203 case 12000:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
204 fscode = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
205 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
207 case 44100:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
208 case 22050:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
209 case 11025:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
210 fscode = 2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
211 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
212 case 32000:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
213 case 16000:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 case 8000:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
215 fscode = 3;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
216 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
217 put_be16(s, fscode); /* codec additional info, for AC3, seems
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
218 to be a frequency code */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
219 /* special hack to compensate rounding errors... */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
220 if (coded_frame_size == 557)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
221 coded_frame_size--;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
222 put_be32(s, coded_frame_size); /* frame length */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
223 put_be32(s, 0x51540); /* unknown */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
224 put_be32(s, 0x249f0); /* unknown */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
225 put_be32(s, 0x249f0); /* unknown */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
226 put_be16(s, 0x01);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
227 /* frame length : seems to be very important */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
228 put_be16(s, coded_frame_size);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
229 put_be32(s, 0); /* unknown */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
230 put_be16(s, stream->enc->sample_rate); /* sample rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
231 put_be32(s, 0x10); /* unknown */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
232 put_be16(s, stream->enc->channels);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
233 put_str8(s, "Int0"); /* codec name */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
234 put_str8(s, "dnet"); /* codec name */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
235 put_be16(s, 0); /* title length */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
236 put_be16(s, 0); /* author length */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
237 put_be16(s, 0); /* copyright length */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
238 put_byte(s, 0); /* end of header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
239 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
240 /* video codec info */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
241 put_be32(s,34); /* size */
614
cbcb3ae970c8 rv20 encoding
michael
parents: 613
diff changeset
242 if(stream->enc->codec_id == CODEC_ID_RV10)
cbcb3ae970c8 rv20 encoding
michael
parents: 613
diff changeset
243 put_tag(s,"VIDORV10");
cbcb3ae970c8 rv20 encoding
michael
parents: 613
diff changeset
244 else
cbcb3ae970c8 rv20 encoding
michael
parents: 613
diff changeset
245 put_tag(s,"VIDORV20");
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
246 put_be16(s, stream->enc->width);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
247 put_be16(s, stream->enc->height);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
248 put_be16(s, (int) stream->frame_rate); /* frames per seconds ? */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
249 put_be32(s,0); /* unknown meaning */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
250 put_be16(s, (int) stream->frame_rate); /* unknown meaning */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
251 put_be32(s,0); /* unknown meaning */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
252 put_be16(s, 8); /* unknown meaning */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
253 /* Seems to be the codec version: only use basic H263. The next
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
254 versions seems to add a diffential DC coding as in
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
255 MPEG... nothing new under the sun */
614
cbcb3ae970c8 rv20 encoding
michael
parents: 613
diff changeset
256 if(stream->enc->codec_id == CODEC_ID_RV10)
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
257 put_be32(s,0x10000000);
614
cbcb3ae970c8 rv20 encoding
michael
parents: 613
diff changeset
258 else
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
259 put_be32(s,0x20103001);
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
260 //put_be32(s,0x10003000);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
261 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
262 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
263
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
264 /* patch data offset field */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
265 data_pos = s->buf_ptr - start_ptr;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
266 rm->data_pos = data_pos;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
267 data_offset_ptr[0] = data_pos >> 24;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
268 data_offset_ptr[1] = data_pos >> 16;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
269 data_offset_ptr[2] = data_pos >> 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
270 data_offset_ptr[3] = data_pos;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
271
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
272 /* data stream */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
273 put_tag(s,"DATA");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
274 put_be32(s,data_size + 10 + 8);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
275 put_be16(s,0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
276
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
277 put_be32(s, nb_packets); /* number of packets */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
278 put_be32(s,0); /* next data header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
279 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
280
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
281 static void write_packet_header(AVFormatContext *ctx, StreamInfo *stream,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
282 int length, int key_frame)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
283 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
284 int timestamp;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
285 ByteIOContext *s = &ctx->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
286
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
287 stream->nb_packets++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
288 stream->packet_total_size += length;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
289 if (length > stream->packet_max_size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
290 stream->packet_max_size = length;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
291
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
292 put_be16(s,0); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
293 put_be16(s,length + 12);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
294 put_be16(s, stream->num); /* stream number */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
295 timestamp = (1000 * (float)stream->nb_frames) / stream->frame_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
296 put_be32(s, timestamp); /* timestamp */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
297 put_byte(s, 0); /* reserved */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
298 put_byte(s, key_frame ? 2 : 0); /* flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
299 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
300
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
301 static int rm_write_header(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
302 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
303 RMContext *rm = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
304 StreamInfo *stream;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
305 int n;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
306 AVCodecContext *codec;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
307
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
308 for(n=0;n<s->nb_streams;n++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
309 s->streams[n]->id = n;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
310 codec = s->streams[n]->codec;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
311 stream = &rm->streams[n];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
312 memset(stream, 0, sizeof(StreamInfo));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
313 stream->num = n;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
314 stream->bit_rate = codec->bit_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
315 stream->enc = codec;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
316
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
317 switch(codec->codec_type) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
318 case CODEC_TYPE_AUDIO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
319 rm->audio_stream = stream;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
320 stream->frame_rate = (float)codec->sample_rate / (float)codec->frame_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
321 /* XXX: dummy values */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
322 stream->packet_max_size = 1024;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
323 stream->nb_packets = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
324 stream->total_frames = stream->nb_packets;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
325 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
326 case CODEC_TYPE_VIDEO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
327 rm->video_stream = stream;
743
af4e24d6310c switch to native time bases
michael
parents: 736
diff changeset
328 stream->frame_rate = (float)codec->time_base.den / (float)codec->time_base.num;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
329 /* XXX: dummy values */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
330 stream->packet_max_size = 4096;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
331 stream->nb_packets = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
332 stream->total_frames = stream->nb_packets;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
333 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
334 default:
537
558a093b04db do not call (av_)abort()
michael
parents: 509
diff changeset
335 return -1;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
336 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
337 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
338
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
339 rv10_write_header(s, 0, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
340 put_flush_packet(&s->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
341 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
342 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
343
470
334e08488ad1 correctly interleave packets during encoding
michael
parents: 468
diff changeset
344 static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
345 {
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 33
diff changeset
346 uint8_t *buf1;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
347 RMContext *rm = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
348 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
349 StreamInfo *stream = rm->audio_stream;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
350 int i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
351
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
352 /* XXX: suppress this malloc */
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 33
diff changeset
353 buf1= (uint8_t*) av_malloc( size * sizeof(uint8_t) );
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
354
470
334e08488ad1 correctly interleave packets during encoding
michael
parents: 468
diff changeset
355 write_packet_header(s, stream, size, !!(flags & PKT_FLAG_KEY));
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
356
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
357 /* for AC3, the words seems to be reversed */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
358 for(i=0;i<size;i+=2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
359 buf1[i] = buf[i+1];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
360 buf1[i+1] = buf[i];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
361 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
362 put_buffer(pb, buf1, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
363 put_flush_packet(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
364 stream->nb_frames++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
365 av_free(buf1);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
366 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
367 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
368
470
334e08488ad1 correctly interleave packets during encoding
michael
parents: 468
diff changeset
369 static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int flags)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
370 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
371 RMContext *rm = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
372 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
373 StreamInfo *stream = rm->video_stream;
470
334e08488ad1 correctly interleave packets during encoding
michael
parents: 468
diff changeset
374 int key_frame = !!(flags & PKT_FLAG_KEY);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
375
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
376 /* XXX: this is incorrect: should be a parameter */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
377
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
378 /* Well, I spent some time finding the meaning of these bits. I am
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
379 not sure I understood everything, but it works !! */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
380 #if 1
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
381 write_packet_header(s, stream, size + 7, key_frame);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
382 /* bit 7: '1' if final packet of a frame converted in several packets */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
383 put_byte(pb, 0x81);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
384 /* bit 7: '1' if I frame. bits 6..0 : sequence number in current
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
385 frame starting from 1 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
386 if (key_frame) {
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
387 put_byte(pb, 0x81);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
388 } else {
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
389 put_byte(pb, 0x01);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
390 }
611
8fcecf36e64c rm encoding fix
michael
parents: 610
diff changeset
391 put_be16(pb, 0x4000 + (size)); /* total frame size */
8fcecf36e64c rm encoding fix
michael
parents: 610
diff changeset
392 put_be16(pb, 0x4000 + (size)); /* offset from the start or the end */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
393 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
394 /* full frame */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
395 write_packet_header(s, size + 6);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
396 put_byte(pb, 0xc0);
611
8fcecf36e64c rm encoding fix
michael
parents: 610
diff changeset
397 put_be16(pb, 0x4000 + size); /* total frame size */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
398 put_be16(pb, 0x4000 + packet_number * 126); /* position in stream */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
399 #endif
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
400 put_byte(pb, stream->nb_frames & 0xff);
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
401
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
402 put_buffer(pb, buf, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
403 put_flush_packet(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
404
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
405 stream->nb_frames++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
406 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
407 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
408
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 370
diff changeset
409 static int rm_write_packet(AVFormatContext *s, AVPacket *pkt)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
410 {
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
411 if (s->streams[pkt->stream_index]->codec->codec_type ==
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
412 CODEC_TYPE_AUDIO)
470
334e08488ad1 correctly interleave packets during encoding
michael
parents: 468
diff changeset
413 return rm_write_audio(s, pkt->data, pkt->size, pkt->flags);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
414 else
470
334e08488ad1 correctly interleave packets during encoding
michael
parents: 468
diff changeset
415 return rm_write_video(s, pkt->data, pkt->size, pkt->flags);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
416 }
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
417
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
418 static int rm_write_trailer(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
419 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
420 RMContext *rm = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
421 int data_size, index_pos, i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
422 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
423
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
424 if (!url_is_streamed(&s->pb)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
425 /* end of file: finish to write header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
426 index_pos = url_fseek(pb, 0, SEEK_CUR);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
427 data_size = index_pos - rm->data_pos;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
428
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
429 /* index */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
430 put_tag(pb, "INDX");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
431 put_be32(pb, 10 + 10 * s->nb_streams);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
432 put_be16(pb, 0);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
433
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
434 for(i=0;i<s->nb_streams;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
435 put_be32(pb, 0); /* zero indices */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
436 put_be16(pb, i); /* stream number */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
437 put_be32(pb, 0); /* next index */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
438 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
439 /* undocumented end header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
440 put_be32(pb, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
441 put_be32(pb, 0);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
442
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
443 url_fseek(pb, 0, SEEK_SET);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
444 for(i=0;i<s->nb_streams;i++)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
445 rm->streams[i].total_frames = rm->streams[i].nb_frames;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
446 rv10_write_header(s, data_size, index_pos);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
447 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
448 /* undocumented end header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
449 put_be32(pb, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
450 put_be32(pb, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
451 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
452 put_flush_packet(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
453 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
454 }
858
66cc656ea404 Replace CONFIG_ENCODERS/CONFIG_DECODERS with CONFIG_MUXERS/CONFIG_DEMUXERS
diego
parents: 820
diff changeset
455 #endif //CONFIG_MUXERS
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
456
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
457 /***************************************************/
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
458
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
459 static void get_str(ByteIOContext *pb, char *buf, int buf_size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
460 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
461 int len, i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
462 char *q;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
463
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
464 len = get_be16(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
465 q = buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
466 for(i=0;i<len;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
467 if (i < buf_size - 1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
468 *q++ = get_byte(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
469 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
470 *q = '\0';
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
471 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
472
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
473 static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
474 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
475 int len, i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
476 char *q;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
477
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
478 len = get_byte(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
479 q = buf;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
480 for(i=0;i<len;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
481 if (i < buf_size - 1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
482 *q++ = get_byte(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
483 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
484 *q = '\0';
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
485 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
486
1106
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
487 static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
488 int read_all)
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
489 {
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
490 RMContext *rm = s->priv_data;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
491 ByteIOContext *pb = &s->pb;
886
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
492 char buf[256];
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
493 uint32_t version;
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
494 int i;
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
495
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
496 /* ra type header */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
497 version = get_be32(pb); /* version */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
498 if (((version >> 16) & 0xff) == 3) {
886
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
499 int64_t startpos = url_ftell(pb);
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
500 /* very old version */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
501 for(i = 0; i < 14; i++)
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
502 get_byte(pb);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
503 get_str8(pb, s->title, sizeof(s->title));
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
504 get_str8(pb, s->author, sizeof(s->author));
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
505 get_str8(pb, s->copyright, sizeof(s->copyright));
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
506 get_str8(pb, s->comment, sizeof(s->comment));
886
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
507 if ((startpos + (version & 0xffff)) >= url_ftell(pb) + 2) {
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
508 // fourcc (should always be "lpcJ")
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
509 get_byte(pb);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
510 get_str8(pb, buf, sizeof(buf));
886
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
511 }
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
512 // Skip extra header crap (this should never happen)
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
513 if ((startpos + (version & 0xffff)) > url_ftell(pb))
7ed1351f8c7e Fix for Real "old" files version 3 with no 4cc. Fixes thankyou144.ra
rtognimp
parents: 885
diff changeset
514 url_fskip(pb, (version & 0xffff) + startpos - url_ftell(pb));
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
515 st->codec->sample_rate = 8000;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
516 st->codec->channels = 1;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
517 st->codec->codec_type = CODEC_TYPE_AUDIO;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
518 st->codec->codec_id = CODEC_ID_RA_144;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
519 } else {
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
520 int flavor, sub_packet_h, coded_framesize, sub_packet_size;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
521 /* old version (4) */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
522 get_be32(pb); /* .ra4 */
687
561f27e36bc4 ra288 demuxing support (doesnt really work, might be demuxer or decoder bug)
michael
parents: 652
diff changeset
523 get_be32(pb); /* data size */
561f27e36bc4 ra288 demuxing support (doesnt really work, might be demuxer or decoder bug)
michael
parents: 652
diff changeset
524 get_be16(pb); /* version2 */
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
525 get_be32(pb); /* header size */
687
561f27e36bc4 ra288 demuxing support (doesnt really work, might be demuxer or decoder bug)
michael
parents: 652
diff changeset
526 flavor= get_be16(pb); /* add codec info / flavor */
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
527 rm->coded_framesize = coded_framesize = get_be32(pb); /* coded frame size */
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
528 get_be32(pb); /* ??? */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
529 get_be32(pb); /* ??? */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
530 get_be32(pb); /* ??? */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
531 rm->sub_packet_h = sub_packet_h = get_be16(pb); /* 1 */
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
532 st->codec->block_align= get_be16(pb); /* frame size */
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
533 rm->sub_packet_size = sub_packet_size = get_be16(pb); /* sub packet size */
687
561f27e36bc4 ra288 demuxing support (doesnt really work, might be demuxer or decoder bug)
michael
parents: 652
diff changeset
534 get_be16(pb); /* ??? */
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
535 if (((version >> 16) & 0xff) == 5) {
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
536 get_be16(pb); get_be16(pb); get_be16(pb); }
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
537 st->codec->sample_rate = get_be16(pb);
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
538 get_be32(pb);
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
539 st->codec->channels = get_be16(pb);
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
540 if (((version >> 16) & 0xff) == 5) {
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
541 get_be32(pb);
887
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 886
diff changeset
542 buf[0] = get_byte(pb);
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 886
diff changeset
543 buf[1] = get_byte(pb);
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 886
diff changeset
544 buf[2] = get_byte(pb);
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 886
diff changeset
545 buf[3] = get_byte(pb);
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 886
diff changeset
546 buf[4] = 0;
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 886
diff changeset
547 } else {
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
548 get_str8(pb, buf, sizeof(buf)); /* desc */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
549 get_str8(pb, buf, sizeof(buf)); /* desc */
887
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 886
diff changeset
550 }
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
551 st->codec->codec_type = CODEC_TYPE_AUDIO;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
552 if (!strcmp(buf, "dnet")) {
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
553 st->codec->codec_id = CODEC_ID_AC3;
687
561f27e36bc4 ra288 demuxing support (doesnt really work, might be demuxer or decoder bug)
michael
parents: 652
diff changeset
554 } else if (!strcmp(buf, "28_8")) {
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
555 st->codec->codec_id = CODEC_ID_RA_288;
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
556 st->codec->extradata_size= 0;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
557 rm->audio_framesize = st->codec->block_align;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
558 st->codec->block_align = coded_framesize;
1079
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
559
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
560 if(rm->audio_framesize >= UINT_MAX / sub_packet_h){
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
561 av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n");
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
562 return -1;
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
563 }
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
564
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
565 rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
566 } else if (!strcmp(buf, "cook")) {
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
567 int codecdata_length, i;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
568 get_be16(pb); get_byte(pb);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
569 if (((version >> 16) & 0xff) == 5)
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
570 get_byte(pb);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
571 codecdata_length = get_be32(pb);
1079
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
572 if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
573 av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
574 return -1;
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
575 }
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
576
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
577 st->codec->codec_id = CODEC_ID_COOK;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
578 st->codec->extradata_size= codecdata_length;
884
2ece9c9dd94c malloc padding to avoid reading past the malloc()ed area.
henry
parents: 879
diff changeset
579 st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
580 for(i = 0; i < codecdata_length; i++)
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
581 ((uint8_t*)st->codec->extradata)[i] = get_byte(pb);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
582 rm->audio_framesize = st->codec->block_align;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
583 st->codec->block_align = rm->sub_packet_size;
1079
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
584
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
585 if(rm->audio_framesize >= UINT_MAX / sub_packet_h){
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
586 av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n");
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
587 return -1;
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
588 }
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
589
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
590 rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h);
1105
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
591 } else if (!strcmp(buf, "raac") || !strcmp(buf, "racp")) {
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
592 int codecdata_length, i;
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
593 get_be16(pb); get_byte(pb);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
594 if (((version >> 16) & 0xff) == 5)
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
595 get_byte(pb);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
596 st->codec->codec_id = CODEC_ID_AAC;
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
597 codecdata_length = get_be32(pb);
1106
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
598 if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
599 av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
600 return -1;
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
601 }
1105
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
602 if (codecdata_length >= 1) {
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
603 st->codec->extradata_size = codecdata_length - 1;
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
604 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
605 get_byte(pb);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
606 for(i = 0; i < st->codec->extradata_size; i++)
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
607 ((uint8_t*)st->codec->extradata)[i] = get_byte(pb);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
608 }
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
609 } else {
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
610 st->codec->codec_id = CODEC_ID_NONE;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
611 pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name),
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
612 buf);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
613 }
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
614 if (read_all) {
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
615 get_byte(pb);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
616 get_byte(pb);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
617 get_byte(pb);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
618
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
619 get_str8(pb, s->title, sizeof(s->title));
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
620 get_str8(pb, s->author, sizeof(s->author));
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
621 get_str8(pb, s->copyright, sizeof(s->copyright));
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
622 get_str8(pb, s->comment, sizeof(s->comment));
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
623 }
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
624 }
1106
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
625 return 0;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
626 }
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
627
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
628 static int rm_read_header_old(AVFormatContext *s, AVFormatParameters *ap)
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
629 {
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
630 RMContext *rm = s->priv_data;
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
631 AVStream *st;
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
632
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
633 rm->old_format = 1;
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
634 st = av_new_stream(s, 0);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
635 if (!st)
1106
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
636 return -1;
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
637 return rm_read_audio_stream_info(s, st, 1);
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
638 }
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
639
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
640 static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
641 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
642 RMContext *rm = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
643 AVStream *st;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
644 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
645 unsigned int tag, v;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
646 int tag_size, size, codec_data_size, i;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 33
diff changeset
647 int64_t codec_pos;
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 85
diff changeset
648 unsigned int h263_hack_version, start_time, duration;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
649 char buf[128];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
650 int flags = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
651
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
652 tag = get_le32(pb);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
653 if (tag == MKTAG('.', 'r', 'a', 0xfd)) {
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
654 /* very old .ra format */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
655 return rm_read_header_old(s, ap);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
656 } else if (tag != MKTAG('.', 'R', 'M', 'F')) {
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 470
diff changeset
657 return AVERROR_IO;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
658 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
659
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
660 get_be32(pb); /* header size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
661 get_be16(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
662 get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
663 get_be32(pb); /* number of headers */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
664
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
665 for(;;) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
666 if (url_feof(pb))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
667 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
668 tag = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
669 tag_size = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
670 get_be16(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
671 #if 0
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
672 printf("tag=%c%c%c%c (%08x) size=%d\n",
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
673 (tag) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
674 (tag >> 8) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
675 (tag >> 16) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
676 (tag >> 24) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
677 tag,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
678 tag_size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
679 #endif
736
82c34355e466 fixing broken_rv20_1mb_.rm
michael
parents: 708
diff changeset
680 if (tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A'))
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
681 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
682 switch(tag) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
683 case MKTAG('P', 'R', 'O', 'P'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
684 /* file header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
685 get_be32(pb); /* max bit rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
686 get_be32(pb); /* avg bit rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
687 get_be32(pb); /* max packet size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
688 get_be32(pb); /* avg packet size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
689 get_be32(pb); /* nb packets */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
690 get_be32(pb); /* duration */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
691 get_be32(pb); /* preroll */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
692 get_be32(pb); /* index offset */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
693 get_be32(pb); /* data offset */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
694 get_be16(pb); /* nb streams */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
695 flags = get_be16(pb); /* flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
696 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
697 case MKTAG('C', 'O', 'N', 'T'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
698 get_str(pb, s->title, sizeof(s->title));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
699 get_str(pb, s->author, sizeof(s->author));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
700 get_str(pb, s->copyright, sizeof(s->copyright));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
701 get_str(pb, s->comment, sizeof(s->comment));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
702 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
703 case MKTAG('M', 'D', 'P', 'R'):
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 85
diff changeset
704 st = av_new_stream(s, 0);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
705 if (!st)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
706 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
707 st->id = get_be16(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
708 get_be32(pb); /* max bit rate */
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
709 st->codec->bit_rate = get_be32(pb); /* bit rate */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
710 get_be32(pb); /* max packet size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
711 get_be32(pb); /* avg packet size */
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 85
diff changeset
712 start_time = get_be32(pb); /* start time */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
713 get_be32(pb); /* preroll */
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 85
diff changeset
714 duration = get_be32(pb); /* duration */
743
af4e24d6310c switch to native time bases
michael
parents: 736
diff changeset
715 st->start_time = start_time;
af4e24d6310c switch to native time bases
michael
parents: 736
diff changeset
716 st->duration = duration;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
717 get_str8(pb, buf, sizeof(buf)); /* desc */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
718 get_str8(pb, buf, sizeof(buf)); /* mimetype */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
719 codec_data_size = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
720 codec_pos = url_ftell(pb);
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
721 st->codec->codec_type = CODEC_TYPE_DATA;
607
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
722 av_set_pts_info(st, 64, 1, 1000);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
723
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
724 v = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
725 if (v == MKTAG(0xfd, 'a', 'r', '.')) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
726 /* ra type header */
1106
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
727 if (rm_read_audio_stream_info(s, st, 0))
8f78a071554d rm_read_audio_stream_info return type is not void
rtogni
parents: 1105
diff changeset
728 return -1;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
729 } else {
604
ed2709c1f49c next try at fixing rv20 decoding
michael
parents: 593
diff changeset
730 int fps, fps2;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
731 if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
732 fail1:
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
733 av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
593
a1f354e84965 skip unknown streams instead of failing
michael
parents: 592
diff changeset
734 goto skip;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
735 }
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
736 st->codec->codec_tag = get_le32(pb);
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
737 // av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
738 if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0')
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
739 && st->codec->codec_tag != MKTAG('R', 'V', '2', '0')
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
740 && st->codec->codec_tag != MKTAG('R', 'V', '3', '0')
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
741 && st->codec->codec_tag != MKTAG('R', 'V', '4', '0'))
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
742 goto fail1;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
743 st->codec->width = get_be16(pb);
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
744 st->codec->height = get_be16(pb);
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
745 st->codec->time_base.num= 1;
604
ed2709c1f49c next try at fixing rv20 decoding
michael
parents: 593
diff changeset
746 fps= get_be16(pb);
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
747 st->codec->codec_type = CODEC_TYPE_VIDEO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
748 get_be32(pb);
604
ed2709c1f49c next try at fixing rv20 decoding
michael
parents: 593
diff changeset
749 fps2= get_be16(pb);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
750 get_be16(pb);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
751
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
752 st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
1079
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
753
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
754 if(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
755 //check is redundant as get_buffer() will catch this
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
756 av_log(s, AV_LOG_ERROR, "st->codec->extradata_size too large\n");
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
757 return -1;
40e81416015d sanity checks some might have been exploitable
michael
parents: 979
diff changeset
758 }
884
2ece9c9dd94c malloc padding to avoid reading past the malloc()ed area.
henry
parents: 879
diff changeset
759 st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
760 get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
761
604
ed2709c1f49c next try at fixing rv20 decoding
michael
parents: 593
diff changeset
762 // av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
763 st->codec->time_base.den = fps * st->codec->time_base.num;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
764 /* modification of h263 codec version (!) */
604
ed2709c1f49c next try at fixing rv20 decoding
michael
parents: 593
diff changeset
765 #ifdef WORDS_BIGENDIAN
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
766 h263_hack_version = ((uint32_t*)st->codec->extradata)[1];
604
ed2709c1f49c next try at fixing rv20 decoding
michael
parents: 593
diff changeset
767 #else
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
768 h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]);
604
ed2709c1f49c next try at fixing rv20 decoding
michael
parents: 593
diff changeset
769 #endif
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
770 st->codec->sub_id = h263_hack_version;
638
5188094c6ec4 RV30/RV40 demuxing (untested)
michael
parents: 632
diff changeset
771 switch((h263_hack_version>>28)){
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
772 case 1: st->codec->codec_id = CODEC_ID_RV10; break;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
773 case 2: st->codec->codec_id = CODEC_ID_RV20; break;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
774 case 3: st->codec->codec_id = CODEC_ID_RV30; break;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
775 case 4: st->codec->codec_id = CODEC_ID_RV40; break;
638
5188094c6ec4 RV30/RV40 demuxing (untested)
michael
parents: 632
diff changeset
776 default: goto fail1;
5188094c6ec4 RV30/RV40 demuxing (untested)
michael
parents: 632
diff changeset
777 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
778 }
593
a1f354e84965 skip unknown streams instead of failing
michael
parents: 592
diff changeset
779 skip:
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
780 /* skip codec info */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
781 size = url_ftell(pb) - codec_pos;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
782 url_fskip(pb, codec_data_size - size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
783 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
784 case MKTAG('D', 'A', 'T', 'A'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
785 goto header_end;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
786 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
787 /* unknown tag: skip it */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
788 url_fskip(pb, tag_size - 10);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
789 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
790 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
791 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
792 header_end:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
793 rm->nb_packets = get_be32(pb); /* number of packets */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
794 if (!rm->nb_packets && (flags & 4))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
795 rm->nb_packets = 3600 * 25;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
796 get_be32(pb); /* next data header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
797 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
798
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
799 fail:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
800 for(i=0;i<s->nb_streams;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
801 av_free(s->streams[i]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
802 }
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 470
diff changeset
803 return AVERROR_IO;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
804 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
805
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
806 static int get_num(ByteIOContext *pb, int *len)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
807 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
808 int n, n1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
809
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
810 n = get_be16(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
811 (*len)-=2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
812 if (n >= 0x4000) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
813 return n - 0x4000;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
814 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
815 n1 = get_be16(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
816 (*len)-=2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
817 return (n << 16) | n1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
818 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
819 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
820
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
821 /* multiple of 20 bytes for ra144 (ugly) */
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
822 #define RAW_PACKET_SIZE 1000
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
823
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
824 static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
825 RMContext *rm = s->priv_data;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
826 ByteIOContext *pb = &s->pb;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
827 int len, num, res, i;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
828 AVStream *st;
632
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
829 uint32_t state=0xFFFFFFFF;
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
830
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
831 while(!url_feof(pb)){
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
832 *pos= url_ftell(pb);
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
833 if(rm->remaining_len > 0){
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
834 num= rm->current_stream;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
835 len= rm->remaining_len;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
836 *timestamp = AV_NOPTS_VALUE;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
837 *flags= 0;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
838 }else{
632
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
839 state= (state<<8) + get_byte(pb);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
840
632
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
841 if(state == MKBETAG('I', 'N', 'D', 'X')){
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
842 len = get_be16(pb) - 6;
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
843 if(len<0)
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
844 continue;
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
845 goto skip;
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
846 }
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
847
632
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
848 if(state > (unsigned)0xFFFF || state < 12)
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
849 continue;
632
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
850 len=state;
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
851 state= 0xFFFFFFFF;
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
852
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
853 num = get_be16(pb);
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
854 *timestamp = get_be32(pb);
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
855 res= get_byte(pb); /* reserved */
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
856 *flags = get_byte(pb); /* flags */
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
857
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
858
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
859 len -= 12;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
860 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
861 for(i=0;i<s->nb_streams;i++) {
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
862 st = s->streams[i];
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
863 if (num == st->id)
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
864 break;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
865 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
866 if (i == s->nb_streams) {
632
9f8fa2f4edfd skip INDX chunks
michael
parents: 614
diff changeset
867 skip:
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
868 /* skip packet if unknown number */
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
869 url_fskip(pb, len);
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
870 rm->remaining_len -= len;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
871 continue;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
872 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
873 *stream_index= i;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
874
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
875 return len;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
876 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
877 return -1;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
878 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
879
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
880 static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
881 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
882 RMContext *rm = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
883 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
884 AVStream *st;
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
885 int i, len, tmp, j;
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
886 int64_t timestamp, pos;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 33
diff changeset
887 uint8_t *ptr;
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
888 int flags;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
889
888
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
890 if (rm->audio_pkt_cnt) {
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
891 // If there are queued audio packet return them first
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
892 st = s->streams[rm->audio_stream_num];
1105
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
893 if (st->codec->codec_id == CODEC_ID_AAC)
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
894 av_get_packet(pb, pkt, rm->sub_packet_lengths[rm->sub_packet_cnt - rm->audio_pkt_cnt]);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
895 else {
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
896 av_new_packet(pkt, st->codec->block_align);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
897 memcpy(pkt->data, rm->audiobuf + st->codec->block_align *
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
898 (rm->sub_packet_h * rm->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
899 st->codec->block_align);
1105
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
900 }
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
901 rm->audio_pkt_cnt--;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
902 pkt->flags = 0;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
903 pkt->stream_index = rm->audio_stream_num;
888
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
904 } else if (rm->old_format) {
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
905 st = s->streams[0];
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
906 if (st->codec->codec_id == CODEC_ID_RA_288) {
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
907 int x, y;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
908
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
909 for (y = 0; y < rm->sub_packet_h; y++)
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
910 for (x = 0; x < rm->sub_packet_h/2; x++)
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
911 if (get_buffer(pb, rm->audiobuf+x*2*rm->audio_framesize+y*rm->coded_framesize, rm->coded_framesize) <= 0)
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
912 return AVERROR_IO;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
913 rm->audio_stream_num = 0;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
914 rm->audio_pkt_cnt = rm->sub_packet_h * rm->audio_framesize / st->codec->block_align - 1;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
915 // Release first audio packet
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
916 av_new_packet(pkt, st->codec->block_align);
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
917 memcpy(pkt->data, rm->audiobuf, st->codec->block_align);
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
918 pkt->flags |= PKT_FLAG_KEY; // Mark first packet as keyframe
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
919 pkt->stream_index = 0;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
920 } else {
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
921 /* just read raw bytes */
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
922 len = RAW_PACKET_SIZE;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
923 len= av_get_packet(pb, pkt, len);
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
924 pkt->stream_index = 0;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
925 if (len <= 0) {
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
926 return AVERROR_IO;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
927 }
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
928 pkt->size = len;
78b99ab16ea2 Support for 28_8 in old ar. files
rtognimp
parents: 887
diff changeset
929 }
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
930 } else {
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
931 int seq=1;
652
b47948262721 support discarding uninterresting packets
michael
parents: 638
diff changeset
932 resync:
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
933 len=sync(s, &timestamp, &flags, &i, &pos);
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
934 if(len<0)
610
1ab7b989f475 try to recover from errors instead of failing fataly
michael
parents: 609
diff changeset
935 return AVERROR_IO;
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
936 st = s->streams[i];
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
937
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
938 if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
609
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
939 int h, pic_num, len2, pos;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
940
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
941 h= get_byte(pb); len--;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
942 if(!(h & 0x40)){
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
943 seq = get_byte(pb); len--;
609
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
944 }
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
945
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
946 if((h & 0xc0) == 0x40){
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
947 len2= pos= 0;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
948 }else{
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
949 len2 = get_num(pb, &len);
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
950 pos = get_num(pb, &len);
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
951 }
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
952 /* picture number */
609
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
953 pic_num= get_byte(pb); len--;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
954 rm->remaining_len= len;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
955 rm->current_stream= st->id;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
956
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
957 // av_log(NULL, AV_LOG_DEBUG, "%X len:%d pos:%d len2:%d pic_num:%d\n",h, len, pos, len2, pic_num);
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
958 if(len2 && len2<len)
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
959 len=len2;
2f0de265bc5e various demuxer fixes
michael
parents: 608
diff changeset
960 rm->remaining_len-= len;
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
961 av_get_packet(pb, pkt, len);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
962 }
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
963
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
964 if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
965 if ((st->codec->codec_id == CODEC_ID_RA_288) ||
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
966 (st->codec->codec_id == CODEC_ID_COOK)) {
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
967 int x;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
968 int sps = rm->sub_packet_size;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
969 int cfs = rm->coded_framesize;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
970 int h = rm->sub_packet_h;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
971 int y = rm->sub_packet_cnt;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
972 int w = rm->audio_framesize;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
973
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
974 if (flags & 2)
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
975 y = rm->sub_packet_cnt = 0;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
976 if (!y)
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
977 rm->audiotimestamp = timestamp;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
978
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
979 switch(st->codec->codec_id) {
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
980 case CODEC_ID_RA_288:
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
981 for (x = 0; x < h/2; x++)
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
982 get_buffer(pb, rm->audiobuf+x*2*w+y*cfs, cfs);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
983 break;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
984 case CODEC_ID_COOK:
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
985 for (x = 0; x < w/sps; x++)
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
986 get_buffer(pb, rm->audiobuf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
987 break;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
988 }
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
989
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
990 if (++(rm->sub_packet_cnt) < h)
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
991 goto resync;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
992 else {
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
993 rm->sub_packet_cnt = 0;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
994 rm->audio_stream_num = i;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
995 rm->audio_pkt_cnt = h * w / st->codec->block_align - 1;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
996 // Release first audio packet
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
997 av_new_packet(pkt, st->codec->block_align);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
998 memcpy(pkt->data, rm->audiobuf, st->codec->block_align);
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
999 timestamp = rm->audiotimestamp;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1000 flags = 2; // Mark first packet as keyframe
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1001 }
1105
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1002 } else if (st->codec->codec_id == CODEC_ID_AAC) {
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1003 int x;
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1004 rm->audio_stream_num = i;
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1005 rm->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4;
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1006 if (rm->sub_packet_cnt) {
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1007 for (x = 0; x < rm->sub_packet_cnt; x++)
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1008 rm->sub_packet_lengths[x] = get_be16(pb);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1009 // Release first audio packet
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1010 rm->audio_pkt_cnt = rm->sub_packet_cnt - 1;
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1011 av_get_packet(pb, pkt, rm->sub_packet_lengths[0]);
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1012 flags = 2; // Mark first packet as keyframe
d187ac890c0e Support for AAC (fourcc raac and racp) in rm files
rtogni
parents: 1079
diff changeset
1013 }
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1014 } else
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1015 av_get_packet(pb, pkt, len);
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
1016 }
652
b47948262721 support discarding uninterresting packets
michael
parents: 638
diff changeset
1017
708
d79164865a7c more fine grained discarding of packets
michael
parents: 688
diff changeset
1018 if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))
d79164865a7c more fine grained discarding of packets
michael
parents: 688
diff changeset
1019 || st->discard >= AVDISCARD_ALL){
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1020 av_free_packet(pkt);
652
b47948262721 support discarding uninterresting packets
michael
parents: 638
diff changeset
1021 goto resync;
b47948262721 support discarding uninterresting packets
michael
parents: 638
diff changeset
1022 }
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
1023
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
1024 pkt->stream_index = i;
607
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1025
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1026 #if 0
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
1027 if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
1028 if(st->codec->codec_id == CODEC_ID_RV20){
607
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1029 int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1030 av_log(NULL, AV_LOG_DEBUG, "%d %Ld %d\n", timestamp, timestamp*512LL/25, seq);
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1031
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1032 seq |= (timestamp&~0x3FFF);
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1033 if(seq - timestamp > 0x2000) seq -= 0x4000;
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1034 if(seq - timestamp < -0x2000) seq += 0x4000;
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1035 }
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1036 }
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1037 #endif
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1038 pkt->pts= timestamp;
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1039 if(flags&2){
607
fce9fc3a0f17 timestamp fix
michael
parents: 604
diff changeset
1040 pkt->flags |= PKT_FLAG_KEY;
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1041 if((seq&0x7F) == 1)
979
d2e5dfdf4def add size to AVIndex
michael
parents: 896
diff changeset
1042 av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1043 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1044 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1045
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1046 /* for AC3, needs to swap bytes */
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
1047 if (st->codec->codec_id == CODEC_ID_AC3) {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1048 ptr = pkt->data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1049 for(j=0;j<len;j+=2) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1050 tmp = ptr[0];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1051 ptr[0] = ptr[1];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1052 ptr[1] = tmp;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1053 ptr += 2;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1054 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1055 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1056 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1057 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1058
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1059 static int rm_read_close(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1060 {
879
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1061 RMContext *rm = s->priv_data;
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1062
1f093ae472d8 Cook compatibe decoder, patch by Benjamin Larsson
rtognimp
parents: 858
diff changeset
1063 av_free(rm->audiobuf);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1064 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1065 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1066
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1067 static int rm_probe(AVProbeData *p)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1068 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1069 /* check file header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1070 if (p->buf_size <= 32)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1071 return 0;
194
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
1072 if ((p->buf[0] == '.' && p->buf[1] == 'R' &&
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
1073 p->buf[2] == 'M' && p->buf[3] == 'F' &&
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
1074 p->buf[4] == 0 && p->buf[5] == 0) ||
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
1075 (p->buf[0] == '.' && p->buf[1] == 'r' &&
37e7cd3d544d support for older real audio files (<= version 3)
bellard
parents: 188
diff changeset
1076 p->buf[2] == 'a' && p->buf[3] == 0xfd))
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1077 return AVPROBE_SCORE_MAX;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1078 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1079 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1080 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1081
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
1082 static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1083 int64_t *ppos, int64_t pos_limit)
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1084 {
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1085 RMContext *rm = s->priv_data;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1086 int64_t pos, dts;
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1087 int stream_index2, flags, len, h;
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1088
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1089 pos = *ppos;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
1090
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1091 if(rm->old_format)
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1092 return AV_NOPTS_VALUE;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1093
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1094 url_fseek(&s->pb, pos, SEEK_SET);
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1095 rm->remaining_len=0;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1096 for(;;){
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1097 int seq=1;
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1098 AVStream *st;
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1099
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1100 len=sync(s, &dts, &flags, &stream_index2, &pos);
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1101 if(len<0)
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1102 return AV_NOPTS_VALUE;
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1103
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1104 st = s->streams[stream_index2];
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
1105 if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1106 h= get_byte(&s->pb); len--;
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1107 if(!(h & 0x40)){
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1108 seq = get_byte(&s->pb); len--;
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1109 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1110 }
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 884
diff changeset
1111
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1112 if((flags&2) && (seq&0x7F) == 1){
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1113 // av_log(s, AV_LOG_DEBUG, "%d %d-%d %Ld %d\n", flags, stream_index2, stream_index, dts, seq);
979
d2e5dfdf4def add size to AVIndex
michael
parents: 896
diff changeset
1114 av_add_index_entry(st, pos, dts, 0, 0, AVINDEX_KEYFRAME);
613
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1115 if(stream_index2 == stream_index)
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1116 break;
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1117 }
2e70d3938f50 seeking in rm 2nd try
michael
parents: 612
diff changeset
1118
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1119 url_fskip(&s->pb, len);
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1120 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1121 *ppos = pos;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1122 return dts;
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1123 }
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1124
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
1125 #ifdef CONFIG_RM_DEMUXER
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
1126 AVInputFormat rm_demuxer = {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1127 "rm",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1128 "rm format",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1129 sizeof(RMContext),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1130 rm_probe,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1131 rm_read_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1132 rm_read_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1133 rm_read_close,
612
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1134 NULL,
fc167cb3b54c seeking in rm
michael
parents: 611
diff changeset
1135 rm_read_dts,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1136 };
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
1137 #endif
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
1138 #ifdef CONFIG_RM_MUXER
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
1139 AVOutputFormat rm_muxer = {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1140 "rm",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1141 "rm format",
14
b167760cd0aa mimetype fixes patch by (Ryutaroh Matsumoto <ryutaroh at it dot ss dot titech dot ac dot jp>)
michaelni
parents: 7
diff changeset
1142 "application/vnd.rn-realmedia",
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1143 "rm,ra",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1144 sizeof(RMContext),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1145 CODEC_ID_AC3,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1146 CODEC_ID_RV10,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1147 rm_write_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1148 rm_write_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1149 rm_write_trailer,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1150 };
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
1151 #endif