Revision b7effd4e libavformat/flvdec.c

View differences:

libavformat/flvdec.c
97 97
                vcodec->extradata_size = 1;
98 98
                vcodec->extradata = av_malloc(1);
99 99
            }
100
            vcodec->extradata[0] = get_byte(s->pb);
100
            vcodec->extradata[0] = avio_r8(s->pb);
101 101
            return 1; // 1 byte body size adjustment for flv_read_packet()
102 102
        case FLV_CODECID_H264:
103 103
            vcodec->codec_id = CODEC_ID_H264;
......
111 111
}
112 112

  
113 113
static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize) {
114
    int length = get_be16(ioc);
114
    int length = avio_rb16(ioc);
115 115
    if(length >= buffsize) {
116 116
        url_fskip(ioc, length);
117 117
        return -1;
118 118
    }
119 119

  
120
    get_buffer(ioc, buffer, length);
120
    avio_read(ioc, buffer, length);
121 121

  
122 122
    buffer[length] = '\0';
123 123

  
......
134 134
    num_val = 0;
135 135
    ioc = s->pb;
136 136

  
137
    amf_type = get_byte(ioc);
137
    amf_type = avio_r8(ioc);
138 138

  
139 139
    switch(amf_type) {
140 140
        case AMF_DATA_TYPE_NUMBER:
141
            num_val = av_int2dbl(get_be64(ioc)); break;
141
            num_val = av_int2dbl(avio_rb64(ioc)); break;
142 142
        case AMF_DATA_TYPE_BOOL:
143
            num_val = get_byte(ioc); break;
143
            num_val = avio_r8(ioc); break;
144 144
        case AMF_DATA_TYPE_STRING:
145 145
            if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
146 146
                return -1;
......
148 148
        case AMF_DATA_TYPE_OBJECT: {
149 149
            unsigned int keylen;
150 150

  
151
            while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
151
            while(url_ftell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) {
152 152
                url_fskip(ioc, keylen); //skip key string
153 153
                if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
154 154
                    return -1; //if we couldn't skip, bomb out.
155 155
            }
156
            if(get_byte(ioc) != AMF_END_OF_OBJECT)
156
            if(avio_r8(ioc) != AMF_END_OF_OBJECT)
157 157
                return -1;
158 158
        }
159 159
            break;
......
168 168
                if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
169 169
                    return -1;
170 170
            }
171
            if(get_byte(ioc) != AMF_END_OF_OBJECT)
171
            if(avio_r8(ioc) != AMF_END_OF_OBJECT)
172 172
                return -1;
173 173
            break;
174 174
        case AMF_DATA_TYPE_ARRAY: {
175 175
            unsigned int arraylen, i;
176 176

  
177
            arraylen = get_be32(ioc);
177
            arraylen = avio_rb32(ioc);
178 178
            for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
179 179
                if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
180 180
                    return -1; //if we couldn't skip, bomb out.
......
222 222
    ioc = s->pb;
223 223

  
224 224
    //first object needs to be "onMetaData" string
225
    type = get_byte(ioc);
225
    type = avio_r8(ioc);
226 226
    if(type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0 || strcmp(buffer, "onMetaData"))
227 227
        return -1;
228 228

  
......
255 255
    int offset, flags;
256 256

  
257 257
    url_fskip(s->pb, 4);
258
    flags = get_byte(s->pb);
258
    flags = avio_r8(s->pb);
259 259
    /* old flvtool cleared this field */
260 260
    /* FIXME: better fix needed */
261 261
    if (!flags) {
......
276 276
            return AVERROR(ENOMEM);
277 277
    }
278 278

  
279
    offset = get_be32(s->pb);
279
    offset = avio_rb32(s->pb);
280 280
    url_fseek(s->pb, offset, SEEK_SET);
281 281
    url_fskip(s->pb, 4);
282 282

  
......
292 292
    if (!st->codec->extradata)
293 293
        return AVERROR(ENOMEM);
294 294
    st->codec->extradata_size = size;
295
    get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
295
    avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
296 296
    return 0;
297 297
}
298 298

  
......
306 306

  
307 307
 for(;;url_fskip(s->pb, 4)){ /* pkt size is repeated at end. skip it */
308 308
    pos = url_ftell(s->pb);
309
    type = get_byte(s->pb);
310
    size = get_be24(s->pb);
311
    dts = get_be24(s->pb);
312
    dts |= get_byte(s->pb) << 24;
309
    type = avio_r8(s->pb);
310
    size = avio_rb24(s->pb);
311
    dts = avio_rb24(s->pb);
312
    dts |= avio_r8(s->pb) << 24;
313 313
//    av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, dts:%d\n", type, size, dts);
314 314
    if (url_feof(s->pb))
315 315
        return AVERROR_EOF;
......
323 323

  
324 324
    if (type == FLV_TAG_TYPE_AUDIO) {
325 325
        is_audio=1;
326
        flags = get_byte(s->pb);
326
        flags = avio_r8(s->pb);
327 327
        size--;
328 328
    } else if (type == FLV_TAG_TYPE_VIDEO) {
329 329
        is_audio=0;
330
        flags = get_byte(s->pb);
330
        flags = avio_r8(s->pb);
331 331
        size--;
332 332
        if ((flags & 0xf0) == 0x50) /* video info / command frame */
333 333
            goto skip;
......
375 375
        const int64_t pos= url_ftell(s->pb);
376 376
        const int64_t fsize= url_fsize(s->pb);
377 377
        url_fseek(s->pb, fsize-4, SEEK_SET);
378
        size= get_be32(s->pb);
378
        size= avio_rb32(s->pb);
379 379
        url_fseek(s->pb, fsize-3-size, SEEK_SET);
380
        if(size == get_be24(s->pb) + 11){
381
            uint32_t ts = get_be24(s->pb);
382
            ts |= get_byte(s->pb) << 24;
380
        if(size == avio_rb24(s->pb) + 11){
381
            uint32_t ts = avio_rb24(s->pb);
382
            ts |= avio_r8(s->pb) << 24;
383 383
            s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
384 384
        }
385 385
        url_fseek(s->pb, pos, SEEK_SET);
......
400 400

  
401 401
    if (st->codec->codec_id == CODEC_ID_AAC ||
402 402
        st->codec->codec_id == CODEC_ID_H264) {
403
        int type = get_byte(s->pb);
403
        int type = avio_r8(s->pb);
404 404
        size--;
405 405
        if (st->codec->codec_id == CODEC_ID_H264) {
406
            int32_t cts = (get_be24(s->pb)+0xff800000)^0xff800000; // sign extension
406
            int32_t cts = (avio_rb24(s->pb)+0xff800000)^0xff800000; // sign extension
407 407
            pts = dts + cts;
408 408
            if (cts < 0) { // dts are wrong
409 409
                flv->wrong_dts = 1;

Also available in: Unified diff