Revision 73823cb9 libavformat/oggdec.c

View differences:

libavformat/oggdec.c
120 120
        os->granule = -1;
121 121
        os->lastpts = AV_NOPTS_VALUE;
122 122
        os->lastdts = AV_NOPTS_VALUE;
123
        os->sync_pos = -1;
124
        os->page_pos = 0;
123 125
        os->nsegs = 0;
124 126
        os->segp = 0;
125 127
        os->incomplete = 0;
......
255 257
    }
256 258

  
257 259
    os = ogg->streams + idx;
260
    os->page_pos = url_ftell(bc) - 27;
258 261

  
259 262
    if(os->psize > 0)
260 263
        ogg_new_buf(ogg, idx);
......
277 280
                if (seg < 255)
278 281
                    break;
279 282
            }
283
            os->sync_pos = os->page_pos;
280 284
        }
281 285
    }else{
282 286
        os->psize = 0;
287
        os->sync_pos = os->page_pos;
283 288
    }
284 289

  
285 290
    if (os->bufsize - os->bufpos < size){
......
303 308
}
304 309

  
305 310
static int
306
ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize)
311
ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpos)
307 312
{
308 313
    struct ogg *ogg = s->priv_data;
309 314
    int idx, i;
......
394 399
            *dstart = os->pstart;
395 400
        if (dsize)
396 401
            *dsize = os->psize;
402
        if (fpos)
403
            *fpos = os->sync_pos;
397 404
        os->pstart += os->psize;
398 405
        os->psize = 0;
406
        os->sync_pos = os->page_pos;
399 407
    }
400 408

  
401 409
    // determine whether there are more complete packets in this page
......
420 428
    struct ogg *ogg = s->priv_data;
421 429

  
422 430
    do{
423
        if (ogg_packet (s, NULL, NULL, NULL) < 0)
431
        if (ogg_packet (s, NULL, NULL, NULL, NULL) < 0)
424 432
            return -1;
425 433
    }while (!ogg->headers);
426 434

  
......
520 528
    struct ogg_stream *os;
521 529
    int idx = -1;
522 530
    int pstart, psize;
531
    int64_t fpos;
523 532

  
524 533
    //Get an ogg packet
525 534
    do{
526
        if (ogg_packet (s, &idx, &pstart, &psize) < 0)
535
        if (ogg_packet (s, &idx, &pstart, &psize, &fpos) < 0)
527 536
            return AVERROR(EIO);
528 537
    }while (idx < 0 || !s->streams[idx]);
529 538

  
......
557 566

  
558 567
    pkt->flags = os->pflags;
559 568
    pkt->duration = os->pduration;
569
    pkt->pos = fpos;
560 570

  
561 571
    return psize;
562 572
}

Also available in: Unified diff