fmt-conversion.c: print name of any unrecognized pixfmt

Change the error message about unrecognized pixfmt values to include
the symbolic name of the pixfmt (available from libavutil).
This commit is contained in:
Uoti Urpala 2011-06-26 01:04:53 +03:00
parent a8b11797d8
commit 949626ee46
1 changed files with 10 additions and 3 deletions

View File

@ -18,6 +18,7 @@
#include "mp_msg.h" #include "mp_msg.h"
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#include <libavutil/pixdesc.h>
#include "libmpcodecs/img_format.h" #include "libmpcodecs/img_format.h"
#include "fmt-conversion.h" #include "fmt-conversion.h"
@ -114,12 +115,18 @@ enum PixelFormat imgfmt2pixfmt(int fmt)
int pixfmt2imgfmt(enum PixelFormat pix_fmt) int pixfmt2imgfmt(enum PixelFormat pix_fmt)
{ {
int i; int i;
int fmt;
for (i = 0; conversion_map[i].pix_fmt != PIX_FMT_NONE; i++) for (i = 0; conversion_map[i].pix_fmt != PIX_FMT_NONE; i++)
if (conversion_map[i].pix_fmt == pix_fmt) if (conversion_map[i].pix_fmt == pix_fmt)
break; break;
fmt = conversion_map[i].fmt; int fmt = conversion_map[i].fmt;
if (!fmt) if (!fmt) {
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 2, 0)
const char *fmtname = av_get_pix_fmt_name(pix_fmt);
mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported PixelFormat %s (%d)\n",
fmtname ? fmtname : "INVALID", pix_fmt);
#else
mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported PixelFormat %i\n", pix_fmt); mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported PixelFormat %i\n", pix_fmt);
#endif
}
return fmt; return fmt;
} }