2001-11-10 23:32:10 +00:00
|
|
|
/*
|
2010-01-30 22:26:47 +00:00
|
|
|
* Only a sample!
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2001-11-09 23:46:06 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
#include <stdio.h>
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
#include "video/img_fourcc.h"
|
2001-11-09 23:46:06 +00:00
|
|
|
#include "tv.h"
|
|
|
|
|
2013-12-21 19:24:20 +00:00
|
|
|
static tvi_handle_t *tvi_init_dummy(struct mp_log *log, tv_param_t* tv_param);
|
2001-11-10 23:32:10 +00:00
|
|
|
/* information about this file */
|
2008-01-13 12:01:57 +00:00
|
|
|
const tvi_info_t tvi_info_dummy = {
|
2014-04-13 16:00:51 +00:00
|
|
|
tvi_init_dummy,
|
|
|
|
"NULL-TV",
|
|
|
|
"dummy",
|
2001-11-09 23:46:06 +00:00
|
|
|
};
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
/* private data's */
|
2010-06-13 17:20:29 +00:00
|
|
|
typedef struct priv {
|
2001-11-10 23:32:10 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
2001-11-09 23:46:06 +00:00
|
|
|
} priv_t;
|
|
|
|
|
|
|
|
#include "tvi_def.h"
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
/* handler creator - entry point ! */
|
2013-12-21 19:24:20 +00:00
|
|
|
static tvi_handle_t *tvi_init_dummy(struct mp_log *log, tv_param_t* tv_param)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2013-12-21 19:24:20 +00:00
|
|
|
return tv_new_handle(sizeof(priv_t), log, &functions);
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
/* initialisation */
|
2001-12-27 23:52:48 +00:00
|
|
|
static int init(priv_t *priv)
|
2001-11-10 23:32:10 +00:00
|
|
|
{
|
2001-12-08 01:22:03 +00:00
|
|
|
priv->width = 320;
|
|
|
|
priv->height = 200;
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-10 23:32:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* that's the real start, we'got the format parameters (checked with control) */
|
|
|
|
static int start(priv_t *priv)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
2001-11-10 23:32:10 +00:00
|
|
|
static int uninit(priv_t *priv)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
2013-11-01 16:33:11 +00:00
|
|
|
static int do_control(priv_t *priv, int cmd, void *arg)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2001-11-10 23:32:10 +00:00
|
|
|
switch(cmd)
|
|
|
|
{
|
2014-04-13 16:00:51 +00:00
|
|
|
case TVI_CONTROL_IS_VIDEO:
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
case TVI_CONTROL_VID_GET_FORMAT:
|
|
|
|
*(int *)arg = MP_FOURCC_YV12;
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
case TVI_CONTROL_VID_SET_FORMAT:
|
|
|
|
{
|
|
|
|
// int req_fmt = *(int *)arg;
|
|
|
|
int req_fmt = *(int *)arg;
|
|
|
|
if (req_fmt != MP_FOURCC_YV12)
|
|
|
|
return TVI_CONTROL_FALSE;
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
}
|
|
|
|
case TVI_CONTROL_VID_SET_WIDTH:
|
|
|
|
priv->width = *(int *)arg;
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
case TVI_CONTROL_VID_GET_WIDTH:
|
|
|
|
*(int *)arg = priv->width;
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
case TVI_CONTROL_VID_SET_HEIGHT:
|
|
|
|
priv->height = *(int *)arg;
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
case TVI_CONTROL_VID_GET_HEIGHT:
|
|
|
|
*(int *)arg = priv->height;
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
case TVI_CONTROL_VID_CHK_WIDTH:
|
|
|
|
case TVI_CONTROL_VID_CHK_HEIGHT:
|
|
|
|
return TVI_CONTROL_TRUE;
|
|
|
|
case TVI_CONTROL_TUN_SET_NORM:
|
|
|
|
return TVI_CONTROL_TRUE;
|
2001-11-10 23:32:10 +00:00
|
|
|
}
|
2008-05-16 08:43:15 +00:00
|
|
|
return TVI_CONTROL_UNKNOWN;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
2002-04-12 10:40:38 +00:00
|
|
|
static double grab_video_frame(priv_t *priv, char *buffer, int len)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2001-11-10 23:32:10 +00:00
|
|
|
memset(buffer, 0x42, len);
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int get_video_framesize(priv_t *priv)
|
|
|
|
{
|
2001-11-10 23:32:10 +00:00
|
|
|
/* YV12 */
|
2008-05-16 08:43:15 +00:00
|
|
|
return priv->width * priv->height * 12 / 8;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
2002-04-12 10:40:38 +00:00
|
|
|
static double grab_audio_frame(priv_t *priv, char *buffer, int len)
|
2001-11-09 23:46:06 +00:00
|
|
|
{
|
2001-11-10 23:32:10 +00:00
|
|
|
memset(buffer, 0x42, len);
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int get_audio_framesize(priv_t *priv)
|
|
|
|
{
|
2008-05-16 08:43:15 +00:00
|
|
|
return 1;
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|