annotate avs.c @ 1268:a6f690337d6c libavformat

support vdva fourcc (dv + dv audio in mov)
author bcoudurier
date Thu, 24 Aug 2006 08:28:11 +0000
parents d18cc9a1fd02
children 0899bfe4105c
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 static int avs_probe(AVProbeData * p)
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 const uint8_t *d;
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 if (p->buf_size < 2)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
49 return 0;
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);
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
109 return AVERROR_IO;
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
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
130 if (ret == AVERROR_IO)
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 */
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
157 return AVERROR_IO;
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)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
171 return AVERROR_IO;
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)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
179 return AVERROR_NOMEM;
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)
d1d7a0e87dea complete AVS playback system (from Creature Shock computer game),
melanson
parents:
diff changeset
196 return AVERROR_NOMEM;
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 };