diff mbox series

[FFmpeg-devel,35/44] avformat/utils: Move av_find_default_stream_index to avformat.c

Message ID AS8PR01MB79449C763D175E778FA1F2A58FC49@AS8PR01MB7944.eurprd01.prod.exchangelabs.com
State Accepted
Commit e00d0ef46d7c4f9763c0482e635b483ff7954104
Headers show
Series [FFmpeg-devel] lib*/version: Move library version functions into files of their own | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt May 7, 2022, 11:28 a.m. UTC
While it is clearly written with demuxers in mind,
it is not forbidden to call it with muxers, hence avformat.c
and not demux_utils.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/avformat.c | 36 ++++++++++++++++++++++++++++++++++++
 libavformat/utils.c    | 36 ------------------------------------
 2 files changed, 36 insertions(+), 36 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index e3dad1f9a5..2b012a903f 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -276,6 +276,42 @@  AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int
     return NULL;
 }
 
+int av_find_default_stream_index(AVFormatContext *s)
+{
+    int best_stream = 0;
+    int best_score = INT_MIN;
+
+    if (s->nb_streams <= 0)
+        return -1;
+    for (unsigned i = 0; i < s->nb_streams; i++) {
+        const AVStream *const st = s->streams[i];
+        const FFStream *const sti = cffstream(st);
+        int score = 0;
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+            if (st->disposition & AV_DISPOSITION_ATTACHED_PIC)
+                score -= 400;
+            if (st->codecpar->width && st->codecpar->height)
+                score += 50;
+            score+= 25;
+        }
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+            if (st->codecpar->sample_rate)
+                score += 50;
+        }
+        if (sti->codec_info_nb_frames)
+            score += 12;
+
+        if (st->discard != AVDISCARD_ALL)
+            score += 200;
+
+        if (score > best_score) {
+            best_score = score;
+            best_stream = i;
+        }
+    }
+    return best_stream;
+}
+
 /**
  * Matches a stream specifier (but ignores requested index).
  *
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e500d35d83..b448f7b9cd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -181,42 +181,6 @@  int ff_is_intra_only(enum AVCodecID id)
     return 1;
 }
 
-int av_find_default_stream_index(AVFormatContext *s)
-{
-    int best_stream = 0;
-    int best_score = INT_MIN;
-
-    if (s->nb_streams <= 0)
-        return -1;
-    for (unsigned i = 0; i < s->nb_streams; i++) {
-        const AVStream *const st = s->streams[i];
-        const FFStream *const sti = cffstream(st);
-        int score = 0;
-        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
-            if (st->disposition & AV_DISPOSITION_ATTACHED_PIC)
-                score -= 400;
-            if (st->codecpar->width && st->codecpar->height)
-                score += 50;
-            score+= 25;
-        }
-        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
-            if (st->codecpar->sample_rate)
-                score += 50;
-        }
-        if (sti->codec_info_nb_frames)
-            score += 12;
-
-        if (st->discard != AVDISCARD_ALL)
-            score += 200;
-
-        if (score > best_score) {
-            best_score = score;
-            best_stream = i;
-        }
-    }
-    return best_stream;
-}
-
 /*******************************************************/
 
 unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)