annotate mm.c @ 6074:258c2ccc68b5 libavformat

Make write_streamheader() return a meaningful error code if no codec tag is defined, rather than return -1.
author stefano
date Wed, 02 Jun 2010 21:57:37 +0000
parents 178de7695c6c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
1 /*
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
2 * American Laser Games MM Format Demuxer
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
3 * Copyright (c) 2006 Peter Ross
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1187
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1187
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1187
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
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: 1187
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1187
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
15 * Lesser General Public License for more details.
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
16 *
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
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: 1187
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
2217
06083249909c license header consistency cosmetics
diego
parents: 2006
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
20 */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
21
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
22 /**
5969
178de7695c6c Remove explicit filename from Doxygen @file commands.
diego
parents: 5910
diff changeset
23 * @file
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
24 * American Laser Games MM Format Demuxer
5508
655d9d34f862 update my email address
pross
parents: 5188
diff changeset
25 * by Peter Ross (pross@xvid.org)
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
26 *
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
27 * The MM format was used by IBM-PC ports of ALG's "arcade shooter" games,
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
28 * including Mad Dog McCree and Crime Patrol.
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
29 *
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
30 * Technical details here:
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
31 * http://wiki.multimedia.cx/index.php?title=American_Laser_Games_MM
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
32 */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
33
4201
7d2f3f1b68d8 Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents: 3763
diff changeset
34 #include "libavutil/intreadwrite.h"
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
35 #include "avformat.h"
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
36
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
37 #define MM_PREAMBLE_SIZE 6
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
38
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
39 #define MM_TYPE_HEADER 0x0
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
40 #define MM_TYPE_INTER 0x5
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
41 #define MM_TYPE_INTRA 0x8
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
42 #define MM_TYPE_INTRA_HH 0xc
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
43 #define MM_TYPE_INTER_HH 0xd
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
44 #define MM_TYPE_INTRA_HHV 0xe
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
45 #define MM_TYPE_INTER_HHV 0xf
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
46 #define MM_TYPE_AUDIO 0x15
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
47 #define MM_TYPE_PALETTE 0x31
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
48
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
49 #define MM_HEADER_LEN_V 0x16 /* video only */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
50 #define MM_HEADER_LEN_AV 0x18 /* video + audio */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
51
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
52 #define MM_PALETTE_COUNT 128
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
53 #define MM_PALETTE_SIZE (MM_PALETTE_COUNT*3)
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
54
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
55 typedef struct {
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
56 unsigned int audio_pts, video_pts;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
57 } MmDemuxContext;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
58
5797
e0e1ddbfca1a Remove static function name prefixes from American Laser Games MM demuxer
pross
parents: 5508
diff changeset
59 static int probe(AVProbeData *p)
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
60 {
5188
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
61 int len, type, fps, w, h;
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
62 if (p->buf_size < MM_HEADER_LEN_AV + MM_PREAMBLE_SIZE)
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
63 return 0;
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
64 /* the first chunk is always the header */
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
65 if (AV_RL16(&p->buf[0]) != MM_TYPE_HEADER)
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
66 return 0;
5188
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
67 len = AV_RL32(&p->buf[2]);
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
68 if (len != MM_HEADER_LEN_V && len != MM_HEADER_LEN_AV)
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
69 return 0;
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
70 fps = AV_RL16(&p->buf[8]);
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
71 w = AV_RL16(&p->buf[12]);
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
72 h = AV_RL16(&p->buf[14]);
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
73 if (!fps || fps > 60 || !w || w > 2048 || !h || h > 2048)
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
74 return 0;
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
75 type = AV_RL16(&p->buf[len]);
2a5cf64915b5 Vastly improved mm_probe function, passes probetest.
reimar
parents: 4513
diff changeset
76 if (!type || type > 0x31)
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
77 return 0;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
78
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
79 /* only return half certainty since this check is a bit sketchy */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
80 return AVPROBE_SCORE_MAX / 2;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
81 }
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
82
5797
e0e1ddbfca1a Remove static function name prefixes from American Laser Games MM demuxer
pross
parents: 5508
diff changeset
83 static int read_header(AVFormatContext *s,
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
84 AVFormatParameters *ap)
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
85 {
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 2001
diff changeset
86 MmDemuxContext *mm = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2274
diff changeset
87 ByteIOContext *pb = s->pb;
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
88 AVStream *st;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
89
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
90 unsigned int type, length;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
91 unsigned int frame_rate, width, height;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
92
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
93 type = get_le16(pb);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
94 length = get_le32(pb);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
95
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
96 if (type != MM_TYPE_HEADER)
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
97 return AVERROR_INVALIDDATA;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
98
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
99 /* read header */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
100 get_le16(pb); /* total number of chunks */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
101 frame_rate = get_le16(pb);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
102 get_le16(pb); /* ibm-pc video bios mode */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
103 width = get_le16(pb);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
104 height = get_le16(pb);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
105 url_fseek(pb, length - 10, SEEK_CUR); /* unknown data */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
106
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
107 /* video stream */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
108 st = av_new_stream(s, 0);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
109 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2217
diff changeset
110 return AVERROR(ENOMEM);
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 5797
diff changeset
111 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
112 st->codec->codec_id = CODEC_ID_MMVIDEO;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
113 st->codec->codec_tag = 0; /* no fourcc */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
114 st->codec->width = width;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
115 st->codec->height = height;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
116 av_set_pts_info(st, 64, 1, frame_rate);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
117
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
118 /* audio stream */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
119 if (length == MM_HEADER_LEN_AV) {
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
120 st = av_new_stream(s, 0);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
121 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2217
diff changeset
122 return AVERROR(ENOMEM);
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 5797
diff changeset
123 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
124 st->codec->codec_tag = 0; /* no fourcc */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
125 st->codec->codec_id = CODEC_ID_PCM_U8;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
126 st->codec->channels = 1;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
127 st->codec->sample_rate = 8000;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
128 av_set_pts_info(st, 64, 1, 8000); /* 8000 hz */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
129 }
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
130
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
131 mm->audio_pts = 0;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
132 mm->video_pts = 0;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
133 return 0;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
134 }
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
135
5797
e0e1ddbfca1a Remove static function name prefixes from American Laser Games MM demuxer
pross
parents: 5508
diff changeset
136 static int read_packet(AVFormatContext *s,
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
137 AVPacket *pkt)
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
138 {
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 2001
diff changeset
139 MmDemuxContext *mm = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2274
diff changeset
140 ByteIOContext *pb = s->pb;
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
141 unsigned char preamble[MM_PREAMBLE_SIZE];
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
142 unsigned int type, length;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
143
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
144 while(1) {
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
145
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
146 if (get_buffer(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
147 return AVERROR(EIO);
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
148 }
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
149
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
150 type = AV_RL16(&preamble[0]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
151 length = AV_RL16(&preamble[2]);
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
152
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
153 switch(type) {
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
154 case MM_TYPE_PALETTE :
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
155 case MM_TYPE_INTER :
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
156 case MM_TYPE_INTRA :
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
157 case MM_TYPE_INTRA_HH :
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
158 case MM_TYPE_INTER_HH :
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
159 case MM_TYPE_INTRA_HHV :
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
160 case MM_TYPE_INTER_HHV :
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
161 /* output preamble + data */
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
162 if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2217
diff changeset
163 return AVERROR(ENOMEM);
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
164 memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
165 if (get_buffer(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
166 return AVERROR(EIO);
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
167 pkt->size = length + MM_PREAMBLE_SIZE;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
168 pkt->stream_index = 0;
3550
db0c31111238 Remove AVPaletteControl from ALG MM demuxer/decoder
pross
parents: 3424
diff changeset
169 pkt->pts = mm->video_pts;
db0c31111238 Remove AVPaletteControl from ALG MM demuxer/decoder
pross
parents: 3424
diff changeset
170 if (type!=MM_TYPE_PALETTE)
db0c31111238 Remove AVPaletteControl from ALG MM demuxer/decoder
pross
parents: 3424
diff changeset
171 mm->video_pts++;
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
172 return 0;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
173
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
174 case MM_TYPE_AUDIO :
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2274
diff changeset
175 if (av_get_packet(s->pb, pkt, length)<0)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2217
diff changeset
176 return AVERROR(ENOMEM);
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
177 pkt->size = length;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
178 pkt->stream_index = 1;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
179 pkt->pts = mm->audio_pts++;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
180 return 0;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
181
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
182 default :
4513
19a64ec3c46f Add a context to av_log() call and update the trace not to be redundant.
benoit
parents: 4331
diff changeset
183 av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
184 url_fseek(pb, length, SEEK_CUR);
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
185 }
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
186 }
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
187
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
188 return 0;
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
189 }
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
190
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
191 AVInputFormat mm_demuxer = {
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
192 "mm",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 2771
diff changeset
193 NULL_IF_CONFIG_SMALL("American Laser Games MM format"),
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
194 sizeof(MmDemuxContext),
5797
e0e1ddbfca1a Remove static function name prefixes from American Laser Games MM demuxer
pross
parents: 5508
diff changeset
195 probe,
e0e1ddbfca1a Remove static function name prefixes from American Laser Games MM demuxer
pross
parents: 5508
diff changeset
196 read_header,
e0e1ddbfca1a Remove static function name prefixes from American Laser Games MM demuxer
pross
parents: 5508
diff changeset
197 read_packet,
950
3a64595e57be complete American Laser Games MM playback system, courtesy of Peter Ross
melanson
parents:
diff changeset
198 };