[FFmpeg-cvslog] pixdesc: Explicitly handle invalid arguments to av_find_best_pix_fmt_of_2()

Mark Thompson git at videolan.org
Sun Jul 23 00:23:47 EEST 2017


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Sat Jul 22 21:49:46 2017 +0100| [f48efb14f9f9000ae8b62fd8e1ddb55d2b8cb1ea] | committer: Mark Thompson

pixdesc: Explicitly handle invalid arguments to av_find_best_pix_fmt_of_2()

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

 libavutil/pixdesc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 1983ce9ef5..e606b8e5c8 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2633,6 +2633,11 @@ enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, en
     const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2);
     int score1, score2;
 
+    if (!desc1) {
+        dst_pix_fmt = dst_pix_fmt2;
+    } else if (!desc2) {
+        dst_pix_fmt = dst_pix_fmt1;
+    } else {
     loss_mask= loss_ptr?~*loss_ptr:~0; /* use loss mask if provided */
     if(!has_alpha)
         loss_mask &= ~FF_LOSS_ALPHA;
@@ -2649,6 +2654,7 @@ enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, en
     } else {
         dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1;
     }
+    }
 
     if (loss_ptr)
         *loss_ptr = av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);



More information about the ffmpeg-cvslog mailing list