aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-08-11 11:15:18 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-08-30 19:42:55 +0200
commitb3825bd711235e883353a12f305f44ae20724f24 (patch)
tree6f2bd78e21d8f12fdba9c6611be102adda195920
parent9c46faaf77b49fdf3fec2520455dfaa6c43fbd3e (diff)
downloadffmpeg-b3825bd711235e883353a12f305f44ae20724f24.tar.gz
avformat/matroskadec: Replace switch with array
This simplification reduces codesize. (It even reduces the size of .rodata here, because the jump table used by the compiler is bigger than the actual array.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavformat/matroskadec.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 98695479c6..e6797b2f57 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2165,6 +2165,15 @@ static void mkv_stereo_mode_display_mul(int stereo_mode,
static int mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
{
+ static const struct {
+ char type;
+ char flags;
+ } stereo_mode_conv [] = {
+#define STEREO_MODE_CONV(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
+ [(STEREOMODETYPE)] = { .type = (STEREO3DTYPE), .flags = (FLAGS) },
+#define IGNORE(STEREOMODETYPE, WDIV, HDIV, WEBM)
+ STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, IGNORE)
+ };
AVStereo3D *stereo;
int ret;
@@ -2172,42 +2181,8 @@ static int mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mo
if (!stereo)
return AVERROR(ENOMEM);
- // 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;
- }
+ stereo->type = stereo_mode_conv[stereo_mode].type;
+ stereo->flags = stereo_mode_conv[stereo_mode].flags;
ret = av_stream_add_side_data(st, AV_PKT_DATA_STEREO3D, (uint8_t *)stereo,
sizeof(*stereo));