[FFmpeg-cvslog] ffplay: factor out picture freeing code

Marton Balint git at videolan.org
Sat Oct 26 14:02:10 CEST 2013


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Oct 19 01:18:41 2013 +0200| [2d059d8de1b4904c3a56ac99dc0badb870a50941] | committer: Marton Balint

ffplay: factor out picture freeing code

Signed-off-by: Marton Balint <cus at passwd.hu>

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

 ffplay.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 2930234..0be7414 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -785,6 +785,14 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw,
     }
 }
 
+static void free_picture(VideoPicture *vp)
+{
+     if (vp->bmp) {
+         SDL_FreeYUVOverlay(vp->bmp);
+         vp->bmp = NULL;
+     }
+}
+
 static void free_subpicture(SubPicture *sp)
 {
     avsubtitle_free(&sp->sub);
@@ -1013,7 +1021,6 @@ static void video_audio_display(VideoState *s)
 
 static void stream_close(VideoState *is)
 {
-    VideoPicture *vp;
     int i;
     /* XXX: use a special url_shutdown call to abort parse cleanly */
     is->abort_request = 1;
@@ -1023,13 +1030,8 @@ static void stream_close(VideoState *is)
     packet_queue_destroy(&is->subtitleq);
 
     /* free all pictures */
-    for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) {
-        vp = &is->pictq[i];
-        if (vp->bmp) {
-            SDL_FreeYUVOverlay(vp->bmp);
-            vp->bmp = NULL;
-        }
-    }
+    for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++)
+        free_picture(&is->pictq[i]);
     for (i = 0; i < SUBPICTURE_QUEUE_SIZE; i++)
         free_subpicture(&is->subpq[i]);
     SDL_DestroyMutex(is->pictq_mutex);
@@ -1505,8 +1507,7 @@ static void alloc_picture(VideoState *is)
 
     vp = &is->pictq[is->pictq_windex];
 
-    if (vp->bmp)
-        SDL_FreeYUVOverlay(vp->bmp);
+    free_picture(vp);
 
     video_open(is, 0, vp);
 



More information about the ffmpeg-cvslog mailing list