annotate avs.c @ 2695:b89af3f21df6 libavformat

revert part of r10899 which was not intended
author aurel
date Thu, 01 Nov 2007 18:02:03 +0000
parents b21c2af60bc9
children d52c718e83f9
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
2217
06083249909c license header consistency cosmetics
diego
parents: 2001
diff changeset
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 {
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 d = p->buf;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
51 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
52 return 50;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
53
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
54 return 0;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
57 static int avs_read_header(AVFormatContext * s, AVFormatParameters * ap)
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 avs_format_t *avs = s->priv_data;
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 s->ctx_flags |= AVFMTCTX_NOHEADER;
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 url_fskip(&s->pb, 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
64 avs->width = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
65 avs->height = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
66 avs->bits_per_sample = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
67 avs->fps = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
68 avs->nb_frames = get_le32(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
69 avs->remaining_frame_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
70 avs->remaining_audio_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
71
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
72 avs->st_video = avs->st_audio = NULL;
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 if (avs->width != 318 || avs->height != 198)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
75 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
76 "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
77 avs->width, avs->height);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
78
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
79 return 0;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
82 static int
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
83 avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
84 avs_block_type_t type, int sub_type, int size,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
85 uint8_t * palette, int palette_size)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
86 {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
87 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
88 int ret;
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 ret = av_new_packet(pkt, size + palette_size);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
91 if (ret < 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
92 return ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
93
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
94 if (palette_size) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
95 pkt->data[0] = 0x00;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
96 pkt->data[1] = 0x03;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
97 pkt->data[2] = palette_size & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
98 pkt->data[3] = (palette_size >> 8) & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
99 memcpy(pkt->data + 4, palette, palette_size - 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
100 }
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 pkt->data[palette_size + 0] = sub_type;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
103 pkt->data[palette_size + 1] = type;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
104 pkt->data[palette_size + 2] = size & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
105 pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
106 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
107 if (ret < size) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
108 av_free_packet(pkt);
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
109 return AVERROR(EIO);
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
110 }
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 pkt->size = ret + palette_size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
113 pkt->stream_index = avs->st_video->index;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
114 if (sub_type == 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
115 pkt->flags |= PKT_FLAG_KEY;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
116
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
117 return 0;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
120 static int avs_read_audio_packet(AVFormatContext * s, AVPacket * pkt)
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 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
123 int ret, size;
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 size = url_ftell(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
126 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
127 size = url_ftell(&s->pb) - size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
128 avs->remaining_audio_size -= size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
129
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
130 if (ret == AVERROR(EIO))
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
131 return 0; /* this indicate EOS */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
132 if (ret < 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
133 return ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
134
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
135 pkt->stream_index = avs->st_audio->index;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
136 pkt->flags |= PKT_FLAG_KEY;
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 return size;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
141 static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
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 avs_format_t *avs = s->priv_data;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
144 int sub_type = 0, size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
145 avs_block_type_t type = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
146 int palette_size = 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
147 uint8_t palette[4 + 3 * 256];
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
148 int ret;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
149
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
150 if (avs->remaining_audio_size > 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
151 if (avs_read_audio_packet(s, pkt) > 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
152 return 0;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
153
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
154 while (1) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
155 if (avs->remaining_frame_size <= 0) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
156 if (!get_le16(&s->pb)) /* found EOF */
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
157 return AVERROR(EIO);
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
158 avs->remaining_frame_size = get_le16(&s->pb) - 4;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
159 }
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 while (avs->remaining_frame_size > 0) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
162 sub_type = get_byte(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
163 type = get_byte(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
164 size = get_le16(&s->pb);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
165 avs->remaining_frame_size -= size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
166
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
167 switch (type) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
168 case AVS_PALETTE:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
169 ret = get_buffer(&s->pb, palette, size - 4);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
170 if (ret < size - 4)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
171 return AVERROR(EIO);
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
172 palette_size = size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
173 break;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
174
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
175 case AVS_VIDEO:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
176 if (!avs->st_video) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
177 avs->st_video = av_new_stream(s, AVS_VIDEO);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
178 if (avs->st_video == NULL)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2217
diff changeset
179 return AVERROR(ENOMEM);
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
180 avs->st_video->codec->codec_type = CODEC_TYPE_VIDEO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
181 avs->st_video->codec->codec_id = CODEC_ID_AVS;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
182 avs->st_video->codec->width = avs->width;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
183 avs->st_video->codec->height = avs->height;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
184 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
185 avs->st_video->nb_frames = avs->nb_frames;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
186 avs->st_video->codec->time_base = (AVRational) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
187 1, avs->fps};
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
188 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
189 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
190 palette, palette_size);
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 case AVS_AUDIO:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
193 if (!avs->st_audio) {
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
194 avs->st_audio = av_new_stream(s, AVS_AUDIO);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
195 if (avs->st_audio == NULL)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2217
diff changeset
196 return AVERROR(ENOMEM);
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
197 avs->st_audio->codec->codec_type = CODEC_TYPE_AUDIO;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
198 }
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
199 avs->remaining_audio_size = size - 4;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
200 size = avs_read_audio_packet(s, pkt);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
201 if (size != 0)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
202 return size;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
203 break;
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
204
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
205 default:
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
206 url_fskip(&s->pb, size - 4);
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 }
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 static int avs_read_close(AVFormatContext * s)
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 return 0;
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
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
217 AVInputFormat avs_demuxer = {
961
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
218 "avs",
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
219 "avs format",
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
220 sizeof(avs_format_t),
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
221 avs_probe,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
222 avs_read_header,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
223 avs_read_packet,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
224 avs_read_close,
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
225 };