summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-30 19:07:09 +0200
committerwm4 <wm4@nowhere>2016-05-30 19:07:22 +0200
commit079f67268f6f5a2ecfd12277b246b1937493c092 (patch)
tree9c34622e36c2fc51e410531532fe10b583a58f78
parent15bb05d2fe7394478144d323a41023722d1a9d38 (diff)
downloadmpv-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.
-rw-r--r--video/mp_image.c5
-rw-r--r--video/mp_image.h2
2 files changed, 3 insertions, 4 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];
diff --git a/video/mp_image.h b/video/mp_image.h
index ef55dc5478..0a43093ecb 100644
--- a/video/mp_image.h
+++ b/video/mp_image.h
@@ -42,7 +42,7 @@ struct mp_image_params {
uint64_t hw_subfmt; // underlying format for some hwaccel pixfmts
// (will use the HW API's format identifiers)
int w, h; // image dimensions
- int p_w, p_h; // define pixel aspect ratio (never 0/0)
+ int p_w, p_h; // define pixel aspect ratio (undefined: 0/0)
enum mp_csp colorspace;
enum mp_csp_levels colorlevels;
enum mp_csp_prim primaries;