---
libavformat/isom.h | 3 +++
libavformat/mov.c | 28 ++++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/libavformat/isom.h b/libavformat/isom.h
index bf0792c..d5ff563 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -135,6 +135,9 @@ typedef struct MOVStreamContext {
int64_t track_end; ///< used for dts generation in fragmented movie
files
unsigned int rap_group_count;
MOVSbgp *rap_group;
+
+ int matrix_present;
+ int display_matrix[3][2];
} MOVStreamContext;
typedef struct MOVContext {
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 30f7f6e..934556c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2388,6 +2388,13 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb,
MOVAtom atom)
sc->width = width >> 16;
sc->height = height >> 16;
+ // save the matrix when it is not the identity one
+ if (display_matrix[0][1] || display_matrix[1][0] ||
+ display_matrix[2][0] || display_matrix[2][1]) {
+ sc->matrix_present = 1;
+ memcpy(sc->display_matrix, display_matrix, sizeof(int) * 3 * 2);
+ }
+
// transform the display width/height according to the matrix
// skip this if the display matrix is the default identity matrix
// or if it is rotating the picture, ex iPhone 3GS
@@ -3129,6 +3136,27 @@ static int mov_read_packet(AVFormatContext *s, AVPacket
*pkt)
sc->has_palette = 0;
}
}
+ if (sc->matrix_present) {
+ AVPacketSideData *sd, *tmp;
+
+ tmp = av_realloc_array(st->side_data,
+ st->nb_side_data + 1, sizeof(*tmp));
+ if (!tmp)
+ return AVERROR(ENOMEM);
+
+ st->side_data = tmp;
+ st->nb_side_data++;
+
+ sd = &st->side_data[st->nb_side_data - 1];
+ sd->type = AV_PKT_DATA_DISPLAYMATRIX;
+ sd->size = sizeof(int) * 3 * 2;
+ sd->data = av_mallocz(sd->size);
+ if (!sd->data)
+ return AVERROR(ENOMEM);
+ memcpy(sd->data, sc->display_matrix, sd->size);
+
+ sc->matrix_present = 0;
+ }
#if CONFIG_DV_DEMUXER
if (mov->dv_demux && sc->dv_audio_container) {
avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size);
--
1.8.3.4 (Apple Git-47)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel