summaryrefslogtreecommitdiff
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-07 14:13:07 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-19 02:54:13 +0200
commitff1264aa4d31b7082f0b7c4dca625f9f2a6391a3 (patch)
treeebc4e15aeb6d7812e4dd80f02ce700562de7fed2 /libavformat/matroskaenc.c
parentb921d4d013a7f4d23fbdba8800780b8171af9d5e (diff)
downloadffmpeg-ff1264aa4d31b7082f0b7c4dca625f9f2a6391a3.tar.gz
avformat/matroskaenc: Use av_stream_get_side_data() instead of loop
in mkv_write_stereo_mode(). Also check the size of the AVStereo3D side data. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index df3ba6ceed..7a6a299873 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1029,6 +1029,8 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
int ret = 0;
const AVDictionaryEntry *tag;
MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB;
+ const AVStereo3D *stereo;
+ int side_data_size = 0;
*h_width = 1;
*h_height = 1;
@@ -1051,12 +1053,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
}
}
- // iterate to find the stereo3d side data
- for (i = 0; i < st->nb_side_data; i++) {
- AVPacketSideData sd = st->side_data[i];
- if (sd.type == AV_PKT_DATA_STEREO3D) {
- AVStereo3D *stereo = (AVStereo3D *)sd.data;
-
+ 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;
@@ -1096,8 +1095,6 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
format++;
break;
}
- break;
- }
}
if (format == MATROSKA_VIDEO_STEREOMODE_TYPE_NB)