mirror of https://github.com/mpv-player/mpv
mp_image, f_decoder_wrapper: implement AV_FRAME_DATA_DISPLAYMATRIX
fixes #9249 (JPEG orientation support) with ffmpeg commit [0].
[0] e93c998602
This commit is contained in:
parent
f9fd50c654
commit
3ec2012cec
|
@ -594,12 +594,14 @@ static void fix_image_params(struct priv *p,
|
|||
if (m.p_w <= 0 || m.p_h <= 0)
|
||||
m.p_w = m.p_h = 1;
|
||||
|
||||
m.rotate = p->codec->rotate;
|
||||
m.stereo3d = p->codec->stereo_mode;
|
||||
|
||||
if (opts->video_rotate < 0) {
|
||||
m.rotate = 0;
|
||||
} else {
|
||||
// ffmpeg commit 535a835e51 says that frame rotate takes priority
|
||||
if (!m.rotate)
|
||||
m.rotate = p->codec->rotate;
|
||||
m.rotate = (m.rotate + opts->video_rotate) % 360;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <libavutil/mem.h>
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/display.h>
|
||||
#include <libavutil/bswap.h>
|
||||
#include <libavutil/hwcontext.h>
|
||||
#include <libavutil/intreadwrite.h>
|
||||
|
@ -973,6 +974,13 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)
|
|||
dst->params.alpha = p->alpha;
|
||||
}
|
||||
|
||||
sd = av_frame_get_side_data(src, AV_FRAME_DATA_DISPLAYMATRIX);
|
||||
if (sd) {
|
||||
double r = av_display_rotation_get((int32_t *)(sd->data));
|
||||
if (!isnan(r))
|
||||
dst->params.rotate = (((int)(-r) % 360) + 360) % 360;
|
||||
}
|
||||
|
||||
sd = av_frame_get_side_data(src, AV_FRAME_DATA_ICC_PROFILE);
|
||||
if (sd)
|
||||
dst->icc_profile = sd->buf;
|
||||
|
|
Loading…
Reference in New Issue