The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / ffmpeg / 0008-Get-stream-durations-using-read_timestamp.patch
1 From c57e5b8154f5fe1457f4c64e04885a2cdfb37f51 Mon Sep 17 00:00:00 2001
2 From: Joakim Plate <elupus@ecce.se>
3 Date: Sat, 22 Oct 2011 19:01:38 +0200
4 Subject: [PATCH 08/13] Get stream durations using read_timestamp
5
6 Patch part of the XBMC patch set for ffmpeg, downloaded from
7 https://github.com/xbmc/FFmpeg/.
8
9 Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
10 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
11 ---
12  libavformat/utils.c | 39 +++++++++++++++++++++++++++++++++++++++
13  1 file changed, 39 insertions(+)
14
15 diff --git a/libavformat/utils.c b/libavformat/utils.c
16 index 3e8af50..f4fb172 100644
17 --- a/libavformat/utils.c
18 +++ b/libavformat/utils.c
19 @@ -2356,6 +2356,41 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
20  #define DURATION_MAX_READ_SIZE 250000LL
21  #define DURATION_MAX_RETRY 4
22  
23 +static void av_estimate_timings_from_pts2(AVFormatContext *ic, int64_t old_offset)
24 +{
25 +    AVStream *st;
26 +    int i, step= 1024;
27 +    int64_t ts, pos;
28 +
29 +    for(i=0;i<ic->nb_streams;i++) {
30 +        st = ic->streams[i];
31 +
32 +        pos = 0;
33 +        ts = ic->iformat->read_timestamp(ic, i, &pos, DURATION_MAX_READ_SIZE);
34 +        if (ts == AV_NOPTS_VALUE)
35 +            continue;
36 +        if (st->start_time > ts || st->start_time == AV_NOPTS_VALUE)
37 +            st->start_time = ts;
38 +
39 +        pos = avio_size(ic->pb) - 1;
40 +        do {
41 +            pos -= step;
42 +            ts = ic->iformat->read_timestamp(ic, i, &pos, pos + step);
43 +            step += step;
44 +        } while (ts == AV_NOPTS_VALUE && pos >= step && step < DURATION_MAX_READ_SIZE);
45 +
46 +        if (ts == AV_NOPTS_VALUE)
47 +            continue;
48 +
49 +        if (st->duration < ts - st->start_time || st->duration == AV_NOPTS_VALUE)
50 +            st->duration = ts - st->start_time;
51 +    }
52 +
53 +    fill_all_stream_timings(ic);
54 +
55 +    avio_seek(ic->pb, old_offset, SEEK_SET);
56 +}
57 +
58  /* only usable for MPEG-PS streams */
59  static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
60  {
61 @@ -2506,6 +2541,10 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
62           * the components */
63          fill_all_stream_timings(ic);
64          ic->duration_estimation_method = AVFMT_DURATION_FROM_STREAM;
65 +    } else if (ic->iformat->read_timestamp && 
66 +        file_size && ic->pb->seekable) {
67 +        /* get accurate estimate from the PTSes */
68 +        av_estimate_timings_from_pts2(ic, old_offset);
69      } else {
70          /* less precise: use bitrate info */
71          estimate_timings_from_bit_rate(ic);
72 -- 
73 2.1.0
74