mirror of https://github.com/mpv-player/mpv
vf: add vf_rescale_dsize()
Needed because mplayer* basically tracks DAR, which makes it harder for filters which want to keep the SAR. The contents of this function are duplicated in a few filters, and will be used instead of custom code as the filters are updated later.
This commit is contained in:
parent
717d904bbc
commit
926c6631ff
|
@ -30,6 +30,7 @@
|
||||||
#include "core/m_option.h"
|
#include "core/m_option.h"
|
||||||
#include "core/m_struct.h"
|
#include "core/m_struct.h"
|
||||||
|
|
||||||
|
#include "core/options.h"
|
||||||
|
|
||||||
#include "video/img_format.h"
|
#include "video/img_format.h"
|
||||||
#include "video/mp_image.h"
|
#include "video/mp_image.h"
|
||||||
|
@ -476,6 +477,20 @@ void vf_uninit_filter_chain(vf_instance_t *vf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When cropping an image that had old_w/old_h/*d_width/*d_height to the new
|
||||||
|
// size new_w/new_h, adjust *d_width/*d_height such that the new image has
|
||||||
|
// the same pixel aspect ratio.
|
||||||
|
void vf_rescale_dsize(struct vf_instance *vf, int *d_width, int *d_height,
|
||||||
|
int old_w, int old_h, int new_w, int new_h)
|
||||||
|
{
|
||||||
|
// No idea what this is about
|
||||||
|
if (vf->opts->screen_size_x || vf->opts->screen_size_y)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*d_width = *d_width * new_w / old_w;
|
||||||
|
*d_height = *d_height * new_h / old_h;
|
||||||
|
}
|
||||||
|
|
||||||
void vf_detc_init_pts_buf(struct vf_detc_pts_buf *p)
|
void vf_detc_init_pts_buf(struct vf_detc_pts_buf *p)
|
||||||
{
|
{
|
||||||
p->inpts_prev = MP_NOPTS_VALUE;
|
p->inpts_prev = MP_NOPTS_VALUE;
|
||||||
|
|
|
@ -141,6 +141,9 @@ int vf_config_wrapper(struct vf_instance *vf,
|
||||||
int width, int height, int d_width, int d_height,
|
int width, int height, int d_width, int d_height,
|
||||||
unsigned int flags, unsigned int outfmt);
|
unsigned int flags, unsigned int outfmt);
|
||||||
|
|
||||||
|
void vf_rescale_dsize(struct vf_instance *vf, int *d_width, int *d_height,
|
||||||
|
int old_w, int old_h, int new_w, int new_h);
|
||||||
|
|
||||||
static inline int norm_qscale(int qscale, int type)
|
static inline int norm_qscale(int qscale, int type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
Loading…
Reference in New Issue