summaryrefslogtreecommitdiffstats
path: root/video/repack.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-05-19 23:58:36 +0200
committerwm4 <wm4@nowhere>2020-05-20 00:02:27 +0200
commit176f422213a6a72529f8a6394c34b06ff04f2fb3 (patch)
tree704624347a59a4c04a5858da4310b4ac6fad1c9e /video/repack.c
parenta20ae0417f2d1e1a2c173f5eaf66a81974df0008 (diff)
downloadmpv-176f422213a6a72529f8a6394c34b06ff04f2fb3.tar.bz2
mpv-176f422213a6a72529f8a6394c34b06ff04f2fb3.tar.xz
video: shuffle imgfmt metadata code around
I guess I decided to stuff it all into mp_imgfmt_desc (the "old" struct). This is probably a mistake. At first I was afraid that this struct would get too fat (probably justified, and hereby happened), but on the other hand mp_imgfmt_get_desc() (which builds the struct) calls the former mp_imgfmt_get_layout(), and the separation doesn't make too much sense anyway. Just merge them. Still, try to keep out the extra info for packed YUV bullshit. I think the result is OK, and there's as much information as there was before. The test output changes a little. There's no independent bits[] array anymore, so formats which did not previously have set this now show it. (These formats are mpv-only and are still missing the metadata. To be added later). Also, the output for the cursed packed formats changes.
Diffstat (limited to 'video/repack.c')
-rw-r--r--video/repack.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/video/repack.c b/video/repack.c
index 775d8afd30..427c297d75 100644
--- a/video/repack.c
+++ b/video/repack.c
@@ -459,17 +459,17 @@ static void fringe_rgb_repack(struct mp_repack *rp,
static void setup_fringe_rgb_packer(struct mp_repack *rp)
{
struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(rp->imgfmt_a);
- struct mp_imgfmt_layout layout;
- mp_imgfmt_get_layout(rp->imgfmt_a, &layout);
+ if (!(desc.flags & MP_IMGFLAG_HAS_COMPS))
+ return;
- if (layout.bits[0] > 16 || (layout.bits[0] % 8u) || layout.extra_w ||
+ if (desc.bpp[0] > 16 || (desc.bpp[0] % 8u) ||
mp_imgfmt_get_forced_csp(rp->imgfmt_a) != MP_CSP_RGB ||
- desc.num_planes != 1 || layout.comps[3].size)
+ desc.num_planes != 1 || desc.comps[3].size)
return;
- int depth = layout.comps[0].size;
+ int depth = desc.comps[0].size;
for (int n = 0; n < 3; n++) {
- struct mp_imgfmt_comp_desc *c = &layout.comps[n];
+ struct mp_imgfmt_comp_desc *c = &desc.comps[n];
if (c->size < 1 || c->size > 8 || c->pad)
return;
@@ -492,8 +492,8 @@ static void setup_fringe_rgb_packer(struct mp_repack *rp)
rp->components[n] = ((int[]){3, 1, 2})[n] - 1;
for (int n = 0; n < 3; n++) {
- int bits = layout.comps[n].size;
- rp->comp_shifts[n] = layout.comps[n].offset;
+ int bits = desc.comps[n].size;
+ rp->comp_shifts[n] = desc.comps[n].offset;
if (rp->comp_lut) {
uint8_t *lut = rp->comp_lut + 256 * n;
uint8_t zmax = (1 << depth) - 1;
@@ -508,11 +508,11 @@ static void setup_fringe_rgb_packer(struct mp_repack *rp)
}
}
- rp->comp_size = (layout.bits[0] + 7) / 8;
+ rp->comp_size = (desc.bpp[0] + 7) / 8;
assert(rp->comp_size == 1 || rp->comp_size == 2);
- if (layout.endian_bytes) {
- assert(rp->comp_size == 2 && layout.endian_bytes == 2);
+ if (desc.endian_shift) {
+ assert(rp->comp_size == 2 && (1 << desc.endian_shift) == 2);
rp->endian_size = 2;
}
}