History

Merge commit '0c4468dc185fa8b9e7d6add914595c5e928b24fd'

* commit '0c4468dc185fa8b9e7d6add914595c5e928b24fd': stereo3d: Add API to get name from value or value from name

Clément Bœsch committed 10 years ago

Commit abb3cc42 parents 5954730 0c4468d5 files · +57 −30Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavformat/dump.c +2 −29
  3. libavutil/stereo3d.c +33 −0
  4. libavutil/stereo3d.h +18 −0
  5. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2016-xx-xx - xxxxxxx / 0c4468d - lavu 55.26.100 / 55.12.0 - opt.h
19+ Add av_stereo3d_type_name() and av_stereo3d_from_name().
20+
1821 2016-06-22 - xxxxxxx - lavu 55.25.100 - hwcontext_dxva2.h
1922 Add new installed header with DXVA2-specific hwcontext definitions.
2023
libavformat/dump.c+2−29
@@ -252,6 +252,7 @@ static void dump_replaygain(void *ctx, AVPacketSideData *sd) · 251 unmodified lines
252252 static void dump_stereo3d(void *ctx, AVPacketSideData *sd)
253253 {
254254 AVStereo3D *stereo;
255+ const char *name;
255256
256257 if (sd->size < sizeof(*stereo)) {
257258 av_log(ctx, AV_LOG_INFO, "invalid data");
@@ -260,35 +261,7 @@ static void dump_stereo3d(void *ctx, AVPacketSideData *sd) · 2 unmodified lines
260261
261262 stereo = (AVStereo3D *)sd->data;
262263
263− switch (stereo->type) {
264− case AV_STEREO3D_2D:
265− av_log(ctx, AV_LOG_INFO, "2D");
266− break;
267− case AV_STEREO3D_SIDEBYSIDE:
268− av_log(ctx, AV_LOG_INFO, "side by side");
269− break;
270− case AV_STEREO3D_TOPBOTTOM:
271− av_log(ctx, AV_LOG_INFO, "top and bottom");
272− break;
273− case AV_STEREO3D_FRAMESEQUENCE:
274− av_log(ctx, AV_LOG_INFO, "frame alternate");
275− break;
276− case AV_STEREO3D_CHECKERBOARD:
277− av_log(ctx, AV_LOG_INFO, "checkerboard");
278− break;
279− case AV_STEREO3D_LINES:
280− av_log(ctx, AV_LOG_INFO, "interleaved lines");
281− break;
282− case AV_STEREO3D_COLUMNS:
283− av_log(ctx, AV_LOG_INFO, "interleaved columns");
284− break;
285− case AV_STEREO3D_SIDEBYSIDE_QUINCUNX:
286− av_log(ctx, AV_LOG_INFO, "side by side (quincunx subsampling)");
287− break;
288− default:
289− av_log(ctx, AV_LOG_WARNING, "unknown");
290− break;
291− }
264+ av_log(ctx, AV_LOG_INFO, "%s", av_stereo3d_type_name(stereo->type));
292265
293266 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
294267 av_log(ctx, AV_LOG_INFO, " (inverted)");
libavutil/stereo3d.c+33−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <stdint.h>
2222 #include <string.h>
2323
24+#include "common.h"
2425 #include "mem.h"
2526 #include "stereo3d.h"
2627
@@ -41,3 +42,35 @@ AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame) · 14 unmodified lines
4142
4243 return (AVStereo3D *)side_data->data;
4344 }
45+
46+static const char *stereo3d_type_names[] = {
47+ [AV_STEREO3D_2D] = "2D",
48+ [AV_STEREO3D_SIDEBYSIDE] = "side by side",
49+ [AV_STEREO3D_TOPBOTTOM] = "top and bottom",
50+ [AV_STEREO3D_FRAMESEQUENCE] = "frame alternate",
51+ [AV_STEREO3D_CHECKERBOARD] = "checkerboard",
52+ [AV_STEREO3D_SIDEBYSIDE_QUINCUNX] = "side by side (quincunx subsampling)",
53+ [AV_STEREO3D_LINES] = "interleaved lines",
54+ [AV_STEREO3D_COLUMNS] = "interleaved columns",
55+};
56+
57+const char *av_stereo3d_type_name(unsigned int type)
58+{
59+ if (type >= FF_ARRAY_ELEMS(stereo3d_type_names))
60+ return "unknown";
61+
62+ return stereo3d_type_names[type];
63+}
64+
65+int av_stereo3d_from_name(const char *name)
66+{
67+ int i;
68+
69+ for (i = 0; i < FF_ARRAY_ELEMS(stereo3d_type_names); i++) {
70+ size_t len = strlen(stereo3d_type_names[i]);
71+ if (!strncmp(stereo3d_type_names[i], name, len))
72+ return i;
73+ }
74+
75+ return -1;
76+}
libavutil/stereo3d.h+18−0
@@ -149,4 +149,22 @@ AVStereo3D *av_stereo3d_alloc(void); · 148 unmodified lines
149149 */
150150 AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame);
151151
152+/**
153+ * Provide a human-readable name of a given stereo3d type.
154+ *
155+ * @param type The input stereo3d type value.
156+ *
157+ * @return The name of the stereo3d value, or "unknown".
158+ */
159+const char *av_stereo3d_type_name(unsigned int type);
160+
161+/**
162+ * Get the AVStereo3DType form a human-readable name.
163+ *
164+ * @param type The input string.
165+ *
166+ * @return The AVStereo3DType value, or -1 if not found.
167+ */
168+int av_stereo3d_from_name(const char *name);
169+
152170 #endif /* AVUTIL_STEREO3D_H */
libavutil/version.h+1−1
@@ -64,7 +64,7 @@ · 63 unmodified lines
6464 */
6565
6666 #define LIBAVUTIL_VERSION_MAJOR 55
67−#define LIBAVUTIL_VERSION_MINOR 25
67+#define LIBAVUTIL_VERSION_MINOR 26
6868 #define LIBAVUTIL_VERSION_MICRO 100
6969
7070 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t