annotate avs.c @ 1688:0ab2495a1815 libavformat

remove sensless casts
author michael
date Sun, 21 Jan 2007 20:15:55 +0000
parents 0899bfe4105c
children 1a3c9056982a
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 *
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
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
19 * 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
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 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
27 voc_dec_context_t voc;
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;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
37 } avs_format_t;
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 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
40 AVS_VIDEO = 0x01,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
41 AVS_AUDIO = 0x02,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
42 AVS_PALETTE = 0x03,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
43 AVS_GAME_DATA = 0x04,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
44 } avs_block_type_t;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
45
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
46 static int avs_probe(AVProbeData * p)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
47 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
48 const uint8_t *d;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
49
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
50 if (p->buf_size < 2)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
51 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
52 d = p->buf;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
53 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
54 return 50;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
55
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
56 return 0;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
59 static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
60 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
61 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
62
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
63 s->ctx_flags |= AVFMTCTX_NOHEADER;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
64
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
65 url_fskip(&s->pb, 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
66 avs->width = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
67 avs->height = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
68 avs->bits_per_sample = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
69 avs->fps = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
70 avs->nb_frames = get_le32(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
71 avs->remaining_frame_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
72 avs->remaining_audio_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
73
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
74 avs->st_video = avs->st_audio = NULL;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
75
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
76 if (avs->width != 318 || avs->height != 198)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
77 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
78 "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
79 avs->width, avs->height);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
80
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
81 return 0;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
84 static int
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
85 avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
86 avs_block_type_t type, int sub_type, int size,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
87 uint8_t * palette, int palette_size)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
88 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
89 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
90 int ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
91
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
92 ret = av_new_packet(pkt, size + palette_size);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
93 if (ret < 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
94 return ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
95
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
96 if (palette_size) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
97 pkt->data[0] = 0x00;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
98 pkt->data[1] = 0x03;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
99 pkt->data[2] = palette_size & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
100 pkt->data[3] = (palette_size >> 8) & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
101 memcpy(pkt->data + 4, palette, palette_size - 4);
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
104 pkt->data[palette_size + 0] = sub_type;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
105 pkt->data[palette_size + 1] = type;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
106 pkt->data[palette_size + 2] = size & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
107 pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
108 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
109 if (ret < size) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
110 av_free_packet(pkt);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
111 return AVERROR_IO;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
114 pkt->size = ret + palette_size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
115 pkt->stream_index = avs->st_video->index;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
116 if (sub_type == 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
117 pkt->flags |= PKT_FLAG_KEY;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
118
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
119 return 0;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
122 static int avs_read_audio_packet(AVFormatContext * s, AVPacket * pkt)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
123 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
124 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
125 int ret, size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
126
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
127 size = url_ftell(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
128 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
129 size = url_ftell(&s->pb) - size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
130 avs->remaining_audio_size -= size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
131
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
132 if (ret == AVERROR_IO)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
133 return 0; /* this indicate EOS */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
134 if (ret < 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
135 return ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
136
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
137 pkt->stream_index = avs->st_audio->index;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
138 pkt->flags |= PKT_FLAG_KEY;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
139
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
140 return size;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
143 static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
144 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
145 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
146 int sub_type = 0, size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
147 avs_block_type_t type = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
148 int palette_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
149 uint8_t palette[4 + 3 * 256];
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
150 int ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
151
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
152 if (avs->remaining_audio_size > 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
153 if (avs_read_audio_packet(s, pkt) > 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
154 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
155
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
156 while (1) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
157 if (avs->remaining_frame_size <= 0) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
158 if (!get_le16(&s->pb)) /* found EOF */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
159 return AVERROR_IO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
160 avs->remaining_frame_size = get_le16(&s->pb) - 4;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
163 while (avs->remaining_frame_size > 0) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
164 sub_type = get_byte(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
165 type = get_byte(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
166 size = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
167 avs->remaining_frame_size -= size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
168
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
169 switch (type) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
170 case AVS_PALETTE:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
171 ret = get_buffer(&s->pb, palette, size - 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
172 if (ret < size - 4)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
173 return AVERROR_IO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
174 palette_size = size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
175 break;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
176
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
177 case AVS_VIDEO:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
178 if (!avs->st_video) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
179 avs->st_video = av_new_stream(s, AVS_VIDEO);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
180 if (avs->st_video == NULL)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
181 return AVERROR_NOMEM;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
182 avs->st_video->codec->codec_type = CODEC_TYPE_VIDEO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
183 avs->st_video->codec->codec_id = CODEC_ID_AVS;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
184 avs->st_video->codec->width = avs->width;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
185 avs->st_video->codec->height = avs->height;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
186 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
187 avs->st_video->nb_frames = avs->nb_frames;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
188 avs->st_video->codec->time_base = (AVRational) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
189 1, avs->fps};
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
190 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
191 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
192 palette, palette_size);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
193
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
194 case AVS_AUDIO:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
195 if (!avs->st_audio) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
196 avs->st_audio = av_new_stream(s, AVS_AUDIO);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
197 if (avs->st_audio == NULL)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
198 return AVERROR_NOMEM;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
199 avs->st_audio->codec->codec_type = CODEC_TYPE_AUDIO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
200 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
201 avs->remaining_audio_size = size - 4;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
202 size = avs_read_audio_packet(s, pkt);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
203 if (size != 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
204 return size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
205 break;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
206
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
207 default:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
208 url_fskip(&s->pb, size - 4);
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
214 static int avs_read_close(AVFormatContext * s)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
215 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
216 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
217 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
218
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
219 AVInputFormat avs_demuxer = {
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
220 "avs",
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
221 "avs format",
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
222 sizeof(avs_format_t),
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
223 avs_probe,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
224 avs_read_header,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
225 avs_read_packet,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
226 avs_read_close,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
227 };