| @@ -32,6 +32,7 @@ · 31 unmodified lines |
| 32 | 32 | #include "libavutil/pixdesc.h" |
| 33 | 33 | #include "libavutil/intreadwrite.h" |
| 34 | 34 | #include "libavutil/imgutils.h" |
| 35 | +#include "libavutil/opt.h" |
| 35 | 36 | |
| 36 | 37 | #include "libmpcodecs/vf.h" |
| 37 | 38 | #include "libmpcodecs/img_format.h" |
| @@ -262,12 +263,23 @@ struct SwsContext *ff_sws_getContextFromCmdLine(int srcW, int srcH, int srcForma · 224 unmodified lines |
| 262 | 263 | } |
| 263 | 264 | |
| 264 | 265 | typedef struct { |
| 266 | + const AVClass *class; |
| 265 | 267 | vf_instance_t vf; |
| 266 | 268 | vf_instance_t next_vf; |
| 267 | 269 | AVFilterContext *avfctx; |
| 268 | 270 | int frame_returned; |
| 271 | + char *filter; |
| 269 | 272 | } MPContext; |
| 270 | 273 | |
| 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 | + |
| 271 | 283 | void ff_mp_msg(int mod, int lev, const char *format, ... ){ |
| 272 | 284 | va_list va; |
| 273 | 285 | 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 |
| 533 | 545 | static void dummy_free(void *opaque, uint8_t *data){} |
| 534 | 546 | |
| 535 | 547 | 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)); |
| 537 | 549 | AVFilterLink *outlink = m->avfctx->outputs[0]; |
| 538 | 550 | AVFrame *picref = av_frame_alloc(); |
| 539 | 551 | int i; |
| @@ -605,13 +617,13 @@ int ff_vf_next_config(struct vf_instance *vf, · 65 unmodified lines |
| 605 | 617 | } |
| 606 | 618 | |
| 607 | 619 | 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)); |
| 609 | 621 | av_log(m->avfctx, AV_LOG_DEBUG, "Received control %d\n", request); |
| 610 | 622 | return 0; |
| 611 | 623 | } |
| 612 | 624 | |
| 613 | 625 | 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)); |
| 615 | 627 | int i; |
| 616 | 628 | av_log(m->avfctx, AV_LOG_DEBUG, "query %X\n", fmt); |
| 617 | 629 | |
| @@ -644,6 +656,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 26 unmodified lines |
| 644 | 656 | |
| 645 | 657 | m->avfctx= ctx; |
| 646 | 658 | |
| 659 | + args = m->filter; |
| 647 | 660 | if(!args || 1!=sscanf(args, "%255[^:=]", name)){ |
| 648 | 661 | av_log(ctx, AV_LOG_ERROR, "Invalid parameter.\n"); |
| 649 | 662 | return AVERROR(EINVAL); |
| @@ -850,4 +863,5 @@ AVFilter avfilter_vf_mp = { · 200 unmodified lines |
| 850 | 863 | .query_formats = query_formats, |
| 851 | 864 | .inputs = mp_inputs, |
| 852 | 865 | .outputs = mp_outputs, |
| 866 | + .priv_class = &mp_class, |
| 853 | 867 | }; |