Revision 6eb2de74

View differences:

libavformat/avidec.c
289 289
            print_tag("strh", tag1, -1);
290 290
#endif
291 291
            if(tag1 == MKTAG('i', 'a', 'v', 's') || tag1 == MKTAG('i', 'v', 'a', 's')){
292
                int64_t dv_dur;
293

  
292 294
                /*
293 295
                 * After some consideration -- I don't think we
294 296
                 * have to support anything but DV in a type1 AVIs.
......
314 316
                url_fskip(pb, 3 * 4);
315 317
                ast->scale = get_le32(pb);
316 318
                ast->rate = get_le32(pb);
319
                url_fskip(pb, 4);  /* start time */
320

  
321
                dv_dur = get_le32(pb);
322
                if (ast->scale > 0 && ast->rate > 0 && dv_dur > 0) {
323
                    dv_dur *= AV_TIME_BASE;
324
                    s->duration = av_rescale(dv_dur, ast->scale, ast->rate);
325
                }
326
                /*
327
                 * else, leave duration alone; timing estimation in utils.c
328
                 *      will make a guess based on bit rate.
329
                 */
330

  
317 331
                stream_index = s->nb_streams - 1;
318
                url_fskip(pb, size - 7*4);
332
                url_fskip(pb, size - 9*4);
319 333
                break;
320 334
            }
321 335

  
......
903 917

  
904 918
//    av_log(NULL, AV_LOG_DEBUG, "XX %"PRId64" %d %"PRId64"\n", timestamp, index, st->index_entries[index].timestamp);
905 919

  
920
    if (ENABLE_DV_DEMUXER && avi->dv_demux) {
921
        /* One and only one real stream for DV in AVI, and it has video  */
922
        /* offsets. Calling with other stream indices should have failed */
923
        /* the av_index_search_timestamp call above.                     */
924
        assert(stream_index == 0);
925

  
926
        /* Feed the DV video stream version of the timestamp to the */
927
        /* DV demux so it can synth correct timestamps              */
928
        dv_offset_reset(avi->dv_demux, timestamp);
929

  
930
        url_fseek(&s->pb, pos, SEEK_SET);
931
        avi->stream_index= -1;
932
        return 0;
933
    }
934

  
906 935
    for(i = 0; i < s->nb_streams; i++) {
907 936
        AVStream *st2 = s->streams[i];
908 937
        AVIStream *ast2 = st2->priv_data;
......
937 966
            ast2->frame_offset *=ast2->sample_size;
938 967
    }
939 968

  
940
    if (ENABLE_DV_DEMUXER && avi->dv_demux)
941
        dv_flush_audio_packets(avi->dv_demux);
942 969
    /* do the seek */
943 970
    url_fseek(&s->pb, pos, SEEK_SET);
944 971
    avi->stream_index= -1;
libavformat/dv.c
358 358
    return offset;
359 359
}
360 360

  
361
void dv_flush_audio_packets(DVDemuxContext *c)
361
void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
362 362
{
363
    c->frames= frame_offset;
364
    if (c->ach)
365
        c->abytes= av_rescale(c->frames,
366
                          c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base,
367
                          8*c->sys->frame_rate);
363 368
    c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
364 369
}
365 370

  
......
419 424
    DVDemuxContext *c = r->dv_demux;
420 425
    int64_t offset= dv_frame_offset(s, c, timestamp, flags);
421 426

  
422
    c->frames= offset / c->sys->frame_size;
423
    if (c->ach)
424
        c->abytes= av_rescale(c->frames,
425
                          c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base,
426
                          8*c->sys->frame_rate);
427
    dv_offset_reset(c, offset / c->sys->frame_size);
427 428

  
428
    dv_flush_audio_packets(c);
429 429
    return url_fseek(&s->pb, offset, SEEK_SET);
430 430
}
431 431

  
libavformat/dv.h
29 29
DVDemuxContext* dv_init_demux(AVFormatContext* s);
30 30
int dv_get_packet(DVDemuxContext*, AVPacket *);
31 31
int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int);
32
void dv_flush_audio_packets(DVDemuxContext*);
32
void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset);
33 33

  
34 34
typedef struct DVMuxContext DVMuxContext;
35 35
DVMuxContext* dv_init_mux(AVFormatContext* s);

Also available in: Unified diff