avformat/matroska: Move ff_mkv_stereo3d_conv() to demuxer

It is now its only user; also make it static.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
pull/390/head
Andreas Rheinhardt 1 year ago
parent 2d09488ac3
commit 9c46faaf77
  1. 58
      libavformat/matroska.c
  2. 3
      libavformat/matroska.h
  3. 58
      libavformat/matroskadec.c

@ -19,8 +19,6 @@
* 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[]
@ -145,59 +143,3 @@ const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_
"block_lr",
"block_rl",
};
int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
{
AVStereo3D *stereo;
int ret;
stereo = av_stereo3d_alloc();
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;
}
ret = av_stream_add_side_data(st, AV_PKT_DATA_STEREO3D, (uint8_t *)stereo,
sizeof(*stereo));
if (ret < 0) {
av_freep(&stereo);
return ret;
}
return 0;
}

@ -23,7 +23,6 @@
#define AVFORMAT_MATROSKA_H
#include "libavcodec/codec_id.h"
#include "avformat.h"
#include "metadata.h"
/* EBML version supported */
@ -437,8 +436,6 @@ extern const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMOD
#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);
#define DVCC_DVVC_BLOCK_TYPE_NAME "Dolby Vision configuration"
#endif /* AVFORMAT_MATROSKA_H */

@ -2163,6 +2163,62 @@ static void mkv_stereo_mode_display_mul(int stereo_mode,
}
}
static int mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
{
AVStereo3D *stereo;
int ret;
stereo = av_stereo3d_alloc();
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;
}
ret = av_stream_add_side_data(st, AV_PKT_DATA_STEREO3D, (uint8_t *)stereo,
sizeof(*stereo));
if (ret < 0) {
av_freep(&stereo);
return ret;
}
return 0;
}
static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
const MatroskaTrackVideoColor *color = track->video.color.elem;
const MatroskaMasteringMeta *mastering_meta;
@ -3008,7 +3064,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
// 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);
int ret = mkv_stereo3d_conv(st, track->video.stereo_mode);
if (ret < 0)
return ret;
}

Loading…
Cancel
Save