Skip to content

Commit

Permalink
mp_image, f_decoder_wrapper: implement AV_FRAME_DATA_DISPLAYMATRIX
Browse files Browse the repository at this point in the history
fixes #9249 (JPEG orientation support) with ffmpeg commit [0].

[0] FFmpeg/FFmpeg@e93c998
  • Loading branch information
Hello71 authored and sfan5 committed Dec 15, 2021
1 parent f9fd50c commit 3ec2012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion filters/f_decoder_wrapper.c
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions video/mp_image.c
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3ec2012

Please sign in to comment.