aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-08-28 23:40:31 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-08-28 23:48:23 +0200
commitfcc39099087e156196e3444ef479b2c778566405 (patch)
treec01fed41ae719924e46f97ada39f186429f63c09 /libavformat
parent31f9c228c042e7f0a017670e7eb18d9b27a71a10 (diff)
parentd4ae8ac92f619507aadd021bb67b517d39d3a36f (diff)
downloadffmpeg-fcc39099087e156196e3444ef479b2c778566405.tar.gz
Merge commit 'd4ae8ac92f619507aadd021bb67b517d39d3a36f'
* commit 'd4ae8ac92f619507aadd021bb67b517d39d3a36f': matroskadec: parse stereo mode on decoding Conflicts: Changelog libavformat/matroska.c libavformat/matroskadec.c See: 4c509fe305bc79a913ef1b690df6c910c732f608 and others Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/matroska.c64
-rw-r--r--libavformat/matroska.h3
-rw-r--r--libavformat/matroskadec.c9
3 files changed, 75 insertions, 1 deletions
diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 88e709b836..8cb392fe7b 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/stereo3d.h"
+
#include "matroska.h"
/* If you add a tag here that is not in ff_codec_bmp_tags[]
@@ -147,3 +149,65 @@ const char * const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_PLANE_CO
"right",
"background",
};
+
+int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
+{
+ AVPacketSideData *sd, *tmp;
+ AVStereo3D *stereo;
+
+ stereo = av_stereo3d_alloc();
+ if (!stereo)
+ return AVERROR(ENOMEM);
+
+ tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
+ if (!tmp) {
+ av_freep(&stereo);
+ 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_STEREO3D;
+ sd->data = (uint8_t *)stereo;
+ sd->size = sizeof(*stereo);
+
+ // note: the missing breaks are intentional
+ switch (stereo_mode) {
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_MONO:
+ stereo->type = AV_STEREO3D_2D;
+ break;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT:
+ stereo->flags |= AV_STEREO3D_FLAG_INVERT;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT:
+ stereo->type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP:
+ stereo->flags |= AV_STEREO3D_FLAG_INVERT;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM:
+ stereo->type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL:
+ stereo->flags |= AV_STEREO3D_FLAG_INVERT;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR:
+ stereo->type = AV_STEREO3D_CHECKERBOARD;
+ break;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL:
+ stereo->flags |= AV_STEREO3D_FLAG_INVERT;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR:
+ stereo->type = AV_STEREO3D_LINES;
+ break;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL:
+ stereo->flags |= AV_STEREO3D_FLAG_INVERT;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR:
+ stereo->type = AV_STEREO3D_COLUMNS;
+ break;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL:
+ stereo->flags |= AV_STEREO3D_FLAG_INVERT;
+ case MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR:
+ stereo->type = AV_STEREO3D_FRAMESEQUENCE;
+ break;
+ }
+
+ return 0;
+}
diff --git a/libavformat/matroska.h b/libavformat/matroska.h
index 99f1c804ac..3b45eeb7a3 100644
--- a/libavformat/matroska.h
+++ b/libavformat/matroska.h
@@ -261,6 +261,7 @@ typedef enum {
MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_GREEN_MAG = 12,
MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR = 13,
MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL = 14,
+ MATROSKA_VIDEO_STEREOMODE_TYPE_NB,
} MatroskaVideoStereoModeType;
/*
@@ -296,4 +297,6 @@ extern const char * const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_P
#define TRACK_NUMBER "webm_dash_manifest_track_number"
#define CODEC_PRIVATE_SIZE "webm_dash_manifest_codec_priv_size"
+int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode);
+
#endif /* AVFORMAT_MATROSKA_H */
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index f88a4569c2..124db82e3a 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -340,7 +340,6 @@ static EbmlSyntax matroska_track_video[] = {
{ MATROSKA_ID_VIDEOPIXELWIDTH, EBML_UINT, 0, offsetof(MatroskaTrackVideo, pixel_width) },
{ MATROSKA_ID_VIDEOPIXELHEIGHT, EBML_UINT, 0, offsetof(MatroskaTrackVideo, pixel_height) },
{ MATROSKA_ID_VIDEOCOLORSPACE, EBML_BIN, 0, offsetof(MatroskaTrackVideo, color_space) },
- { MATROSKA_ID_VIDEOSTEREOMODE, EBML_UINT, 0, offsetof(MatroskaTrackVideo, stereo_mode) },
{ MATROSKA_ID_VIDEOALPHAMODE, EBML_UINT, 0, offsetof(MatroskaTrackVideo, alpha_mode) },
{ MATROSKA_ID_VIDEOPIXELCROPB, EBML_NONE },
{ MATROSKA_ID_VIDEOPIXELCROPT, EBML_NONE },
@@ -348,6 +347,7 @@ static EbmlSyntax matroska_track_video[] = {
{ MATROSKA_ID_VIDEOPIXELCROPR, EBML_NONE },
{ MATROSKA_ID_VIDEODISPLAYUNIT, EBML_NONE },
{ MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_NONE },
+ { MATROSKA_ID_VIDEOSTEREOMODE, EBML_UINT, 0, offsetof(MatroskaTrackVideo, stereo_mode), { .u = MATROSKA_VIDEO_STEREOMODE_TYPE_NB } },
{ MATROSKA_ID_VIDEOASPECTRATIO, EBML_NONE },
{ 0 }
};
@@ -2006,6 +2006,13 @@ static int matroska_parse_tracks(AVFormatContext *s)
break;
}
}
+ // add stream level stereo3d side data if it is a supported format
+ if (track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB &&
+ track->video.stereo_mode != 10 && track->video.stereo_mode != 12) {
+ int ret = ff_mkv_stereo3d_conv(st, track->video.stereo_mode);
+ if (ret < 0)
+ return ret;
+ }
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = track->audio.out_samplerate;