|
|
|
@ -31,6 +31,7 @@ |
|
|
|
|
|
|
|
|
|
#include "libavutil/attributes.h" |
|
|
|
|
#include "libavutil/channel_layout.h" |
|
|
|
|
#include "libavutil/display.h" |
|
|
|
|
#include "libavutil/intreadwrite.h" |
|
|
|
|
#include "libavutil/intfloat.h" |
|
|
|
|
#include "libavutil/mathematics.h" |
|
|
|
@ -2610,22 +2611,8 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
|
|
|
|
sc->width = width >> 16; |
|
|
|
|
sc->height = height >> 16; |
|
|
|
|
|
|
|
|
|
//Assign clockwise rotate values based on transform matrix so that
|
|
|
|
|
//we can compensate for iPhone orientation during capture.
|
|
|
|
|
|
|
|
|
|
if (display_matrix[1][0] == -65536 && display_matrix[0][1] == 65536) { |
|
|
|
|
av_dict_set(&st->metadata, "rotate", "90", 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) { |
|
|
|
|
av_dict_set(&st->metadata, "rotate", "180", 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (display_matrix[1][0] == 65536 && display_matrix[0][1] == -65536) { |
|
|
|
|
av_dict_set(&st->metadata, "rotate", "270", 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// save the matrix when it is not the default identity
|
|
|
|
|
// save the matrix and add rotate metadata when it is not the default
|
|
|
|
|
// identity
|
|
|
|
|
if (display_matrix[0][0] != (1 << 16) || |
|
|
|
|
display_matrix[1][1] != (1 << 16) || |
|
|
|
|
display_matrix[2][2] != (1 << 30) || |
|
|
|
@ -2633,6 +2620,7 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
|
|
|
|
display_matrix[1][0] || display_matrix[1][2] || |
|
|
|
|
display_matrix[2][0] || display_matrix[2][1]) { |
|
|
|
|
int i, j; |
|
|
|
|
double rotate; |
|
|
|
|
|
|
|
|
|
av_freep(&sc->display_matrix); |
|
|
|
|
sc->display_matrix = av_malloc(sizeof(int32_t) * 9); |
|
|
|
@ -2642,6 +2630,16 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
|
|
|
|
for (i = 0; i < 3; i++) |
|
|
|
|
for (j = 0; j < 3; j++) |
|
|
|
|
sc->display_matrix[i * 3 + j] = display_matrix[j][i]; |
|
|
|
|
|
|
|
|
|
rotate = av_display_rotation_get(sc->display_matrix); |
|
|
|
|
if (!isnan(rotate)) { |
|
|
|
|
char rotate_buf[64]; |
|
|
|
|
rotate = -rotate; |
|
|
|
|
if (rotate < 0) // for backward compatibility
|
|
|
|
|
rotate += 360; |
|
|
|
|
snprintf(rotate_buf, sizeof(rotate_buf), "%g", rotate); |
|
|
|
|
av_dict_set(&st->metadata, "rotate", rotate_buf, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// transform the display width/height according to the matrix
|
|
|
|
|