Browse code

lavu: make sure av_pix_fmt_desc_next returns a valid pix fmt.

This is required because there are some "holes" in the list for
compatibility with the fork.

The commit also removes the now unecessary check from cmdutils.

Found-by: wm4

Clément Bœsch authored on 2012/12/16 07:28:15
Showing 2 changed files
... ...
@@ -1195,8 +1195,6 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
1195 1195
 
1196 1196
     while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
1197 1197
         enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
1198
-        if(!pix_desc->name)
1199
-            continue;
1200 1198
         printf("%c%c%c%c%c %-16s       %d            %2d\n",
1201 1199
                sws_isSupportedInput (pix_fmt)      ? 'I' : '.',
1202 1200
                sws_isSupportedOutput(pix_fmt)      ? 'O' : '.',
... ...
@@ -1757,8 +1757,11 @@ const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
1757 1757
 {
1758 1758
     if (!prev)
1759 1759
         return &av_pix_fmt_descriptors[0];
1760
-    if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
1761
-        return prev + 1;
1760
+    while (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) {
1761
+        prev++;
1762
+        if (prev->name)
1763
+            return prev;
1764
+    }
1762 1765
     return NULL;
1763 1766
 }
1764 1767