mirror of https://github.com/mpv-player/mpv
mp_image: pass through colorspace info to libavfilter
This change affects vf_lavfi. Until recently, libavfilter was not colorspace aware at all. This changed with the addition of colorspace fields to AVFrame. libavfilter's vf_scale picks them up (as of recent ffmpeg git). Since this support is still kind of wonky and not part of the normal format negotiation, this won't set the correct output colorspace, though. Not adding a separate test for HAVE_AVFRAME_COLORSPACE. This is slightly unclean, but on the other hand adding an explicit test seems like a waste of effort.
This commit is contained in:
parent
ff0680c9b4
commit
13a0e6373e
|
@ -521,6 +521,9 @@ void mp_image_copy_fields_from_av_frame(struct mp_image *dst,
|
|||
#endif
|
||||
}
|
||||
|
||||
// Not strictly related, but was added in a similar timeframe.
|
||||
#define HAVE_AVFRAME_COLORSPACE HAVE_AVCODEC_CHROMA_POS_API
|
||||
|
||||
// Copy properties and data of the mp_image into the AVFrame, without taking
|
||||
// care of memory management issues.
|
||||
void mp_image_copy_fields_to_av_frame(struct AVFrame *dst,
|
||||
|
@ -543,6 +546,11 @@ void mp_image_copy_fields_to_av_frame(struct AVFrame *dst,
|
|||
dst->top_field_first = 1;
|
||||
if (src->fields & MP_IMGFIELD_REPEAT_FIRST)
|
||||
dst->repeat_pict = 1;
|
||||
|
||||
#if HAVE_AVFRAME_COLORSPACE
|
||||
dst->colorspace = mp_csp_to_avcol_spc(src->colorspace);
|
||||
dst->color_range = mp_csp_levels_to_avcol_range(src->levels);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAVE_AVUTIL_REFCOUNTING
|
||||
|
|
Loading…
Reference in New Issue