Merge commit 'd4ae8ac92f619507aadd021bb67b517d39d3a36f'

* commit 'd4ae8ac92f619507aadd021bb67b517d39d3a36f':
  matroskadec: parse stereo mode on decoding

Conflicts:
	Changelog
	libavformat/matroska.c
	libavformat/matroskadec.c

See: 4c509fe305 and others
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-08-28 23:40:31 +02:00
commit fcc3909908
5 changed files with 77 additions and 2 deletions

View File

@ -10,6 +10,7 @@ version <next>:
- LZMA compression support in TIFF decoder
- support for H.261 RTP payload format (RFC 4587)
- added codecview filter to visualize information exported by some codecs
- matroska 3d support thorugh side data
version 2.3:

View File

@ -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;
}

View File

@ -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 */

View File

@ -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;

View File

@ -1,5 +1,5 @@
#tb 0: 1/1000
0, 0, 0, 0, 2108, 0x59b92a34, S=1, 1900, 0x8fb3adc5
0, 0, 0, 0, 2108, 0x59b92a34, S=2, 1900, 0x8fb3adc5, 8, 0x00000000
0, 32, 32, 0, 142, 0x2f2a3fed, F=0x0, S=1, 160, 0xa13346af
0, 65, 65, 0, 157, 0x17804767, F=0x0, S=1, 209, 0x64115f15
0, 99, 99, 0, 206, 0x537262ca, F=0x0, S=1, 317, 0x44a09dd0