diff mbox

[FFmpeg-devel,2/3] avformat/movenc: add rtp_hinting_needed() helper function

Message ID 20180402083658.24460-3-timo.teras@iki.fi
State Accepted
Commit 53688b62ca96ad9a3b0e7d201caca61c79a68648
Headers show

Commit Message

Timo Teräs April 2, 2018, 8:36 a.m. UTC
This is shared test and this simplifies code a bit. Follow up
commit will have additional tests for this function.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
---
 libavformat/movenc.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

Comments

Michael Niedermayer April 4, 2018, 1:48 a.m. UTC | #1
On Mon, Apr 02, 2018 at 11:36:57AM +0300, Timo Teräs wrote:
> This is shared test and this simplifies code a bit. Follow up
> commit will have additional tests for this function.
> 
> Signed-off-by: Timo Teräs <timo.teras@iki.fi>
> ---
>  libavformat/movenc.c | 30 ++++++++++++------------------
>  1 file changed, 12 insertions(+), 18 deletions(-)

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 230aeb6a6d..f6a314894c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -141,6 +141,13 @@  static int co64_required(const MOVTrack *track)
     return 0;
 }
 
+static int rtp_hinting_needed(const AVStream *st)
+{
+    /* Add hint tracks for each audio and video stream */
+    return st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+           st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
+}
+
 /* Chunk offset atom */
 static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track)
 {
@@ -5945,14 +5952,9 @@  static int mov_init(AVFormatContext *s)
         mov->chapter_track = mov->nb_streams++;
 
     if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
-        /* Add hint tracks for each audio and video stream */
-        for (i = 0; i < s->nb_streams; i++) {
-            AVStream *st = s->streams[i];
-            if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
-                st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+        for (i = 0; i < s->nb_streams; i++)
+            if (rtp_hinting_needed(s->streams[i]))
                 mov->nb_streams++;
-            }
-        }
     }
 
     if (   mov->write_tmcd == -1 && (mov->mode == MODE_MOV || mov->mode == MODE_MP4)
@@ -6175,15 +6177,10 @@  static int mov_write_header(AVFormatContext *s)
         nb_tracks++;
 
     if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
-        /* Add hint tracks for each audio and video stream */
         hint_track = nb_tracks;
-        for (i = 0; i < s->nb_streams; i++) {
-            AVStream *st = s->streams[i];
-            if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
-                st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+        for (i = 0; i < s->nb_streams; i++)
+            if (rtp_hinting_needed(s->streams[i]))
                 nb_tracks++;
-            }
-        }
     }
 
     if (mov->mode == MODE_MOV || mov->mode == MODE_MP4)
@@ -6261,11 +6258,8 @@  static int mov_write_header(AVFormatContext *s)
             return ret;
 
     if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
-        /* Initialize the hint tracks for each audio and video stream */
         for (i = 0; i < s->nb_streams; i++) {
-            AVStream *st = s->streams[i];
-            if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
-                st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+            if (rtp_hinting_needed(s->streams[i])) {
                 if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0)
                     return ret;
                 hint_track++;