~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavformat/siff.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-30 14:27:42 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430142742-quvblxk1tj6adlh5
Tags: 4:0.7~b1-1ubuntu1
* Merge from debian. Remaining changes:
  - don't build against libfaad, libdirac, librtmp and libopenjpeg
    (all in universe)
  - explicitly --enable-pic on powerpc, cf. LP #654666
  - different arm configure bits that should probably better be
    merged into debian
* Cherry-picked from git: 
  - install doc/APIChanges and refer to them in NEWS.Debian (Closes: #623682)
  - don't try to install non-existing documentation, fixes FTBFS on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Beam Software SIFF demuxer
3
3
 * Copyright (c) 2007 Konstantin Shishkov
4
4
 *
5
 
 * This file is part of FFmpeg.
 
5
 * This file is part of Libav.
6
6
 *
7
 
 * FFmpeg is free software; you can redistribute it and/or
 
7
 * Libav is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU Lesser General Public
9
9
 * License as published by the Free Software Foundation; either
10
10
 * version 2.1 of the License, or (at your option) any later version.
11
11
 *
12
 
 * FFmpeg is distributed in the hope that it will be useful,
 
12
 * Libav is distributed in the hope that it will be useful,
13
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
15
 * Lesser General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with FFmpeg; if not, write to the Free Software
 
18
 * License along with Libav; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
 
84
84
    return 0;
85
85
}
86
86
 
87
 
static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb)
 
87
static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
88
88
{
89
89
    AVStream *st;
90
90
    int width, height;
91
91
 
92
 
    if (get_le32(pb) != TAG_VBHD){
 
92
    if (avio_rl32(pb) != TAG_VBHD){
93
93
        av_log(s, AV_LOG_ERROR, "Header chunk is missing\n");
94
94
        return -1;
95
95
    }
96
 
    if(get_be32(pb) != 32){
 
96
    if(avio_rb32(pb) != 32){
97
97
        av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n");
98
98
        return -1;
99
99
    }
100
 
    if(get_le16(pb) != 1){
 
100
    if(avio_rl16(pb) != 1){
101
101
        av_log(s, AV_LOG_ERROR, "Incorrect header version\n");
102
102
        return -1;
103
103
    }
104
 
    width = get_le16(pb);
105
 
    height = get_le16(pb);
106
 
    url_fskip(pb, 4);
107
 
    c->frames = get_le16(pb);
 
104
    width = avio_rl16(pb);
 
105
    height = avio_rl16(pb);
 
106
    avio_skip(pb, 4);
 
107
    c->frames = avio_rl16(pb);
108
108
    if(!c->frames){
109
109
        av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
110
110
        return -1;
111
111
    }
112
 
    c->bits = get_le16(pb);
113
 
    c->rate = get_le16(pb);
 
112
    c->bits = avio_rl16(pb);
 
113
    c->rate = avio_rl16(pb);
114
114
    c->block_align = c->rate * (c->bits >> 3);
115
115
 
116
 
    url_fskip(pb, 16); //zeroes
 
116
    avio_skip(pb, 16); //zeroes
117
117
 
118
118
    st = av_new_stream(s, 0);
119
119
    if (!st)
135
135
    return 0;
136
136
}
137
137
 
138
 
static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb)
 
138
static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
139
139
{
140
 
    if (get_le32(pb) != TAG_SHDR){
 
140
    if (avio_rl32(pb) != TAG_SHDR){
141
141
        av_log(s, AV_LOG_ERROR, "Header chunk is missing\n");
142
142
        return -1;
143
143
    }
144
 
    if(get_be32(pb) != 8){
 
144
    if(avio_rb32(pb) != 8){
145
145
        av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n");
146
146
        return -1;
147
147
    }
148
 
    url_fskip(pb, 4); //unknown value
149
 
    c->rate = get_le16(pb);
150
 
    c->bits = get_le16(pb);
 
148
    avio_skip(pb, 4); //unknown value
 
149
    c->rate = avio_rl16(pb);
 
150
    c->bits = avio_rl16(pb);
151
151
    c->block_align = c->rate * (c->bits >> 3);
152
152
    return create_audio_stream(s, c);
153
153
}
154
154
 
155
155
static int siff_read_header(AVFormatContext *s, AVFormatParameters *ap)
156
156
{
157
 
    ByteIOContext *pb = s->pb;
 
157
    AVIOContext *pb = s->pb;
158
158
    SIFFContext *c = s->priv_data;
159
159
    uint32_t tag;
160
160
 
161
 
    if (get_le32(pb) != TAG_SIFF)
 
161
    if (avio_rl32(pb) != TAG_SIFF)
162
162
        return -1;
163
 
    url_fskip(pb, 4); //ignore size
164
 
    tag = get_le32(pb);
 
163
    avio_skip(pb, 4); //ignore size
 
164
    tag = avio_rl32(pb);
165
165
 
166
166
    if (tag != TAG_VBV1 && tag != TAG_SOUN){
167
167
        av_log(s, AV_LOG_ERROR, "Not a VBV file\n");
172
172
        return -1;
173
173
    if (tag == TAG_SOUN && siff_parse_soun(s, c, pb) < 0)
174
174
        return -1;
175
 
    if (get_le32(pb) != MKTAG('B', 'O', 'D', 'Y')){
 
175
    if (avio_rl32(pb) != MKTAG('B', 'O', 'D', 'Y')){
176
176
        av_log(s, AV_LOG_ERROR, "'BODY' chunk is missing\n");
177
177
        return -1;
178
178
    }
179
 
    url_fskip(pb, 4); //ignore size
 
179
    avio_skip(pb, 4); //ignore size
180
180
 
181
181
    return 0;
182
182
}
190
190
        if (c->cur_frame >= c->frames)
191
191
            return AVERROR(EIO);
192
192
        if (c->curstrm == -1){
193
 
            c->pktsize = get_le32(s->pb) - 4;
194
 
            c->flags = get_le16(s->pb);
 
193
            c->pktsize = avio_rl32(s->pb) - 4;
 
194
            c->flags = avio_rl16(s->pb);
195
195
            c->gmcsize = (c->flags & VB_HAS_GMC) ? 4 : 0;
196
196
            if (c->gmcsize)
197
 
                get_buffer(s->pb, c->gmc, c->gmcsize);
198
 
            c->sndsize = (c->flags & VB_HAS_AUDIO) ? get_le32(s->pb): 0;
 
197
                avio_read(s->pb, c->gmc, c->gmcsize);
 
198
            c->sndsize = (c->flags & VB_HAS_AUDIO) ? avio_rl32(s->pb): 0;
199
199
            c->curstrm = !!(c->flags & VB_HAS_AUDIO);
200
200
        }
201
201
 
206
206
            AV_WL16(pkt->data, c->flags);
207
207
            if (c->gmcsize)
208
208
                memcpy(pkt->data + 2, c->gmc, c->gmcsize);
209
 
            get_buffer(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2);
 
209
            avio_read(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2);
210
210
            pkt->stream_index = 0;
211
211
            c->curstrm = -1;
212
212
        }else{
227
227
    return pkt->size;
228
228
}
229
229
 
230
 
AVInputFormat siff_demuxer = {
 
230
AVInputFormat ff_siff_demuxer = {
231
231
    "siff",
232
232
    NULL_IF_CONFIG_SMALL("Beam Software SIFF"),
233
233
    sizeof(SIFFContext),