History

lavfi/mp: switch to an AVOptions-based system.

Clément Bœsch committed 13 years ago

Commit 838d8031 parent 70b72ca2 files · +32 −4Browse files

Unified · Split

2 files
  1. libavfilter/avfilter.c +15 −1
  2. libavfilter/vf_mp.c +17 −3
libavfilter/avfilter.c+15−1
@@ -680,7 +680,6 @@ static const char *const filters_left_to_update[] = { · 679 unmodified lines
680680 #endif
681681 "atempo",
682682 "buffer",
683− "mp",
684683 "pan",
685684 "scale",
686685 };
@@ -818,6 +817,21 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 131 unmodified lines
818817 goto fail;
819818 #endif
820819 } else {
820+#if CONFIG_MP_FILTER
821+ if (!strcmp(filter->filter->name, "mp")) {
822+ char *escaped;
823+
824+ if (!strncmp(args, "filter=", 7))
825+ args += 7;
826+ ret = av_escape(&escaped, args, ":=", AV_ESCAPE_MODE_BACKSLASH, 0);
827+ if (ret < 0) {
828+ av_log(filter, AV_LOG_ERROR, "Unable to escape MPlayer filters arg '%s'\n", args);
829+ goto fail;
830+ }
831+ ret = process_options(filter, &options, escaped);
832+ av_free(escaped);
833+ } else
834+#endif
821835 ret = process_options(filter, &options, args);
822836 if (ret < 0)
823837 goto fail;
libavfilter/vf_mp.c+17−3
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/pixdesc.h"
3333 #include "libavutil/intreadwrite.h"
3434 #include "libavutil/imgutils.h"
35+#include "libavutil/opt.h"
3536
3637 #include "libmpcodecs/vf.h"
3738 #include "libmpcodecs/img_format.h"
@@ -262,12 +263,23 @@ struct SwsContext *ff_sws_getContextFromCmdLine(int srcW, int srcH, int srcForma · 224 unmodified lines
262263 }
263264
264265 typedef struct {
266+ const AVClass *class;
265267 vf_instance_t vf;
266268 vf_instance_t next_vf;
267269 AVFilterContext *avfctx;
268270 int frame_returned;
271+ char *filter;
269272 } MPContext;
270273
274+#define OFFSET(x) offsetof(MPContext, x)
275+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
276+static const AVOption mp_options[] = {
277+ { "filter", "set MPlayer filter name and parameters", OFFSET(filter), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
278+ { NULL }
279+};
280+
281+AVFILTER_DEFINE_CLASS(mp);
282+
271283 void ff_mp_msg(int mod, int lev, const char *format, ... ){
272284 va_list va;
273285 va_start(va, format);
@@ -533,7 +545,7 @@ mp_image_t* ff_vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgty · 259 unmodified lines
533545 static void dummy_free(void *opaque, uint8_t *data){}
534546
535547 int ff_vf_next_put_image(struct vf_instance *vf,mp_image_t *mpi, double pts){
536− MPContext *m= (void*)vf;
548+ MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, vf));
537549 AVFilterLink *outlink = m->avfctx->outputs[0];
538550 AVFrame *picref = av_frame_alloc();
539551 int i;
@@ -605,13 +617,13 @@ int ff_vf_next_config(struct vf_instance *vf, · 65 unmodified lines
605617 }
606618
607619 int ff_vf_next_control(struct vf_instance *vf, int request, void* data){
608− MPContext *m= (void*)vf;
620+ MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, vf));
609621 av_log(m->avfctx, AV_LOG_DEBUG, "Received control %d\n", request);
610622 return 0;
611623 }
612624
613625 static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt){
614− MPContext *m= (void*)vf;
626+ MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, vf));
615627 int i;
616628 av_log(m->avfctx, AV_LOG_DEBUG, "query %X\n", fmt);
617629
@@ -644,6 +656,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 26 unmodified lines
644656
645657 m->avfctx= ctx;
646658
659+ args = m->filter;
647660 if(!args || 1!=sscanf(args, "%255[^:=]", name)){
648661 av_log(ctx, AV_LOG_ERROR, "Invalid parameter.\n");
649662 return AVERROR(EINVAL);
@@ -850,4 +863,5 @@ AVFilter avfilter_vf_mp = { · 200 unmodified lines
850863 .query_formats = query_formats,
851864 .inputs = mp_inputs,
852865 .outputs = mp_outputs,
866+ .priv_class = &mp_class,
853867 };

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