Mercurial > mplayer.hg
changeset 36309:583523331410
vf_screenshot: slice handling fix.
We can only support slices if the next filter does so.
Fixes bugzilla issue #2140.
author | reimar |
---|---|
date | Mon, 05 Aug 2013 18:36:57 +0000 |
parents | 687e65bf99f9 |
children | 7b135b3b8b38 |
files | libmpcodecs/vf_screenshot.c |
diffstat | 1 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/vf_screenshot.c Mon Aug 05 16:51:10 2013 +0000 +++ b/libmpcodecs/vf_screenshot.c Mon Aug 05 18:36:57 2013 +0000 @@ -59,10 +59,24 @@ //===========================================================================// +static void draw_slice(struct vf_instance *vf, unsigned char** src, + int* stride, int w,int h, int x, int y) +{ + if (vf->priv->store_slices) { + uint8_t *dst[MP_MAX_PLANES] = {NULL}; + int dst_stride[MP_MAX_PLANES] = {0}; + dst_stride[0] = vf->priv->stride; + dst[0] = vf->priv->buffer; + sws_scale(vf->priv->ctx, src, stride, y, h, dst, dst_stride); + } + vf_next_draw_slice(vf,src,stride,w,h,x,y); +} + static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { + int res; vf->priv->ctx=sws_getContextFromCmdLine(width, height, outfmt, d_width, d_height, IMGFMT_RGB24); @@ -78,7 +92,11 @@ free(vf->priv->buffer); // probably reconfigured vf->priv->buffer = NULL; - return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); + res = vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); + // Our draw_slice only works properly if the + // following filter can do slices. + vf->draw_slice=vf->next->draw_slice ? draw_slice : NULL; + return res; } static void write_png(struct vf_priv_s *priv) @@ -150,19 +168,6 @@ } -static void draw_slice(struct vf_instance *vf, unsigned char** src, - int* stride, int w,int h, int x, int y) -{ - if (vf->priv->store_slices) { - uint8_t *dst[MP_MAX_PLANES] = {NULL}; - int dst_stride[MP_MAX_PLANES] = {0}; - dst_stride[0] = vf->priv->stride; - dst[0] = vf->priv->buffer; - sws_scale(vf->priv->ctx, src, stride, y, h, dst, dst_stride); - } - vf_next_draw_slice(vf,src,stride,w,h,x,y); -} - static void get_image(struct vf_instance *vf, mp_image_t *mpi) { // FIXME: should vf.c really call get_image when using slices??