From 933805daa16cfbc74610a2221b537c4ddb15d33e Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 21 Oct 2012 01:10:32 +0200 Subject: mp_image: add IMGFMT_BGR0/PIX_FMT_BGR0 Needed by ffv1. --- libmpcodecs/img_format.c | 1 + libmpcodecs/img_format.h | 2 ++ libmpcodecs/mp_image.c | 5 +++++ 3 files changed, 8 insertions(+) (limited to 'libmpcodecs') diff --git a/libmpcodecs/img_format.c b/libmpcodecs/img_format.c index 7f82f95db2..b7e4f3ebf7 100644 --- a/libmpcodecs/img_format.c +++ b/libmpcodecs/img_format.c @@ -191,6 +191,7 @@ struct mp_imgfmt_entry mp_imgfmt_list[] = { {"argb", IMGFMT_ARGB}, {"bgra", IMGFMT_BGRA}, {"abgr", IMGFMT_ABGR}, + {"bgr0", IMGFMT_BGR0}, {"gbrp", IMGFMT_GBRP}, {"mjpeg", IMGFMT_MJPEG}, {"mjpg", IMGFMT_MJPEG}, diff --git a/libmpcodecs/img_format.h b/libmpcodecs/img_format.h index 42e601a270..edd7040327 100644 --- a/libmpcodecs/img_format.h +++ b/libmpcodecs/img_format.h @@ -101,6 +101,8 @@ #define IMGFMT_RGB_DEPTH(fmt) ((fmt)&0x3F) #define IMGFMT_BGR_DEPTH(fmt) ((fmt)&0x3F) +// AV_PIX_FMT_BGR0 +#define IMGFMT_BGR0 0x1DC70000 /* Planar YUV Formats */ diff --git a/libmpcodecs/mp_image.c b/libmpcodecs/mp_image.c index 006b0bf4f3..241f2886bc 100644 --- a/libmpcodecs/mp_image.c +++ b/libmpcodecs/mp_image.c @@ -119,6 +119,11 @@ void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ mpi->flags|=MP_IMGFLAG_SWAPPED; return; } + switch (out_fmt) { + case IMGFMT_BGR0: + mpi->bpp = 32; + return; + } mpi->num_planes=3; if (out_fmt == IMGFMT_GBRP) { mpi->bpp=24; -- cgit v1.2.3 From de3f6718124372f64443a0b86527c1abf86d6f8c Mon Sep 17 00:00:00 2001 From: reimar Date: Sat, 5 Nov 2011 18:20:44 +0000 Subject: vd_ffmpeg, vf: fix crashes with some game formats Fixes for palette allocation handling. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34304 b3059339-0415-0410-9bf9-f77b7e298cf2 This caused a crash with http://samples.ffmpeg.org/cdxl/fruit.cdxl if direct rendering was used. (Which is rarely these days.) With small changes: avoid av_freep() use, as this function is not sane. --- libmpcodecs/vd_ffmpeg.c | 3 --- libmpcodecs/vf.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'libmpcodecs') diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index d36e4122a0..343a26d8d3 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -583,9 +583,6 @@ static void release_buffer(struct AVCodecContext *avctx, AVFrame *pic) } if (mpi) { - // Palette support: free palette buffer allocated in get_buffer - if (mpi->bpp == 8) - av_freep(&mpi->planes[1]); // release mpi (in case MPI_IMGTYPE_NUMBERED is used, e.g. for VDPAU) mpi->usage_count--; } diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 5ec7d19570..8cf6002246 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -252,6 +252,8 @@ mp_image_t *vf_get_image(vf_instance_t *vf, unsigned int outfmt, break; } if (mpi) { + int missing_palette = !(mpi->flags & MP_IMGFLAG_RGB_PALETTE) && + (mp_imgflag & MP_IMGFLAG_RGB_PALETTE); mpi->type = mp_imgtype; mpi->w = vf->w; mpi->h = vf->h; @@ -263,11 +265,15 @@ mp_image_t *vf_get_image(vf_instance_t *vf, unsigned int outfmt, MP_IMGFLAG_DRAW_CALLBACK | MP_IMGFLAG_RGB_PALETTE); if (!vf->draw_slice) mpi->flags &= ~MP_IMGFLAG_DRAW_CALLBACK; - if (mpi->width != w2 || mpi->height != h) { + if (mpi->width != w2 || mpi->height != h || missing_palette) { if (mpi->flags & MP_IMGFLAG_ALLOCATED) { - if (mpi->width < w2 || mpi->height < h) { + if (mpi->width < w2 || mpi->height < h || missing_palette) { // need to re-allocate buffer memory: av_free(mpi->planes[0]); + if (mpi->flags & MP_IMGFLAG_RGB_PALETTE) + av_free(mpi->planes[1]); + for (int n = 0; n < MP_MAX_PLANES; n++) + mpi->planes[n] = NULL; mpi->flags &= ~MP_IMGFLAG_ALLOCATED; mp_msg(MSGT_VFILTER, MSGL_V, "vf.c: have to REALLOCATE buffer memory :(\n"); -- cgit v1.2.3 From 022517bdf5a1fc484096217bac8c7d7fbc78fa7b Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 22 Oct 2012 22:38:37 +0200 Subject: vd: remove references to vf_palette and vf_lavc Both of these video filters have been deleted. There wasn't any use-case left where these were needed. Videos with paletted pixel formats still work. --- libmpcodecs/vd.c | 51 +++------------------------------------------------ 1 file changed, 3 insertions(+), 48 deletions(-) (limited to 'libmpcodecs') diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c index 48e2b0627e..511665aeac 100644 --- a/libmpcodecs/vd.c +++ b/libmpcodecs/vd.c @@ -60,8 +60,7 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h, unsigned int out_fmt = 0; int screen_size_x = 0; int screen_size_y = 0; - vf_instance_t *vf = sh->vfilter, *sc = NULL; - int palette = 0; + vf_instance_t *vf = sh->vfilter; int vocfg_flags = 0; if (w) @@ -125,58 +124,14 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h, sh->output_flags = flags; if (flags & VFCAP_CSP_SUPPORTED_BY_HW) break; - } else if (!palette - && !(flags & - (VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_CSP_SUPPORTED)) - && (out_fmt == IMGFMT_RGB8 || out_fmt == IMGFMT_BGR8)) { - sh->outfmtidx = j; // pass index to the control() function this way - if (sh->vd_driver->control(sh, VDCTRL_QUERY_FORMAT, &out_fmt) != - CONTROL_FALSE) - palette = 1; } } if (j < 0) { // TODO: no match - we should use conversion... - if (strcmp(vf->info->name, "scale") && palette != -1) { + if (strcmp(vf->info->name, "scale")) { mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Could not find matching colorspace - retrying with -vf scale...\n"); - sc = vf = vf_open_filter(opts, vf, "scale", NULL); - goto csp_again; - } else if (palette == 1) { - mp_msg(MSGT_DECVIDEO, MSGL_V, "vd: Trying -vf palette...\n"); - palette = -1; - vf = vf_open_filter(opts, vf, "palette", NULL); + vf = vf_open_filter(opts, vf, "scale", NULL); goto csp_again; - } else { - // sws failed, if the last filter (vf_vo) support MPEGPES try - // to append vf_lavc - vf_instance_t *vo, *vp = NULL, *ve, *vpp = NULL; - // Remove the scale filter if we added it ourselves - if (vf == sc) { - ve = vf; - vf = vf->next; - vf_uninit_filter(ve); - } - // Find the last filter (vf_vo) - for (vo = vf; vo->next; vo = vo->next) { - vpp = vp; - vp = vo; - } - if (vo->query_format(vo, IMGFMT_MPEGPES) - && (!vp || (vp && strcmp(vp->info->name, "lavc")))) { - ve = vf_open_filter(opts, vo, "lavc", NULL); - if (vp) - vp->next = ve; - else - vf = ve; - goto csp_again; - } - if (vp && !strcmp(vp->info->name,"lavc")) { - if (vpp) - vpp->next = vo; - else - vf = vo; - vf_uninit_filter(vp); - } } mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "The selected video_out device is incompatible with this codec.\n"\ -- cgit v1.2.3 From 8bf4a60bbee3878e7e6b1366bf296cf8d3eedc8f Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 22 Oct 2012 22:52:22 +0200 Subject: VF: remove IMGFMT_MPEGPES This wasn't used anymore. Remove the reference to IMGFMT_MJPEG in vf_dlopen as well. Thus format is used as FourCC in the TV code (i.e. it's on the demuxer level, just like raw formats), and never appears in the video filter chain. For starters, vd_ffmpeg can never produce this format. --- libmpcodecs/img_format.c | 1 - libmpcodecs/img_format.h | 1 - libmpcodecs/mp_image.c | 2 +- libmpcodecs/vf.c | 3 --- libmpcodecs/vf_dlopen.c | 2 +- libmpcodecs/vf_expand.c | 13 ------------- 6 files changed, 2 insertions(+), 20 deletions(-) (limited to 'libmpcodecs') diff --git a/libmpcodecs/img_format.c b/libmpcodecs/img_format.c index b7e4f3ebf7..1084a8f9a1 100644 --- a/libmpcodecs/img_format.c +++ b/libmpcodecs/img_format.c @@ -195,7 +195,6 @@ struct mp_imgfmt_entry mp_imgfmt_list[] = { {"gbrp", IMGFMT_GBRP}, {"mjpeg", IMGFMT_MJPEG}, {"mjpg", IMGFMT_MJPEG}, - {"mpes", IMGFMT_MPEGPES}, {"vdpau_h264", IMGFMT_VDPAU_H264}, {"vdpau_mpeg1", IMGFMT_VDPAU_MPEG1}, {"vdpau_mpeg2", IMGFMT_VDPAU_MPEG2}, diff --git a/libmpcodecs/img_format.h b/libmpcodecs/img_format.h index edd7040327..b488734f02 100644 --- a/libmpcodecs/img_format.h +++ b/libmpcodecs/img_format.h @@ -198,7 +198,6 @@ #define IMGFMT_UYVP 0x50565955 // 10-bit UYVY /* Compressed Formats */ -#define IMGFMT_MPEGPES (('M'<<24)|('P'<<16)|('E'<<8)|('S')) #define IMGFMT_MJPEG (('M')|('J'<<8)|('P'<<16)|('G'<<24)) // VDPAU specific format. diff --git a/libmpcodecs/mp_image.c b/libmpcodecs/mp_image.c index 241f2886bc..412495f096 100644 --- a/libmpcodecs/mp_image.c +++ b/libmpcodecs/mp_image.c @@ -99,7 +99,7 @@ void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED); mpi->imgfmt=out_fmt; // compressed formats - if(out_fmt == IMGFMT_MPEGPES || IMGFMT_IS_HWACCEL(out_fmt)){ + if(IMGFMT_IS_HWACCEL(out_fmt)){ mpi->bpp=0; return; } diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 8cf6002246..6ec932445a 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -363,11 +363,8 @@ mp_image_t *vf_get_image(vf_instance_t *vf, unsigned int outfmt, //============================================================================ -// By default vf doesn't accept MPEGPES static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt) { - if (fmt == IMGFMT_MPEGPES) - return 0; return vf_next_query_format(vf, fmt); } diff --git a/libmpcodecs/vf_dlopen.c b/libmpcodecs/vf_dlopen.c index 71da4f1636..183b31be84 100644 --- a/libmpcodecs/vf_dlopen.c +++ b/libmpcodecs/vf_dlopen.c @@ -281,7 +281,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) static int query_format(struct vf_instance *vf, unsigned int fmt) { - if (IMGFMT_IS_HWACCEL(fmt) || fmt == IMGFMT_MJPEG || fmt == IMGFMT_MPEGPES) + if (IMGFMT_IS_HWACCEL(fmt)) return 0; // these can't really be filtered if (fmt == IMGFMT_RGB8 || fmt == IMGFMT_BGR8) return 0; // we don't have palette support, sorry diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c index b8ac9f728d..ff13a8501e 100644 --- a/libmpcodecs/vf_expand.c +++ b/libmpcodecs/vf_expand.c @@ -48,7 +48,6 @@ static struct vf_priv_s { int exp_x,exp_y; double aspect; int round; - int passthrough; int first_slice; } const vf_priv_dflt = { -1,-1, @@ -57,7 +56,6 @@ static struct vf_priv_s { -1,-1, 0., 1, - 0, 0 }; @@ -69,10 +67,6 @@ static int config(struct vf_instance *vf, { struct MPOpts *opts = vf->opts; mp_image_t test_mpi; - if(outfmt == IMGFMT_MPEGPES) { - vf->priv->passthrough = 1; - return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); - } mp_image_setfmt(&test_mpi, outfmt); if (outfmt == IMGFMT_IF09 || !test_mpi.bpp) return 0; vf->priv->exp_x = vf->priv->cfg_exp_x; @@ -261,13 +255,6 @@ static void clear_borders(struct vf_instance *vf, int w, int h) } static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ - if (vf->priv->passthrough) { - mp_image_t *dmpi = vf_get_image(vf->next, IMGFMT_MPEGPES, - MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h); - dmpi->planes[0]=mpi->planes[0]; - return vf_next_put_image(vf,dmpi, pts); - } - if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ vf->dmpi=mpi->priv; if(!vf->dmpi) { mp_tmsg(MSGT_VFILTER, MSGL_WARN, "Why do we get NULL??\n"); return 0; } -- cgit v1.2.3 From 60cbc9461b86b13c68cc9537bc9a124ddc07a399 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 23 Oct 2012 18:04:34 +0200 Subject: cleanup: remove vd_internal.h This was stupid crap for old vd_* files, and vd_ffmpeg doesn't need it. --- libmpcodecs/vd_internal.h | 48 ----------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 libmpcodecs/vd_internal.h (limited to 'libmpcodecs') diff --git a/libmpcodecs/vd_internal.h b/libmpcodecs/vd_internal.h deleted file mode 100644 index b4d74a6a48..0000000000 --- a/libmpcodecs/vd_internal.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_VD_INTERNAL_H -#define MPLAYER_VD_INTERNAL_H - -#include "codec-cfg.h" -#include "img_format.h" - -#include "stream/stream.h" -#include "libmpdemux/demuxer.h" -#include "libmpdemux/stheader.h" - -#include "vd.h" - -extern int divx_quality; - -// prototypes: -//static vd_info_t info; -static int control(sh_video_t *sh,int cmd,void* arg,...); -static int init(sh_video_t *sh); -static void uninit(sh_video_t *sh); -static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags); - -#define LIBVD_EXTERN(x) const vd_functions_t mpcodecs_vd_##x = {\ - &info,\ - init,\ - uninit,\ - control,\ - decode\ -}; - -#endif /* MPLAYER_VD_INTERNAL_H */ -- cgit v1.2.3