summaryrefslogtreecommitdiffstats
path: root/abs/core/ffmpeg/fs56089.patch
blob: 6aca38f9f96cb3368af1d7e5ac4031a6af4502f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
diff -rupN ffmpeg-3.4.orig/libavformat/aviobuf.c ffmpeg-3.4/libavformat/aviobuf.c
--- ffmpeg-3.4.orig/libavformat/aviobuf.c	2017-11-02 14:57:16.078834563 +0100
+++ ffmpeg-3.4/libavformat/aviobuf.c	2017-11-02 15:02:52.549816990 +0100
@@ -531,6 +531,24 @@ void avio_write_marker(AVIOContext *s, i
     s->last_time = time;
 }
 
+static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size)
+{
+    int ret;
+
+    if (!s->read_packet)
+        return AVERROR_EOF;
+    ret = s->read_packet(s->opaque, buf, size);
+#if FF_API_OLD_AVIO_EOF_0
+    if (!ret && !s->max_packet_size) {
+        av_log(NULL, AV_LOG_WARNING, "Invalid return value 0 for stream protocol\n");
+        ret = AVERROR_EOF;
+    }
+#else
+    av_assert2(ret || s->max_packet_size);
+#endif
+    return ret;
+}
+
 /* Input stream */
 
 static void fill_buffer(AVIOContext *s)
@@ -569,10 +587,7 @@ static void fill_buffer(AVIOContext *s)
         len = s->orig_buffer_size;
     }
 
-    if (s->read_packet)
-        len = s->read_packet(s->opaque, dst, len);
-    else
-        len = 0;
+    len = read_packet_wrapper(s, dst, len);
     if (len <= 0) {
         /* do not modify buffer if EOF reached so that a seek back can
            be done without rereading data */
@@ -644,8 +659,7 @@ int avio_read(AVIOContext *s, unsigned c
         if (len == 0 || s->write_flag) {
             if((s->direct || size > s->buffer_size) && !s->update_checksum) {
                 // bypass the buffer and read data directly into buf
-                if(s->read_packet)
-                    len = s->read_packet(s->opaque, buf, size);
+                len = read_packet_wrapper(s, buf, size);
 
                 if (len <= 0) {
                     /* do not modify buffer if EOF reached so that a seek back can
@@ -711,7 +725,7 @@ int avio_read_partial(AVIOContext *s, un
         return -1;
 
     if (s->read_packet && s->write_flag) {
-        len = s->read_packet(s->opaque, buf, size);
+        len = read_packet_wrapper(s, buf, size);
         if (len > 0)
             s->pos += len;
         return len;
diff -rupN ffmpeg-3.4.orig/libavformat/avio.h ffmpeg-3.4/libavformat/avio.h
--- ffmpeg-3.4.orig/libavformat/avio.h	2017-11-02 14:57:16.078834563 +0100
+++ ffmpeg-3.4/libavformat/avio.h	2017-11-02 14:59:15.602300896 +0100
@@ -452,6 +452,8 @@ void avio_free_directory_entry(AVIODirEn
  * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
  * @param opaque An opaque pointer to user-specific data.
  * @param read_packet  A function for refilling the buffer, may be NULL.
+ *                     For stream protocols, must never return 0 but rather
+ *                     a proper AVERROR code.
  * @param write_packet A function for writing the buffer contents, may be NULL.
  *        The function may not change the input buffers content.
  * @param seek A function for seeking to specified byte position, may be NULL.
diff -rupN ffmpeg-3.4.orig/libavformat/version.h ffmpeg-3.4/libavformat/version.h
--- ffmpeg-3.4.orig/libavformat/version.h	2017-11-02 14:57:16.082167807 +0100
+++ ffmpeg-3.4/libavformat/version.h	2017-11-02 15:04:01.704627612 +0100
@@ -97,6 +97,9 @@
 #ifndef FF_API_OLD_ROTATE_API
 #define FF_API_OLD_ROTATE_API           (LIBAVFORMAT_VERSION_MAJOR < 58)
 #endif
+#ifndef FF_API_OLD_AVIO_EOF_0
+#define FF_API_OLD_AVIO_EOF_0           (LIBAVFORMAT_VERSION_MAJOR < 58)
+#endif
 
 
 #ifndef FF_API_R_FRAME_RATE