Mercurial > libavformat.hg
annotate thp.c @ 1988:deacffc2740e libavformat
THP PCM decoder, used on the Nintendo GameCube.
patch by Marco Gerards, mgerards xs4all nl
| author | diego |
|---|---|
| date | Sat, 07 Apr 2007 16:03:23 +0000 |
| parents | 51c5fe603dba |
| children | 1a3c9056982a |
| rev | line source |
|---|---|
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
1 /* |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
2 * THP Demuxer |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
3 * Copyright (c) 2007 Marco Gerards. |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
4 * |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
6 * |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
11 * |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
16 * |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
20 */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
21 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
22 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
23 #include "avformat.h" |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
24 #include "allformats.h" |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
25 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
26 typedef struct ThpDemuxContext { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
27 int version; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
28 int first_frame; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
29 int first_framesz; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
30 int last_frame; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
31 int compoff; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
32 int framecnt; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
33 AVRational fps; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
34 int frame; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
35 int next_frame; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
36 int next_framesz; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
37 int video_stream_index; |
| 1988 | 38 int audio_stream_index; |
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
39 int compcount; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
40 unsigned char components[16]; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
41 AVStream* vst; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
42 int has_audio; |
| 1988 | 43 int audiosize; |
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
44 } ThpDemuxContext; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
45 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
46 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
47 static int thp_probe(AVProbeData *p) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
48 { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
49 /* check file header */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
50 if (p->buf_size < 4) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
51 return 0; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
52 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
53 if (AV_RL32(p->buf) == MKTAG('T', 'H', 'P', '\0')) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
54 return AVPROBE_SCORE_MAX; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
55 else |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
56 return 0; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
57 } |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
58 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
59 static int thp_read_header(AVFormatContext *s, |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
60 AVFormatParameters *ap) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
61 { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
62 ThpDemuxContext *thp = s->priv_data; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
63 AVStream *st; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
64 ByteIOContext *pb = &s->pb; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
65 int i; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
66 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
67 /* Read the file header. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
68 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
69 get_be32(pb); /* Skip Magic. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
70 thp->version = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
71 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
72 get_be32(pb); /* Max buf size. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
73 get_be32(pb); /* Max samples. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
74 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
75 thp->fps = av_d2q(av_int2flt(get_be32(pb)), INT_MAX); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
76 thp->framecnt = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
77 thp->first_framesz = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
78 get_be32(pb); /* Data size. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
79 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
80 thp->compoff = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
81 get_be32(pb); /* offsetDataOffset. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
82 thp->first_frame = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
83 thp->last_frame = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
84 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
85 thp->next_framesz = thp->first_framesz; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
86 thp->next_frame = thp->first_frame; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
87 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
88 /* Read the component structure. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
89 url_fseek (pb, thp->compoff, SEEK_SET); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
90 thp->compcount = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
91 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
92 /* Read the list of component types. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
93 get_buffer(pb, thp->components, 16); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
94 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
95 for (i = 0; i < thp->compcount; i++) { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
96 if (thp->components[i] == 0) { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
97 if (thp->vst != 0) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
98 break; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
99 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
100 /* Video component. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
101 st = av_new_stream(s, 0); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
102 if (!st) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
103 return AVERROR_NOMEM; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
104 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
105 /* The denominator and numerator are switched because 1/fps |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
106 is required. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
107 av_set_pts_info(st, 64, thp->fps.den, thp->fps.num); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
108 st->codec->codec_type = CODEC_TYPE_VIDEO; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
109 st->codec->codec_id = CODEC_ID_THP; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
110 st->codec->codec_tag = 0; /* no fourcc */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
111 st->codec->width = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
112 st->codec->height = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
113 st->codec->sample_rate = av_q2d(thp->fps); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
114 thp->vst = st; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
115 thp->video_stream_index = st->index; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
116 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
117 if (thp->version == 0x11000) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
118 get_be32(pb); /* Unknown. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
119 } |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
120 else if (thp->components[i] == 1) { |
| 1988 | 121 if (thp->has_audio != 0) |
| 122 break; | |
| 123 | |
| 124 /* Audio component. */ | |
| 125 st = av_new_stream(s, 0); | |
| 126 if (!st) | |
| 127 return AVERROR_NOMEM; | |
| 128 | |
| 129 st->codec->codec_type = CODEC_TYPE_AUDIO; | |
| 130 st->codec->codec_id = CODEC_ID_ADPCM_THP; | |
| 131 st->codec->codec_tag = 0; /* no fourcc */ | |
| 132 st->codec->channels = get_be32(pb); /* numChannels. */ | |
| 133 st->codec->sample_rate = get_be32(pb); /* Frequency. */ | |
| 134 | |
| 135 av_set_pts_info(st, 64, 1, st->codec->sample_rate); | |
| 136 | |
| 137 thp->audio_stream_index = st->index; | |
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
138 thp->has_audio = 1; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
139 } |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
140 } |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
141 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
142 return 0; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
143 } |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
144 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
145 static int thp_read_packet(AVFormatContext *s, |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
146 AVPacket *pkt) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
147 { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
148 ThpDemuxContext *thp = s->priv_data; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
149 ByteIOContext *pb = &s->pb; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
150 int size; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
151 int ret; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
152 |
| 1988 | 153 if (thp->audiosize == 0) { |
| 154 | |
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
155 /* Terminate when last frame is reached. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
156 if (thp->frame >= thp->framecnt) |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
157 return AVERROR_IO; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
158 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
159 url_fseek(pb, thp->next_frame, SEEK_SET); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
160 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
161 /* Locate the next frame and read out its size. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
162 thp->next_frame += thp->next_framesz; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
163 thp->next_framesz = get_be32(pb); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
164 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
165 get_be32(pb); /* Previous total size. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
166 size = get_be32(pb); /* Total size of this frame. */ |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
167 |
| 1988 | 168 /* Store the audiosize so the next time this function is called, |
| 169 the audio can be read. */ | |
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
170 if (thp->has_audio) |
| 1988 | 171 thp->audiosize = get_be32(pb); /* Audio size. */ |
| 172 else | |
| 173 thp->frame++; | |
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
174 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
175 ret = av_get_packet(pb, pkt, size); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
176 if (ret != size) { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
177 av_free_packet(pkt); |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
178 return AVERROR_IO; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
179 } |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
180 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
181 pkt->stream_index = thp->video_stream_index; |
| 1988 | 182 } |
| 183 else { | |
| 184 ret = av_get_packet(pb, pkt, thp->audiosize); | |
| 185 if (ret != thp->audiosize) { | |
| 186 av_free_packet(pkt); | |
| 187 return AVERROR_IO; | |
| 188 } | |
| 189 | |
| 190 pkt->stream_index = thp->audio_stream_index; | |
| 191 thp->audiosize = 0; | |
| 192 thp->frame++; | |
| 193 } | |
|
1974
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
194 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
195 return 0; |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
196 } |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
197 |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
198 AVInputFormat thp_demuxer = { |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
199 "thp", |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
200 "THP", |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
201 sizeof(ThpDemuxContext), |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
202 thp_probe, |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
203 thp_read_header, |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
204 thp_read_packet |
|
51c5fe603dba
support for the THP game format by Marco Gerards, mgerards xs4all nl
diego
parents:
diff
changeset
|
205 }; |
