2010-01-30 16:57:40 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2005-11-18 14:39:25 +00:00
|
|
|
#include "config.h"
|
2005-09-11 06:42:32 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/mp_msg.h"
|
|
|
|
#include "video/img_format.h"
|
|
|
|
#include "video/mp_image.h"
|
2005-09-11 06:42:32 +00:00
|
|
|
#include "vf.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/sws_utils.h"
|
|
|
|
#include "video/fmt-conversion.h"
|
|
|
|
#include "video/memcpy_pic.h"
|
2005-09-11 06:42:32 +00:00
|
|
|
|
2011-10-06 18:46:01 +00:00
|
|
|
#include <libswscale/swscale.h>
|
2007-10-09 12:46:10 +00:00
|
|
|
|
2005-09-11 06:42:32 +00:00
|
|
|
struct vf_priv_s {
|
2011-10-06 18:46:01 +00:00
|
|
|
mp_image_t *image;
|
|
|
|
void (*image_callback)(void *, mp_image_t *);
|
|
|
|
void *image_callback_ctx;
|
2012-11-04 17:16:36 +00:00
|
|
|
int shot;
|
2005-09-11 06:42:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//===========================================================================//
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int config(struct vf_instance *vf,
|
2008-11-23 11:58:11 +00:00
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt)
|
2005-09-11 06:42:32 +00:00
|
|
|
{
|
2011-10-06 18:46:01 +00:00
|
|
|
free_mp_image(vf->priv->image);
|
|
|
|
vf->priv->image = new_mp_image(width, height);
|
|
|
|
mp_image_setfmt(vf->priv->image, outfmt);
|
2012-11-21 18:40:33 +00:00
|
|
|
vf->priv->image->display_w = d_width;
|
|
|
|
vf->priv->image->display_h = d_height;
|
2005-09-11 06:42:32 +00:00
|
|
|
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
|
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static void get_image(struct vf_instance *vf, mp_image_t *mpi)
|
2008-11-23 11:59:37 +00:00
|
|
|
{
|
2008-11-23 11:58:11 +00:00
|
|
|
vf->dmpi= vf_get_image(vf->next, mpi->imgfmt,
|
|
|
|
mpi->type, mpi->flags/* | MP_IMGFLAG_READABLE*/, mpi->width, mpi->height);
|
2005-09-11 15:08:48 +00:00
|
|
|
|
2011-08-16 00:49:19 +00:00
|
|
|
for (int i = 0; i < MP_MAX_PLANES; i++) {
|
|
|
|
mpi->planes[i]=vf->dmpi->planes[i];
|
|
|
|
mpi->stride[i]=vf->dmpi->stride[i];
|
2005-09-11 10:52:24 +00:00
|
|
|
}
|
|
|
|
mpi->width=vf->dmpi->width;
|
|
|
|
|
|
|
|
mpi->flags|=MP_IMGFLAG_DIRECT;
|
2008-11-23 11:58:11 +00:00
|
|
|
|
2005-09-11 10:52:24 +00:00
|
|
|
mpi->priv=(void*)vf->dmpi;
|
2005-09-11 06:42:32 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
|
2005-09-11 06:42:32 +00:00
|
|
|
{
|
2005-09-12 18:33:26 +00:00
|
|
|
mp_image_t *dmpi = (mp_image_t *)mpi->priv;
|
2008-11-23 11:58:11 +00:00
|
|
|
|
2012-11-04 17:16:36 +00:00
|
|
|
if(!(mpi->flags&(MP_IMGFLAG_DIRECT))){
|
2008-11-23 11:58:11 +00:00
|
|
|
dmpi=vf_get_image(vf->next,mpi->imgfmt,
|
|
|
|
MP_IMGTYPE_EXPORT, 0,
|
|
|
|
mpi->width, mpi->height);
|
|
|
|
vf_clone_mpi_attributes(dmpi, mpi);
|
2011-08-16 00:49:19 +00:00
|
|
|
for (int i = 0; i < MP_MAX_PLANES; i++) {
|
|
|
|
dmpi->planes[i]=mpi->planes[i];
|
|
|
|
dmpi->stride[i]=mpi->stride[i];
|
|
|
|
}
|
2008-11-23 11:58:11 +00:00
|
|
|
dmpi->width=mpi->width;
|
|
|
|
dmpi->height=mpi->height;
|
2005-09-11 10:52:24 +00:00
|
|
|
}
|
2005-09-11 06:42:32 +00:00
|
|
|
|
|
|
|
if(vf->priv->shot) {
|
2011-10-06 18:46:01 +00:00
|
|
|
vf->priv->shot=0;
|
2012-11-04 17:16:36 +00:00
|
|
|
mp_image_t image = *dmpi;
|
2012-11-21 18:56:25 +00:00
|
|
|
image.flags &= ~MP_IMGFLAG_ALLOCATED;
|
2012-11-10 01:02:24 +00:00
|
|
|
mp_image_copy_attributes(&image, mpi);
|
|
|
|
mp_image_set_display_size(&image, vf->priv->image->display_w,
|
|
|
|
vf->priv->image->display_h);
|
2011-10-06 18:46:01 +00:00
|
|
|
vf->priv->image_callback(vf->priv->image_callback_ctx, &image);
|
2005-09-11 06:42:32 +00:00
|
|
|
}
|
|
|
|
|
2006-03-21 21:26:42 +00:00
|
|
|
return vf_next_put_image(vf, dmpi, pts);
|
2005-09-11 06:42:32 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 10:58:29 +00:00
|
|
|
static int control (vf_instance_t *vf, int request, void *data)
|
2005-09-11 06:42:32 +00:00
|
|
|
{
|
|
|
|
if(request==VFCTRL_SCREENSHOT) {
|
2011-10-06 18:46:01 +00:00
|
|
|
struct vf_ctrl_screenshot *cmd = (struct vf_ctrl_screenshot *)data;
|
|
|
|
vf->priv->image_callback = cmd->image_callback;
|
|
|
|
vf->priv->image_callback_ctx = cmd->image_callback_ctx;
|
|
|
|
vf->priv->shot=1;
|
2005-09-11 06:42:32 +00:00
|
|
|
return CONTROL_TRUE;
|
|
|
|
}
|
|
|
|
return vf_next_control (vf, request, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================//
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int query_format(struct vf_instance *vf, unsigned int fmt)
|
2005-09-11 06:42:32 +00:00
|
|
|
{
|
2011-08-16 00:49:19 +00:00
|
|
|
enum PixelFormat av_format = imgfmt2pixfmt(fmt);
|
|
|
|
|
|
|
|
if (av_format != PIX_FMT_NONE && sws_isSupportedInput(av_format))
|
2008-11-23 11:58:11 +00:00
|
|
|
return vf_next_query_format(vf, fmt);
|
2005-09-11 06:42:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-23 12:01:48 +00:00
|
|
|
static void uninit(vf_instance_t *vf)
|
|
|
|
{
|
2011-10-06 18:46:01 +00:00
|
|
|
free_mp_image(vf->priv->image);
|
2008-11-23 12:01:48 +00:00
|
|
|
free(vf->priv);
|
|
|
|
}
|
|
|
|
|
2010-02-21 13:40:49 +00:00
|
|
|
static int vf_open(vf_instance_t *vf, char *args)
|
2005-09-11 06:42:32 +00:00
|
|
|
{
|
|
|
|
vf->config=config;
|
|
|
|
vf->control=control;
|
|
|
|
vf->put_image=put_image;
|
|
|
|
vf->query_format=query_format;
|
2005-09-11 10:52:24 +00:00
|
|
|
vf->get_image=get_image;
|
2005-10-30 08:45:24 +00:00
|
|
|
vf->uninit=uninit;
|
2005-09-11 06:42:32 +00:00
|
|
|
vf->priv=malloc(sizeof(struct vf_priv_s));
|
|
|
|
vf->priv->shot=0;
|
2011-10-06 18:46:01 +00:00
|
|
|
vf->priv->image=NULL;
|
2005-09-11 06:42:32 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-12-02 14:57:15 +00:00
|
|
|
const vf_info_t vf_info_screenshot = {
|
2005-09-11 06:42:32 +00:00
|
|
|
"screenshot to file",
|
|
|
|
"screenshot",
|
|
|
|
"A'rpi, Jindrich Makovicka",
|
|
|
|
"",
|
2010-02-21 13:40:49 +00:00
|
|
|
vf_open,
|
2005-09-11 06:42:32 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-01-17 02:50:08 +00:00
|
|
|
// screenshot.c will look for a filter named "screenshot_force", and not use
|
|
|
|
// the VO based screenshot code if it's in the filter chain.
|
|
|
|
const vf_info_t vf_info_screenshot_force = {
|
|
|
|
"screenshot to file (override VO based screenshot code)",
|
|
|
|
"screenshot_force",
|
|
|
|
"A'rpi, Jindrich Makovicka",
|
|
|
|
"",
|
|
|
|
vf_open,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2005-09-11 06:42:32 +00:00
|
|
|
//===========================================================================//
|