1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-23 11:47:45 +00:00

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.)
This commit is contained in:
wm4 2019-10-20 01:39:38 +02:00
parent 986daac45e
commit df8a0ecbf3

View File

@ -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(&reg, 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 = &reg.planes[n];
printf(" %d: {", n);