summaryrefslogtreecommitdiff
path: root/libavutil/stereo3d.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2016-04-21 17:24:07 -0400
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-05-17 12:25:27 -0400
commit0c4468dc185fa8b9e7d6add914595c5e928b24fd (patch)
tree72ca617953ba608bf21bb3584058770a353d11e2 /libavutil/stereo3d.c
parentd621b2f795684f7119057f986066060adbe84220 (diff)
stereo3d: Add API to get name from value or value from name
Use it in av_dump_format() instead of a huge switch case.
Diffstat (limited to 'libavutil/stereo3d.c')
-rw-r--r--libavutil/stereo3d.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index 2dcfddf14b..0d72609cd0 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -21,6 +21,7 @@
#include <stdint.h>
#include <string.h>
+#include "common.h"
#include "mem.h"
#include "stereo3d.h"
@@ -41,3 +42,35 @@ AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
return (AVStereo3D *)side_data->data;
}
+
+static const char *stereo3d_type_names[] = {
+ [AV_STEREO3D_2D] = "2D",
+ [AV_STEREO3D_SIDEBYSIDE] = "side by side",
+ [AV_STEREO3D_TOPBOTTOM] = "top and bottom",
+ [AV_STEREO3D_FRAMESEQUENCE] = "frame alternate",
+ [AV_STEREO3D_CHECKERBOARD] = "checkerboard",
+ [AV_STEREO3D_SIDEBYSIDE_QUINCUNX] = "side by side (quincunx subsampling)",
+ [AV_STEREO3D_LINES] = "interleaved lines",
+ [AV_STEREO3D_COLUMNS] = "interleaved columns",
+};
+
+const char *av_stereo3d_type_name(unsigned int type)
+{
+ if (type >= FF_ARRAY_ELEMS(stereo3d_type_names))
+ return "unknown";
+
+ return stereo3d_type_names[type];
+}
+
+int av_stereo3d_from_name(const char *name)
+{
+ int i;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(stereo3d_type_names); i++) {
+ size_t len = strlen(stereo3d_type_names[i]);
+ if (!strncmp(stereo3d_type_names[i], name, len))
+ return i;
+ }
+
+ return -1;
+}