summaryrefslogtreecommitdiffstats
path: root/video/out/gpu
diff options
context:
space:
mode:
authorBin Jin <bjin@ctrl-d.org>2019-03-07 14:53:52 +0000
committersfan5 <sfan5@live.de>2019-03-09 12:56:11 +0100
commitb3cbd4650984902548432f15be9f267f9cb2230e (patch)
tree8307aef32199a54c4312bba9bbca29ed376b251f /video/out/gpu
parente37c253b9207980a33ff3789b560efa3c4b6eb3e (diff)
downloadmpv-b3cbd4650984902548432f15be9f267f9cb2230e.tar.bz2
mpv-b3cbd4650984902548432f15be9f267f9cb2230e.tar.xz
vo_gpu: make texture offset available to CHROMA hooks
Before this commit, texture offset is set after all source textures are finalized. Which means CHROMA hooks won't be able to align with luma planes. This could be problematic for chroma prescalers utilizing information from luma plane. Fix this by find the reference texture early, and set global texture offset early.
Diffstat (limited to 'video/out/gpu')
-rw-r--r--video/out/gpu/video.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 593f5fb9c1..416ba928d1 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -2072,6 +2072,23 @@ static void pass_read_video(struct gl_video *p)
}
}
+ // The basic idea is we assume the rgb/luma texture is the "reference" and
+ // scale everything else to match, after all planes are finalized.
+ // We find the reference texture first, in order to maintain texture offset
+ // between hooks on different type of planes.
+ int reference_tex_num = 0;
+ for (int n = 0; n < 4; n++) {
+ switch (img[n].type) {
+ case PLANE_RGB:
+ case PLANE_XYZ:
+ case PLANE_LUMA: break;
+ default: continue;
+ }
+
+ reference_tex_num = n;
+ break;
+ }
+
// Dispatch the hooks for all of these textures, saving and perhaps
// modifying them in the process
for (int n = 0; n < 4; n++) {
@@ -2086,26 +2103,18 @@ static void pass_read_video(struct gl_video *p)
}
img[n] = pass_hook(p, name, img[n], &offsets[n]);
+
+ if (reference_tex_num == n) {
+ // The reference texture is finalized now.
+ p->texture_w = img[n].w;
+ p->texture_h = img[n].h;
+ p->texture_offset = offsets[n];
+ }
}
// At this point all planes are finalized but they may not be at the
// required size yet. Furthermore, they may have texture offsets that
- // require realignment. For lack of something better to do, we assume
- // the rgb/luma texture is the "reference" and scale everything else
- // to match.
- for (int n = 0; n < 4; n++) {
- switch (img[n].type) {
- case PLANE_RGB:
- case PLANE_XYZ:
- case PLANE_LUMA: break;
- default: continue;
- }
-
- p->texture_w = img[n].w;
- p->texture_h = img[n].h;
- p->texture_offset = offsets[n];
- break;
- }
+ // require realignment.
// Compute the reference rect
struct mp_rect_f src = {0.0, 0.0, p->image_params.w, p->image_params.h};