Skip to content

Commit

Permalink
mp_image: pass rotation correctly to/from AVFrame
Browse files Browse the repository at this point in the history
Fixes rotating image by --video-rotate when filtering.

Fixes: mpv-player#12771
  • Loading branch information
kasper93 authored and sfan5 committed Nov 3, 2023
1 parent fe0d2b4 commit 7480efa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion video/mp_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,6 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)

if (src->opaque_ref) {
struct mp_image_params *p = (void *)src->opaque_ref->data;
dst->params.rotate = p->rotate;
dst->params.stereo3d = p->stereo3d;
// Might be incorrect if colorspace changes.
dst->params.color.light = p->color.light;
Expand Down Expand Up @@ -1197,6 +1196,14 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src)
clm->MaxCLL = src->params.color.sig_peak * MP_REF_WHITE;
}

{
AVFrameSideData *sd = av_frame_new_side_data(dst,
AV_FRAME_DATA_DISPLAYMATRIX,
sizeof(int32_t) * 9);
MP_HANDLE_OOM(sd);
av_display_rotation_set((int32_t *)sd->data, src->params.rotate);
}

// Add back side data, but only for types which are not specially handled
// above. Keep in mind that the types above will be out of sync anyway.
for (int n = 0; n < new_ref->num_ff_side_data; n++) {
Expand Down

0 comments on commit 7480efa

Please sign in to comment.