summaryrefslogtreecommitdiffstats
path: root/video/fmt-conversion.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-08 17:20:57 +0100
committerwm4 <wm4@nowhere>2019-11-08 21:22:49 +0100
commit1edb3d061bd88e86cba05e9383d6decb4a13950b (patch)
tree18b5438f040464f841c5e0b9ae0a877175759c75 /video/fmt-conversion.c
parenta6c8b4efa59628a755755c510aa9ee6db2728fb9 (diff)
downloadmpv-1edb3d061bd88e86cba05e9383d6decb4a13950b.tar.bz2
mpv-1edb3d061bd88e86cba05e9383d6decb4a13950b.tar.xz
test: add dumping of img_format metadata
This is fragile enough that it warrants getting "monitored". This takes the commented test program code from img_format.c, makes it output to a text file, and then compares it to a "ref" file stored in git. Originally, I wanted to do the comparison etc. in a shell or Python script. But why not do it in C. So mpv calls /usr/bin/diff as a sub-process now. This test will start producing different output if FFmpeg adds new pixel formats or pixel format flags, or if mpv adds new IMGFMT (either aliases to FFmpeg formats or own formats). That is unavoidable, and requires manual inspection of the results, and then updating the ref file. The changes in the non-test code are to guarantee that the format ID conversion functions only translate between valid IDs.
Diffstat (limited to 'video/fmt-conversion.c')
-rw-r--r--video/fmt-conversion.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/video/fmt-conversion.c b/video/fmt-conversion.c
index 72f4407e70..b9b3d5ef66 100644
--- a/video/fmt-conversion.c
+++ b/video/fmt-conversion.c
@@ -95,7 +95,7 @@ enum AVPixelFormat imgfmt2pixfmt(int fmt)
enum AVPixelFormat pixfmt = fmt - IMGFMT_AVPIXFMT_START;
// Avoid duplicate format - each format must be unique.
int mpfmt = pixfmt2imgfmt(pixfmt);
- if (mpfmt == fmt)
+ if (mpfmt == fmt && av_pix_fmt_desc_get(pixfmt))
return pixfmt;
return AV_PIX_FMT_NONE;
}
@@ -118,7 +118,7 @@ int pixfmt2imgfmt(enum AVPixelFormat pix_fmt)
}
int generic = IMGFMT_AVPIXFMT_START + pix_fmt;
- if (generic < IMGFMT_AVPIXFMT_END)
+ if (generic < IMGFMT_AVPIXFMT_END && av_pix_fmt_desc_get(pix_fmt))
return generic;
return 0;