summaryrefslogtreecommitdiffstats
path: root/video/zimg.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-21 23:11:23 +0200
committerwm4 <wm4@nowhere>2020-04-23 13:24:35 +0200
commit0f8f6a665b7bf7fc8786541eff518bacddbe1442 (patch)
treebb47ac337b6a249c2036910c599aaeb27728efa3 /video/zimg.c
parent7cb83593c2a032e91f82a90d0a9de8cf4d0fb158 (diff)
downloadmpv-0f8f6a665b7bf7fc8786541eff518bacddbe1442.tar.bz2
mpv-0f8f6a665b7bf7fc8786541eff518bacddbe1442.tar.xz
video: change chroma_w/chroma_h fields to use shift instead of size
When I added mp_regular_imgfmt, I made the chroma subsampling use the actual chroma division factor, instead of a shift (log2 of the actual value). I had some ideas about how this was (probably?) more intuitive and general. But nothing ever uses non-power of 2 subsampling (except jpeg in rare cases apparently, because the world is a bad place). Change the fields back to use shifts and rename them to avoid mistakes.
Diffstat (limited to 'video/zimg.c')
-rw-r--r--video/zimg.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/video/zimg.c b/video/zimg.c
index 1ce73b6f2c..1edda723e4 100644
--- a/video/zimg.c
+++ b/video/zimg.c
@@ -816,8 +816,6 @@ static void setup_fringe_rgb_packer(struct mp_zimg_repack *r,
.component_size = 1,
.num_planes = 3,
.planes = { {1, {2}}, {1, {3}}, {1, {1}} },
- .chroma_w = 1,
- .chroma_h = 1,
};
r->zimgfmt = mp_find_regular_imgfmt(&gbrp);
if (!r->zimgfmt)
@@ -890,8 +888,8 @@ static void setup_fringe_yuv422_packer(struct mp_zimg_repack *r)
.component_size = r->comp_size,
.num_planes = 3,
.planes = { {1, {1}}, {1, {2}}, {1, {3}} },
- .chroma_w = 2,
- .chroma_h = 1,
+ .chroma_xs = 1,
+ .chroma_ys = 0,
};
r->zimgfmt = mp_find_regular_imgfmt(&yuvfmt);
r->repack = fringe_yuv422_repack;
@@ -977,8 +975,6 @@ static void setup_misc_packer(struct mp_zimg_repack *r)
{1, {2}},
{1, {3}},
},
- .chroma_w = 1,
- .chroma_h = 1,
};
int planar_fmt = mp_find_regular_imgfmt(&planar10);
if (!planar_fmt)
@@ -996,8 +992,6 @@ static void setup_misc_packer(struct mp_zimg_repack *r)
.component_size = 1,
.num_planes = 4,
.planes = { {1, {2}}, {1, {3}}, {1, {1}}, {1, {4}}, },
- .chroma_w = 1,
- .chroma_h = 1,
};
int grap_fmt = mp_find_regular_imgfmt(&gbrap);
if (!grap_fmt)
@@ -1118,8 +1112,7 @@ static bool setup_format_ne(zimg_image_format *zfmt, struct mp_zimg_repack *r,
return false;
// no weird stuff
- if (desc.num_planes > 4 || !MP_IS_POWER_OF_2(desc.chroma_w) ||
- !MP_IS_POWER_OF_2(desc.chroma_h))
+ if (desc.num_planes > 4)
return false;
// Endian swapping.
@@ -1164,8 +1157,8 @@ static bool setup_format_ne(zimg_image_format *zfmt, struct mp_zimg_repack *r,
// Note: formats with subsampled chroma may have odd width or height in
// mpv and FFmpeg. This is because the width/height is actually a cropping
// rectangle. Reconstruct the image allocation size and set the cropping.
- zfmt->width = r->real_w = MP_ALIGN_UP(fmt.w, desc.chroma_w);
- zfmt->height = r->real_h = MP_ALIGN_UP(fmt.h, desc.chroma_h);
+ zfmt->width = r->real_w = MP_ALIGN_UP(fmt.w, 1 << desc.chroma_xs);
+ zfmt->height = r->real_h = MP_ALIGN_UP(fmt.h, 1 << desc.chroma_ys);
if (!r->pack && ctx) {
// Relies on ctx->zimg_dst being initialized first.
struct mp_zimg_repack *dst = ctx->zimg_dst;
@@ -1174,8 +1167,8 @@ static bool setup_format_ne(zimg_image_format *zfmt, struct mp_zimg_repack *r,
}
- zfmt->subsample_w = mp_log2(desc.chroma_w);
- zfmt->subsample_h = mp_log2(desc.chroma_h);
+ zfmt->subsample_w = desc.chroma_xs;
+ zfmt->subsample_h = desc.chroma_ys;
zfmt->color_family = ZIMG_COLOR_YUV;
if (desc.num_planes <= 2) {