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