Revision b7effd4e libavformat/smacker.c

View differences:

libavformat/smacker.c
105 105
    int tbase;
106 106

  
107 107
    /* read and check header */
108
    smk->magic = get_le32(pb);
108
    smk->magic = avio_rl32(pb);
109 109
    if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
110 110
        return -1;
111
    smk->width = get_le32(pb);
112
    smk->height = get_le32(pb);
113
    smk->frames = get_le32(pb);
114
    smk->pts_inc = (int32_t)get_le32(pb);
115
    smk->flags = get_le32(pb);
111
    smk->width = avio_rl32(pb);
112
    smk->height = avio_rl32(pb);
113
    smk->frames = avio_rl32(pb);
114
    smk->pts_inc = (int32_t)avio_rl32(pb);
115
    smk->flags = avio_rl32(pb);
116 116
    if(smk->flags & SMACKER_FLAG_RING_FRAME)
117 117
        smk->frames++;
118 118
    for(i = 0; i < 7; i++)
119
        smk->audio[i] = get_le32(pb);
120
    smk->treesize = get_le32(pb);
119
        smk->audio[i] = avio_rl32(pb);
120
    smk->treesize = avio_rl32(pb);
121 121

  
122 122
    if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (this check is probably redundant)
123 123
        av_log(s, AV_LOG_ERROR, "treesize too large\n");
......
125 125
    }
126 126

  
127 127
//FIXME remove extradata "rebuilding"
128
    smk->mmap_size = get_le32(pb);
129
    smk->mclr_size = get_le32(pb);
130
    smk->full_size = get_le32(pb);
131
    smk->type_size = get_le32(pb);
128
    smk->mmap_size = avio_rl32(pb);
129
    smk->mclr_size = avio_rl32(pb);
130
    smk->full_size = avio_rl32(pb);
131
    smk->type_size = avio_rl32(pb);
132 132
    for(i = 0; i < 7; i++)
133
        smk->rates[i] = get_le32(pb);
134
    smk->pad = get_le32(pb);
133
        smk->rates[i] = avio_rl32(pb);
134
    smk->pad = avio_rl32(pb);
135 135
    /* setup data */
136 136
    if(smk->frames > 0xFFFFFF) {
137 137
        av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
......
144 144

  
145 145
    /* read frame info */
146 146
    for(i = 0; i < smk->frames; i++) {
147
        smk->frm_size[i] = get_le32(pb);
147
        smk->frm_size[i] = avio_rl32(pb);
148 148
    }
149 149
    for(i = 0; i < smk->frames; i++) {
150
        smk->frm_flags[i] = get_byte(pb);
150
        smk->frm_flags[i] = avio_r8(pb);
151 151
    }
152 152

  
153 153
    /* init video codec */
......
207 207
        av_free(smk->frm_flags);
208 208
        return -1;
209 209
    }
210
    ret = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
210
    ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
211 211
    if(ret != st->codec->extradata_size - 16){
212 212
        av_free(smk->frm_size);
213 213
        av_free(smk->frm_flags);
......
251 251
            uint8_t oldpal[768];
252 252

  
253 253
            memcpy(oldpal, pal, 768);
254
            size = get_byte(s->pb);
254
            size = avio_r8(s->pb);
255 255
            size = size * 4 - 1;
256 256
            frame_size -= size;
257 257
            frame_size--;
258 258
            sz = 0;
259 259
            pos = url_ftell(s->pb) + size;
260 260
            while(sz < 256){
261
                t = get_byte(s->pb);
261
                t = avio_r8(s->pb);
262 262
                if(t & 0x80){ /* skip palette entries */
263 263
                    sz += (t & 0x7F) + 1;
264 264
                    pal += ((t & 0x7F) + 1) * 3;
265 265
                } else if(t & 0x40){ /* copy with offset */
266
                    off = get_byte(s->pb) * 3;
266
                    off = avio_r8(s->pb) * 3;
267 267
                    j = (t & 0x3F) + 1;
268 268
                    while(j-- && sz < 256) {
269 269
                        *pal++ = oldpal[off + 0];
......
274 274
                    }
275 275
                } else { /* new entries */
276 276
                    *pal++ = smk_pal[t];
277
                    *pal++ = smk_pal[get_byte(s->pb) & 0x3F];
278
                    *pal++ = smk_pal[get_byte(s->pb) & 0x3F];
277
                    *pal++ = smk_pal[avio_r8(s->pb) & 0x3F];
278
                    *pal++ = smk_pal[avio_r8(s->pb) & 0x3F];
279 279
                    sz++;
280 280
                }
281 281
            }
......
288 288
        for(i = 0; i < 7; i++) {
289 289
            if(flags & 1) {
290 290
                int size;
291
                size = get_le32(s->pb) - 4;
291
                size = avio_rl32(s->pb) - 4;
292 292
                frame_size -= size;
293 293
                frame_size -= 4;
294 294
                smk->curstream++;
295 295
                smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size);
296 296
                smk->buf_sizes[smk->curstream] = size;
297
                ret = get_buffer(s->pb, smk->bufs[smk->curstream], size);
297
                ret = avio_read(s->pb, smk->bufs[smk->curstream], size);
298 298
                if(ret != size)
299 299
                    return AVERROR(EIO);
300 300
                smk->stream_id[smk->curstream] = smk->indexes[i];
......
307 307
            palchange |= 2;
308 308
        pkt->data[0] = palchange;
309 309
        memcpy(pkt->data + 1, smk->pal, 768);
310
        ret = get_buffer(s->pb, pkt->data + 769, frame_size);
310
        ret = avio_read(s->pb, pkt->data + 769, frame_size);
311 311
        if(ret != frame_size)
312 312
            return AVERROR(EIO);
313 313
        pkt->stream_index = smk->videoindex;

Also available in: Unified diff