From df8a0ecbf32dd9af914ceb67df1861743b84f1e8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 20 Oct 2019 01:39:38 +0200 Subject: img_format: update test program The plane pointer checking assert() triggered at least on gray8, because that has a "pseudo palettes" in ffmpeg, which mpv refuses to allocate. Remove a strange duplicated printf(). Log the component type where available. (Why is this even here, I hate it when there are commented test programs in source files.) --- video/img_format.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/video/img_format.c b/video/img_format.c index be81e15b41..0ac943b6f0 100644 --- a/video/img_format.c +++ b/video/img_format.c @@ -523,9 +523,6 @@ int main(int argc, char **argv) printf(" fcsp=%d", fcsp); printf(" ctype=%d", mp_imgfmt_get_component_type(mpfmt)); printf("\n"); - printf(" planes=%d, chroma=%d:%d align=%d:%d bits=%d cbits=%d\n", - d.num_planes, d.chroma_xs, d.chroma_ys, d.align_x, d.align_y, - d.plane_bits, d.component_bits); printf(" planes=%d, chroma=%d:%d align=%d:%d bits=%d cbits=%d\n", d.num_planes, d.chroma_xs, d.chroma_ys, d.align_x, d.align_y, d.plane_bits, d.component_bits); @@ -545,18 +542,29 @@ int main(int argc, char **argv) assert(mpi); // A rather fuzzy test, which might fail even if there's no bug. for (int n = 0; n < 4; n++) { - assert(!!mpi->planes[n] == !!fr->data[n]); - assert(mpi->stride[n] == fr->linesize[n]); + if (!!mpi->planes[n] != !!fr->data[n]) { + printf(" Warning: p%d: %p %p\n", n, + mpi->planes[n], fr->data[n]); + } + if (mpi->stride[n] != fr->linesize[n]) { + printf(" Warning: p%d: %d %d\n", n, + mpi->stride[n], fr->linesize[n]); + } } talloc_free(mpi); av_frame_free(&fr); } struct mp_regular_imgfmt reg; if (mp_get_regular_imgfmt(®, mpfmt)) { - printf(" Regular: %d planes, %d bytes per comp., %d bit-pad " - "%dx%d chroma\n", + const char *type = "unknown"; + switch (reg.component_type) { + case MP_COMPONENT_TYPE_UINT: type = "uint"; break; + case MP_COMPONENT_TYPE_FLOAT: type = "float"; break; + } + printf(" Regular: %d planes, %d bytes per comp., %d bit-pad, " + "%dx%d chroma, type=%s\n", reg.num_planes, reg.component_size, reg.component_pad, - reg.chroma_w, reg.chroma_h); + reg.chroma_w, reg.chroma_h, type); for (int n = 0; n < reg.num_planes; n++) { struct mp_regular_imgfmt_plane *plane = ®.planes[n]; printf(" %d: {", n); -- cgit v1.2.3