summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-10 17:45:20 +0100
committerwm4 <wm4@nowhere>2020-02-10 17:45:20 +0100
commitc31661466b8a7efcad418a0ba49f632ea035b2e4 (patch)
treeb05d9c2fd1f358719076e8551cba549e8ec92572
parenta841fe9484c203ca3492d8a5f88f60f8534c853b (diff)
downloadmpv-c31661466b8a7efcad418a0ba49f632ea035b2e4.tar.bz2
mpv-c31661466b8a7efcad418a0ba49f632ea035b2e4.tar.xz
zimg: fix some confusion about plane permutation
We reorder the planes between mpv and zimg conventions. It turns out the code still confused when which convention was used. So the way it actually works is that the _only_ place where zimg order is used is the zimg_image_buffer.plane[] array. plane_aligned[] and zmask[] were accessed incorrectly, although I guess it rarely had a reason to fail (plane reordering is mostly for RGB, which has planes of all the same size). Adjust some comments accordingly too.
-rw-r--r--video/zimg.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/video/zimg.c b/video/zimg.c
index dd5eb87d69..1ed5ca41da 100644
--- a/video/zimg.c
+++ b/video/zimg.c
@@ -75,8 +75,8 @@ struct mp_zimg_repack {
struct mp_image_params fmt; // original mp format (possibly packed format)
int zimgfmt; // zimg equivalent unpacked format
int zplanes; // number of planes (zimgfmt)
- unsigned zmask[4]; // zmask[n] = zimg_image_buffer.plane[n].mask
- int z_planes[4]; // z_planes[zimg_index] = mp_index
+ unsigned zmask[4]; // zmask[mp_index] = zimg mask (using mp index!)
+ int z_planes[4]; // z_planes[zimg_index] = mp_index (or -1)
bool pass_through_y; // luma plane optimization for e.g. nv12
// If set, the pack/unpack callback to pass to zimg.
@@ -465,16 +465,21 @@ static void wrap_buffer(struct mp_zimg_repack *r,
}
for (int n = 0; n < r->zplanes; n++) {
+ // Note: this is really the only place we have to care about plane
+ // permutation (zimg_image_buffer may have a different plane order
+ // than the shadow mpi like r->tmp). We never use the zimg indexes
+ // in other places.
int mplane = r->z_planes[n];
- r->use_buf[mplane] = !plane_aligned[n];
+ r->use_buf[mplane] = !plane_aligned[mplane];
if (!(r->pass_through_y && mplane == 0))
r->use_buf[mplane] |= !!r->repack;
struct mp_image *tmpi = r->use_buf[mplane] ? r->tmp : mpi;
buf->plane[n].data = tmpi->planes[mplane];
buf->plane[n].stride = tmpi->stride[mplane];
- buf->plane[n].mask = r->use_buf[mplane] ? r->zmask[n] : ZIMG_BUFFER_MAX;
+ buf->plane[n].mask = r->use_buf[mplane] ? r->zmask[mplane]
+ : ZIMG_BUFFER_MAX;
}
*cb = r->repack ? r->repack : repack_align;