| @@ -26,47 +26,19 @@ · 25 unmodified lines |
| 26 | #include "libavutil/opt.h" | 26 | #include "libavutil/opt.h" |
| 27 | #include "libavutil/imgutils.h" | 27 | #include "libavutil/imgutils.h" |
| 28 | #include "libavutil/internal.h" | 28 | #include "libavutil/internal.h" |
| | 29 | #include "libavutil/opt.h" |
| 29 | #include "libavutil/pixdesc.h" | 30 | #include "libavutil/pixdesc.h" |
| 30 | #include "avfilter.h" | 31 | #include "avfilter.h" |
| 31 | #include "formats.h" | 32 | #include "formats.h" |
| 32 | #include "internal.h" | 33 | #include "internal.h" |
| 33 | #include "video.h" | 34 | #include "video.h" |
| 34 | | 35 | |
| 35 | enum FieldOrder { | | |
| 36 | ORDER_TFF, | | |
| 37 | ORDER_BFF, | | |
| 38 | ORDER_NB, | | |
| 39 | }; | | |
| 40 | | | |
| 41 | typedef struct { | 36 | typedef struct { |
| 42 | const AVClass *class; | 37 | const AVClass *class; |
| 43 | enum FieldOrder order; | 38 | int dst_tff; ///< output bff/tff |
| 44 | unsigned int dst_tff; ///< output bff/tff | | |
| 45 | int line_size[4]; ///< bytes of pixel data per line for each plane | 39 | int line_size[4]; ///< bytes of pixel data per line for each plane |
| 46 | } FieldOrderContext; | 40 | } FieldOrderContext; |
| 47 | | 41 | |
| 48 | #define OFFSET(x) offsetof(FieldOrderContext, x) | | |
| 49 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM | | |
| 50 | | | |
| 51 | static const AVOption fieldorder_options[] = { | | |
| 52 | { "order", "set output field order", OFFSET(order), AV_OPT_TYPE_INT, {.i64=ORDER_TFF}, 0, ORDER_NB-1, FLAGS, "order" }, | | |
| 53 | { "tff", "set top field first", 0, AV_OPT_TYPE_CONST, {.i64=ORDER_TFF}, .flags=FLAGS, .unit="order" }, | | |
| 54 | { "bff", "set bottom field first", 0, AV_OPT_TYPE_CONST, {.i64=ORDER_BFF}, .flags=FLAGS, .unit="order" }, | | |
| 55 | { NULL } | | |
| 56 | }; | | |
| 57 | | | |
| 58 | AVFILTER_DEFINE_CLASS(fieldorder); | | |
| 59 | | | |
| 60 | static av_cold int init(AVFilterContext *ctx, const char *args) | | |
| 61 | { | | |
| 62 | FieldOrderContext *fieldorder = ctx->priv; | | |
| 63 | | | |
| 64 | fieldorder->dst_tff = fieldorder->order == ORDER_TFF; | | |
| 65 | av_log(ctx, AV_LOG_VERBOSE, "tff:%d\n", fieldorder->dst_tff); | | |
| 66 | | | |
| 67 | return 0; | | |
| 68 | } | | |
| 69 | | | |
| 70 | static int query_formats(AVFilterContext *ctx) | 42 | static int query_formats(AVFilterContext *ctx) |
| 71 | { | 43 | { |
| 72 | AVFilterFormats *formats; | 44 | AVFilterFormats *formats; |
| @@ -176,6 +148,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 103 unmodified lines |
| 176 | return ff_filter_frame(outlink, frame); | 148 | return ff_filter_frame(outlink, frame); |
| 177 | } | 149 | } |
| 178 | | 150 | |
| | 151 | #define OFFSET(x) offsetof(FieldOrderContext, x) |
| | 152 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
| | 153 | |
| | 154 | static const AVOption fieldorder_options[] = { |
| | 155 | { "order", "output field order", OFFSET(dst_tff), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "order" }, |
| | 156 | { "bff", "bottom field first", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags=FLAGS, .unit = "order" }, |
| | 157 | { "tff", "top field first", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags=FLAGS, .unit = "order" }, |
| | 158 | { NULL }, |
| | 159 | }; |
| | 160 | |
| | 161 | AVFILTER_DEFINE_CLASS(fieldorder); |
| | 162 | |
| 179 | static const AVFilterPad avfilter_vf_fieldorder_inputs[] = { | 163 | static const AVFilterPad avfilter_vf_fieldorder_inputs[] = { |
| 180 | { | 164 | { |
| 181 | .name = "default", | 165 | .name = "default", |
| @@ -196,16 +180,12 @@ static const AVFilterPad avfilter_vf_fieldorder_outputs[] = { · 14 unmodified lines |
| 196 | { NULL } | 180 | { NULL } |
| 197 | }; | 181 | }; |
| 198 | | 182 | |
| 199 | static const char *const shorthand[] = { "order", NULL }; | | |
| 200 | | | |
| 201 | AVFilter avfilter_vf_fieldorder = { | 183 | AVFilter avfilter_vf_fieldorder = { |
| 202 | .name = "fieldorder", | 184 | .name = "fieldorder", |
| 203 | .description = NULL_IF_CONFIG_SMALL("Set the field order."), | 185 | .description = NULL_IF_CONFIG_SMALL("Set the field order."), |
| 204 | .init = init, | | |
| 205 | .priv_size = sizeof(FieldOrderContext), | 186 | .priv_size = sizeof(FieldOrderContext), |
| | 187 | .priv_class = &fieldorder_class, |
| 206 | .query_formats = query_formats, | 188 | .query_formats = query_formats, |
| 207 | .inputs = avfilter_vf_fieldorder_inputs, | 189 | .inputs = avfilter_vf_fieldorder_inputs, |
| 208 | .outputs = avfilter_vf_fieldorder_outputs, | 190 | .outputs = avfilter_vf_fieldorder_outputs, |
| 209 | .priv_class = &fieldorder_class, | | |
| 210 | .shorthand = shorthand, | | |
| 211 | }; | 191 | }; |