Skip to content

Commit

Permalink
demux_mkv: support ProjectionPoseRoll element
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 authored and Dudemanguy committed Sep 17, 2023
1 parent 338f31e commit a4bf0bd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions demux/demux_mkv.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ typedef struct mkv_track {
struct mp_colorspace color;
uint32_t v_crop_top, v_crop_left, v_crop_right, v_crop_bottom;
bool v_crop_top_set, v_crop_left_set, v_crop_right_set, v_crop_bottom_set;
float v_projection_pose_roll;
bool v_projection_pose_roll_set;

uint32_t a_channels, a_bps;
float a_sfreq;
Expand Down Expand Up @@ -606,6 +608,20 @@ static void parse_trackcolour(struct demuxer *demuxer, struct mkv_track *track,
}
}

static void parse_trackprojection(struct demuxer *demuxer, struct mkv_track *track,
struct ebml_projection *projection)
{
if (projection->n_projection_pose_yaw || projection->n_projection_pose_pitch)
MP_WARN(demuxer, "Projection pose yaw/pitch not supported!\n");

if (projection->n_projection_pose_roll) {
track->v_projection_pose_roll = projection->projection_pose_roll;
track->v_projection_pose_roll_set = true;
MP_DBG(demuxer, "| + Projection pose roll: %f\n",
track->v_projection_pose_roll);
}
}

static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
struct ebml_video *video)
{
Expand Down Expand Up @@ -667,6 +683,8 @@ static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
}
if (video->n_colour)
parse_trackcolour(demuxer, track, &video->colour);
if (video->n_projection)
parse_trackprojection(demuxer, track, &video->projection);
}

/**
Expand Down Expand Up @@ -1509,6 +1527,11 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
sh_v->crop.y1 = track->v_height -
(track->v_crop_bottom_set ? track->v_crop_bottom : 0);

if (track->v_projection_pose_roll_set) {
int rotate = lrintf(fmodf(fmodf(track->v_projection_pose_roll, 360) + 360, 360));
sh_v->rotate = rotate;
}

done:
demux_add_sh_stream(demuxer, sh);

Expand Down

0 comments on commit a4bf0bd

Please sign in to comment.