[FFmpeg-cvslog] matroska: Factor out mkv_write_stereo_mode

Luca Barbato git at videolan.org
Tue Jul 1 21:00:20 CEST 2014


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sat Jun  7 01:38:00 2014 +0200| [48e6432407a73d5006d84609456e6e0bc3dd8fc4] | committer: Luca Barbato

matroska: Factor out mkv_write_stereo_mode

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48e6432407a73d5006d84609456e6e0bc3dd8fc4
---

 libavformat/matroskaenc.c |   39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 6916d34..b55ad35 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -624,6 +624,27 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
     return ret;
 }
 
+static void mkv_write_stereo_mode(AVIOContext *pb, uint8_t stereo_fmt,
+                                  int mode)
+{
+    int valid_fmt = 0;
+
+    switch (mode) {
+    case MODE_WEBM:
+        if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM ||
+            stereo_fmt == MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT)
+            valid_fmt = 1;
+        break;
+    case MODE_MATROSKAv2:
+        if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL)
+            valid_fmt = 1;
+        break;
+    }
+
+    if (valid_fmt)
+        put_ebml_uint (pb, MATROSKA_ID_VIDEOSTEREOMODE, stereo_fmt);
+}
+
 static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
                            int i, AVIOContext *pb)
 {
@@ -723,23 +744,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
         put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
         put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
         if ((tag = av_dict_get(s->metadata, "stereo_mode", NULL, 0))) {
-            uint8_t stereo_fmt = atoi(tag->value);
-            int valid_fmt = 0;
-
-            switch (mkv->mode) {
-            case MODE_WEBM:
-                if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM ||
-                    stereo_fmt == MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT)
-                    valid_fmt = 1;
-                break;
-            case MODE_MATROSKAv2:
-                if (stereo_fmt <= MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL)
-                    valid_fmt = 1;
-                break;
-            }
-
-            if (valid_fmt)
-                put_ebml_uint (pb, MATROSKA_ID_VIDEOSTEREOMODE, stereo_fmt);
+            mkv_write_stereo_mode(pb, atoi(tag->value), mkv->mode);
         }
         if (st->sample_aspect_ratio.num) {
             int d_width = codec->width*av_q2d(st->sample_aspect_ratio);



More information about the ffmpeg-cvslog mailing list