[FFmpeg-devel] [PATCH 21/44] avformat/utils: Move avformat_queue_attached_pictures to demux_utils.c

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat May 7 14:28:07 EEST 2022


AVStream.attached_pic is only used for demuxers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/demux_utils.c | 24 ++++++++++++++++++++++++
 libavformat/utils.c       | 23 -----------------------
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/libavformat/demux_utils.c b/libavformat/demux_utils.c
index 0ec9f3b2fa..ca5750d1ef 100644
--- a/libavformat/demux_utils.c
+++ b/libavformat/demux_utils.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcodec/packet_internal.h"
 #include "avformat.h"
 #include "demux.h"
 #include "internal.h"
@@ -83,3 +84,26 @@ void av_format_inject_global_side_data(AVFormatContext *s)
         ffstream(st)->inject_global_side_data = 1;
     }
 }
+
+int avformat_queue_attached_pictures(AVFormatContext *s)
+{
+    FFFormatContext *const si = ffformatcontext(s);
+    int ret;
+    for (unsigned i = 0; i < s->nb_streams; i++)
+        if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC &&
+            s->streams[i]->discard < AVDISCARD_ALL) {
+            if (s->streams[i]->attached_pic.size <= 0) {
+                av_log(s, AV_LOG_WARNING,
+                       "Attached picture on stream %d has invalid size, "
+                       "ignoring\n", i);
+                continue;
+            }
+
+            ret = avpriv_packet_list_put(&si->raw_packet_buffer,
+                                         &s->streams[i]->attached_pic,
+                                         av_packet_ref, 0);
+            if (ret < 0)
+                return ret;
+        }
+    return 0;
+}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b20dad2458..492fca000a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -175,29 +175,6 @@ int av_filename_number_test(const char *filename)
            (av_get_frame_filename(buf, sizeof(buf), filename, 1) >= 0);
 }
 
-int avformat_queue_attached_pictures(AVFormatContext *s)
-{
-    FFFormatContext *const si = ffformatcontext(s);
-    int ret;
-    for (unsigned i = 0; i < s->nb_streams; i++)
-        if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC &&
-            s->streams[i]->discard < AVDISCARD_ALL) {
-            if (s->streams[i]->attached_pic.size <= 0) {
-                av_log(s, AV_LOG_WARNING,
-                    "Attached picture on stream %d has invalid size, "
-                    "ignoring\n", i);
-                continue;
-            }
-
-            ret = avpriv_packet_list_put(&si->raw_packet_buffer,
-                                     &s->streams[i]->attached_pic,
-                                     av_packet_ref, 0);
-            if (ret < 0)
-                return ret;
-        }
-    return 0;
-}
-
 int ff_add_attached_pic(AVFormatContext *s, AVStream *st0, AVIOContext *pb,
                         AVBufferRef **buf, int size)
 {
-- 
2.32.0



More information about the ffmpeg-devel mailing list