Skip to content

Commit

Permalink
video: clean up some imgfmt related stuff
Browse files Browse the repository at this point in the history
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 00653a3). With this I've decided to keep mp_imgfmt_desc,
just removing the weird parts, and keeping the saner parts.
  • Loading branch information
wm4 committed May 17, 2020
1 parent 00ac63c commit caee874
Show file tree
Hide file tree
Showing 15 changed files with 747 additions and 756 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Interface changes
- reading loop-file property as native property or mpv_node will now return
"inf" instead of boolean true (also affects loop option)
- remove some --vo-direct3d-... options (it got dumbed down; use --vo=gpu)
- remove video-params/plane-depth property (was too vaguely defined)
--- mpv 0.32.0 ---
- change behavior when using legacy option syntax with options that start
with two dashes (``--`` instead of a ``-``). Now, using the recommended
Expand Down
5 changes: 0 additions & 5 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2236,11 +2236,6 @@ Property list
different resolution, which is the reason this value can sometimes be
odd or confusing. Can be unavailable with some formats.

``video-params/plane-depth``
Bit depth for each color component as integer. This is only exposed
for planar or single-component formats, and is unavailable for other
formats.

``video-params/w``, ``video-params/h``
Video size as integers, with no aspect correction applied.

Expand Down
2 changes: 0 additions & 2 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2131,8 +2131,6 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg)
{"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.imgfmt))},
{"average-bpp", SUB_PROP_INT(bpp),
.unavailable = !bpp},
{"plane-depth", SUB_PROP_INT(desc.plane_bits),
.unavailable = !(desc.flags & MP_IMGFLAG_YUV_P)},
{"w", SUB_PROP_INT(p.w)},
{"h", SUB_PROP_INT(p.h)},
{"dw", SUB_PROP_INT(d_w)},
Expand Down
8 changes: 4 additions & 4 deletions sub/draw_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ static void blend_slice(struct mp_draw_sub_cache *p)
int h = (1 << vid->fmt.chroma_ys) - (1 << ys) + 1;
int cw = mp_chroma_div_up(vid->w, xs);
for (int y = 0; y < h; y++) {
p->blend_line(mp_image_pixel_ptr(vid, plane, 0, y),
mp_image_pixel_ptr(ov, plane, 0, y),
xs || ys ? mp_image_pixel_ptr(ca, 0, 0, y)
: mp_image_pixel_ptr(ov, ov->num_planes - 1, 0, y),
p->blend_line(mp_image_pixel_ptr_ny(vid, plane, 0, y),
mp_image_pixel_ptr_ny(ov, plane, 0, y),
xs || ys ? mp_image_pixel_ptr_ny(ca, 0, 0, y)
: mp_image_pixel_ptr_ny(ov, ov->num_planes - 1, 0, y),
cw);
}
}
Expand Down
14 changes: 8 additions & 6 deletions test/img_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void run(struct test_ctx *ctx)

struct mp_imgfmt_desc d = mp_imgfmt_get_desc(mpfmt);
if (d.id) {
fprintf(f, " Legacy desc: ");
fprintf(f, " Basic desc: ");
#define FLAG(t, c) if (d.flags & (t)) fprintf(f, "[%s]", c);
FLAG(MP_IMGFLAG_BYTE_ALIGNED, "ba")
FLAG(MP_IMGFLAG_ALPHA, "a")
Expand All @@ -95,13 +95,15 @@ static void run(struct test_ctx *ctx)
FLAG(MP_IMGFLAG_PAL, "pal")
FLAG(MP_IMGFLAG_HWACCEL, "hw")
fprintf(f, "\n");
fprintf(f, " 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);
fprintf(f, " planes=%d, chroma=%d:%d align=%d:%d\n",
d.num_planes, d.chroma_xs, d.chroma_ys, d.align_x, d.align_y);
fprintf(f, " {");
for (int n = 0; n < MP_MAX_PLANES; n++) {
fprintf(f, "%d/%d/[%d:%d] ", d.bytes[n], d.bpp[n],
d.xs[n], d.ys[n]);
if (n >= d.num_planes) {
assert(d.bpp[n] == 0 && d.xs[n] == 0 && d.ys[n] == 0);
continue;
}
fprintf(f, "%d/[%d:%d] ", d.bpp[n], d.xs[n], d.ys[n]);
}
fprintf(f, "}\n");
} else {
Expand Down
Loading

0 comments on commit caee874

Please sign in to comment.