2002-04-06 22:05:01 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-11-18 14:39:25 +00:00
|
|
|
#include "config.h"
|
2002-05-25 13:22:28 +00:00
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
|
2004-12-01 09:30:11 +00:00
|
|
|
#ifdef MP_DEBUG
|
|
|
|
#include <assert.h>
|
|
|
|
#endif
|
|
|
|
|
2005-11-18 14:39:25 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
|
|
|
#include "m_option.h"
|
|
|
|
#include "m_struct.h"
|
2002-08-13 23:32:05 +00:00
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
|
2002-04-13 19:14:34 +00:00
|
|
|
#include "img_format.h"
|
|
|
|
#include "mp_image.h"
|
2002-04-06 22:05:01 +00:00
|
|
|
#include "vf.h"
|
|
|
|
|
2005-11-18 14:39:25 +00:00
|
|
|
#include "libvo/fastmemcpy.h"
|
2003-05-20 17:42:33 +00:00
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
extern vf_info_t vf_info_vo;
|
2002-07-27 11:40:15 +00:00
|
|
|
extern vf_info_t vf_info_rectangle;
|
2003-04-04 20:12:24 +00:00
|
|
|
#ifndef HAVE_NO_POSIX_SELECT
|
2002-10-23 00:26:27 +00:00
|
|
|
extern vf_info_t vf_info_bmovl;
|
2003-04-04 20:12:24 +00:00
|
|
|
#endif
|
2002-04-06 22:05:01 +00:00
|
|
|
extern vf_info_t vf_info_crop;
|
|
|
|
extern vf_info_t vf_info_expand;
|
2006-01-22 18:11:35 +00:00
|
|
|
#if defined(USE_LIBPOSTPROC) || defined(USE_LIBPOSTPROC_SO)
|
2002-04-07 03:20:41 +00:00
|
|
|
extern vf_info_t vf_info_pp;
|
2003-10-16 08:45:10 +00:00
|
|
|
#endif
|
2002-04-07 20:21:37 +00:00
|
|
|
extern vf_info_t vf_info_scale;
|
2002-04-26 19:46:36 +00:00
|
|
|
#ifdef USE_LIBFAME
|
2002-04-08 23:12:22 +00:00
|
|
|
extern vf_info_t vf_info_fame;
|
2002-04-26 19:46:36 +00:00
|
|
|
#endif
|
2002-04-09 14:01:53 +00:00
|
|
|
extern vf_info_t vf_info_format;
|
2004-02-06 20:31:57 +00:00
|
|
|
extern vf_info_t vf_info_noformat;
|
2002-04-09 14:01:53 +00:00
|
|
|
extern vf_info_t vf_info_yuy2;
|
2002-04-11 03:17:14 +00:00
|
|
|
extern vf_info_t vf_info_flip;
|
2002-04-13 14:18:57 +00:00
|
|
|
extern vf_info_t vf_info_rgb2bgr;
|
2002-04-19 02:18:46 +00:00
|
|
|
extern vf_info_t vf_info_rotate;
|
2002-04-21 14:36:36 +00:00
|
|
|
extern vf_info_t vf_info_mirror;
|
2002-04-21 17:22:37 +00:00
|
|
|
extern vf_info_t vf_info_palette;
|
2002-04-27 23:34:44 +00:00
|
|
|
extern vf_info_t vf_info_lavc;
|
2003-12-19 22:15:37 +00:00
|
|
|
extern vf_info_t vf_info_zrmjpeg;
|
2002-05-06 22:48:22 +00:00
|
|
|
extern vf_info_t vf_info_dvbscale;
|
2002-05-12 19:06:54 +00:00
|
|
|
extern vf_info_t vf_info_cropdetect;
|
2002-06-03 14:13:28 +00:00
|
|
|
extern vf_info_t vf_info_test;
|
2002-06-14 01:14:56 +00:00
|
|
|
extern vf_info_t vf_info_noise;
|
2002-06-21 17:38:06 +00:00
|
|
|
extern vf_info_t vf_info_yvu9;
|
2002-07-31 19:50:42 +00:00
|
|
|
extern vf_info_t vf_info_lavcdeint;
|
2002-08-21 23:08:20 +00:00
|
|
|
extern vf_info_t vf_info_eq;
|
2002-09-27 21:08:36 +00:00
|
|
|
extern vf_info_t vf_info_eq2;
|
2002-08-30 06:16:40 +00:00
|
|
|
extern vf_info_t vf_info_halfpack;
|
2002-09-10 23:18:31 +00:00
|
|
|
extern vf_info_t vf_info_dint;
|
2002-10-16 18:40:03 +00:00
|
|
|
extern vf_info_t vf_info_1bpp;
|
2002-10-25 16:49:33 +00:00
|
|
|
extern vf_info_t vf_info_2xsai;
|
2002-10-29 22:37:11 +00:00
|
|
|
extern vf_info_t vf_info_unsharp;
|
2002-10-31 18:13:56 +00:00
|
|
|
extern vf_info_t vf_info_swapuv;
|
2002-10-31 20:03:08 +00:00
|
|
|
extern vf_info_t vf_info_il;
|
2003-10-22 21:21:52 +00:00
|
|
|
extern vf_info_t vf_info_fil;
|
2002-10-31 23:26:11 +00:00
|
|
|
extern vf_info_t vf_info_boxblur;
|
2002-11-04 16:42:17 +00:00
|
|
|
extern vf_info_t vf_info_sab;
|
2002-11-04 20:39:27 +00:00
|
|
|
extern vf_info_t vf_info_smartblur;
|
2002-11-05 13:29:10 +00:00
|
|
|
extern vf_info_t vf_info_perspective;
|
2003-02-11 21:44:55 +00:00
|
|
|
extern vf_info_t vf_info_down3dright;
|
2003-01-23 16:33:57 +00:00
|
|
|
extern vf_info_t vf_info_field;
|
2003-01-30 22:53:32 +00:00
|
|
|
extern vf_info_t vf_info_denoise3d;
|
2003-02-15 22:24:32 +00:00
|
|
|
extern vf_info_t vf_info_hqdn3d;
|
2003-02-20 03:16:41 +00:00
|
|
|
extern vf_info_t vf_info_detc;
|
2003-02-20 04:57:37 +00:00
|
|
|
extern vf_info_t vf_info_telecine;
|
2003-08-11 20:04:30 +00:00
|
|
|
extern vf_info_t vf_info_tinterlace;
|
2003-03-01 05:35:09 +00:00
|
|
|
extern vf_info_t vf_info_tfields;
|
2003-04-19 01:39:37 +00:00
|
|
|
extern vf_info_t vf_info_ivtc;
|
|
|
|
extern vf_info_t vf_info_ilpack;
|
2003-04-27 18:55:04 +00:00
|
|
|
extern vf_info_t vf_info_dsize;
|
2003-05-22 12:38:42 +00:00
|
|
|
extern vf_info_t vf_info_decimate;
|
2003-08-03 12:09:58 +00:00
|
|
|
extern vf_info_t vf_info_softpulldown;
|
2003-08-18 15:24:08 +00:00
|
|
|
extern vf_info_t vf_info_pullup;
|
2003-12-08 22:57:47 +00:00
|
|
|
extern vf_info_t vf_info_filmdint;
|
2003-08-31 21:41:24 +00:00
|
|
|
extern vf_info_t vf_info_framestep;
|
|
|
|
extern vf_info_t vf_info_tile;
|
2003-09-03 22:44:28 +00:00
|
|
|
extern vf_info_t vf_info_delogo;
|
2005-06-08 15:29:26 +00:00
|
|
|
extern vf_info_t vf_info_remove_logo;
|
2003-10-23 18:36:02 +00:00
|
|
|
extern vf_info_t vf_info_hue;
|
2003-10-26 23:07:21 +00:00
|
|
|
extern vf_info_t vf_info_spp;
|
2005-11-08 13:15:19 +00:00
|
|
|
extern vf_info_t vf_info_uspp;
|
2005-06-04 07:05:02 +00:00
|
|
|
extern vf_info_t vf_info_fspp;
|
2005-07-09 07:49:51 +00:00
|
|
|
extern vf_info_t vf_info_pp7;
|
2003-11-29 19:34:26 +00:00
|
|
|
extern vf_info_t vf_info_yuvcsp;
|
2004-01-29 09:50:17 +00:00
|
|
|
extern vf_info_t vf_info_kerndeint;
|
2004-01-30 17:38:15 +00:00
|
|
|
extern vf_info_t vf_info_rgbtest;
|
2004-02-05 15:56:05 +00:00
|
|
|
extern vf_info_t vf_info_qp;
|
2004-03-29 04:39:04 +00:00
|
|
|
extern vf_info_t vf_info_phase;
|
2004-04-17 17:08:31 +00:00
|
|
|
extern vf_info_t vf_info_divtc;
|
2004-04-28 04:02:46 +00:00
|
|
|
extern vf_info_t vf_info_harddup;
|
2004-04-28 04:29:17 +00:00
|
|
|
extern vf_info_t vf_info_softskip;
|
2005-09-11 06:42:32 +00:00
|
|
|
extern vf_info_t vf_info_screenshot;
|
2006-07-07 18:26:51 +00:00
|
|
|
extern vf_info_t vf_info_ass;
|
2006-06-06 00:11:13 +00:00
|
|
|
extern vf_info_t vf_info_mcdeint;
|
2006-06-06 23:30:23 +00:00
|
|
|
extern vf_info_t vf_info_yadif;
|
2006-07-15 09:18:44 +00:00
|
|
|
extern vf_info_t vf_info_blackframe;
|
2002-04-06 22:05:01 +00:00
|
|
|
|
|
|
|
// list of available filters:
|
|
|
|
static vf_info_t* filter_list[]={
|
2002-07-27 11:40:15 +00:00
|
|
|
&vf_info_rectangle,
|
2003-04-04 20:12:24 +00:00
|
|
|
#ifndef HAVE_NO_POSIX_SELECT
|
2002-10-23 00:26:27 +00:00
|
|
|
&vf_info_bmovl,
|
2003-04-04 20:12:24 +00:00
|
|
|
#endif
|
2002-04-06 22:05:01 +00:00
|
|
|
&vf_info_crop,
|
|
|
|
&vf_info_expand,
|
2006-01-22 18:11:35 +00:00
|
|
|
#if defined(USE_LIBPOSTPROC) || defined(USE_LIBPOSTPROC_SO)
|
2002-04-07 03:20:41 +00:00
|
|
|
&vf_info_pp,
|
2003-03-05 10:20:14 +00:00
|
|
|
#endif
|
2002-04-07 20:21:37 +00:00
|
|
|
&vf_info_scale,
|
2002-04-06 22:05:01 +00:00
|
|
|
// &vf_info_osd,
|
|
|
|
&vf_info_vo,
|
2002-04-26 19:46:36 +00:00
|
|
|
#ifdef USE_LIBFAME
|
2002-04-08 23:12:22 +00:00
|
|
|
&vf_info_fame,
|
2002-04-26 19:46:36 +00:00
|
|
|
#endif
|
2002-04-09 14:01:53 +00:00
|
|
|
&vf_info_format,
|
2004-02-06 20:31:57 +00:00
|
|
|
&vf_info_noformat,
|
2002-04-09 14:01:53 +00:00
|
|
|
&vf_info_yuy2,
|
2002-04-11 03:17:14 +00:00
|
|
|
&vf_info_flip,
|
2002-04-13 14:18:57 +00:00
|
|
|
&vf_info_rgb2bgr,
|
2002-04-19 02:18:46 +00:00
|
|
|
&vf_info_rotate,
|
2002-04-21 14:36:36 +00:00
|
|
|
&vf_info_mirror,
|
2002-04-21 17:22:37 +00:00
|
|
|
&vf_info_palette,
|
2002-04-27 23:35:23 +00:00
|
|
|
#ifdef USE_LIBAVCODEC
|
2002-04-27 23:34:44 +00:00
|
|
|
&vf_info_lavc,
|
2002-07-31 19:50:42 +00:00
|
|
|
&vf_info_lavcdeint,
|
2003-12-19 22:15:37 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ZR
|
|
|
|
&vf_info_zrmjpeg,
|
2002-04-27 23:35:23 +00:00
|
|
|
#endif
|
2002-05-06 22:48:22 +00:00
|
|
|
&vf_info_dvbscale,
|
2002-05-12 19:06:54 +00:00
|
|
|
&vf_info_cropdetect,
|
2002-06-03 14:13:28 +00:00
|
|
|
&vf_info_test,
|
2002-06-14 01:14:56 +00:00
|
|
|
&vf_info_noise,
|
2002-06-21 17:38:06 +00:00
|
|
|
&vf_info_yvu9,
|
2002-08-21 23:08:20 +00:00
|
|
|
&vf_info_eq,
|
2002-09-27 21:08:36 +00:00
|
|
|
&vf_info_eq2,
|
2002-08-30 06:16:40 +00:00
|
|
|
&vf_info_halfpack,
|
2002-09-10 23:18:31 +00:00
|
|
|
&vf_info_dint,
|
2002-10-16 18:40:03 +00:00
|
|
|
&vf_info_1bpp,
|
2002-10-25 16:49:33 +00:00
|
|
|
&vf_info_2xsai,
|
2002-10-29 22:37:11 +00:00
|
|
|
&vf_info_unsharp,
|
2002-10-31 18:13:56 +00:00
|
|
|
&vf_info_swapuv,
|
2002-10-31 20:03:08 +00:00
|
|
|
&vf_info_il,
|
2003-10-22 21:21:52 +00:00
|
|
|
&vf_info_fil,
|
2002-10-31 23:26:11 +00:00
|
|
|
&vf_info_boxblur,
|
2002-11-04 16:42:17 +00:00
|
|
|
&vf_info_sab,
|
2002-11-04 20:39:27 +00:00
|
|
|
&vf_info_smartblur,
|
2002-11-05 13:29:10 +00:00
|
|
|
&vf_info_perspective,
|
2003-02-11 21:44:55 +00:00
|
|
|
&vf_info_down3dright,
|
2003-01-23 16:33:57 +00:00
|
|
|
&vf_info_field,
|
2003-01-30 22:53:32 +00:00
|
|
|
&vf_info_denoise3d,
|
2003-02-15 22:24:32 +00:00
|
|
|
&vf_info_hqdn3d,
|
2003-02-20 03:16:41 +00:00
|
|
|
&vf_info_detc,
|
2003-02-20 04:57:37 +00:00
|
|
|
&vf_info_telecine,
|
2003-08-11 20:04:30 +00:00
|
|
|
&vf_info_tinterlace,
|
2003-03-01 05:35:09 +00:00
|
|
|
&vf_info_tfields,
|
2003-04-19 01:39:37 +00:00
|
|
|
&vf_info_ivtc,
|
|
|
|
&vf_info_ilpack,
|
2003-04-27 18:55:04 +00:00
|
|
|
&vf_info_dsize,
|
2003-05-22 12:38:42 +00:00
|
|
|
&vf_info_decimate,
|
2003-08-03 12:09:58 +00:00
|
|
|
&vf_info_softpulldown,
|
2003-08-18 15:24:08 +00:00
|
|
|
&vf_info_pullup,
|
2003-12-08 22:57:47 +00:00
|
|
|
&vf_info_filmdint,
|
2003-08-31 21:41:24 +00:00
|
|
|
&vf_info_framestep,
|
|
|
|
&vf_info_tile,
|
2003-09-03 22:44:28 +00:00
|
|
|
&vf_info_delogo,
|
2005-06-08 15:29:26 +00:00
|
|
|
&vf_info_remove_logo,
|
2003-10-23 18:36:02 +00:00
|
|
|
&vf_info_hue,
|
2006-03-16 21:56:24 +00:00
|
|
|
#ifdef USE_LIBAVCODEC_DSPUTIL
|
2003-10-26 23:07:21 +00:00
|
|
|
&vf_info_spp,
|
2005-11-08 13:15:19 +00:00
|
|
|
&vf_info_uspp,
|
2005-06-04 07:05:02 +00:00
|
|
|
&vf_info_fspp,
|
2006-03-16 21:56:24 +00:00
|
|
|
&vf_info_qp,
|
2006-06-07 22:14:00 +00:00
|
|
|
&vf_info_mcdeint,
|
2003-10-26 23:07:21 +00:00
|
|
|
#endif
|
2003-11-29 19:34:26 +00:00
|
|
|
&vf_info_yuvcsp,
|
2004-01-29 09:50:17 +00:00
|
|
|
&vf_info_kerndeint,
|
2004-01-30 17:38:15 +00:00
|
|
|
&vf_info_rgbtest,
|
2004-02-26 14:41:42 +00:00
|
|
|
#ifdef USE_LIBAVCODEC
|
2006-03-16 21:56:24 +00:00
|
|
|
&vf_info_pp7,
|
2004-02-26 14:41:42 +00:00
|
|
|
#endif
|
2004-03-29 04:39:04 +00:00
|
|
|
&vf_info_phase,
|
2004-04-17 17:08:31 +00:00
|
|
|
&vf_info_divtc,
|
2004-04-28 04:02:46 +00:00
|
|
|
&vf_info_harddup,
|
2004-04-28 04:29:17 +00:00
|
|
|
&vf_info_softskip,
|
2005-09-11 06:42:32 +00:00
|
|
|
#ifdef HAVE_PNG
|
|
|
|
&vf_info_screenshot,
|
2006-07-07 18:26:51 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_ASS
|
|
|
|
&vf_info_ass,
|
2005-09-11 06:42:32 +00:00
|
|
|
#endif
|
2006-06-06 23:30:23 +00:00
|
|
|
&vf_info_yadif,
|
2006-07-15 09:18:44 +00:00
|
|
|
&vf_info_blackframe,
|
2002-04-06 22:05:01 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2003-03-15 18:01:02 +00:00
|
|
|
// For the vf option
|
|
|
|
m_obj_settings_t* vf_settings = NULL;
|
|
|
|
// For the vop option
|
|
|
|
m_obj_settings_t* vo_plugin_args = NULL;
|
|
|
|
m_obj_list_t vf_obj_list = {
|
|
|
|
(void**)filter_list,
|
|
|
|
M_ST_OFF(vf_info_t,name),
|
|
|
|
M_ST_OFF(vf_info_t,info),
|
|
|
|
M_ST_OFF(vf_info_t,opts)
|
|
|
|
};
|
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
//============================================================================
|
|
|
|
// mpi stuff:
|
|
|
|
|
2002-04-17 19:05:14 +00:00
|
|
|
void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){
|
|
|
|
int y;
|
|
|
|
if(mpi->flags&MP_IMGFLAG_PLANAR){
|
2002-04-17 21:50:25 +00:00
|
|
|
y0&=~1;h+=h&1;
|
2002-04-17 19:51:24 +00:00
|
|
|
if(x0==0 && w==mpi->width){
|
2002-04-17 19:05:14 +00:00
|
|
|
// full width clear:
|
|
|
|
memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h);
|
2002-06-23 21:08:31 +00:00
|
|
|
memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift));
|
|
|
|
memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift));
|
2002-04-17 21:50:25 +00:00
|
|
|
} else
|
2002-04-17 19:05:14 +00:00
|
|
|
for(y=y0;y<y0+h;y+=2){
|
|
|
|
memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w);
|
|
|
|
memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w);
|
2002-06-23 21:08:31 +00:00
|
|
|
memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
|
|
|
|
memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
|
2002-04-17 19:05:14 +00:00
|
|
|
}
|
2002-04-17 21:50:25 +00:00
|
|
|
return;
|
2002-04-17 19:05:14 +00:00
|
|
|
}
|
|
|
|
// packed:
|
|
|
|
for(y=y0;y<y0+h;y++){
|
|
|
|
unsigned char* dst=mpi->planes[0]+mpi->stride[0]*y+(mpi->bpp>>3)*x0;
|
|
|
|
if(mpi->flags&MP_IMGFLAG_YUV){
|
2002-05-20 03:25:26 +00:00
|
|
|
unsigned int* p=(unsigned int*) dst;
|
2002-04-17 19:05:14 +00:00
|
|
|
int size=(mpi->bpp>>3)*w/4;
|
|
|
|
int i;
|
2004-05-31 15:07:58 +00:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
#define CLEAR_PACKEDYUV_PATTERN 0x00800080
|
|
|
|
#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000
|
|
|
|
#else
|
|
|
|
#define CLEAR_PACKEDYUV_PATTERN 0x80008000
|
|
|
|
#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080
|
|
|
|
#endif
|
2002-04-17 19:05:14 +00:00
|
|
|
if(mpi->flags&MP_IMGFLAG_SWAPPED){
|
2004-05-31 15:07:58 +00:00
|
|
|
for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;
|
|
|
|
for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;
|
2002-04-17 19:05:14 +00:00
|
|
|
} else {
|
2004-05-31 15:07:58 +00:00
|
|
|
for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN;
|
|
|
|
for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN;
|
2002-04-17 19:05:14 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
memset(dst,0,(mpi->bpp>>3)*w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){
|
|
|
|
mp_image_t* mpi=NULL;
|
2004-12-01 09:30:11 +00:00
|
|
|
int w2;
|
|
|
|
|
|
|
|
#ifdef MP_DEBUG
|
|
|
|
assert(w == -1 || w >= vf->w);
|
|
|
|
assert(h == -1 || h >= vf->h);
|
|
|
|
assert(vf->w > 0);
|
|
|
|
assert(vf->h > 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// fprintf(stderr, "get_image: %d:%d, vf: %d:%d\n", w,h,vf->w,vf->h);
|
|
|
|
|
|
|
|
if (w == -1) w = vf->w;
|
|
|
|
if (h == -1) h = vf->h;
|
|
|
|
|
|
|
|
w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE)?((w+15)&(~15)):w;
|
2002-05-06 22:48:22 +00:00
|
|
|
|
|
|
|
if(vf->put_image==vf_next_put_image){
|
|
|
|
// passthru mode, if the plugin uses the fallback/default put_image() code
|
|
|
|
return vf_get_image(vf->next,outfmt,mp_imgtype,mp_imgflag,w,h);
|
|
|
|
}
|
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
// Note: we should call libvo first to check if it supports direct rendering
|
|
|
|
// and if not, then fallback to software buffers:
|
|
|
|
switch(mp_imgtype){
|
|
|
|
case MP_IMGTYPE_EXPORT:
|
|
|
|
if(!vf->imgctx.export_images[0]) vf->imgctx.export_images[0]=new_mp_image(w2,h);
|
|
|
|
mpi=vf->imgctx.export_images[0];
|
|
|
|
break;
|
|
|
|
case MP_IMGTYPE_STATIC:
|
|
|
|
if(!vf->imgctx.static_images[0]) vf->imgctx.static_images[0]=new_mp_image(w2,h);
|
|
|
|
mpi=vf->imgctx.static_images[0];
|
|
|
|
break;
|
|
|
|
case MP_IMGTYPE_TEMP:
|
|
|
|
if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);
|
|
|
|
mpi=vf->imgctx.temp_images[0];
|
|
|
|
break;
|
|
|
|
case MP_IMGTYPE_IPB:
|
|
|
|
if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame:
|
|
|
|
if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);
|
|
|
|
mpi=vf->imgctx.temp_images[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MP_IMGTYPE_IP:
|
|
|
|
if(!vf->imgctx.static_images[vf->imgctx.static_idx]) vf->imgctx.static_images[vf->imgctx.static_idx]=new_mp_image(w2,h);
|
|
|
|
mpi=vf->imgctx.static_images[vf->imgctx.static_idx];
|
|
|
|
vf->imgctx.static_idx^=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(mpi){
|
|
|
|
mpi->type=mp_imgtype;
|
2004-12-01 09:30:11 +00:00
|
|
|
mpi->w=vf->w; mpi->h=vf->h;
|
2002-08-02 22:55:54 +00:00
|
|
|
// keep buffer allocation status & color flags only:
|
|
|
|
// mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);
|
|
|
|
mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS;
|
|
|
|
// accept restrictions & draw_slice flags only:
|
|
|
|
mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK);
|
2002-04-06 22:05:01 +00:00
|
|
|
if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
|
2002-12-29 02:57:49 +00:00
|
|
|
if(mpi->width!=w2 || mpi->height!=h){
|
|
|
|
// printf("vf.c: MPI parameters changed! %dx%d -> %dx%d \n", mpi->width,mpi->height,w2,h);
|
2002-04-06 22:05:01 +00:00
|
|
|
if(mpi->flags&MP_IMGFLAG_ALLOCATED){
|
2002-12-29 02:57:49 +00:00
|
|
|
if(mpi->width<w2 || mpi->height<h){
|
|
|
|
// need to re-allocate buffer memory:
|
|
|
|
free(mpi->planes[0]);
|
|
|
|
mpi->flags&=~MP_IMGFLAG_ALLOCATED;
|
2006-03-31 00:15:47 +00:00
|
|
|
mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n");
|
2002-12-29 02:57:49 +00:00
|
|
|
}
|
2003-07-13 22:51:20 +00:00
|
|
|
// } else {
|
|
|
|
} {
|
2003-03-05 10:23:52 +00:00
|
|
|
mpi->width=w2; mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;
|
|
|
|
mpi->height=h; mpi->chroma_height=(h + (1<<mpi->chroma_y_shift) - 1)>>mpi->chroma_y_shift;
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!mpi->bpp) mp_image_setfmt(mpi,outfmt);
|
|
|
|
if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){
|
|
|
|
|
|
|
|
// check libvo first!
|
|
|
|
if(vf->get_image) vf->get_image(vf,mpi);
|
|
|
|
|
|
|
|
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
|
2002-06-23 15:03:54 +00:00
|
|
|
// non-direct and not yet allocated image. allocate it!
|
2002-08-02 22:55:54 +00:00
|
|
|
|
|
|
|
// check if codec prefer aligned stride:
|
|
|
|
if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){
|
|
|
|
int align=(mpi->flags&MP_IMGFLAG_PLANAR &&
|
|
|
|
mpi->flags&MP_IMGFLAG_YUV) ?
|
|
|
|
(8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME
|
2002-10-10 01:09:23 +00:00
|
|
|
w2=((w+align)&(~align));
|
|
|
|
if(mpi->width!=w2){
|
|
|
|
// we have to change width... check if we CAN co it:
|
|
|
|
int flags=vf->query_format(vf,outfmt); // should not fail
|
|
|
|
if(!(flags&3)) mp_msg(MSGT_DECVIDEO,MSGL_WARN,"??? vf_get_image{vf->query_format(outfmt)} failed!\n");
|
|
|
|
// printf("query -> 0x%X \n",flags);
|
|
|
|
if(flags&VFCAP_ACCEPT_STRIDE){
|
|
|
|
mpi->width=w2;
|
2003-03-05 10:23:52 +00:00
|
|
|
mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;
|
2002-10-10 01:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-02 22:55:54 +00:00
|
|
|
}
|
|
|
|
|
2002-06-23 15:03:54 +00:00
|
|
|
// IF09 - allocate space for 4. plane delta info - unused
|
2002-06-23 21:08:31 +00:00
|
|
|
if (mpi->imgfmt == IMGFMT_IF09)
|
|
|
|
{
|
2002-06-23 15:03:54 +00:00
|
|
|
mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
|
2002-06-23 21:08:31 +00:00
|
|
|
mpi->chroma_width*mpi->chroma_height);
|
2003-05-23 13:20:43 +00:00
|
|
|
/* export delta table */
|
2003-05-23 14:09:19 +00:00
|
|
|
mpi->planes[3]=mpi->planes[0]+(mpi->width*mpi->height)+2*(mpi->chroma_width*mpi->chroma_height);
|
2002-06-23 21:08:31 +00:00
|
|
|
}
|
2002-06-23 15:03:54 +00:00
|
|
|
else
|
|
|
|
mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
|
2002-04-06 22:05:01 +00:00
|
|
|
if(mpi->flags&MP_IMGFLAG_PLANAR){
|
2002-06-23 15:03:54 +00:00
|
|
|
// YV12/I420/YVU9/IF09. feel free to add other planar formats here...
|
2003-07-13 22:51:20 +00:00
|
|
|
//if(!mpi->stride[0])
|
|
|
|
mpi->stride[0]=mpi->width;
|
|
|
|
//if(!mpi->stride[1])
|
2005-02-16 23:47:00 +00:00
|
|
|
if(mpi->num_planes > 2){
|
2003-07-13 22:51:20 +00:00
|
|
|
mpi->stride[1]=mpi->stride[2]=mpi->chroma_width;
|
2002-04-06 22:05:01 +00:00
|
|
|
if(mpi->flags&MP_IMGFLAG_SWAPPED){
|
|
|
|
// I420/IYUV (Y,U,V)
|
|
|
|
mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
|
2002-06-23 21:08:31 +00:00
|
|
|
mpi->planes[2]=mpi->planes[1]+mpi->chroma_width*mpi->chroma_height;
|
2002-04-06 22:05:01 +00:00
|
|
|
} else {
|
2002-06-23 21:08:31 +00:00
|
|
|
// YV12,YVU9,IF09 (Y,V,U)
|
2002-04-06 22:05:01 +00:00
|
|
|
mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height;
|
2002-06-23 21:08:31 +00:00
|
|
|
mpi->planes[1]=mpi->planes[2]+mpi->chroma_width*mpi->chroma_height;
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
2005-02-16 23:47:00 +00:00
|
|
|
} else {
|
|
|
|
// NV12/NV21
|
|
|
|
mpi->stride[1]=mpi->chroma_width;
|
|
|
|
mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
|
|
|
|
}
|
2002-04-06 22:05:01 +00:00
|
|
|
} else {
|
2003-07-13 22:51:20 +00:00
|
|
|
//if(!mpi->stride[0])
|
|
|
|
mpi->stride[0]=mpi->width*mpi->bpp/8;
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
2002-12-29 02:57:49 +00:00
|
|
|
// printf("clearing img!\n");
|
2002-04-17 19:51:24 +00:00
|
|
|
vf_mpi_clear(mpi,0,0,mpi->width,mpi->height);
|
2002-04-06 22:05:01 +00:00
|
|
|
mpi->flags|=MP_IMGFLAG_ALLOCATED;
|
|
|
|
}
|
|
|
|
}
|
2003-02-23 20:40:21 +00:00
|
|
|
if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)
|
|
|
|
if(vf->start_slice) vf->start_slice(vf,mpi);
|
2002-04-06 22:05:01 +00:00
|
|
|
if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){
|
2003-02-23 20:40:21 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_V,"*** [%s] %s%s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n",
|
2002-04-06 22:05:01 +00:00
|
|
|
vf->info->name,
|
|
|
|
(mpi->type==MP_IMGTYPE_EXPORT)?"Exporting":
|
|
|
|
((mpi->flags&MP_IMGFLAG_DIRECT)?"Direct Rendering":"Allocating"),
|
2003-02-23 20:40:21 +00:00
|
|
|
(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)?" (slices)":"",
|
2002-04-06 22:05:01 +00:00
|
|
|
mpi->width,mpi->height,mpi->bpp,
|
2002-07-11 19:16:30 +00:00
|
|
|
(mpi->flags&MP_IMGFLAG_YUV)?"YUV":((mpi->flags&MP_IMGFLAG_SWAPPED)?"BGR":"RGB"),
|
2002-04-06 22:05:01 +00:00
|
|
|
(mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed",
|
|
|
|
mpi->bpp*mpi->width*mpi->height/8);
|
2006-01-12 20:04:36 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %p,%p,%p strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\n",
|
2002-06-21 17:38:06 +00:00
|
|
|
mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2],
|
2002-06-23 21:08:31 +00:00
|
|
|
mpi->stride[0], mpi->stride[1], mpi->stride[2],
|
|
|
|
mpi->chroma_width, mpi->chroma_height, mpi->chroma_x_shift, mpi->chroma_y_shift);
|
2002-04-06 22:05:01 +00:00
|
|
|
mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED;
|
|
|
|
}
|
|
|
|
|
2006-04-27 02:46:33 +00:00
|
|
|
mpi->qscale = NULL;
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
2002-12-29 02:57:49 +00:00
|
|
|
// printf("\rVF_MPI: %p %p %p %d %d %d \n",
|
|
|
|
// mpi->planes[0],mpi->planes[1],mpi->planes[2],
|
|
|
|
// mpi->stride[0],mpi->stride[1],mpi->stride[2]);
|
2002-04-06 22:05:01 +00:00
|
|
|
return mpi;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2002-10-30 17:48:39 +00:00
|
|
|
// By default vf doesn't accept MPEGPES
|
|
|
|
static int vf_default_query_format(struct vf_instance_s* vf, unsigned int fmt){
|
|
|
|
if(fmt == IMGFMT_MPEGPES) return 0;
|
|
|
|
return vf_next_query_format(vf,fmt);
|
|
|
|
}
|
|
|
|
|
2006-07-09 17:45:36 +00:00
|
|
|
vf_instance_t* vf_open_plugin(vf_info_t** filter_list, vf_instance_t* next, const char *name, char **args){
|
2002-04-06 22:05:01 +00:00
|
|
|
vf_instance_t* vf;
|
|
|
|
int i;
|
|
|
|
for(i=0;;i++){
|
|
|
|
if(!filter_list[i]){
|
2002-08-13 23:24:20 +00:00
|
|
|
mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name);
|
2002-04-06 22:05:01 +00:00
|
|
|
return NULL; // no such filter!
|
|
|
|
}
|
|
|
|
if(!strcmp(filter_list[i]->name,name)) break;
|
|
|
|
}
|
|
|
|
vf=malloc(sizeof(vf_instance_t));
|
|
|
|
memset(vf,0,sizeof(vf_instance_t));
|
|
|
|
vf->info=filter_list[i];
|
|
|
|
vf->next=next;
|
|
|
|
vf->config=vf_next_config;
|
|
|
|
vf->control=vf_next_control;
|
2002-10-30 17:48:39 +00:00
|
|
|
vf->query_format=vf_default_query_format;
|
2002-04-06 22:05:01 +00:00
|
|
|
vf->put_image=vf_next_put_image;
|
2002-04-11 20:56:17 +00:00
|
|
|
vf->default_caps=VFCAP_ACCEPT_STRIDE;
|
|
|
|
vf->default_reqs=0;
|
2003-03-15 18:01:02 +00:00
|
|
|
if(vf->info->opts) { // vf_vo get some special argument
|
|
|
|
m_struct_t* st = vf->info->opts;
|
|
|
|
void* vf_priv = m_struct_alloc(st);
|
|
|
|
int n;
|
|
|
|
for(n = 0 ; args && args[2*n] ; n++)
|
|
|
|
m_struct_set(st,vf_priv,args[2*n],args[2*n+1]);
|
|
|
|
vf->priv = vf_priv;
|
|
|
|
args = NULL;
|
|
|
|
} else // Otherwise we should have the '_oldargs_'
|
|
|
|
if(args && !strcmp(args[0],"_oldargs_"))
|
|
|
|
args = (char**)args[1];
|
|
|
|
else
|
|
|
|
args = NULL;
|
|
|
|
if(vf->info->open(vf,(char*)args)>0) return vf; // Success!
|
2002-04-06 22:05:01 +00:00
|
|
|
free(vf);
|
2002-08-13 23:24:20 +00:00
|
|
|
mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name);
|
2002-04-06 22:05:01 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-07-09 17:45:36 +00:00
|
|
|
vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args){
|
2003-03-15 18:01:02 +00:00
|
|
|
if(args && strcmp(args[0],"_oldargs_")) {
|
|
|
|
int i,l = 0;
|
|
|
|
for(i = 0 ; args && args[2*i] ; i++)
|
|
|
|
l += 1 + strlen(args[2*i]) + 1 + strlen(args[2*i+1]);
|
|
|
|
l += strlen(name);
|
|
|
|
{
|
|
|
|
char str[l+1];
|
|
|
|
char* p = str;
|
|
|
|
p += sprintf(str,"%s",name);
|
|
|
|
for(i = 0 ; args && args[2*i] ; i++)
|
|
|
|
p += sprintf(p," %s=%s",args[2*i],args[2*i+1]);
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n",str);
|
|
|
|
}
|
|
|
|
} else if(strcmp(name,"vo")) {
|
|
|
|
if(args && strcmp(args[0],"_oldargs_") == 0)
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter
|
|
|
|
"[%s=%s]\n", name,args[1]);
|
|
|
|
else
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter
|
|
|
|
"[%s]\n", name);
|
|
|
|
}
|
|
|
|
return vf_open_plugin(filter_list,next,name,args);
|
2002-04-10 23:23:36 +00:00
|
|
|
}
|
|
|
|
|
2004-12-18 14:06:35 +00:00
|
|
|
/**
|
|
|
|
* \brief adds a filter before the last one (which should be the vo filter).
|
|
|
|
* \param vf start of the filter chain.
|
|
|
|
* \param name name of the filter to add.
|
|
|
|
* \param args argument list for the filter.
|
|
|
|
* \return pointer to the filter instance that was created.
|
|
|
|
*/
|
|
|
|
vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) {
|
|
|
|
vf_instance_t *vo, *prev = NULL, *new;
|
|
|
|
// Find the last filter (should be vf_vo)
|
|
|
|
for (vo = *vf; vo->next; vo = vo->next)
|
|
|
|
prev = vo;
|
|
|
|
new = vf_open_filter(vo, name, args);
|
|
|
|
if (prev)
|
|
|
|
prev->next = new;
|
|
|
|
else
|
|
|
|
*vf = new;
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
//============================================================================
|
|
|
|
|
2002-04-11 20:56:17 +00:00
|
|
|
unsigned int vf_match_csp(vf_instance_t** vfp,unsigned int* list,unsigned int preferred){
|
|
|
|
vf_instance_t* vf=*vfp;
|
|
|
|
unsigned int* p;
|
|
|
|
unsigned int best=0;
|
|
|
|
int ret;
|
|
|
|
if((p=list)) while(*p){
|
|
|
|
ret=vf->query_format(vf,*p);
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3);
|
|
|
|
if(ret&2){ best=*p; break;} // no conversion -> bingo!
|
|
|
|
if(ret&1 && !best) best=*p; // best with conversion
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
if(best) return best; // bingo, they have common csp!
|
|
|
|
// ok, then try with scale:
|
|
|
|
if(vf->info == &vf_info_scale) return 0; // avoid infinite recursion!
|
|
|
|
vf=vf_open_filter(vf,"scale",NULL);
|
|
|
|
if(!vf) return 0; // failed to init "scale"
|
|
|
|
// try the preferred csp first:
|
|
|
|
if(preferred && vf->query_format(vf,preferred)) best=preferred; else
|
|
|
|
// try the list again, now with "scaler" :
|
|
|
|
if((p=list)) while(*p){
|
|
|
|
ret=vf->query_format(vf,*p);
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3);
|
|
|
|
if(ret&2){ best=*p; break;} // no conversion -> bingo!
|
|
|
|
if(ret&1 && !best) best=*p; // best with conversion
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
if(best) *vfp=vf; // else uninit vf !FIXME!
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
2003-04-19 02:48:53 +00:00
|
|
|
void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src){
|
|
|
|
dst->pict_type= src->pict_type;
|
2003-08-18 14:49:06 +00:00
|
|
|
dst->fields = src->fields;
|
2003-04-19 02:48:53 +00:00
|
|
|
dst->qscale_type= src->qscale_type;
|
|
|
|
if(dst->width == src->width && dst->height == src->height){
|
|
|
|
dst->qstride= src->qstride;
|
|
|
|
dst->qscale= src->qscale;
|
|
|
|
}
|
|
|
|
}
|
2006-07-06 06:58:17 +00:00
|
|
|
|
|
|
|
void vf_queue_frame(vf_instance_t *vf, int (*func)(vf_instance_t *))
|
|
|
|
{
|
|
|
|
vf->continue_buffered_image = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output the next buffered image (if any) from the filter chain.
|
|
|
|
// The queue could be kept as a simple stack/list instead avoiding the
|
|
|
|
// looping here, but there's currently no good context variable where
|
|
|
|
// that could be stored so this was easier to implement.
|
|
|
|
|
|
|
|
int vf_output_queued_frame(vf_instance_t *vf)
|
|
|
|
{
|
|
|
|
while (1) {
|
|
|
|
int ret;
|
|
|
|
vf_instance_t *current;
|
|
|
|
vf_instance_t *last=NULL;
|
|
|
|
int (*tmp)(vf_instance_t *);
|
|
|
|
for (current = vf; current; current = current->next)
|
|
|
|
if (current->continue_buffered_image)
|
|
|
|
last = current;
|
|
|
|
if (!last)
|
|
|
|
return 0;
|
|
|
|
tmp = last->continue_buffered_image;
|
|
|
|
last->continue_buffered_image = NULL;
|
|
|
|
ret = tmp(last);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-01 20:21:58 +00:00
|
|
|
/**
|
|
|
|
* \brief Video config() function wrapper
|
|
|
|
*
|
|
|
|
* Blocks config() calls with different size or format for filters
|
|
|
|
* with VFCAP_CONSTANT
|
|
|
|
*
|
|
|
|
* First call is redirected to vf->config.
|
|
|
|
*
|
|
|
|
* In following calls, it verifies that the configuration parameters
|
|
|
|
* are unchanged, and returns either success or error.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int vf_config_wrapper(struct vf_instance_s* vf,
|
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt)
|
|
|
|
{
|
2005-12-16 18:32:58 +00:00
|
|
|
int r;
|
2005-03-01 20:21:58 +00:00
|
|
|
if ((vf->default_caps&VFCAP_CONSTANT) && vf->fmt.have_configured) {
|
|
|
|
if ((vf->fmt.orig_width != width)
|
|
|
|
|| (vf->fmt.orig_height != height)
|
|
|
|
|| (vf->fmt.orig_fmt != outfmt)) {
|
2005-03-08 22:11:49 +00:00
|
|
|
mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_ResolutionDoesntMatch);
|
2005-03-01 20:21:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
vf->fmt.have_configured = 1;
|
|
|
|
vf->fmt.orig_height = height;
|
|
|
|
vf->fmt.orig_width = width;
|
|
|
|
vf->fmt.orig_fmt = outfmt;
|
2005-12-16 18:32:58 +00:00
|
|
|
r = vf->config(vf, width, height, d_width, d_height, flags, outfmt);
|
|
|
|
if (!r) vf->fmt.have_configured = 0;
|
|
|
|
return r;
|
2005-03-01 20:21:58 +00:00
|
|
|
}
|
2003-04-19 02:48:53 +00:00
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
int vf_next_config(struct vf_instance_s* vf,
|
|
|
|
int width, int height, int d_width, int d_height,
|
2002-04-11 20:56:17 +00:00
|
|
|
unsigned int voflags, unsigned int outfmt){
|
|
|
|
int miss;
|
|
|
|
int flags=vf->next->query_format(vf->next,outfmt);
|
|
|
|
if(!flags){
|
|
|
|
// hmm. colorspace mismatch!!!
|
|
|
|
// let's insert the 'scale' filter, it does the job for us:
|
|
|
|
vf_instance_t* vf2;
|
|
|
|
if(vf->next->info==&vf_info_scale) return 0; // scale->scale
|
|
|
|
vf2=vf_open_filter(vf->next,"scale",NULL);
|
|
|
|
if(!vf2) return 0; // shouldn't happen!
|
|
|
|
vf->next=vf2;
|
|
|
|
flags=vf->next->query_format(vf->next,outfmt);
|
|
|
|
if(!flags){
|
2002-08-13 23:24:20 +00:00
|
|
|
mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CannotFindColorspace);
|
2002-04-11 20:56:17 +00:00
|
|
|
return 0; // FAIL
|
|
|
|
}
|
|
|
|
}
|
2002-05-20 03:25:26 +00:00
|
|
|
mp_msg(MSGT_VFILTER,MSGL_V,"REQ: flags=0x%X req=0x%X \n",flags,vf->default_reqs);
|
2002-04-11 20:56:17 +00:00
|
|
|
miss=vf->default_reqs - (flags&vf->default_reqs);
|
|
|
|
if(miss&VFCAP_ACCEPT_STRIDE){
|
|
|
|
// vf requires stride support but vf->next doesn't support it!
|
|
|
|
// let's insert the 'expand' filter, it does the job for us:
|
|
|
|
vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL);
|
|
|
|
if(!vf2) return 0; // shouldn't happen!
|
|
|
|
vf->next=vf2;
|
|
|
|
}
|
2004-12-01 09:30:11 +00:00
|
|
|
vf->next->w = width; vf->next->h = height;
|
2005-03-01 20:21:58 +00:00
|
|
|
return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt);
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int vf_next_control(struct vf_instance_s* vf, int request, void* data){
|
|
|
|
return vf->next->control(vf->next,request,data);
|
|
|
|
}
|
|
|
|
|
|
|
|
int vf_next_query_format(struct vf_instance_s* vf, unsigned int fmt){
|
2002-04-11 20:56:17 +00:00
|
|
|
int flags=vf->next->query_format(vf->next,fmt);
|
|
|
|
if(flags) flags|=vf->default_caps;
|
|
|
|
return flags;
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
|
|
|
|
2006-03-21 21:26:42 +00:00
|
|
|
int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi, double pts){
|
|
|
|
return vf->next->put_image(vf->next,mpi, pts);
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
|
|
|
|
2002-12-05 00:22:37 +00:00
|
|
|
void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stride,int w, int h, int x, int y){
|
2003-05-20 17:42:33 +00:00
|
|
|
if (vf->next->draw_slice) {
|
|
|
|
vf->next->draw_slice(vf->next,src,stride,w,h,x,y);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!vf->dmpi) {
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_ERR,"draw_slice: dmpi not stored by vf_%s\n", vf->info->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(vf->dmpi->flags & MP_IMGFLAG_PLANAR)) {
|
|
|
|
memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+vf->dmpi->bpp/8*x,
|
2003-06-02 00:17:36 +00:00
|
|
|
src[0], vf->dmpi->bpp/8*w, h, vf->dmpi->stride[0], stride[0]);
|
2003-05-20 17:42:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+x, src[0],
|
|
|
|
w, h, vf->dmpi->stride[0], stride[0]);
|
|
|
|
memcpy_pic(vf->dmpi->planes[1]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1]+(x>>vf->dmpi->chroma_x_shift),
|
|
|
|
src[1], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[1], stride[1]);
|
|
|
|
memcpy_pic(vf->dmpi->planes[2]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]+(x>>vf->dmpi->chroma_x_shift),
|
|
|
|
src[2], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[2], stride[2]);
|
2002-12-05 00:22:37 +00:00
|
|
|
}
|
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
vf_instance_t* append_filters(vf_instance_t* last){
|
2003-03-15 18:01:02 +00:00
|
|
|
vf_instance_t* vf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// -vf take precedence over -vop
|
|
|
|
if(vf_settings) {
|
|
|
|
// We want to add them in the 'right order'
|
|
|
|
for(i = 0 ; vf_settings[i].name ; i++)
|
|
|
|
/* NOP */;
|
|
|
|
for(i-- ; i >= 0 ; i--) {
|
|
|
|
//printf("Open filter %s\n",vf_settings[i].name);
|
|
|
|
vf = vf_open_filter(last,vf_settings[i].name,vf_settings[i].attribs);
|
|
|
|
if(vf) last=vf;
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
2003-03-15 18:01:02 +00:00
|
|
|
} else if(vo_plugin_args) {
|
|
|
|
for(i = 0 ; vo_plugin_args[i].name ; i++) {
|
|
|
|
vf = vf_open_filter(last,vo_plugin_args[i].name,
|
|
|
|
vo_plugin_args[i].attribs);
|
|
|
|
if(vf) last=vf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return last;
|
2002-04-06 22:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2002-04-20 22:24:19 +00:00
|
|
|
void vf_uninit_filter(vf_instance_t* vf){
|
|
|
|
if(vf->uninit) vf->uninit(vf);
|
|
|
|
free_mp_image(vf->imgctx.static_images[0]);
|
|
|
|
free_mp_image(vf->imgctx.static_images[1]);
|
|
|
|
free_mp_image(vf->imgctx.temp_images[0]);
|
|
|
|
free_mp_image(vf->imgctx.export_images[0]);
|
|
|
|
free(vf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vf_uninit_filter_chain(vf_instance_t* vf){
|
|
|
|
while(vf){
|
|
|
|
vf_instance_t* next=vf->next;
|
|
|
|
vf_uninit_filter(vf);
|
|
|
|
vf=next;
|
|
|
|
}
|
|
|
|
}
|
2002-05-13 21:05:03 +00:00
|
|
|
|
2006-02-09 14:08:03 +00:00
|
|
|
void vf_list_plugins(void){
|
2002-05-13 21:05:03 +00:00
|
|
|
int i=0;
|
|
|
|
while(filter_list[i]){
|
|
|
|
mp_msg(MSGT_VFILTER,MSGL_INFO,"\t%-10s: %s\n",filter_list[i]->name,filter_list[i]->info);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|