From c54fc507da8edcc2c5d3bc3f50b0881d1c1406d7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 5 Nov 2012 14:25:04 +0100 Subject: video/filter: change filter API, use refcounting, remove filter DR Change the entire filter API to use reference counted images instead of vf_get_image(). Remove filter "direct rendering". This was useful for vf_expand and (in rare cases) vf_sub: DR allowed these filters to pass a cropped image to the filters before them. Then, on filtering, the image was "uncropped", so that black bars could be added around the image without copying. This means that in some cases, vf_expand will be slower (-vf gradfun,expand for example). Note that another form of DR used for in-place filters has been replaced by simpler logic. Instead of trying to do DR, filters can check if the image is writeable (with mp_image_is_writeable()), and do true in-place if that's the case. This affects filters like vf_gradfun and vf_sub. Everything has to support strides now. If something doesn't, making a copy of the image data is required. --- video/decode/dec_video.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'video/decode/dec_video.c') diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 9ec5e3db65..8730703216 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -104,7 +104,6 @@ int get_video_colors(sh_video_t *sh_video, const char *item, int *value) void get_detected_video_colorspace(struct sh_video *sh, struct mp_csp_details *csp) { struct MPOpts *opts = sh->opts; - struct vf_instance *vf = sh->vfilter; csp->format = opts->requested_colorspace; csp->levels_in = opts->requested_input_range; @@ -113,7 +112,7 @@ void get_detected_video_colorspace(struct sh_video *sh, struct mp_csp_details *c if (csp->format == MP_CSP_AUTO) csp->format = sh->colorspace; if (csp->format == MP_CSP_AUTO) - csp->format = mp_csp_guess_colorspace(vf->w, vf->h); + csp->format = mp_csp_guess_colorspace(sh->disp_w, sh->disp_h); if (csp->levels_in == MP_CSP_LEVELS_AUTO) csp->levels_in = sh->color_range; @@ -400,8 +399,10 @@ void *decode_video(sh_video_t *sh_video, struct demux_packet *packet, } #endif - if (!mpi || drop_frame) + if (!mpi || drop_frame) { + talloc_free(mpi); return NULL; // error / skipped frame + } if (field_dominance == 0) mpi->fields |= MP_IMGFIELD_TOP_FIRST; @@ -432,11 +433,3 @@ void *decode_video(sh_video_t *sh_video, struct demux_packet *packet, sh_video->num_sorted_pts_problems++; return mpi; } - -int filter_video(sh_video_t *sh_video, void *frame, double pts) -{ - mp_image_t *mpi = frame; - vf_instance_t *vf = sh_video->vfilter; - // apply video filters and call the leaf vo/ve - return vf->put_image(vf, mpi, pts); -} -- cgit v1.2.3