Mercurial > libavformat.hg
annotate avs.c @ 4874:5370b0c1653c libavformat
Increase the SDP buffer size (again!) and also increase the temporary
buffer size of the fmtp parameter buffer. For Vorbis RT(S)P, these
contain full Vorbis headers, which can be up to 12kb each, formatted
in base64, so 16kb total. Patch required for proper Vorbis/RTP playback,
submitted as GSoC qualification task in the thread "RTP/Vorbis payload
implementation (GSoC qual task)" by Colin McQuillan m.niloc googlemail
com.
author | rbultje |
---|---|
date | Tue, 14 Apr 2009 13:22:40 +0000 |
parents | 3d6e7901bf05 |
children | 536e5527c1e0 |
rev | line source |
---|---|
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
1 /* |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
2 * AVS demuxer. |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
3 * Copyright (c) 2006 Aurelien Jacobs <aurel@gnuage.org> |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
16 * |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
2217 | 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
20 */ |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
21 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
22 #include "avformat.h" |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
23 #include "voc.h" |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
24 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
25 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
26 typedef struct avs_format { |
4081 | 27 VocDecContext voc; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
28 AVStream *st_video; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
29 AVStream *st_audio; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
30 int width; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
31 int height; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
32 int bits_per_sample; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
33 int fps; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
34 int nb_frames; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
35 int remaining_frame_size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
36 int remaining_audio_size; |
4081 | 37 } AvsFormat; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
38 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
39 typedef enum avs_block_type { |
3291
fb5f48e1956f
Fix icc warning #188: enumerated type mixed with another type
cehoyos
parents:
2771
diff
changeset
|
40 AVS_NONE = 0x00, |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
41 AVS_VIDEO = 0x01, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
42 AVS_AUDIO = 0x02, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
43 AVS_PALETTE = 0x03, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
44 AVS_GAME_DATA = 0x04, |
4081 | 45 } AvsBlockType; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
46 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
47 static int avs_probe(AVProbeData * p) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
48 { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
49 const uint8_t *d; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
50 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
51 d = p->buf; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
52 if (d[0] == 'w' && d[1] == 'W' && d[2] == 0x10 && d[3] == 0) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
53 return 50; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
54 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
55 return 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
56 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
57 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
58 static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
59 { |
4081 | 60 AvsFormat *avs = s->priv_data; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
61 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
62 s->ctx_flags |= AVFMTCTX_NOHEADER; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
63 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
64 url_fskip(s->pb, 4); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
65 avs->width = get_le16(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
66 avs->height = get_le16(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
67 avs->bits_per_sample = get_le16(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
68 avs->fps = get_le16(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
69 avs->nb_frames = get_le32(s->pb); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
70 avs->remaining_frame_size = 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
71 avs->remaining_audio_size = 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
72 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
73 avs->st_video = avs->st_audio = NULL; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
74 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
75 if (avs->width != 318 || avs->height != 198) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
76 av_log(s, AV_LOG_ERROR, "This avs pretend to be %dx%d " |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
77 "when the avs format is supposed to be 318x198 only.\n", |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
78 avs->width, avs->height); |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
79 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
80 return 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
81 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
82 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
83 static int |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
84 avs_read_video_packet(AVFormatContext * s, AVPacket * pkt, |
4081 | 85 AvsBlockType type, int sub_type, int size, |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
86 uint8_t * palette, int palette_size) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
87 { |
4081 | 88 AvsFormat *avs = s->priv_data; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
89 int ret; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
90 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
91 ret = av_new_packet(pkt, size + palette_size); |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
92 if (ret < 0) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
93 return ret; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
94 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
95 if (palette_size) { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
96 pkt->data[0] = 0x00; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
97 pkt->data[1] = 0x03; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
98 pkt->data[2] = palette_size & 0xFF; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
99 pkt->data[3] = (palette_size >> 8) & 0xFF; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
100 memcpy(pkt->data + 4, palette, palette_size - 4); |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
101 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
102 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
103 pkt->data[palette_size + 0] = sub_type; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
104 pkt->data[palette_size + 1] = type; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
105 pkt->data[palette_size + 2] = size & 0xFF; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
106 pkt->data[palette_size + 3] = (size >> 8) & 0xFF; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
107 ret = get_buffer(s->pb, pkt->data + palette_size + 4, size - 4) + 4; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
108 if (ret < size) { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
109 av_free_packet(pkt); |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
110 return AVERROR(EIO); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
111 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
112 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
113 pkt->size = ret + palette_size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
114 pkt->stream_index = avs->st_video->index; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
115 if (sub_type == 0) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
116 pkt->flags |= PKT_FLAG_KEY; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
117 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
118 return 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
119 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
120 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
121 static int avs_read_audio_packet(AVFormatContext * s, AVPacket * pkt) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
122 { |
4081 | 123 AvsFormat *avs = s->priv_data; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
124 int ret, size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
125 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
126 size = url_ftell(s->pb); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
127 ret = voc_get_packet(s, pkt, avs->st_audio, avs->remaining_audio_size); |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
128 size = url_ftell(s->pb) - size; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
129 avs->remaining_audio_size -= size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
130 |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
131 if (ret == AVERROR(EIO)) |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
132 return 0; /* this indicate EOS */ |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
133 if (ret < 0) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
134 return ret; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
135 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
136 pkt->stream_index = avs->st_audio->index; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
137 pkt->flags |= PKT_FLAG_KEY; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
138 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
139 return size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
140 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
141 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
142 static int avs_read_packet(AVFormatContext * s, AVPacket * pkt) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
143 { |
4081 | 144 AvsFormat *avs = s->priv_data; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
145 int sub_type = 0, size = 0; |
4081 | 146 AvsBlockType type = AVS_NONE; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
147 int palette_size = 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
148 uint8_t palette[4 + 3 * 256]; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
149 int ret; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
150 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
151 if (avs->remaining_audio_size > 0) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
152 if (avs_read_audio_packet(s, pkt) > 0) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
153 return 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
154 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
155 while (1) { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
156 if (avs->remaining_frame_size <= 0) { |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
157 if (!get_le16(s->pb)) /* found EOF */ |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
158 return AVERROR(EIO); |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
159 avs->remaining_frame_size = get_le16(s->pb) - 4; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
160 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
161 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
162 while (avs->remaining_frame_size > 0) { |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
163 sub_type = get_byte(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
164 type = get_byte(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
165 size = get_le16(s->pb); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
166 avs->remaining_frame_size -= size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
167 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
168 switch (type) { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
169 case AVS_PALETTE: |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
170 ret = get_buffer(s->pb, palette, size - 4); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
171 if (ret < size - 4) |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
172 return AVERROR(EIO); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
173 palette_size = size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
174 break; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
175 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
176 case AVS_VIDEO: |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
177 if (!avs->st_video) { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
178 avs->st_video = av_new_stream(s, AVS_VIDEO); |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
179 if (avs->st_video == NULL) |
2273
7eb456c4ed8a
Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents:
2217
diff
changeset
|
180 return AVERROR(ENOMEM); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
181 avs->st_video->codec->codec_type = CODEC_TYPE_VIDEO; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
182 avs->st_video->codec->codec_id = CODEC_ID_AVS; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
183 avs->st_video->codec->width = avs->width; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
184 avs->st_video->codec->height = avs->height; |
3908
1d3d17de20ba
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
3424
diff
changeset
|
185 avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample; |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
186 avs->st_video->nb_frames = avs->nb_frames; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
187 avs->st_video->codec->time_base = (AVRational) { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
188 1, avs->fps}; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
189 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
190 return avs_read_video_packet(s, pkt, type, sub_type, size, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
191 palette, palette_size); |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
192 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
193 case AVS_AUDIO: |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
194 if (!avs->st_audio) { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
195 avs->st_audio = av_new_stream(s, AVS_AUDIO); |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
196 if (avs->st_audio == NULL) |
2273
7eb456c4ed8a
Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents:
2217
diff
changeset
|
197 return AVERROR(ENOMEM); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
198 avs->st_audio->codec->codec_type = CODEC_TYPE_AUDIO; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
199 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
200 avs->remaining_audio_size = size - 4; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
201 size = avs_read_audio_packet(s, pkt); |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
202 if (size != 0) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
203 return size; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
204 break; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
205 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
206 default: |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2274
diff
changeset
|
207 url_fskip(s->pb, size - 4); |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
208 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
209 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
210 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
211 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
212 |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
213 static int avs_read_close(AVFormatContext * s) |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
214 { |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
215 return 0; |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
216 } |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
217 |
1169 | 218 AVInputFormat avs_demuxer = { |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
219 "avs", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3291
diff
changeset
|
220 NULL_IF_CONFIG_SMALL("AVS format"), |
4081 | 221 sizeof(AvsFormat), |
961
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
222 avs_probe, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
223 avs_read_header, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
224 avs_read_packet, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
225 avs_read_close, |
d1d7a0e87dea
complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff
changeset
|
226 }; |