mirror of
https://github.com/mpv-player/mpv
synced 2025-03-24 12:22:25 +00:00
mp_image: add helper for copying image attributes
This enw function is similar to mp_image_set_params(), but doesn't force setting "hard" parameters like image size and format.
This commit is contained in:
parent
3b5f8ea571
commit
6f17410f88
@ -36,6 +36,8 @@
|
|||||||
#include "memcpy_pic.h"
|
#include "memcpy_pic.h"
|
||||||
#include "fmt-conversion.h"
|
#include "fmt-conversion.h"
|
||||||
|
|
||||||
|
#include "video/filter/vf.h"
|
||||||
|
|
||||||
#if HAVE_PTHREADS
|
#if HAVE_PTHREADS
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
static pthread_mutex_t refcount_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t refcount_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
@ -468,6 +470,26 @@ void mp_image_set_params(struct mp_image *image,
|
|||||||
image->chroma_location = params->chroma_location;
|
image->chroma_location = params->chroma_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set most image parameters, but not image format or size.
|
||||||
|
// Display size is used to set the PAR.
|
||||||
|
void mp_image_set_attributes(struct mp_image *image,
|
||||||
|
const struct mp_image_params *params)
|
||||||
|
{
|
||||||
|
struct mp_image_params nparams = *params;
|
||||||
|
nparams.imgfmt = image->imgfmt;
|
||||||
|
nparams.w = image->w;
|
||||||
|
nparams.h = image->h;
|
||||||
|
if (nparams.imgfmt != params->imgfmt)
|
||||||
|
mp_image_params_guess_csp(&nparams);
|
||||||
|
if (nparams.w != params->w || nparams.h != params->h) {
|
||||||
|
if (nparams.d_w && nparams.d_h) {
|
||||||
|
vf_rescale_dsize(&nparams.d_w, &nparams.d_h,
|
||||||
|
params->w, params->h, nparams.w, nparams.h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mp_image_set_params(image, &nparams);
|
||||||
|
}
|
||||||
|
|
||||||
void mp_image_set_colorspace_details(struct mp_image *image,
|
void mp_image_set_colorspace_details(struct mp_image *image,
|
||||||
struct mp_csp_details *csp)
|
struct mp_csp_details *csp)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +153,9 @@ void mp_image_params_from_image(struct mp_image_params *params,
|
|||||||
void mp_image_set_params(struct mp_image *image,
|
void mp_image_set_params(struct mp_image *image,
|
||||||
const struct mp_image_params *params);
|
const struct mp_image_params *params);
|
||||||
|
|
||||||
|
void mp_image_set_attributes(struct mp_image *image,
|
||||||
|
const struct mp_image_params *params);
|
||||||
|
|
||||||
struct AVFrame;
|
struct AVFrame;
|
||||||
void mp_image_copy_fields_from_av_frame(struct mp_image *dst,
|
void mp_image_copy_fields_from_av_frame(struct mp_image *dst,
|
||||||
struct AVFrame *src);
|
struct AVFrame *src);
|
||||||
|
Loading…
Reference in New Issue
Block a user