summaryrefslogtreecommitdiff
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-07 14:19:27 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-19 03:04:46 +0200
commit99c58e49e84e055d0a2b8f0372dfa3dbe815819b (patch)
treea0d3a80b929ac4fde8b5423f8f15c65eb016231d /libavformat/matroskaenc.c
parentff1264aa4d31b7082f0b7c4dca625f9f2a6391a3 (diff)
downloadffmpeg-99c58e49e84e055d0a2b8f0372dfa3dbe815819b.tar.gz
avformat/matroskaenc: Clean up mkv_write_stereo_mode()
Mostly reindentation after the last commit. Also remove a variable that is always zero; move another variable to a more local scope and don't assign a value to a local variable immediately before leaving the function. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c87
1 files changed, 42 insertions, 45 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 7a6a299873..05750cbf0d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1025,8 +1025,6 @@ static void mkv_write_field_order(AVIOContext *pb, int mode,
static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
AVStream *st, int mode, int *h_width, int *h_height)
{
- int i;
- int ret = 0;
const AVDictionaryEntry *tag;
MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB;
const AVStereo3D *stereo;
@@ -1039,7 +1037,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
(tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) {
int stereo_mode = atoi(tag->value);
- for (i=0; i<MATROSKA_VIDEO_STEREOMODE_TYPE_NB; i++)
+ for (int i = 0; i < MATROSKA_VIDEO_STEREOMODE_TYPE_NB; i++)
if (!strcmp(tag->value, ff_matroska_video_stereo_mode[i])){
stereo_mode = i;
break;
@@ -1056,49 +1054,49 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
stereo = (const AVStereo3D*)av_stream_get_side_data(st, AV_PKT_DATA_STEREO3D,
&side_data_size);
if (side_data_size >= sizeof(AVStereo3D)) {
- switch (stereo->type) {
- case AV_STEREO3D_2D:
- format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO;
- break;
- case AV_STEREO3D_SIDEBYSIDE:
- format = (stereo->flags & AV_STEREO3D_FLAG_INVERT)
- ? MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
- : MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT;
- *h_width = 2;
- break;
- case AV_STEREO3D_TOPBOTTOM:
- format = MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM;
- if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
- format--;
- *h_height = 2;
- break;
- case AV_STEREO3D_CHECKERBOARD:
- format = MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR;
- if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
- format--;
- break;
- case AV_STEREO3D_LINES:
- format = MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR;
- if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
- format--;
- *h_height = 2;
- break;
- case AV_STEREO3D_COLUMNS:
- format = MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR;
- if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
- format--;
- *h_width = 2;
- break;
- case AV_STEREO3D_FRAMESEQUENCE:
- format = MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR;
- if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
- format++;
- break;
- }
+ switch (stereo->type) {
+ case AV_STEREO3D_2D:
+ format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO;
+ break;
+ case AV_STEREO3D_SIDEBYSIDE:
+ format = (stereo->flags & AV_STEREO3D_FLAG_INVERT)
+ ? MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
+ : MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT;
+ *h_width = 2;
+ break;
+ case AV_STEREO3D_TOPBOTTOM:
+ format = MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM;
+ if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
+ format--;
+ *h_height = 2;
+ break;
+ case AV_STEREO3D_CHECKERBOARD:
+ format = MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR;
+ if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
+ format--;
+ break;
+ case AV_STEREO3D_LINES:
+ format = MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR;
+ if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
+ format--;
+ *h_height = 2;
+ break;
+ case AV_STEREO3D_COLUMNS:
+ format = MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR;
+ if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
+ format--;
+ *h_width = 2;
+ break;
+ case AV_STEREO3D_FRAMESEQUENCE:
+ format = MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR;
+ if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
+ format++;
+ break;
+ }
}
if (format == MATROSKA_VIDEO_STEREOMODE_TYPE_NB)
- return ret;
+ return 0;
// if webm, do not write unsupported modes
if ((mode == MODE_WEBM &&
@@ -1107,14 +1105,13 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
|| format >= MATROSKA_VIDEO_STEREOMODE_TYPE_NB) {
av_log(s, AV_LOG_ERROR,
"The specified stereo mode is not valid.\n");
- format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB;
return AVERROR(EINVAL);
}
// write StereoMode if format is valid
put_ebml_uint(pb, MATROSKA_ID_VIDEOSTEREOMODE, format);
- return ret;
+ return 0;
}
static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,