diff options
author | wm4 <wm4@nowhere> | 2020-05-17 14:57:13 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-18 01:54:59 +0200 |
commit | caee8748da5c25b928f699bfa9f1ac4a5f3ae0ce (patch) | |
tree | 492d46f6ab40eee4c5b3e17b3666d21843db4166 /video/repack.c | |
parent | 00ac63c37b18ef3e7fbe5c227eb10073b264a26a (diff) | |
download | mpv-caee8748da5c25b928f699bfa9f1ac4a5f3ae0ce.tar.bz2 mpv-caee8748da5c25b928f699bfa9f1ac4a5f3ae0ce.tar.xz |
video: clean up some imgfmt related stuff
Remove the vaguely defined plane_bits and component_bits fields from
struct mp_imgfmt_desc. Add weird replacements for existing uses. Remove
the bytes[] field, replace uses with bpp[].
Fix some potential alignment issues in existing code. As a compromise,
split mp_image_pixel_ptr() into 2 functions, because I think it's a bad
idea to implicitly round, but for some callers being slightly less
strict is convenient.
This shouldn't really change anything. In fact, it's a 100% useless
change. I'm just cleaning up what I started almost 8 years ago (see
commit 00653a3eb052). With this I've decided to keep mp_imgfmt_desc,
just removing the weird parts, and keeping the saner parts.
Diffstat (limited to 'video/repack.c')
-rw-r--r-- | video/repack.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/video/repack.c b/video/repack.c index db9bc31ac7..f5d8739fc4 100644 --- a/video/repack.c +++ b/video/repack.c @@ -132,8 +132,8 @@ static void copy_plane(struct mp_image *dst, int dst_x, int dst_y, assert(dst->fmt.bpp[p] == src->fmt.bpp[p]); for (int y = 0; y < h; y++) { - void *pd = mp_image_pixel_ptr(dst, p, dst_x, dst_y + y); - void *ps = mp_image_pixel_ptr(src, p, src_x, src_y + y); + void *pd = mp_image_pixel_ptr_ny(dst, p, dst_x, dst_y + y); + void *ps = mp_image_pixel_ptr_ny(src, p, src_x, src_y + y); memcpy(pd, ps, size); } } @@ -147,17 +147,17 @@ static void swap_endian(struct mp_image *dst, int dst_x, int dst_y, for (int p = 0; p < dst->fmt.num_planes; p++) { int xs = dst->fmt.xs[p]; - int bpp = dst->fmt.bytes[p]; + int bpp = dst->fmt.bpp[p] / 8; int words_per_pixel = bpp / endian_size; int num_words = ((w + (1 << xs) - 1) >> xs) * words_per_pixel; // Number of lines on this plane. int h = (1 << dst->fmt.chroma_ys) - (1 << dst->fmt.ys[p]) + 1; - assert(src->fmt.bytes[p] == bpp); + assert(src->fmt.bpp[p] == bpp * 8); for (int y = 0; y < h; y++) { - void *s = mp_image_pixel_ptr(src, p, src_x, src_y + y); - void *d = mp_image_pixel_ptr(dst, p, dst_x, dst_y + y); + void *s = mp_image_pixel_ptr_ny(src, p, src_x, src_y + y); + void *d = mp_image_pixel_ptr_ny(dst, p, dst_x, dst_y + y); switch (endian_size) { case 2: for (int x = 0; x < num_words; x++) @@ -851,8 +851,8 @@ static void repack_float(struct mp_repack *rp, for (int p = 0; p < b->num_planes; p++) { int h = (1 << b->fmt.chroma_ys) - (1 << b->fmt.ys[p]) + 1; for (int y = 0; y < h; y++) { - void *pa = mp_image_pixel_ptr(a, p, a_x, a_y + y); - void *pb = mp_image_pixel_ptr(b, p, b_x, b_y + y); + void *pa = mp_image_pixel_ptr_ny(a, p, a_x, a_y + y); + void *pb = mp_image_pixel_ptr_ny(b, p, b_x, b_y + y); packer(pa, pb, w >> b->fmt.xs[p], rp->f32_m[p], rp->f32_o[p], rp->f32_pmax[p]); |