From a7fee50ca0489eee0518c58b57a1e87f081bd573 Mon Sep 17 00:00:00 2001 From: harklu Date: Tue, 16 Aug 2011 02:49:19 +0200 Subject: vf_screenshot: better check for pixel format swscale support vf_screenshot checked for a list of pixel formats that were known to work with swscale. However, the list was incomplete. If a pixel format was used that was not on the vf_screenshot list, but was supported both by swscale and the VO driver, mplayer2 would insert a useless scale filter to convert to a format supported by vf_screenshot. Fix this by making vf_screenshot check directly whether the pixel format is supported by swscale with sws_isSupportedInput(). --- libmpcodecs/vf_screenshot.c | 54 ++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) (limited to 'libmpcodecs') diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c index 655a014886..04f0d6e5d9 100644 --- a/libmpcodecs/vf_screenshot.c +++ b/libmpcodecs/vf_screenshot.c @@ -20,9 +20,6 @@ #include #include -#if HAVE_MALLOC_H -#include -#endif #include #include @@ -30,15 +27,16 @@ #include #include -#include "mp_msg.h" +#include +#include +#include "mp_msg.h" #include "img_format.h" #include "mp_image.h" #include "vf.h" #include "vf_scale.h" +#include "fmt-conversion.h" -#include "libswscale/swscale.h" -#include "libavcodec/avcodec.h" struct vf_priv_s { int frameno; @@ -170,13 +168,9 @@ static void get_image(struct vf_instance *vf, mp_image_t *mpi) vf->dmpi= vf_get_image(vf->next, mpi->imgfmt, mpi->type, mpi->flags/* | MP_IMGFLAG_READABLE*/, mpi->width, mpi->height); - mpi->planes[0]=vf->dmpi->planes[0]; - mpi->stride[0]=vf->dmpi->stride[0]; - if(mpi->flags&MP_IMGFLAG_PLANAR){ - mpi->planes[1]=vf->dmpi->planes[1]; - mpi->planes[2]=vf->dmpi->planes[2]; - mpi->stride[1]=vf->dmpi->stride[1]; - mpi->stride[2]=vf->dmpi->stride[2]; + for (int i = 0; i < MP_MAX_PLANES; i++) { + mpi->planes[i]=vf->dmpi->planes[i]; + mpi->stride[i]=vf->dmpi->stride[i]; } mpi->width=vf->dmpi->width; @@ -197,12 +191,10 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height); vf_clone_mpi_attributes(dmpi, mpi); - dmpi->planes[0]=mpi->planes[0]; - dmpi->planes[1]=mpi->planes[1]; - dmpi->planes[2]=mpi->planes[2]; - dmpi->stride[0]=mpi->stride[0]; - dmpi->stride[1]=mpi->stride[1]; - dmpi->stride[2]=mpi->stride[2]; + for (int i = 0; i < MP_MAX_PLANES; i++) { + dmpi->planes[i]=mpi->planes[i]; + dmpi->stride[i]=mpi->stride[i]; + } dmpi->width=mpi->width; dmpi->height=mpi->height; } @@ -248,28 +240,10 @@ static int control (vf_instance_t *vf, int request, void *data) static int query_format(struct vf_instance *vf, unsigned int fmt) { - switch(fmt){ - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - case IMGFMT_BGR32: - case IMGFMT_BGR24: - case IMGFMT_BGR16: - case IMGFMT_BGR15: - case IMGFMT_BGR12: - case IMGFMT_RGB32: - case IMGFMT_RGB24: - case IMGFMT_Y800: - case IMGFMT_Y8: - case IMGFMT_YVU9: - case IMGFMT_IF09: - case IMGFMT_444P: - case IMGFMT_422P: - case IMGFMT_411P: + enum PixelFormat av_format = imgfmt2pixfmt(fmt); + + if (av_format != PIX_FMT_NONE && sws_isSupportedInput(av_format)) return vf_next_query_format(vf, fmt); - } return 0; } -- cgit v1.2.3