annotate avs.c @ 972:d983c2b9333e libavformat

kill some warnings
author mru
date Sat, 25 Feb 2006 22:41:31 +0000
parents d1d7a0e87dea
children d89d7ef290da
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
6 * 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
7 * License as published by the Free Software Foundation; either
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
9 *
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
13 * Lesser General Public License for more details.
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
14 *
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
18 */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
19
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
20 #include "avformat.h"
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
21 #include "voc.h"
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
22
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
23
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
24 typedef struct avs_format {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
25 voc_dec_context_t voc;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
26 AVStream *st_video;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
27 AVStream *st_audio;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
28 int width;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
29 int height;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
30 int bits_per_sample;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
31 int fps;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
32 int nb_frames;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
33 int remaining_frame_size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
34 int remaining_audio_size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
35 } avs_format_t;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
36
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
37 typedef enum avs_block_type {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
38 AVS_VIDEO = 0x01,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
39 AVS_AUDIO = 0x02,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
40 AVS_PALETTE = 0x03,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
41 AVS_GAME_DATA = 0x04,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
42 } avs_block_type_t;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
43
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
44
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
45 #ifdef CONFIG_DEMUXERS
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 if (p->buf_size < 2)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
52 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
53 d = p->buf;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
54 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
55 return 50;
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 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
58 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
59
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
60 static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap)
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 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
63
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
64 s->ctx_flags |= AVFMTCTX_NOHEADER;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
65
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
66 url_fskip(&s->pb, 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
67 avs->width = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
68 avs->height = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
69 avs->bits_per_sample = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
70 avs->fps = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
71 avs->nb_frames = get_le32(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
72 avs->remaining_frame_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
73 avs->remaining_audio_size = 0;
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 avs->st_video = avs->st_audio = NULL;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
76
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
77 if (avs->width != 318 || avs->height != 198)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
78 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
79 "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
80 avs->width, avs->height);
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 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
83 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
84
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
85 static int
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
86 avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
87 avs_block_type_t type, int sub_type, int size,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
88 uint8_t * palette, int palette_size)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
89 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
90 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
91 int ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
92
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
93 ret = av_new_packet(pkt, size + palette_size);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
94 if (ret < 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
95 return ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
96
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
97 if (palette_size) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
98 pkt->data[0] = 0x00;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
99 pkt->data[1] = 0x03;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
100 pkt->data[2] = palette_size & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
101 pkt->data[3] = (palette_size >> 8) & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
102 memcpy(pkt->data + 4, palette, palette_size - 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
103 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
104
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
105 pkt->data[palette_size + 0] = sub_type;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
106 pkt->data[palette_size + 1] = type;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
107 pkt->data[palette_size + 2] = size & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
108 pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
109 ret = get_buffer(&s->pb, pkt->data + palette_size + 4, size - 4) + 4;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
110 if (ret < size) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
111 av_free_packet(pkt);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
112 return AVERROR_IO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
113 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
114
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
115 pkt->size = ret + palette_size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
116 pkt->stream_index = avs->st_video->index;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
117 if (sub_type == 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
118 pkt->flags |= PKT_FLAG_KEY;
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 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
121 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
122
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
123 static int avs_read_audio_packet(AVFormatContext * s, AVPacket * pkt)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
124 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
125 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
126 int ret, size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
127
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
128 size = url_ftell(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
129 ret = voc_get_packet(s, pkt, avs->st_audio, avs->remaining_audio_size);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
130 size = url_ftell(&s->pb) - size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
131 avs->remaining_audio_size -= size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
132
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
133 if (ret == AVERROR_IO)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
134 return 0; /* this indicate EOS */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
135 if (ret < 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
136 return ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
137
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
138 pkt->stream_index = avs->st_audio->index;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
139 pkt->flags |= PKT_FLAG_KEY;
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 return size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
142 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
143
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
144 static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
145 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
146 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
147 int sub_type = 0, size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
148 avs_block_type_t type = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
149 int palette_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
150 uint8_t palette[4 + 3 * 256];
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
151 int ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
152
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
153 if (avs->remaining_audio_size > 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
154 if (avs_read_audio_packet(s, pkt) > 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
155 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
156
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
157 while (1) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
158 if (avs->remaining_frame_size <= 0) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
159 if (!get_le16(&s->pb)) /* found EOF */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
160 return AVERROR_IO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
161 avs->remaining_frame_size = get_le16(&s->pb) - 4;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
162 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
163
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
164 while (avs->remaining_frame_size > 0) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
165 sub_type = get_byte(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
166 type = get_byte(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
167 size = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
168 avs->remaining_frame_size -= size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
169
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
170 switch (type) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
171 case AVS_PALETTE:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
172 ret = get_buffer(&s->pb, palette, size - 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
173 if (ret < size - 4)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
174 return AVERROR_IO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
175 palette_size = size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
176 break;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
177
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
178 case AVS_VIDEO:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
179 if (!avs->st_video) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
180 avs->st_video = av_new_stream(s, AVS_VIDEO);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
181 if (avs->st_video == NULL)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
182 return AVERROR_NOMEM;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
183 avs->st_video->codec->codec_type = CODEC_TYPE_VIDEO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
184 avs->st_video->codec->codec_id = CODEC_ID_AVS;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
185 avs->st_video->codec->width = avs->width;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
186 avs->st_video->codec->height = avs->height;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
187 avs->st_video->codec->bits_per_sample=avs->bits_per_sample;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
188 avs->st_video->nb_frames = avs->nb_frames;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
189 avs->st_video->codec->time_base = (AVRational) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
190 1, avs->fps};
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
191 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
192 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
193 palette, palette_size);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
194
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
195 case AVS_AUDIO:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
196 if (!avs->st_audio) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
197 avs->st_audio = av_new_stream(s, AVS_AUDIO);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
198 if (avs->st_audio == NULL)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
199 return AVERROR_NOMEM;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
200 avs->st_audio->codec->codec_type = CODEC_TYPE_AUDIO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
201 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
202 avs->remaining_audio_size = size - 4;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
203 size = avs_read_audio_packet(s, pkt);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
204 if (size != 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
205 return size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
206 break;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
207
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
208 default:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
209 url_fskip(&s->pb, size - 4);
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 }
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 static int avs_read_close(AVFormatContext * s)
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 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
218 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
219
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
220 static AVInputFormat avs_iformat = {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
221 "avs",
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
222 "avs format",
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
223 sizeof(avs_format_t),
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
224 avs_probe,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
225 avs_read_header,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
226 avs_read_packet,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
227 avs_read_close,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
228 };
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
229
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
230 #endif /* CONFIG_DEMUXERS */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
231
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
232 int avs_init(void)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
233 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
234 #ifdef CONFIG_DEMUXERS
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
235 av_register_input_format(&avs_iformat);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
236 #endif /* CONFIG_DEMUXERS */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
237 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
238 }