Commit 99c58e49 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt

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: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent ff1264aa
...@@ -1025,8 +1025,6 @@ static void mkv_write_field_order(AVIOContext *pb, int mode, ...@@ -1025,8 +1025,6 @@ static void mkv_write_field_order(AVIOContext *pb, int mode,
static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
AVStream *st, int mode, int *h_width, int *h_height) AVStream *st, int mode, int *h_width, int *h_height)
{ {
int i;
int ret = 0;
const AVDictionaryEntry *tag; const AVDictionaryEntry *tag;
MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB; MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB;
const AVStereo3D *stereo; const AVStereo3D *stereo;
...@@ -1039,7 +1037,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, ...@@ -1039,7 +1037,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
(tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) { (tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) {
int stereo_mode = atoi(tag->value); 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])){ if (!strcmp(tag->value, ff_matroska_video_stereo_mode[i])){
stereo_mode = i; stereo_mode = i;
break; break;
...@@ -1056,49 +1054,49 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, ...@@ -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, stereo = (const AVStereo3D*)av_stream_get_side_data(st, AV_PKT_DATA_STEREO3D,
&side_data_size); &side_data_size);
if (side_data_size >= sizeof(AVStereo3D)) { if (side_data_size >= sizeof(AVStereo3D)) {
switch (stereo->type) { switch (stereo->type) {
case AV_STEREO3D_2D: case AV_STEREO3D_2D:
format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO; format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO;
break; break;
case AV_STEREO3D_SIDEBYSIDE: case AV_STEREO3D_SIDEBYSIDE:
format = (stereo->flags & AV_STEREO3D_FLAG_INVERT) format = (stereo->flags & AV_STEREO3D_FLAG_INVERT)
? MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT ? MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
: MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT; : MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT;
*h_width = 2; *h_width = 2;
break; break;
case AV_STEREO3D_TOPBOTTOM: case AV_STEREO3D_TOPBOTTOM:
format = MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM; format = MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM;
if (stereo->flags & AV_STEREO3D_FLAG_INVERT) if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
format--; format--;
*h_height = 2; *h_height = 2;
break; break;
case AV_STEREO3D_CHECKERBOARD: case AV_STEREO3D_CHECKERBOARD:
format = MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR; format = MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR;
if (stereo->flags & AV_STEREO3D_FLAG_INVERT) if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
format--; format--;
break; break;
case AV_STEREO3D_LINES: case AV_STEREO3D_LINES:
format = MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR; format = MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR;
if (stereo->flags & AV_STEREO3D_FLAG_INVERT) if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
format--; format--;
*h_height = 2; *h_height = 2;
break; break;
case AV_STEREO3D_COLUMNS: case AV_STEREO3D_COLUMNS:
format = MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR; format = MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR;
if (stereo->flags & AV_STEREO3D_FLAG_INVERT) if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
format--; format--;
*h_width = 2; *h_width = 2;
break; break;
case AV_STEREO3D_FRAMESEQUENCE: case AV_STEREO3D_FRAMESEQUENCE:
format = MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR; format = MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR;
if (stereo->flags & AV_STEREO3D_FLAG_INVERT) if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
format++; format++;
break; break;
} }
} }
if (format == MATROSKA_VIDEO_STEREOMODE_TYPE_NB) if (format == MATROSKA_VIDEO_STEREOMODE_TYPE_NB)
return ret; return 0;
// if webm, do not write unsupported modes // if webm, do not write unsupported modes
if ((mode == MODE_WEBM && if ((mode == MODE_WEBM &&
...@@ -1107,14 +1105,13 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb, ...@@ -1107,14 +1105,13 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
|| format >= MATROSKA_VIDEO_STEREOMODE_TYPE_NB) { || format >= MATROSKA_VIDEO_STEREOMODE_TYPE_NB) {
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"The specified stereo mode is not valid.\n"); "The specified stereo mode is not valid.\n");
format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB;
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
// write StereoMode if format is valid // write StereoMode if format is valid
put_ebml_uint(pb, MATROSKA_ID_VIDEOSTEREOMODE, format); put_ebml_uint(pb, MATROSKA_ID_VIDEOSTEREOMODE, format);
return ret; return 0;
} }
static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment