00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #include "avfilter.h"
00027 #include "video.h"
00028
00029 enum SetFieldMode {
00030 MODE_AUTO = -1,
00031 MODE_BFF,
00032 MODE_TFF,
00033 MODE_PROG,
00034 };
00035
00036 typedef struct {
00037 enum SetFieldMode mode;
00038 } SetFieldContext;
00039
00040 static av_cold int init(AVFilterContext *ctx, const char *args)
00041 {
00042 SetFieldContext *setfield = ctx->priv;
00043
00044 setfield->mode = MODE_AUTO;
00045
00046 if (args) {
00047 char c;
00048 if (sscanf(args, "%d%c", &setfield->mode, &c) != 1) {
00049 if (!strcmp("tff", args)) setfield->mode = MODE_TFF;
00050 else if (!strcmp("bff", args)) setfield->mode = MODE_BFF;
00051 else if (!strcmp("prog", args)) setfield->mode = MODE_PROG;
00052 else if (!strcmp("auto", args)) setfield->mode = MODE_AUTO;
00053 else {
00054 av_log(ctx, AV_LOG_ERROR, "Invalid argument '%s'\n", args);
00055 return AVERROR(EINVAL);
00056 }
00057 } else {
00058 if (setfield->mode < -1 || setfield->mode > 1) {
00059 av_log(ctx, AV_LOG_ERROR,
00060 "Provided integer value %d must be included between -1 and +1\n",
00061 setfield->mode);
00062 return AVERROR(EINVAL);
00063 }
00064 av_log(ctx, AV_LOG_WARNING,
00065 "Using -1/0/1 is deprecated, use auto/tff/bff/prog\n");
00066 }
00067 }
00068
00069 return 0;
00070 }
00071
00072 static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
00073 {
00074 SetFieldContext *setfield = inlink->dst->priv;
00075 AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
00076
00077 if (setfield->mode == MODE_PROG) {
00078 outpicref->video->interlaced = 0;
00079 } else if (setfield->mode != MODE_AUTO) {
00080 outpicref->video->interlaced = 1;
00081 outpicref->video->top_field_first = setfield->mode;
00082 }
00083 return ff_start_frame(inlink->dst->outputs[0], outpicref);
00084 }
00085
00086 AVFilter avfilter_vf_setfield = {
00087 .name = "setfield",
00088 .description = NULL_IF_CONFIG_SMALL("Force field for the output video frame."),
00089 .init = init,
00090
00091 .priv_size = sizeof(SetFieldContext),
00092
00093 .inputs = (const AVFilterPad[]) {
00094 { .name = "default",
00095 .type = AVMEDIA_TYPE_VIDEO,
00096 .get_video_buffer = ff_null_get_video_buffer,
00097 .start_frame = start_frame, },
00098 { .name = NULL }
00099 },
00100 .outputs = (const AVFilterPad[]) {
00101 { .name = "default",
00102 .type = AVMEDIA_TYPE_VIDEO, },
00103 { .name = NULL }
00104 },
00105 };