[FFmpeg-devel] [PATCH 07/10] avformat/matroska: set Monoscopic view for 2D projection
James Almer
jamrial at gmail.com
Sun Jun 23 02:15:17 EEST 2024
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/matroska.h | 36 ++++++++++++--------
libavformat/matroskadec.c | 6 ++--
libavformat/matroskaenc.c | 8 ++---
tests/ref/fate/matroska-spherical-mono | 2 +-
tests/ref/fate/matroska-spherical-mono-remux | 4 +--
tests/ref/fate/matroska-vp8-alpha-remux | 2 +-
6 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/libavformat/matroska.h b/libavformat/matroska.h
index 719f2ef796..8c4d8dcb99 100644
--- a/libavformat/matroska.h
+++ b/libavformat/matroska.h
@@ -392,35 +392,41 @@ extern const AVMetadataConv ff_mkv_metadata_conv[];
* as well as WebM compatibility.
*
* MAP and MKV_ONLY are macros to be provided by the user.
- * MAP(MatroskaVideoStereoModeType, AVStereo3DType, AV_STEREO3D_FLAG_*,
- * HALF_WIDTH, HALF_HEIGHT, WebM-compatibility)
+ * MAP(MatroskaVideoStereoModeType, AVStereo3DType, AVStereo3DView,
+ * AV_STEREO3D_FLAG_*, HALF_WIDTH, HALF_HEIGHT, WebM-compatibility)
* is for the stereo modes that have a Stereo3D counterpart.
* MKV_ONLY(MatroskaVideoStereoModeType, HALF_WIDTH, HALF_HEIGHT, WebM)
* is for those that don't have a Stereo3D counterpart.
* */
#define STEREOMODE_STEREO3D_MAPPING(MAP, MKV_ONLY) \
- MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_MONO, AV_STEREO3D_2D, 0, 0, 0, 1) \
- MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT, AV_STEREO3D_SIDEBYSIDE, 0, 1, 0, 1) \
+ MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_MONO, AV_STEREO3D_2D, \
+ AV_STEREO3D_VIEW_MONO, 0, 0, 0, 1) \
+ MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT, AV_STEREO3D_SIDEBYSIDE, \
+ AV_STEREO3D_VIEW_PACKED, 0, 1, 0, 1) \
MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP, AV_STEREO3D_TOPBOTTOM, \
- AV_STEREO3D_FLAG_INVERT, 0, 1, 1) \
- MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM, AV_STEREO3D_TOPBOTTOM, 0, 0, 1, 1) \
+ AV_STEREO3D_VIEW_PACKED, AV_STEREO3D_FLAG_INVERT, 0, 1, 1) \
+ MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM, AV_STEREO3D_TOPBOTTOM, \
+ AV_STEREO3D_VIEW_PACKED, 0, 0, 1, 1) \
MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL, AV_STEREO3D_CHECKERBOARD, \
- AV_STEREO3D_FLAG_INVERT, 0, 0, 0) \
- MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR, AV_STEREO3D_CHECKERBOARD, 0, 0, 0, 0) \
+ AV_STEREO3D_VIEW_PACKED, AV_STEREO3D_FLAG_INVERT, 0, 0, 0) \
+ MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR, AV_STEREO3D_CHECKERBOARD, \
+ AV_STEREO3D_VIEW_PACKED, 0, 0, 0, 0) \
MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL, AV_STEREO3D_LINES, \
- AV_STEREO3D_FLAG_INVERT, 0, 1, 0) \
- MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR, AV_STEREO3D_LINES, 0, 0, 1, 0) \
+ AV_STEREO3D_VIEW_PACKED, AV_STEREO3D_FLAG_INVERT, 0, 1, 0) \
+ MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR, AV_STEREO3D_LINES, \
+ AV_STEREO3D_VIEW_PACKED, 0, 0, 1, 0) \
MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL, AV_STEREO3D_COLUMNS, \
- AV_STEREO3D_FLAG_INVERT, 1, 0, 0) \
- MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR, AV_STEREO3D_COLUMNS, 0, 1, 0, 0) \
+ AV_STEREO3D_VIEW_PACKED, AV_STEREO3D_FLAG_INVERT, 1, 0, 0) \
+ MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR, AV_STEREO3D_COLUMNS, \
+ AV_STEREO3D_VIEW_PACKED, 0, 1, 0, 0) \
MKV_ONLY(MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_CYAN_RED, 0, 0, 0) \
MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT, AV_STEREO3D_SIDEBYSIDE, \
- AV_STEREO3D_FLAG_INVERT, 1, 0, 1) \
+ AV_STEREO3D_VIEW_PACKED, AV_STEREO3D_FLAG_INVERT, 1, 0, 1) \
MKV_ONLY(MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_GREEN_MAG, 0, 0, 0) \
MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR, AV_STEREO3D_FRAMESEQUENCE, \
- 0, 0, 0, 0) \
+ AV_STEREO3D_VIEW_PACKED, 0, 0, 0, 0) \
MAP(MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL, AV_STEREO3D_FRAMESEQUENCE, \
- AV_STEREO3D_FLAG_INVERT, 0, 0, 0)
+ AV_STEREO3D_VIEW_PACKED, AV_STEREO3D_FLAG_INVERT, 0, 0, 0)
extern const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB];
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 6bc5fa621e..e6437ac68f 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2245,10 +2245,11 @@ static int mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mo
{
static const struct {
char type;
+ char view;
char flags;
} stereo_mode_conv [] = {
-#define STEREO_MODE_CONV(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
- [(STEREOMODETYPE)] = { .type = (STEREO3DTYPE), .flags = (FLAGS) },
+#define STEREO_MODE_CONV(STEREOMODETYPE, STEREO3DTYPE, STEREO3DVIEW, FLAGS, WDIV, HDIV, WEBM) \
+ [(STEREOMODETYPE)] = { .type = (STEREO3DTYPE), .view = (STEREO3DVIEW), .flags = (FLAGS) },
#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, NOTHING)
};
@@ -2259,6 +2260,7 @@ static int mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mo
return AVERROR(ENOMEM);
stereo->type = stereo_mode_conv[stereo_mode].type;
+ stereo->view = stereo_mode_conv[stereo_mode].view;
stereo->flags = stereo_mode_conv[stereo_mode].flags;
if (!av_packet_side_data_add(&st->codecpar->coded_side_data, &st->codecpar->nb_coded_side_data,
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 094cf61357..dfcdda1adc 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1605,20 +1605,20 @@ static int mkv_write_stereo_mode(AVFormatContext *s, EbmlWriter *writer,
* indicates whether the MatroskaVideoStereoModeType with that value
* uses double width/height or is WebM compatible. */
#define FLAG(STEREOMODETYPE, BOOL) | (BOOL) << (STEREOMODETYPE)
-#define WDIV1(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
+#define WDIV1(STEREOMODETYPE, STEREO3DTYPE, STEREO3DVIEW, FLAGS, WDIV, HDIV, WEBM) \
FLAG(STEREOMODETYPE, WDIV)
#define WDIV2(STEREOMODETYPE, WDIV, HDIV, WEBM) \
FLAG(STEREOMODETYPE, WDIV)
// The zero in the following line consumes the first '|'.
const unsigned width_bitfield = 0 STEREOMODE_STEREO3D_MAPPING(WDIV1, WDIV2);
-#define HDIV1(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
+#define HDIV1(STEREOMODETYPE, STEREO3DTYPE, STEREO3DVIEW, FLAGS, WDIV, HDIV, WEBM) \
FLAG(STEREOMODETYPE, HDIV)
#define HDIV2(STEREOMODETYPE, WDIV, HDIV, WEBM) \
FLAG(STEREOMODETYPE, HDIV)
const unsigned height_bitfield = 0 STEREOMODE_STEREO3D_MAPPING(HDIV1, HDIV2);
-#define WEBM1(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
+#define WEBM1(STEREOMODETYPE, STEREO3DTYPE, STEREO3DVIEW, FLAGS, WDIV, HDIV, WEBM) \
FLAG(STEREOMODETYPE, WEBM)
#define WEBM2(STEREOMODETYPE, WDIV, HDIV, WEBM) \
FLAG(STEREOMODETYPE, WEBM)
@@ -1646,7 +1646,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, EbmlWriter *writer,
const AVStereo3D *stereo;
/* The following macro presumes all MATROSKA_VIDEO_STEREOMODE_TYPE_*
* values to be in the range 0..254. */
-#define STEREOMODE(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
+#define STEREOMODE(STEREOMODETYPE, STEREO3DTYPE, STEREO3DVIEW, FLAGS, WDIV, HDIV, WEBM) \
[(STEREO3DTYPE)][!!((FLAGS) & AV_STEREO3D_FLAG_INVERT)] = (STEREOMODETYPE) + 1,
#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
static const unsigned char conversion_table[][2] = {
diff --git a/tests/ref/fate/matroska-spherical-mono b/tests/ref/fate/matroska-spherical-mono
index b108596350..aa17e9c624 100644
--- a/tests/ref/fate/matroska-spherical-mono
+++ b/tests/ref/fate/matroska-spherical-mono
@@ -3,7 +3,7 @@
side_data_type=Stereo 3D
type=2D
inverted=0
-view=packed
+view=monoscopic
primary_eye=none
baseline=0
horizontal_disparity_adjustment=0/1
diff --git a/tests/ref/fate/matroska-spherical-mono-remux b/tests/ref/fate/matroska-spherical-mono-remux
index eec41b77f3..75a9b73a37 100644
--- a/tests/ref/fate/matroska-spherical-mono-remux
+++ b/tests/ref/fate/matroska-spherical-mono-remux
@@ -27,7 +27,7 @@ DISPOSITION:forced=1
side_data_type=Stereo 3D
type=2D
inverted=0
-view=packed
+view=monoscopic
primary_eye=none
baseline=0
horizontal_disparity_adjustment=0/1
@@ -56,7 +56,7 @@ DISPOSITION:forced=0
side_data_type=Stereo 3D
type=2D
inverted=0
-view=packed
+view=monoscopic
primary_eye=none
baseline=0
horizontal_disparity_adjustment=0/1
diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux
index 06bcc4b4ba..814463eeda 100644
--- a/tests/ref/fate/matroska-vp8-alpha-remux
+++ b/tests/ref/fate/matroska-vp8-alpha-remux
@@ -35,7 +35,7 @@ DISPOSITION:still_image=0
side_data_type=Stereo 3D
type=2D
inverted=0
-view=packed
+view=monoscopic
primary_eye=none
baseline=0
horizontal_disparity_adjustment=0/1
--
2.45.2
More information about the ffmpeg-devel
mailing list