diff options
author | wm4 <wm4@nowhere> | 2016-05-30 19:07:09 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-05-30 19:07:22 +0200 |
commit | 079f67268f6f5a2ecfd12277b246b1937493c092 (patch) | |
tree | 9c34622e36c2fc51e410531532fe10b583a58f78 /video/mp_image.c | |
parent | 15bb05d2fe7394478144d323a41023722d1a9d38 (diff) | |
download | mpv-079f67268f6f5a2ecfd12277b246b1937493c092.tar.bz2 mpv-079f67268f6f5a2ecfd12277b246b1937493c092.tar.xz |
mp_image: don't reset pixel aspect with mp_image_set_size()
No reason to do so. See also commit 240ba92b.
Since now many mp_images will never have a pixel aspect ratio set,
redefine a 0/0 aspect ratio to "undefined" instead invalid. This also
brings it more in line with how decoder vs. container aspect ratios are
handled.
Most callers seem to be fine with the new behavior.
mp_image_params_valid() in particular has to be adjusted, or some things
stop working due to mp_images not becoming valid after setting size and
format.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r-- | video/mp_image.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index 52087fdf83..21773ef660 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -87,7 +87,6 @@ void mp_image_setfmt(struct mp_image *mpi, int out_fmt) mpi->fmt = fmt; mpi->imgfmt = fmt.id; mpi->num_planes = fmt.num_planes; - mp_image_set_size(mpi, mpi->w, mpi->h); mpi->params = params; } @@ -122,7 +121,6 @@ void mp_image_set_size(struct mp_image *mpi, int w, int h) assert(w >= 0 && h >= 0); mpi->w = mpi->params.w = w; mpi->h = mpi->params.h = h; - mpi->params.p_w = mpi->params.p_h = 1; } void mp_image_set_params(struct mp_image *image, @@ -543,7 +541,7 @@ bool mp_image_params_valid(const struct mp_image_params *p) if (p->w <= 0 || p->h <= 0 || (p->w + 128LL) * (p->h + 128LL) >= INT_MAX / 8) return false; - if (p->p_w <= 0 || p->p_h <= 0) + if (p->p_w < 0 || p->p_h < 0) return false; if (p->rotate < 0 || p->rotate >= 360) @@ -673,6 +671,7 @@ static void mp_image_copy_fields_from_av_frame(struct mp_image *dst, { mp_image_setfmt(dst, pixfmt2imgfmt(src->format)); mp_image_set_size(dst, src->width, src->height); + dst->params.p_w = dst->params.p_h = 1; for (int i = 0; i < 4; i++) { dst->planes[i] = src->data[i]; |