Allow extensibility.
Stefano Sabatini authored on 2012/09/30 20:03:08... | ... |
@@ -3519,8 +3519,11 @@ Default mode is @code{merge}. |
3519 | 3519 |
|
3520 | 3520 |
Transpose rows with columns in the input video and optionally flip it. |
3521 | 3521 |
|
3522 |
-It accepts a parameter representing an integer, which can assume the |
|
3523 |
-values: |
|
3522 |
+This filter accepts the following named parameters: |
|
3523 |
+ |
|
3524 |
+@table @option |
|
3525 |
+@item dir |
|
3526 |
+Specify the transposition direction. Can assume the following values: |
|
3524 | 3527 |
|
3525 | 3528 |
@table @samp |
3526 | 3529 |
@item 0, 4 |
... | ... |
@@ -3558,6 +3561,7 @@ l.r l.L |
3558 | 3558 |
|
3559 | 3559 |
For values between 4-7 transposition is only done if the input video |
3560 | 3560 |
geometry is portrait and not landscape. |
3561 |
+@end table |
|
3561 | 3562 |
|
3562 | 3563 |
@section unsharp |
3563 | 3564 |
|
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
|
31 | 31 |
#define LIBAVFILTER_VERSION_MAJOR 3 |
32 | 32 |
#define LIBAVFILTER_VERSION_MINOR 19 |
33 |
-#define LIBAVFILTER_VERSION_MICRO 100 |
|
33 |
+#define LIBAVFILTER_VERSION_MICRO 101 |
|
34 | 34 |
|
35 | 35 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
36 | 36 |
LIBAVFILTER_VERSION_MINOR, \ |
... | ... |
@@ -28,6 +28,7 @@ |
28 | 28 |
#include <stdio.h> |
29 | 29 |
|
30 | 30 |
#include "libavutil/intreadwrite.h" |
31 |
+#include "libavutil/opt.h" |
|
31 | 32 |
#include "libavutil/pixdesc.h" |
32 | 33 |
#include "libavutil/imgutils.h" |
33 | 34 |
#include "libavutil/internal.h" |
... | ... |
@@ -37,6 +38,7 @@ |
37 | 37 |
#include "video.h" |
38 | 38 |
|
39 | 39 |
typedef struct { |
40 |
+ const AVClass *class; |
|
40 | 41 |
int hsub, vsub; |
41 | 42 |
int pixsteps[4]; |
42 | 43 |
|
... | ... |
@@ -48,20 +50,25 @@ typedef struct { |
48 | 48 |
int passthrough; ///< landscape passthrough mode enabled |
49 | 49 |
} TransContext; |
50 | 50 |
|
51 |
+#define OFFSET(x) offsetof(TransContext, x) |
|
52 |
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
|
53 |
+ |
|
54 |
+static const AVOption transpose_options[] = { |
|
55 |
+ { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, {.i64=0}, 0, 7, FLAGS }, |
|
56 |
+ { NULL }, |
|
57 |
+}; |
|
58 |
+ |
|
59 |
+AVFILTER_DEFINE_CLASS(transpose); |
|
60 |
+ |
|
51 | 61 |
static av_cold int init(AVFilterContext *ctx, const char *args) |
52 | 62 |
{ |
53 | 63 |
TransContext *trans = ctx->priv; |
54 |
- trans->dir = 0; |
|
64 |
+ const char *shorthand[] = { "dir", NULL }; |
|
55 | 65 |
|
56 |
- if (args) |
|
57 |
- sscanf(args, "%d", &trans->dir); |
|
66 |
+ trans->class = &transpose_class; |
|
67 |
+ av_opt_set_defaults(trans); |
|
58 | 68 |
|
59 |
- if (trans->dir < 0 || trans->dir > 7) { |
|
60 |
- av_log(ctx, AV_LOG_ERROR, "Invalid value %d not between 0 and 7.\n", |
|
61 |
- trans->dir); |
|
62 |
- return AVERROR(EINVAL); |
|
63 |
- } |
|
64 |
- return 0; |
|
69 |
+ return av_opt_set_from_string(trans, args, shorthand, "=", ":"); |
|
65 | 70 |
} |
66 | 71 |
|
67 | 72 |
static int query_formats(AVFilterContext *ctx) |
... | ... |
@@ -262,4 +269,5 @@ AVFilter avfilter_vf_transpose = { |
262 | 262 |
.config_props = config_props_output, |
263 | 263 |
.type = AVMEDIA_TYPE_VIDEO, }, |
264 | 264 |
{ .name = NULL}}, |
265 |
+ .priv_class = &transpose_class, |
|
265 | 266 |
}; |