[FFmpeg-cvslog] avformat/movenc: Use dedicated pointer for access to MOVTrack

Andreas Rheinhardt git at videolan.org
Tue Jan 4 06:21:39 EET 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Dec 16 02:16:29 2021 +0100| [029598bd4aa696253370c4429abe3c2c95f2e788] | committer: Andreas Rheinhardt

avformat/movenc: Use dedicated pointer for access to MOVTrack

Improves readability and slightly decreases codesize.
While just at it, also remove a check whether the packet list is
nonempty before freeing it, as freeing an empty list is fine
and basically a no-op.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=029598bd4aa696253370c4429abe3c2c95f2e788
---

 libavformat/movenc.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e5391bb80f..24965c89c2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6457,29 +6457,29 @@ static void mov_free(AVFormatContext *s)
     }
 
     for (i = 0; i < mov->nb_streams; i++) {
-        if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
-            ff_mov_close_hinting(&mov->tracks[i]);
-        else if (mov->tracks[i].tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd)
-            av_freep(&mov->tracks[i].par);
-        av_freep(&mov->tracks[i].cluster);
-        av_freep(&mov->tracks[i].frag_info);
-        av_packet_free(&mov->tracks[i].cover_image);
-
-        if (mov->tracks[i].eac3_priv) {
-            struct eac3_info *info = mov->tracks[i].eac3_priv;
+        MOVTrack *const track = &mov->tracks[i];
+
+        if (track->tag == MKTAG('r','t','p',' '))
+            ff_mov_close_hinting(track);
+        else if (track->tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd)
+            av_freep(&track->par);
+        av_freep(&track->cluster);
+        av_freep(&track->frag_info);
+        av_packet_free(&track->cover_image);
+
+        if (track->eac3_priv) {
+            struct eac3_info *info = track->eac3_priv;
             av_packet_free(&info->pkt);
-            av_freep(&mov->tracks[i].eac3_priv);
+            av_freep(&track->eac3_priv);
         }
-        if (mov->tracks[i].vos_len)
-            av_freep(&mov->tracks[i].vos_data);
+        if (track->vos_len)
+            av_freep(&track->vos_data);
 
-        ff_mov_cenc_free(&mov->tracks[i].cenc);
-        ffio_free_dyn_buf(&mov->tracks[i].mdat_buf);
+        ff_mov_cenc_free(&track->cenc);
+        ffio_free_dyn_buf(&track->mdat_buf);
 
-        if (mov->tracks[i].squashed_packet_queue) {
-            avpriv_packet_list_free(&(mov->tracks[i].squashed_packet_queue),
-                                    &(mov->tracks[i].squashed_packet_queue_end));
-        }
+        avpriv_packet_list_free(&track->squashed_packet_queue,
+                                &track->squashed_packet_queue_end);
     }
 
     av_freep(&mov->tracks);



More information about the ffmpeg-cvslog mailing list