Browse code

Add int64_t probesize2 instead of int probesize to AVFormatContext.

Allows to set a probesize >2G.
Tested-by: Oliver Fromme

Carl Eugen Hoyos authored on 2014/07/30 18:09:25
Showing 7 changed files
... ...
@@ -1296,9 +1296,7 @@ typedef struct AVFormatContext {
1296 1296
 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate.
1297 1297
 
1298 1298
     /**
1299
-     * Maximum size of the data read from input for determining
1300
-     * the input container format.
1301
-     * Demuxing only, set by the caller before avformat_open_input().
1299
+     * @deprecated deprecated in favor of probesize2
1302 1300
      */
1303 1301
     unsigned int probesize;
1304 1302
 
... ...
@@ -1671,6 +1669,14 @@ typedef struct AVFormatContext {
1671 1671
      * Can be set to 0 to let avformat choose using a heuristic.
1672 1672
      */
1673 1673
     int64_t max_analyze_duration2;
1674
+
1675
+    /**
1676
+     * Maximum size of the data read from input for determining
1677
+     * the input container format.
1678
+     * Demuxing only, set by the caller before avformat_open_input()
1679
+     * via AVOptions (NO direct access).
1680
+     */
1681
+    int64_t probesize2;
1674 1682
 } AVFormatContext;
1675 1683
 
1676 1684
 int av_format_get_probe_score(const AVFormatContext *s);
... ...
@@ -95,7 +95,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size);
95 95
  * within the current pos and pos+buf_size is possible.
96 96
  * Once the stream position moves outside this window this guarantee is lost.
97 97
  */
98
-int ffio_ensure_seekback(AVIOContext *s, int buf_size);
98
+int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size);
99 99
 
100 100
 int ffio_limit(AVIOContext *s, int size);
101 101
 
... ...
@@ -767,7 +767,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
767 767
     return 0;
768 768
 }
769 769
 
770
-int ffio_ensure_seekback(AVIOContext *s, int buf_size)
770
+int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
771 771
 {
772 772
     uint8_t *buffer;
773 773
     int max_buffer_size = s->max_packet_size ?
... ...
@@ -2242,12 +2242,13 @@ static void finished_reading_packet(AVFormatContext *s, int raw_packet_size)
2242 2242
         avio_skip(pb, skip);
2243 2243
 }
2244 2244
 
2245
-static int handle_packets(MpegTSContext *ts, int nb_packets)
2245
+static int handle_packets(MpegTSContext *ts, int64_t nb_packets)
2246 2246
 {
2247 2247
     AVFormatContext *s = ts->stream;
2248 2248
     uint8_t packet[TS_PACKET_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
2249 2249
     const uint8_t *data;
2250
-    int packet_num, ret = 0;
2250
+    int64_t packet_num;
2251
+    int ret = 0;
2251 2252
 
2252 2253
     if (avio_tell(s->pb) != ts->last_pos) {
2253 2254
         int i;
... ...
@@ -2369,9 +2370,9 @@ static int mpegts_read_header(AVFormatContext *s)
2369 2369
     AVIOContext *pb   = s->pb;
2370 2370
     uint8_t buf[8 * 1024] = {0};
2371 2371
     int len;
2372
-    int64_t pos;
2372
+    int64_t pos, probesize = s->probesize ? s->probesize : s->probesize2;
2373 2373
 
2374
-    ffio_ensure_seekback(pb, s->probesize);
2374
+    ffio_ensure_seekback(pb, probesize);
2375 2375
 
2376 2376
     /* read the first 8192 bytes to get packet size */
2377 2377
     pos = avio_tell(pb);
... ...
@@ -2394,7 +2395,7 @@ static int mpegts_read_header(AVFormatContext *s)
2394 2394
 
2395 2395
         mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
2396 2396
 
2397
-        handle_packets(ts, s->probesize / ts->raw_packet_size);
2397
+        handle_packets(ts, probesize / ts->raw_packet_size);
2398 2398
         /* if could not find service, enable auto_guess */
2399 2399
 
2400 2400
         ts->auto_guess = 1;
... ...
@@ -36,7 +36,7 @@
36 36
 static const AVOption avformat_options[] = {
37 37
 {"avioflags", NULL, OFFSET(avio_flags), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, INT_MIN, INT_MAX, D|E, "avioflags"},
38 38
 {"direct", "reduce buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVIO_FLAG_DIRECT }, INT_MIN, INT_MAX, D|E, "avioflags"},
39
-{"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.i64 = 5000000 }, 32, INT_MAX, D},
39
+{"probesize", "set probing size", OFFSET(probesize2), AV_OPT_TYPE_INT64, {.i64 = 5000000 }, 32, INT64_MAX, D},
40 40
 {"formatprobesize", "number of bytes to probe file format", OFFSET(format_probesize), AV_OPT_TYPE_INT, {.i64 = PROBE_BUF_MAX}, 0, INT_MAX-1, D},
41 41
 {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, E},
42 42
 {"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, D|E, "fflags"},
... ...
@@ -2950,10 +2950,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
2950 2950
     int64_t old_offset  = avio_tell(ic->pb);
2951 2951
     // new streams might appear, no options for those
2952 2952
     int orig_nb_streams = ic->nb_streams;
2953
-    int flush_codecs    = ic->probesize > 0;
2953
+    int flush_codecs;
2954 2954
     int64_t max_analyze_duration = ic->max_analyze_duration2;
2955
+    int64_t probesize = ic->probesize2;
2956
+
2955 2957
     if (!max_analyze_duration)
2956 2958
         max_analyze_duration = ic->max_analyze_duration;
2959
+    if (ic->probesize)
2960
+        probesize = ic->probesize;
2961
+    flush_codecs = probesize > 0;
2957 2962
 
2958 2963
     av_opt_set(ic, "skip_clear", "1", AV_OPT_SEARCH_CHILDREN);
2959 2964
 
... ...
@@ -3081,10 +3086,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
3081 3081
             }
3082 3082
         }
3083 3083
         /* We did not get all the codec info, but we read too much data. */
3084
-        if (read_size >= ic->probesize) {
3084
+        if (read_size >= probesize) {
3085 3085
             ret = count;
3086 3086
             av_log(ic, AV_LOG_DEBUG,
3087
-                   "Probe buffer size limit of %d bytes reached\n", ic->probesize);
3087
+                   "Probe buffer size limit of %"PRId64" bytes reached\n", probesize);
3088 3088
             for (i = 0; i < ic->nb_streams; i++)
3089 3089
                 if (!ic->streams[i]->r_frame_rate.num &&
3090 3090
                     ic->streams[i]->info->duration_count <= 1 &&
... ...
@@ -3328,7 +3333,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
3328 3328
         }
3329 3329
     }
3330 3330
 
3331
-    if (ic->probesize)
3331
+    if (probesize)
3332 3332
     estimate_timings(ic, old_offset);
3333 3333
 
3334 3334
     if (ret >= 0 && ic->nb_streams)
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/version.h"
31 31
 
32 32
 #define LIBAVFORMAT_VERSION_MAJOR 55
33
-#define LIBAVFORMAT_VERSION_MINOR 49
33
+#define LIBAVFORMAT_VERSION_MINOR 50
34 34
 #define LIBAVFORMAT_VERSION_MICRO 100
35 35
 
36 36
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \