mirror of https://github.com/mpv-player/mpv
video: remove redundant mp_image display_w/_h members
Commit 5e4e248
added a mp_image_params field to mp_image, and moved many
parameters to that struct. display_w/h was left redundant with
mp_image_params.d_w/d_h. These fields were supposed to be always in
sync, but it seems some code forgot to do this correctly, such as
vf_fix_img_params() or mp_image_copy_attributes(). This led to the
problem in github issue #756, because display_w/_h could become
incorrect.
It turns out that most code didn't use the old fields anyway. Just
remove them. Note that mp_image_params.d_w/d_h are supposed to be always
valid, so the additional checks for 0 shouldn't be needed. Remove these
checks as well.
Fixes #756.
This commit is contained in:
parent
a69e91756d
commit
f6f8dc7782
|
@ -296,11 +296,8 @@ static char *gen_fname(screenshot_ctx *ctx, const char *file_ext)
|
|||
|
||||
static void add_subs(struct MPContext *mpctx, struct mp_image *image)
|
||||
{
|
||||
int d_w = image->display_w ? image->display_w : image->w;
|
||||
int d_h = image->display_h ? image->display_h : image->h;
|
||||
|
||||
double sar = (double)image->w / image->h;
|
||||
double dar = (double)d_w / d_h;
|
||||
double dar = (double)image->params.d_w / image->params.d_h;
|
||||
struct mp_osd_res res = {
|
||||
.w = image->w,
|
||||
.h = image->h,
|
||||
|
|
|
@ -264,8 +264,8 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts,
|
|||
{
|
||||
struct mp_image *allocated_image = NULL;
|
||||
struct image_writer_opts defs = image_writer_opts_defaults;
|
||||
int d_w = image->display_w ? image->display_w : image->w;
|
||||
int d_h = image->display_h ? image->display_h : image->h;
|
||||
int d_w = image->params.d_w;
|
||||
int d_h = image->params.d_h;
|
||||
bool is_anamorphic = image->w != d_w || image->h != d_h;
|
||||
|
||||
if (!opts)
|
||||
|
|
|
@ -180,9 +180,8 @@ void mp_image_set_size(struct mp_image *mpi, int w, int h)
|
|||
if (w >= (1 << 14) || h >= (1 << 14) || w < 0 || h < 0)
|
||||
abort();
|
||||
|
||||
mpi->w = mpi->params.w = w;
|
||||
mpi->h = mpi->params.h = h;
|
||||
mp_image_set_display_size(mpi, mpi->w, mpi->h);
|
||||
mpi->w = mpi->params.w = mpi->params.d_w = w;
|
||||
mpi->h = mpi->params.h = mpi->params.d_h = h;
|
||||
for (int n = 0; n < mpi->num_planes; n++) {
|
||||
mpi->plane_w[n] = mp_chroma_div_up(mpi->w, mpi->fmt.xs[n]);
|
||||
mpi->plane_h[n] = mp_chroma_div_up(mpi->h, mpi->fmt.ys[n]);
|
||||
|
@ -191,14 +190,6 @@ void mp_image_set_size(struct mp_image *mpi, int w, int h)
|
|||
mpi->chroma_height = mpi->plane_h[1];
|
||||
}
|
||||
|
||||
void mp_image_set_display_size(struct mp_image *mpi, int dw, int dh)
|
||||
{
|
||||
mpi->params.d_w = dw;
|
||||
mpi->params.d_h = dh;
|
||||
mpi->display_w = dw;
|
||||
mpi->display_h = dh;
|
||||
}
|
||||
|
||||
void mp_image_set_params(struct mp_image *image,
|
||||
const struct mp_image_params *params)
|
||||
{
|
||||
|
@ -206,7 +197,6 @@ void mp_image_set_params(struct mp_image *image,
|
|||
// possibly reinitialize stuff
|
||||
mp_image_setfmt(image, params->imgfmt);
|
||||
mp_image_set_size(image, params->w, params->h);
|
||||
mp_image_set_display_size(image, params->d_w, params->d_h);
|
||||
}
|
||||
|
||||
struct mp_image *mp_image_alloc(int imgfmt, int w, int h)
|
||||
|
@ -359,8 +349,8 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src)
|
|||
dst->qscale_type = src->qscale_type;
|
||||
dst->pts = src->pts;
|
||||
if (dst->w == src->w && dst->h == src->h) {
|
||||
dst->display_w = src->display_w;
|
||||
dst->display_h = src->display_h;
|
||||
dst->params.d_w = src->params.d_w;
|
||||
dst->params.d_h = src->params.d_h;
|
||||
}
|
||||
if ((dst->flags & MP_IMGFLAG_YUV) == (src->flags & MP_IMGFLAG_YUV)) {
|
||||
dst->params.colorspace = src->params.colorspace;
|
||||
|
|
|
@ -85,7 +85,6 @@ typedef struct mp_image {
|
|||
int chroma_y_shift; // vertical
|
||||
|
||||
int w,h; // visible dimensions
|
||||
int display_w,display_h; // if set (!= 0), anamorphic size
|
||||
uint8_t *planes[MP_MAX_PLANES];
|
||||
int stride[MP_MAX_PLANES];
|
||||
|
||||
|
@ -125,7 +124,6 @@ void mp_image_crop_rc(struct mp_image *img, struct mp_rect rc);
|
|||
void mp_image_vflip(struct mp_image *img);
|
||||
|
||||
void mp_image_set_size(struct mp_image *mpi, int w, int h);
|
||||
void mp_image_set_display_size(struct mp_image *mpi, int dw, int dh);
|
||||
|
||||
void mp_image_setfmt(mp_image_t* mpi, int out_fmt);
|
||||
void mp_image_steal_data(struct mp_image *dst, struct mp_image *src);
|
||||
|
|
Loading…
Reference in New Issue