summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2014-05-15 22:06:49 -0400
committerAnton Khirnov <anton@khirnov.net>2014-05-19 13:13:10 +0200
commitbddd8cbf68551f6405b2bf77cc3e212af9fbe834 (patch)
treee4055879d665ee6dfd982d6ca2a3b203d92a5c9c /libavcodec
parent9929b3564c0dca42ed7baa6798ef15b6f0013c83 (diff)
Add transformation matrix API.
Add AV_PKT_DATA_DISPLAYMATRIX and AV_FRAME_DATA_DISPLAYMATRIX as stream and frame side data (respectively) to describe a display transformation matrix for linear transformation operations on the decoded video. Add functions to easily extract a rotation angle from a matrix and conversely to setup a matrix for a given rotation angle. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h9
-rw-r--r--libavcodec/utils.c9
2 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5640710850..f8d815f69b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -959,6 +959,15 @@ enum AVPacketSideDataType {
* ReplayGain information in form of the AVReplayGain struct.
*/
AV_PKT_DATA_REPLAYGAIN,
+
+ /**
+ * This side data contains a 3x3 transformation matrix describing an affine
+ * transformation that needs to be applied to the decoded video frames for
+ * correct presentation.
+ *
+ * See libavutil/display.h for a detailed description of the data.
+ */
+ AV_PKT_DATA_DISPLAYMATRIX,
};
typedef struct AVPacketSideData {
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 71cbc57b44..cb456d5ae0 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -598,6 +598,15 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
memcpy(frame_sd->data, packet_sd, size);
}
+ /* copy the displaymatrix to the output frame */
+ packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size);
+ if (packet_sd) {
+ frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX, size);
+ if (!frame_sd)
+ return AVERROR(ENOMEM);
+
+ memcpy(frame_sd->data, packet_sd, size);
+ }
return 0;
}