mirror of
https://github.com/mpv-player/mpv
synced 2024-08-24 07:21:49 +02:00
VO: remove vo_jpeg, vo_png, vo_pnm, vo_tga
All of these have been replaced by vo_image.
This commit is contained in:
parent
eb1182eb50
commit
44f23e36e8
4
Makefile
4
Makefile
@ -394,16 +394,13 @@ SRCS_MPLAYER-$(GL_X11) += libvo/x11_common.c
|
||||
|
||||
SRCS_MPLAYER-$(JACK) += libao2/ao_jack.c
|
||||
SRCS_MPLAYER-$(JOYSTICK) += input/joystick.c
|
||||
SRCS_MPLAYER-$(JPEG) += libvo/vo_jpeg.c
|
||||
SRCS_MPLAYER-$(LIRC) += input/lirc.c
|
||||
SRCS_MPLAYER-$(MD5SUM) += libvo/vo_md5sum.c
|
||||
SRCS_MPLAYER-$(OPENAL) += libao2/ao_openal.c
|
||||
SRCS_MPLAYER-$(OSS) += libao2/ao_oss.c
|
||||
SRCS_MPLAYER-$(PNM) += libvo/vo_pnm.c
|
||||
SRCS_MPLAYER-$(PULSE) += libao2/ao_pulse.c
|
||||
SRCS_MPLAYER-$(PORTAUDIO) += libao2/ao_portaudio.c
|
||||
SRCS_MPLAYER-$(RSOUND) += libao2/ao_rsound.c
|
||||
SRCS_MPLAYER-$(TGA) += libvo/vo_tga.c
|
||||
SRCS_MPLAYER-$(V4L2) += libvo/vo_v4l2.c
|
||||
SRCS_MPLAYER-$(V4L2) += libao2/ao_v4l2.c
|
||||
SRCS_MPLAYER-$(VDPAU) += libvo/vo_vdpau.c
|
||||
@ -431,7 +428,6 @@ SRCS_MPLAYER = command.c \
|
||||
libvo/old_vo_wrapper.c \
|
||||
libvo/video_out.c \
|
||||
libvo/vo_null.c \
|
||||
libvo/vo_png.c \
|
||||
libvo/vo_image.c \
|
||||
$(SRCS_MPLAYER-yes)
|
||||
|
||||
|
38
configure
vendored
38
configure
vendored
@ -339,7 +339,7 @@ Optional features:
|
||||
|
||||
Codecs:
|
||||
--enable-gif enable GIF support [autodetect]
|
||||
--enable-png enable PNG input/output support [autodetect]
|
||||
--enable-png enable PNG input support [autodetect]
|
||||
--enable-mng enable MNG input support [autodetect]
|
||||
--enable-jpeg enable JPEG input/output support [autodetect]
|
||||
--enable-libcdio enable libcdio support [autodetect]
|
||||
@ -371,8 +371,6 @@ Video output:
|
||||
--enable-xshape enable XShape support [autodetect]
|
||||
--disable-xss disable screensaver support via xss [autodetect]
|
||||
--enable-directfb enable DirectFB video output [autodetect]
|
||||
--disable-tga disable Targa video output [enable]
|
||||
--disable-pnm disable PNM video output [enable]
|
||||
--disable-md5sum disable md5sum video output [enable]
|
||||
--disable-yuv4mpeg disable yuv4mpeg video output [enable]
|
||||
--disable-corevideo disable CoreVideo video output [autodetect]
|
||||
@ -462,7 +460,6 @@ _nas=auto
|
||||
_png=auto
|
||||
_mng=auto
|
||||
_jpeg=auto
|
||||
_pnm=yes
|
||||
_md5sum=yes
|
||||
_yuv4mpeg=yes
|
||||
_gif=auto
|
||||
@ -525,7 +522,6 @@ _apple_remote=auto
|
||||
_apple_ir=auto
|
||||
_termcap=auto
|
||||
_termios=auto
|
||||
_tga=yes
|
||||
_directfb=auto
|
||||
#language=en
|
||||
_shm=auto
|
||||
@ -687,8 +683,6 @@ for ac_option do
|
||||
--disable-mng) _mng=no ;;
|
||||
--enable-jpeg) _jpeg=yes ;;
|
||||
--disable-jpeg) _jpeg=no ;;
|
||||
--enable-pnm) _pnm=yes ;;
|
||||
--disable-pnm) _pnm=no ;;
|
||||
--enable-md5sum) _md5sum=yes ;;
|
||||
--disable-md5sum) _md5sum=no ;;
|
||||
--enable-yuv4mpeg) _yuv4mpeg=yes ;;
|
||||
@ -809,8 +803,6 @@ for ac_option do
|
||||
--disable-termcap) _termcap=no ;;
|
||||
--enable-termios) _termios=yes ;;
|
||||
--disable-termios) _termios=no ;;
|
||||
--disable-tga) _tga=no ;;
|
||||
--enable-tga) _tga=yes ;;
|
||||
--enable-directfb) _directfb=yes ;;
|
||||
--disable-directfb) _directfb=no ;;
|
||||
--enable-shm) _shm=yes ;;
|
||||
@ -2062,17 +2054,6 @@ echores "$_libquvi"
|
||||
#########
|
||||
|
||||
|
||||
echocheck "tga"
|
||||
if test "$_tga" = yes ; then
|
||||
def_tga='#define CONFIG_TGA 1'
|
||||
vomodules="tga $vomodules"
|
||||
else
|
||||
def_tga='#undef CONFIG_TGA'
|
||||
novomodules="tga $novomodules"
|
||||
fi
|
||||
echores "$_tga"
|
||||
|
||||
|
||||
echocheck "md5sum support"
|
||||
if test "$_md5sum" = yes; then
|
||||
def_md5sum="#define CONFIG_MD5SUM 1"
|
||||
@ -2505,19 +2486,6 @@ else
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echocheck "PNM support"
|
||||
if test "$_pnm" = yes; then
|
||||
def_pnm="#define CONFIG_PNM 1"
|
||||
vomodules="pnm $vomodules"
|
||||
else
|
||||
def_pnm="#undef CONFIG_PNM"
|
||||
novomodules="pnm $novomodules"
|
||||
fi
|
||||
echores "$_pnm"
|
||||
|
||||
|
||||
|
||||
echocheck "GIF support"
|
||||
# This is to appease people who want to force gif support.
|
||||
# If it is forced to yes, then we still do checks to determine
|
||||
@ -4015,7 +3983,6 @@ OPENAL = $_openal
|
||||
OSS = $_ossaudio
|
||||
PE_EXECUTABLE = $_pe_executable
|
||||
PNG = $_png
|
||||
PNM = $_pnm
|
||||
PRIORITY = $_priority
|
||||
PULSE = $_pulse
|
||||
PORTAUDIO = $_portaudio
|
||||
@ -4028,7 +3995,6 @@ RADIO_CAPTURE=$_radio_capture
|
||||
REAL_CODECS = $_real
|
||||
RSOUND = $_rsound
|
||||
STREAM_CACHE = $_stream_cache
|
||||
TGA = $_tga
|
||||
TV = $_tv
|
||||
TV_BSDBT848 = $_tv_bsdbt848
|
||||
TV_DSHOW = $_tv_dshow
|
||||
@ -4306,8 +4272,6 @@ $def_jpeg
|
||||
$def_md5sum
|
||||
$def_mng
|
||||
$def_png
|
||||
$def_pnm
|
||||
$def_tga
|
||||
$def_v4l2
|
||||
$def_vdpau
|
||||
$def_vm
|
||||
|
@ -81,7 +81,6 @@ extern struct vo_driver video_out_gl_nosw;
|
||||
extern struct vo_driver video_out_gl;
|
||||
extern struct vo_driver video_out_gl3;
|
||||
extern struct vo_driver video_out_null;
|
||||
extern struct vo_driver video_out_png;
|
||||
extern struct vo_driver video_out_image;
|
||||
extern struct vo_driver video_out_caca;
|
||||
extern struct vo_driver video_out_yuv4mpeg;
|
||||
@ -89,13 +88,10 @@ extern struct vo_driver video_out_direct3d;
|
||||
extern struct vo_driver video_out_direct3d_shaders;
|
||||
extern struct vo_driver video_out_directx;
|
||||
extern struct vo_driver video_out_v4l2;
|
||||
extern struct vo_driver video_out_jpeg;
|
||||
extern struct vo_driver video_out_gif89a;
|
||||
extern struct vo_driver video_out_directfb;
|
||||
extern struct vo_driver video_out_tga;
|
||||
extern struct vo_driver video_out_corevideo;
|
||||
extern struct vo_driver video_out_sharedbuffer;
|
||||
extern struct vo_driver video_out_pnm;
|
||||
extern struct vo_driver video_out_md5sum;
|
||||
|
||||
const struct vo_driver *video_out_drivers[] =
|
||||
@ -146,20 +142,10 @@ const struct vo_driver *video_out_drivers[] =
|
||||
#ifdef CONFIG_YUV4MPEG
|
||||
&video_out_yuv4mpeg,
|
||||
#endif
|
||||
&video_out_png,
|
||||
&video_out_image,
|
||||
#ifdef CONFIG_JPEG
|
||||
&video_out_jpeg,
|
||||
#endif
|
||||
#ifdef CONFIG_GIF
|
||||
&video_out_gif89a,
|
||||
#endif
|
||||
#ifdef CONFIG_TGA
|
||||
&video_out_tga,
|
||||
#endif
|
||||
#ifdef CONFIG_PNM
|
||||
&video_out_pnm,
|
||||
#endif
|
||||
#ifdef CONFIG_MD5SUM
|
||||
&video_out_md5sum,
|
||||
#endif
|
||||
|
410
libvo/vo_jpeg.c
410
libvo/vo_jpeg.c
@ -1,410 +0,0 @@
|
||||
/*
|
||||
* JPEG Renderer for MPlayer
|
||||
*
|
||||
* Copyright (C) 2002 by Pontscho <pontscho@makacs.poliod.hu>
|
||||
* Copyright (C) 2003 by Alex
|
||||
* Copyright (C) 2004, 2005 by Ivo van Poorten <ivop@euronet.nl>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Global Includes */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <jpeglib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Local Includes */
|
||||
|
||||
#include "config.h"
|
||||
#include "subopt-helper.h"
|
||||
#include "mp_msg.h"
|
||||
#include "video_out.h"
|
||||
#include "video_out_internal.h"
|
||||
#include "osdep/io.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Defines */
|
||||
|
||||
/* Used for temporary buffers to store file- and pathnames */
|
||||
#define BUFLENGTH 512
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Info */
|
||||
|
||||
static const vo_info_t info=
|
||||
{
|
||||
"JPEG file",
|
||||
"jpeg",
|
||||
"Zoltan Ponekker (pontscho@makacs.poliod.hu)",
|
||||
""
|
||||
};
|
||||
|
||||
const LIBVO_EXTERN (jpeg)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Global Variables */
|
||||
|
||||
static int image_width;
|
||||
static int image_height;
|
||||
static int image_d_width;
|
||||
static int image_d_height;
|
||||
|
||||
int jpeg_baseline = 1;
|
||||
int jpeg_progressive_mode = 0;
|
||||
int jpeg_optimize = 100;
|
||||
int jpeg_smooth = 0;
|
||||
int jpeg_quality = 75;
|
||||
int jpeg_dpi = 72; /** Screen resolution = 72 dpi */
|
||||
char *jpeg_outdir = NULL;
|
||||
char *jpeg_subdirs = NULL;
|
||||
int jpeg_maxfiles = 1000;
|
||||
|
||||
static int framenum = 0;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Create a directory.
|
||||
*
|
||||
* This function creates a directory. If it already exists, it tests if
|
||||
* it's a directory and not something else, and if it is, it tests whether
|
||||
* the directory is writable or not.
|
||||
*
|
||||
* \param buf Pointer to directory name.
|
||||
* \param verbose Verbose on success. If verbose is non-zero, it will print
|
||||
* a message if it was successful in creating the directory.
|
||||
*
|
||||
* \return nothing In case anything fails, the player will exit. If it
|
||||
* returns, everything went well.
|
||||
*/
|
||||
|
||||
static void jpeg_mkdir(const char *buf, int verbose) {
|
||||
struct stat stat_p;
|
||||
|
||||
if ( mkdir(buf, 0755) < 0 ) {
|
||||
switch (errno) { /* use switch in case other errors need to be caught
|
||||
and handled in the future */
|
||||
case EEXIST:
|
||||
if ( mp_stat(buf, &stat_p ) < 0 ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
|
||||
_("This error has occurred"), strerror(errno) );
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
|
||||
_("Unable to access"), buf);
|
||||
return;
|
||||
}
|
||||
if ( !S_ISDIR(stat_p.st_mode) ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
|
||||
buf, _("already exists, but is not a directory."));
|
||||
return;
|
||||
}
|
||||
if ( !(stat_p.st_mode & S_IWUSR) ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Output directory already exists, but is not writable."));
|
||||
return;
|
||||
}
|
||||
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Output directory already exists and is writable."));
|
||||
break;
|
||||
|
||||
default:
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
|
||||
_("This error has occurred"), strerror(errno) );
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Unable to create output directory."));
|
||||
return;
|
||||
} /* end switch */
|
||||
} else if ( verbose ) {
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Output directory successfully created."));
|
||||
} /* end if */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int config(uint32_t width, uint32_t height, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags, char *title,
|
||||
uint32_t format)
|
||||
{
|
||||
char buf[BUFLENGTH];
|
||||
|
||||
/* Create outdir. */
|
||||
|
||||
snprintf(buf, BUFLENGTH, "%s", jpeg_outdir);
|
||||
|
||||
jpeg_mkdir(buf, 1); /* This function only returns if creation was
|
||||
successful. If not, the player will exit. */
|
||||
|
||||
image_height = height;
|
||||
image_width = width;
|
||||
/* Save for JFIF-Header PAR */
|
||||
image_d_width = d_width;
|
||||
image_d_height = d_height;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static uint32_t jpeg_write(const char * name, uint8_t * buffer)
|
||||
{
|
||||
FILE *outfile;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
JSAMPROW row_pointer[1];
|
||||
int row_stride;
|
||||
|
||||
if ( !buffer ) return 1;
|
||||
if ( (outfile = fopen(name, "wb") ) == NULL ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name,
|
||||
_("Unable to create output file."));
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
|
||||
info.short_name, _("This error has occurred"),
|
||||
strerror(errno) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
jpeg_create_compress(&cinfo);
|
||||
jpeg_stdio_dest(&cinfo, outfile);
|
||||
|
||||
cinfo.image_width = image_width;
|
||||
cinfo.image_height = image_height;
|
||||
cinfo.input_components = 3;
|
||||
cinfo.in_color_space = JCS_RGB;
|
||||
|
||||
jpeg_set_defaults(&cinfo);
|
||||
/* Important: Header info must be set AFTER jpeg_set_defaults() */
|
||||
cinfo.write_JFIF_header = TRUE;
|
||||
cinfo.JFIF_major_version = 1;
|
||||
cinfo.JFIF_minor_version = 2;
|
||||
cinfo.density_unit = 1; /* 0=unknown, 1=dpi, 2=dpcm */
|
||||
/* Image DPI is determined by Y_density, so we leave that at
|
||||
jpeg_dpi if possible and crunch X_density instead (PAR > 1) */
|
||||
cinfo.X_density = jpeg_dpi*image_width/image_d_width;
|
||||
cinfo.Y_density = jpeg_dpi*image_height/image_d_height;
|
||||
cinfo.write_Adobe_marker = TRUE;
|
||||
|
||||
jpeg_set_quality(&cinfo,jpeg_quality, jpeg_baseline);
|
||||
cinfo.optimize_coding = jpeg_optimize;
|
||||
cinfo.smoothing_factor = jpeg_smooth;
|
||||
|
||||
if ( jpeg_progressive_mode ) {
|
||||
jpeg_simple_progression(&cinfo);
|
||||
}
|
||||
|
||||
jpeg_start_compress(&cinfo, TRUE);
|
||||
|
||||
row_stride = image_width * 3;
|
||||
while (cinfo.next_scanline < cinfo.image_height) {
|
||||
row_pointer[0] = &buffer[cinfo.next_scanline * row_stride];
|
||||
(void)jpeg_write_scanlines(&cinfo, row_pointer,1);
|
||||
}
|
||||
|
||||
jpeg_finish_compress(&cinfo);
|
||||
fclose(outfile);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int draw_frame(uint8_t *src[])
|
||||
{
|
||||
static int framecounter = 0, subdircounter = 0;
|
||||
char buf[BUFLENGTH];
|
||||
static char subdirname[BUFLENGTH] = "";
|
||||
|
||||
/* Start writing to new subdirectory after a certain amount of frames */
|
||||
if ( framecounter == jpeg_maxfiles ) {
|
||||
framecounter = 0;
|
||||
}
|
||||
|
||||
/* If framecounter is zero (or reset to zero), increment subdirectory
|
||||
* number and create the subdirectory.
|
||||
* If jpeg_subdirs is not set, do nothing and resort to old behaviour. */
|
||||
if ( !framecounter && jpeg_subdirs ) {
|
||||
subdircounter++;
|
||||
snprintf(subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, subdircounter);
|
||||
snprintf(buf, BUFLENGTH, "%s/%s", jpeg_outdir, subdirname);
|
||||
jpeg_mkdir(buf, 0); /* This function only returns if creation was
|
||||
successful. If not, the player will exit. */
|
||||
}
|
||||
|
||||
framenum++;
|
||||
|
||||
/* snprintf the full pathname of the outputfile */
|
||||
snprintf(buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname,
|
||||
framenum);
|
||||
|
||||
framecounter++;
|
||||
|
||||
return jpeg_write(buf, src[0]);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void draw_osd(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void flip_page (void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int draw_slice(uint8_t *src[], int stride[], int w, int h,
|
||||
int x, int y)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int query_format(uint32_t format)
|
||||
{
|
||||
if (format == IMGFMT_RGB24) {
|
||||
return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void uninit(void)
|
||||
{
|
||||
free(jpeg_subdirs);
|
||||
jpeg_subdirs = NULL;
|
||||
free(jpeg_outdir);
|
||||
jpeg_outdir = NULL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void check_events(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Validation function for values [0-100]
|
||||
*/
|
||||
|
||||
static int int_zero_hundred(void *valp)
|
||||
{
|
||||
int *val = valp;
|
||||
return *val >= 0 && *val <= 100;
|
||||
}
|
||||
|
||||
static int preinit(const char *arg)
|
||||
{
|
||||
const opt_t subopts[] = {
|
||||
{"progressive", OPT_ARG_BOOL, &jpeg_progressive_mode, NULL},
|
||||
{"baseline", OPT_ARG_BOOL, &jpeg_baseline, NULL},
|
||||
{"optimize", OPT_ARG_INT, &jpeg_optimize,
|
||||
int_zero_hundred},
|
||||
{"smooth", OPT_ARG_INT, &jpeg_smooth,
|
||||
int_zero_hundred},
|
||||
{"quality", OPT_ARG_INT, &jpeg_quality,
|
||||
int_zero_hundred},
|
||||
{"dpi", OPT_ARG_INT, &jpeg_dpi, NULL},
|
||||
{"outdir", OPT_ARG_MSTRZ, &jpeg_outdir, NULL},
|
||||
{"subdirs", OPT_ARG_MSTRZ, &jpeg_subdirs, NULL},
|
||||
{"maxfiles", OPT_ARG_INT, &jpeg_maxfiles, int_pos},
|
||||
{NULL, 0, NULL, NULL}
|
||||
};
|
||||
const char *info_message = NULL;
|
||||
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: %s\n", info.short_name,
|
||||
"Parsing suboptions.");
|
||||
|
||||
jpeg_progressive_mode = 0;
|
||||
jpeg_baseline = 1;
|
||||
jpeg_optimize = 100;
|
||||
jpeg_smooth = 0;
|
||||
jpeg_quality = 75;
|
||||
jpeg_maxfiles = 1000;
|
||||
jpeg_outdir = strdup(".");
|
||||
jpeg_subdirs = NULL;
|
||||
|
||||
if (subopt_parse(arg, subopts) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (jpeg_progressive_mode) info_message = _("Progressive JPEG enabled.");
|
||||
else info_message = _("Progressive JPEG disabled.");
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
|
||||
|
||||
if (jpeg_baseline) info_message = _("Baseline JPEG enabled.");
|
||||
else info_message = _("Baseline JPEG disabled.");
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
|
||||
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: optimize --> %d\n", info.short_name,
|
||||
jpeg_optimize);
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: smooth --> %d\n", info.short_name,
|
||||
jpeg_smooth);
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: quality --> %d\n", info.short_name,
|
||||
jpeg_quality);
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: dpi --> %d\n", info.short_name,
|
||||
jpeg_dpi);
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: outdir --> %s\n", info.short_name,
|
||||
jpeg_outdir);
|
||||
if (jpeg_subdirs) {
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: subdirs --> %s\n", info.short_name,
|
||||
jpeg_subdirs);
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: maxfiles --> %d\n", info.short_name,
|
||||
jpeg_maxfiles);
|
||||
}
|
||||
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: %s\n", info.short_name,
|
||||
"Suboptions parsed OK.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int control(uint32_t request, void *data)
|
||||
{
|
||||
switch (request) {
|
||||
case VOCTRL_QUERY_FORMAT:
|
||||
return query_format(*((uint32_t*)data));
|
||||
}
|
||||
return VO_NOTIMPL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#undef BUFLENGTH
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
202
libvo/vo_png.c
202
libvo/vo_png.c
@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Portable Network Graphics renderer
|
||||
*
|
||||
* Copyright 2001 by Felix Buenemann <atmosfear@users.sourceforge.net>
|
||||
*
|
||||
* Uses libpng (which uses zlib), so see according licenses.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "mp_msg.h"
|
||||
#include "mp_msg.h"
|
||||
#include "video_out.h"
|
||||
#include "video_out_internal.h"
|
||||
#include "subopt-helper.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "fmt-conversion.h"
|
||||
|
||||
static const vo_info_t info =
|
||||
{
|
||||
"PNG file",
|
||||
"png",
|
||||
"Felix Buenemann <atmosfear@users.sourceforge.net>",
|
||||
""
|
||||
};
|
||||
|
||||
const LIBVO_EXTERN (png)
|
||||
|
||||
static int z_compression;
|
||||
static int framenum;
|
||||
static int use_alpha;
|
||||
static AVCodecContext *avctx;
|
||||
static AVFrame *pic;
|
||||
static uint8_t *outbuffer;
|
||||
int outbuffer_size;
|
||||
|
||||
static int
|
||||
config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
||||
{
|
||||
if(z_compression == 0) {
|
||||
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Warning: compression level set to 0, compression disabled!\n");
|
||||
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Info: Use -vo png:z=<n> to set compression level from 0 to 9.\n");
|
||||
mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_PNG] Info: (0 = no compression, 1 = fastest, lowest - 9 best, slowest compression)\n");
|
||||
}
|
||||
|
||||
mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression);
|
||||
uninit();
|
||||
struct AVCodec *png_codec = avcodec_find_encoder(CODEC_ID_PNG);
|
||||
if (!png_codec)
|
||||
goto error;
|
||||
avctx = avcodec_alloc_context3(png_codec);
|
||||
if (!avctx)
|
||||
goto error;
|
||||
pic = avcodec_alloc_frame();
|
||||
if (!pic)
|
||||
goto error;
|
||||
avctx->width = width;
|
||||
avctx->height = height;
|
||||
avctx->pix_fmt = imgfmt2pixfmt(format);
|
||||
avctx->compression_level = z_compression;
|
||||
if (avcodec_open2(avctx, png_codec, NULL) < 0)
|
||||
goto error;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
uninit();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t draw_image(mp_image_t* mpi){
|
||||
int buffersize;
|
||||
int res;
|
||||
char buf[100];
|
||||
FILE *outfile;
|
||||
|
||||
// if -dr or -slices then do nothing:
|
||||
if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
|
||||
|
||||
snprintf (buf, 100, "%08d.png", ++framenum);
|
||||
outfile = fopen(buf, "wb");
|
||||
if (!outfile) {
|
||||
mp_msg(MSGT_VO,MSGL_WARN, "\n[VO_PNG] Error opening '%s' for writing!\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
avcodec_get_frame_defaults(pic);
|
||||
|
||||
pic->data[0] = mpi->planes[0];
|
||||
pic->linesize[0] = mpi->stride[0];
|
||||
buffersize = mpi->w * mpi->h * 8;
|
||||
if (outbuffer_size < buffersize) {
|
||||
av_freep(&outbuffer);
|
||||
outbuffer = av_malloc(buffersize);
|
||||
outbuffer_size = buffersize;
|
||||
}
|
||||
res = avcodec_encode_video(avctx, outbuffer, outbuffer_size, pic);
|
||||
|
||||
if(res < 0){
|
||||
mp_msg(MSGT_VO,MSGL_WARN, "[VO_PNG] Error in create_png.\n");
|
||||
fclose(outfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fwrite(outbuffer, res, 1, outfile);
|
||||
fclose(outfile);
|
||||
|
||||
return VO_TRUE;
|
||||
}
|
||||
|
||||
static void draw_osd(void){}
|
||||
|
||||
static void flip_page (void){}
|
||||
|
||||
static int draw_frame(uint8_t * src[])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
query_format(uint32_t format)
|
||||
{
|
||||
const int supported_flags = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE;
|
||||
switch(format){
|
||||
case IMGFMT_RGB24:
|
||||
return use_alpha ? 0 : supported_flags;
|
||||
case IMGFMT_BGR32:
|
||||
return use_alpha ? supported_flags : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void uninit(void)
|
||||
{
|
||||
if (avctx)
|
||||
avcodec_close(avctx);
|
||||
av_freep(&avctx);
|
||||
av_freep(&outbuffer);
|
||||
av_free(pic);
|
||||
pic = NULL;
|
||||
outbuffer_size = 0;
|
||||
}
|
||||
|
||||
static void check_events(void){}
|
||||
|
||||
static int int_zero_to_nine(void *value)
|
||||
{
|
||||
int *sh = value;
|
||||
return *sh >= 0 && *sh <= 9;
|
||||
}
|
||||
|
||||
static const opt_t subopts[] = {
|
||||
{"alpha", OPT_ARG_BOOL, &use_alpha, NULL},
|
||||
{"z", OPT_ARG_INT, &z_compression, int_zero_to_nine},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static int preinit(const char *arg)
|
||||
{
|
||||
z_compression = 0;
|
||||
use_alpha = 0;
|
||||
if (subopt_parse(arg, subopts) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int control(uint32_t request, void *data)
|
||||
{
|
||||
switch (request) {
|
||||
case VOCTRL_DRAW_IMAGE:
|
||||
return draw_image(data);
|
||||
case VOCTRL_QUERY_FORMAT:
|
||||
return query_format(*((uint32_t*)data));
|
||||
}
|
||||
return VO_NOTIMPL;
|
||||
}
|
586
libvo/vo_pnm.c
586
libvo/vo_pnm.c
@ -1,586 +0,0 @@
|
||||
/*
|
||||
* PPM/PGM/PGMYUV video output driver
|
||||
*
|
||||
* copyright (C) 2004, 2005 Ivo van Poorten
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Global Includes */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Local Includes */
|
||||
|
||||
#include "config.h"
|
||||
#include "subopt-helper.h"
|
||||
#include "mp_msg.h"
|
||||
#include "video_out.h"
|
||||
#include "video_out_internal.h"
|
||||
#include "osdep/io.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Defines */
|
||||
|
||||
/* Used for temporary buffers to store file- and pathnames */
|
||||
#define BUFLENGTH 512
|
||||
|
||||
#define PNM_ASCII_MODE 0
|
||||
#define PNM_RAW_MODE 1
|
||||
#define PNM_TYPE_PPM 0
|
||||
#define PNM_TYPE_PGM 1
|
||||
#define PNM_TYPE_PGMYUV 2
|
||||
|
||||
#define PNM_LINE_OF_ASCII "%03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d\n"
|
||||
#define PNM_LINE15(a,b) a[b], a[b+1], a[b+2], a[b+3], a[b+4], a[b+5], a[b+6], \
|
||||
a[b+7], a[b+8], a[b+9], a[b+10], a[b+11], a[b+12], \
|
||||
a[b+13], a[b+14]
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Info */
|
||||
|
||||
static const vo_info_t info=
|
||||
{
|
||||
"PPM/PGM/PGMYUV file",
|
||||
"pnm",
|
||||
"Ivo van Poorten (ivop@euronet.nl)",
|
||||
""
|
||||
};
|
||||
|
||||
const LIBVO_EXTERN (pnm)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Global Variables */
|
||||
|
||||
int pnm_type = PNM_TYPE_PPM;
|
||||
int pnm_mode = PNM_RAW_MODE;
|
||||
|
||||
char *pnm_outdir = NULL;
|
||||
char *pnm_subdirs = NULL;
|
||||
int pnm_maxfiles = 1000;
|
||||
char *pnm_file_extension = NULL;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief An error occured while writing to a file.
|
||||
*
|
||||
* The program failed to write data to a file.
|
||||
* It displays a message and exits the player.
|
||||
*
|
||||
* \return nothing It does not return.
|
||||
*/
|
||||
|
||||
static void pnm_write_error(void) {
|
||||
mp_tmsg(MSGT_VO, MSGL_ERR, "%s: Error writing file.\n", info.short_name);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Pre-initialisation.
|
||||
*
|
||||
* This function is called before initialising the video output driver. It
|
||||
* parses all suboptions and sets variables accordingly. If an error occurs
|
||||
* (like an option being out of range, not having any value or an unknown
|
||||
* option is stumbled upon) the player will exit.
|
||||
*
|
||||
* \param arg A string containing all the suboptions passed to the video
|
||||
* output driver.
|
||||
*
|
||||
* \return 0 All went well.
|
||||
*/
|
||||
|
||||
static int preinit(const char *arg)
|
||||
{
|
||||
int ppm_type = 0, pgm_type = 0, pgmyuv_type = 0,
|
||||
raw_mode = 0, ascii_mode = 0;
|
||||
const opt_t subopts[] = {
|
||||
{"ppm", OPT_ARG_BOOL, &ppm_type, NULL},
|
||||
{"pgm", OPT_ARG_BOOL, &pgm_type, NULL},
|
||||
{"pgmyuv", OPT_ARG_BOOL, &pgmyuv_type, NULL},
|
||||
{"raw", OPT_ARG_BOOL, &raw_mode, NULL},
|
||||
{"ascii", OPT_ARG_BOOL, &ascii_mode, NULL},
|
||||
{"outdir", OPT_ARG_MSTRZ, &pnm_outdir, NULL},
|
||||
{"subdirs", OPT_ARG_MSTRZ, &pnm_subdirs, NULL},
|
||||
{"maxfiles", OPT_ARG_INT, &pnm_maxfiles, int_pos},
|
||||
{NULL, 0, NULL, NULL}
|
||||
};
|
||||
const char *info_message = NULL;
|
||||
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: %s\n", info.short_name,
|
||||
"Parsing suboptions.");
|
||||
|
||||
pnm_maxfiles = 1000;
|
||||
pnm_outdir = strdup(".");
|
||||
pnm_subdirs = NULL;
|
||||
|
||||
if (subopt_parse(arg, subopts) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pnm_type = PNM_TYPE_PPM;
|
||||
pnm_mode = PNM_RAW_MODE;
|
||||
|
||||
if (pgmyuv_type) pnm_type = PNM_TYPE_PGMYUV;
|
||||
if (pgm_type) pnm_type = PNM_TYPE_PGM;
|
||||
if (ppm_type) pnm_type = PNM_TYPE_PPM;
|
||||
if (ascii_mode) pnm_mode = PNM_ASCII_MODE;
|
||||
if (raw_mode) pnm_mode = PNM_RAW_MODE;
|
||||
|
||||
switch (pnm_mode) {
|
||||
case PNM_ASCII_MODE:
|
||||
info_message = _("ASCII mode enabled.");
|
||||
break;
|
||||
case PNM_RAW_MODE:
|
||||
info_message = _("Raw mode enabled.");
|
||||
break;
|
||||
}
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
|
||||
|
||||
switch (pnm_type) {
|
||||
case PNM_TYPE_PPM:
|
||||
info_message = _("Will write PPM files.");
|
||||
break;
|
||||
case PNM_TYPE_PGM:
|
||||
info_message = _("Will write PGM files.");
|
||||
break;
|
||||
case PNM_TYPE_PGMYUV:
|
||||
info_message = _("Will write PGMYUV files.");
|
||||
break;
|
||||
}
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message);
|
||||
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: %s\n", info.short_name,
|
||||
"Suboptions parsed OK.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Create a directory.
|
||||
*
|
||||
* This function creates a directory. If it already exists, it tests if
|
||||
* it's a directory and not something else, and if it is, it tests whether
|
||||
* the directory is writable or not.
|
||||
*
|
||||
* \param buf Pointer to directory name.
|
||||
* \param verbose Verbose on success. If verbose is non-zero, it will print
|
||||
* a message if it was successful in creating the directory.
|
||||
*
|
||||
* \return nothing In case anything fails, the player will exit. If it
|
||||
* returns, everything went well.
|
||||
*/
|
||||
|
||||
static void pnm_mkdir(char *buf, int verbose) {
|
||||
struct stat stat_p;
|
||||
|
||||
if ( mkdir(buf, 0755) < 0 ) {
|
||||
switch (errno) { /* use switch in case other errors need to be caught
|
||||
and handled in the future */
|
||||
case EEXIST:
|
||||
if ( mp_stat(buf, &stat_p ) < 0 ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
|
||||
_("This error has occurred"), strerror(errno) );
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
|
||||
_("Unable to access"), buf);
|
||||
return;
|
||||
}
|
||||
if ( !S_ISDIR(stat_p.st_mode) ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name,
|
||||
buf, _("already exists, but is not a directory."));
|
||||
return;
|
||||
}
|
||||
if ( !(stat_p.st_mode & S_IWUSR) ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Output directory already exists, but is not writable."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(buf, ".") != 0) {
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Output directory already exists and is writable."));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name,
|
||||
_("This error has occurred"), strerror(errno) );
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Unable to create output directory."));
|
||||
return;
|
||||
} /* end switch */
|
||||
} else if ( verbose ) {
|
||||
mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name,
|
||||
buf, _("Output directory successfully created."));
|
||||
} /* end if */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Configure the video output driver.
|
||||
*
|
||||
* This functions configures the video output driver. It determines the
|
||||
* width and height of the image(s) and creates the output directory.
|
||||
*
|
||||
* \return 0 All went well.
|
||||
*/
|
||||
|
||||
static int config(uint32_t width, uint32_t height, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags, char *title,
|
||||
uint32_t format)
|
||||
{
|
||||
char buf[BUFLENGTH];
|
||||
|
||||
if (vo_config_count > 0 ) { /* Already configured */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create outdir. */
|
||||
|
||||
snprintf(buf, BUFLENGTH, "%s", pnm_outdir);
|
||||
pnm_mkdir(buf, 1); /* This function only returns if creation was
|
||||
successful. If not, the player will exit. */
|
||||
|
||||
if (pnm_type == PNM_TYPE_PPM) {
|
||||
pnm_file_extension = strdup("ppm");
|
||||
} else if (pnm_type == PNM_TYPE_PGM) {
|
||||
pnm_file_extension = strdup("pgm");
|
||||
} else if (pnm_type == PNM_TYPE_PGMYUV) {
|
||||
pnm_file_extension = strdup("pgmyuv");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Write PNM file to output file
|
||||
*
|
||||
* This function writes PPM, PGM or PGMYUV data to an output file, depending
|
||||
* on which type was selected on the commandline. pnm_type and pnm_mode are
|
||||
* global variables. Depending on which mode was selected, it will write
|
||||
* a RAW or an ASCII file.
|
||||
*
|
||||
* \param outfile Filedescriptor of output file.
|
||||
* \param mpi The image to write.
|
||||
*
|
||||
* \return none The player will exit if anything goes wrong.
|
||||
*/
|
||||
|
||||
static void pnm_write_pnm(FILE *outfile, mp_image_t *mpi)
|
||||
{
|
||||
uint32_t w = mpi->w;
|
||||
uint32_t h = mpi->h;
|
||||
uint8_t *rgbimage = mpi->planes[0];
|
||||
uint8_t *planeY = mpi->planes[0];
|
||||
uint8_t *planeU = mpi->planes[1];
|
||||
uint8_t *planeV = mpi->planes[2];
|
||||
uint8_t *curline;
|
||||
uint32_t strideY = mpi->stride[0];
|
||||
uint32_t strideU = mpi->stride[1];
|
||||
uint32_t strideV = mpi->stride[2];
|
||||
|
||||
unsigned int i, j;
|
||||
|
||||
if (pnm_mode == PNM_RAW_MODE) {
|
||||
|
||||
if (pnm_type == PNM_TYPE_PPM) {
|
||||
if ( fprintf(outfile, "P6\n%d %d\n255\n", w, h) < 0 )
|
||||
pnm_write_error();
|
||||
if ( fwrite(rgbimage, w * 3, h, outfile) < h ) pnm_write_error();
|
||||
} else if (pnm_type == PNM_TYPE_PGM) {
|
||||
if ( fprintf(outfile, "P5\n%d %d\n255\n", w, h) < 0 )
|
||||
pnm_write_error();
|
||||
for (i=0; i<h; i++) {
|
||||
if ( fwrite(planeY + i * strideY, w, 1, outfile) < 1 )
|
||||
pnm_write_error();
|
||||
}
|
||||
} else if (pnm_type == PNM_TYPE_PGMYUV) {
|
||||
if ( fprintf(outfile, "P5\n%d %d\n255\n", w, h*3/2) < 0 )
|
||||
pnm_write_error();
|
||||
for (i=0; i<h; i++) {
|
||||
if ( fwrite(planeY + i * strideY, w, 1, outfile) < 1 )
|
||||
pnm_write_error();
|
||||
}
|
||||
w = w / 2;
|
||||
h = h / 2;
|
||||
for (i=0; i<h; i++) {
|
||||
if ( fwrite(planeU + i * strideU, w, 1, outfile) < 1 )
|
||||
pnm_write_error();
|
||||
if ( fwrite(planeV + i * strideV, w, 1, outfile) < 1 )
|
||||
pnm_write_error();
|
||||
}
|
||||
} /* end if pnm_type */
|
||||
|
||||
} else if (pnm_mode == PNM_ASCII_MODE) {
|
||||
|
||||
if (pnm_type == PNM_TYPE_PPM) {
|
||||
if ( fprintf(outfile, "P3\n%d %d\n255\n", w, h) < 0 )
|
||||
pnm_write_error();
|
||||
for (i=0; i <= w * h * 3 - 16 ; i += 15) {
|
||||
if ( fprintf(outfile, PNM_LINE_OF_ASCII,
|
||||
PNM_LINE15(rgbimage,i) ) < 0 ) pnm_write_error();
|
||||
}
|
||||
while (i < (w * h * 3) ) {
|
||||
if ( fprintf(outfile, "%03d ", rgbimage[i]) < 0 )
|
||||
pnm_write_error();
|
||||
i++;
|
||||
}
|
||||
if ( fputc('\n', outfile) < 0 ) pnm_write_error();
|
||||
} else if ( (pnm_type == PNM_TYPE_PGM) ||
|
||||
(pnm_type == PNM_TYPE_PGMYUV) ) {
|
||||
|
||||
/* different header for pgm and pgmyuv. pgmyuv is 'higher' */
|
||||
if (pnm_type == PNM_TYPE_PGM) {
|
||||
if ( fprintf(outfile, "P2\n%d %d\n255\n", w, h) < 0 )
|
||||
pnm_write_error();
|
||||
} else { /* PNM_TYPE_PGMYUV */
|
||||
if ( fprintf(outfile, "P2\n%d %d\n255\n", w, h*3/2) < 0 )
|
||||
pnm_write_error();
|
||||
}
|
||||
|
||||
/* output Y plane for both PGM and PGMYUV */
|
||||
for (j=0; j<h; j++) {
|
||||
curline = planeY + strideY * j;
|
||||
for (i=0; i <= w - 16; i+=15) {
|
||||
if ( fprintf(outfile, PNM_LINE_OF_ASCII,
|
||||
PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
|
||||
}
|
||||
while (i < w ) {
|
||||
if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
|
||||
pnm_write_error();
|
||||
i++;
|
||||
}
|
||||
if ( fputc('\n', outfile) < 0 ) pnm_write_error();
|
||||
}
|
||||
|
||||
/* also output U and V planes fpr PGMYUV */
|
||||
if (pnm_type == PNM_TYPE_PGMYUV) {
|
||||
w = w / 2;
|
||||
h = h / 2;
|
||||
for (j=0; j<h; j++) {
|
||||
curline = planeU + strideU * j;
|
||||
for (i=0; i<= w-16; i+=15) {
|
||||
if ( fprintf(outfile, PNM_LINE_OF_ASCII,
|
||||
PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
|
||||
}
|
||||
while (i < w ) {
|
||||
if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
|
||||
pnm_write_error();
|
||||
i++;
|
||||
}
|
||||
if ( fputc('\n', outfile) < 0 ) pnm_write_error();
|
||||
|
||||
curline = planeV + strideV * j;
|
||||
for (i=0; i<= w-16; i+=15) {
|
||||
if ( fprintf(outfile, PNM_LINE_OF_ASCII,
|
||||
PNM_LINE15(curline,i) ) < 0 ) pnm_write_error();
|
||||
}
|
||||
while (i < w ) {
|
||||
if ( fprintf(outfile, "%03d ", curline[i]) < 0 )
|
||||
pnm_write_error();
|
||||
i++;
|
||||
}
|
||||
if ( fputc('\n', outfile) < 0 ) pnm_write_error();
|
||||
}
|
||||
}
|
||||
|
||||
} /* end if pnm_type */
|
||||
} /* end if pnm_mode */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Write a PNM image.
|
||||
*
|
||||
* This function gets called first if a PNM image has to be written to disk.
|
||||
* It contains the subdirectory framework and it calls pnm_write_pnm() to
|
||||
* actually write the image to disk.
|
||||
*
|
||||
* \param mpi The image to write.
|
||||
*
|
||||
* \return none The player will exit if anything goes wrong.
|
||||
*/
|
||||
|
||||
static void pnm_write_image(mp_image_t *mpi)
|
||||
{
|
||||
static int framenum = 0, framecounter = 0, subdircounter = 0;
|
||||
char buf[BUFLENGTH];
|
||||
static char subdirname[BUFLENGTH] = "";
|
||||
FILE *outfile;
|
||||
|
||||
if (!mpi) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: No image data supplied to video output driver\n", info.short_name );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Start writing to new subdirectory after a certain amount of frames */
|
||||
if ( framecounter == pnm_maxfiles ) {
|
||||
framecounter = 0;
|
||||
}
|
||||
|
||||
/* If framecounter is zero (or reset to zero), increment subdirectory
|
||||
* number and create the subdirectory.
|
||||
* If pnm_subdirs is not set, do nothing. */
|
||||
if ( !framecounter && pnm_subdirs ) {
|
||||
subdircounter++;
|
||||
snprintf(subdirname, BUFLENGTH, "%s%08d", pnm_subdirs, subdircounter);
|
||||
snprintf(buf, BUFLENGTH, "%s/%s", pnm_outdir, subdirname);
|
||||
pnm_mkdir(buf, 0); /* This function only returns if creation was
|
||||
successful. If not, the player will exit. */
|
||||
}
|
||||
|
||||
framenum++;
|
||||
framecounter++;
|
||||
|
||||
/* snprintf the full pathname of the outputfile */
|
||||
snprintf(buf, BUFLENGTH, "%s/%s/%08d.%s", pnm_outdir, subdirname,
|
||||
framenum, pnm_file_extension);
|
||||
|
||||
if ( (outfile = fopen(buf, "wb") ) == NULL ) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name,
|
||||
"Unable to create output file.");
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n",
|
||||
info.short_name, "This error has occurred",
|
||||
strerror(errno) );
|
||||
return;
|
||||
}
|
||||
|
||||
pnm_write_pnm(outfile, mpi);
|
||||
|
||||
fclose(outfile);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static uint32_t draw_image(mp_image_t *mpi)
|
||||
{
|
||||
if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Planar */
|
||||
if (mpi->flags & MP_IMGFLAG_YUV) { /* Planar YUV */
|
||||
pnm_write_image(mpi);
|
||||
return VO_TRUE;
|
||||
} else { /* Planar RGB */
|
||||
return VO_FALSE;
|
||||
}
|
||||
} else { /* Packed */
|
||||
if (mpi->flags & MP_IMGFLAG_YUV) { /* Packed YUV */
|
||||
return VO_FALSE;
|
||||
} else { /* Packed RGB */
|
||||
pnm_write_image(mpi);
|
||||
return VO_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return VO_FALSE;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int draw_frame(uint8_t *src[])
|
||||
{
|
||||
mp_msg(MSGT_VO, MSGL_V, "%s: draw_frame() is called!\n", info.short_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int draw_slice(uint8_t *src[], int stride[], int w, int h,
|
||||
int x, int y)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int query_format(uint32_t format)
|
||||
{
|
||||
/* Ensure that for PPM we get Packed RGB and for PGM(YUV) we get
|
||||
* Planar YUV */
|
||||
if (pnm_type == PNM_TYPE_PPM) {
|
||||
if (format == IMGFMT_RGB24) {
|
||||
return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
|
||||
}
|
||||
} else if ( (pnm_type == PNM_TYPE_PGM) || (pnm_type == PNM_TYPE_PGMYUV) ) {
|
||||
if (format == IMGFMT_YV12) {
|
||||
return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int control(uint32_t request, void *data)
|
||||
{
|
||||
switch (request) {
|
||||
case VOCTRL_QUERY_FORMAT:
|
||||
return query_format(*((uint32_t*)data));
|
||||
case VOCTRL_DRAW_IMAGE:
|
||||
return draw_image(data);
|
||||
}
|
||||
return VO_NOTIMPL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void uninit(void)
|
||||
{
|
||||
free(pnm_subdirs);
|
||||
pnm_subdirs = NULL;
|
||||
free(pnm_outdir);
|
||||
pnm_outdir = NULL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void check_events(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void draw_osd(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void flip_page (void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#undef BUFLENGTH
|
||||
#undef PNM_RAW_MODE
|
||||
#undef PNM_ASCII_MODE
|
||||
#undef PNM_TYPE_PPM
|
||||
#undef PNM_TYPE_PGM
|
||||
#undef PNM_TYPE_PGMYUV
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
231
libvo/vo_tga.c
231
libvo/vo_tga.c
@ -1,231 +0,0 @@
|
||||
/*
|
||||
* TARGA video output
|
||||
*
|
||||
* This video output module writes TARGA uncompressed files in 15, 24 and 32
|
||||
* bit BGR format.
|
||||
*
|
||||
* to select the output format use the format filter:
|
||||
* mplayer -vo tga -vf format=bgr15 ...
|
||||
* mplayer -vo tga -vf format=bgr24 ...
|
||||
* mplayer -vo tga -vf format=bgr32 ...
|
||||
*
|
||||
* The 16 bit files are loaded without problem from Gimp and ImageMagick but
|
||||
* give an error with entice (a visualizer from the enlightenment package
|
||||
* that uses the imlib2 package).
|
||||
*
|
||||
* In 32-bit mode the alpha channel is set to 255 (0xff). For big-endian
|
||||
* machines, TGA_ALPHA32 changes from 0xff000000 to 0x000000ff, and
|
||||
* TGA_SHIFT32 from 0 to 8.
|
||||
*
|
||||
* I need to fill the alpha channel because entice considers that alpha
|
||||
* channel (and displays nothing, only the background!), but ImageMagick
|
||||
* (the program display) or gimp doesn't care.
|
||||
*
|
||||
* Maybe it is possible (with a compilation switch) to avoid the fill of
|
||||
* the alpha channel and work outside MPlayer (if needed).
|
||||
*
|
||||
* Daniele Forghieri ( guru@digitalfantasy.it )
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "mp_msg.h"
|
||||
#include "video_out.h"
|
||||
#include "video_out_internal.h"
|
||||
|
||||
static const vo_info_t info =
|
||||
{
|
||||
"Targa output",
|
||||
"tga",
|
||||
"Daniele Forghieri - guru@digitalfantasy.it",
|
||||
""
|
||||
};
|
||||
|
||||
|
||||
const LIBVO_EXTERN (tga)
|
||||
|
||||
/* locals vars */
|
||||
static int frame_num = 0;
|
||||
|
||||
static void tga_make_header(uint8_t *h, int dx, int dy, int bpp)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 18; i++) {
|
||||
switch (i) {
|
||||
case 2:
|
||||
*h = 0x02;
|
||||
break;
|
||||
|
||||
case 12:
|
||||
*h = dx & 0xff;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
*h = (dx >> 8) & 0xff;
|
||||
break;
|
||||
|
||||
case 14:
|
||||
*h = dy & 0xff;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
*h = (dy >> 8) & 0xff;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
*h = bpp;
|
||||
break;
|
||||
|
||||
case 17:
|
||||
*h = 0x20;
|
||||
break;
|
||||
|
||||
default:
|
||||
*h = 0;
|
||||
}
|
||||
++h;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int write_tga( char *file, int bpp, int dx, int dy, uint8_t *buf, int stride)
|
||||
{
|
||||
int er;
|
||||
FILE *fo;
|
||||
|
||||
fo = fopen(file, "wb");
|
||||
if (fo != NULL) {
|
||||
uint8_t hdr[18];
|
||||
|
||||
er = 0;
|
||||
tga_make_header(hdr, dx, dy, bpp);
|
||||
if (fwrite(hdr, sizeof(hdr), 1, fo) == 1) {
|
||||
int wb;
|
||||
|
||||
wb = ((bpp + 7) / 8) * dx;
|
||||
while (dy-- > 0) {
|
||||
if (fwrite(buf, wb, 1, fo) != 1) {
|
||||
er = 4;
|
||||
break;
|
||||
}
|
||||
buf += stride;
|
||||
}
|
||||
}
|
||||
else {
|
||||
er = 2;
|
||||
}
|
||||
|
||||
fclose(fo);
|
||||
}
|
||||
else {
|
||||
er = 1;
|
||||
}
|
||||
|
||||
if (er) {
|
||||
fprintf(stderr, "Error writing file [%s]\n", file);
|
||||
}
|
||||
return er;
|
||||
}
|
||||
|
||||
static uint32_t draw_image(mp_image_t* mpi)
|
||||
{
|
||||
char file[20 + 1];
|
||||
|
||||
snprintf (file, 20, "%08d.tga", ++frame_num);
|
||||
|
||||
write_tga( file,
|
||||
mpi->bpp,
|
||||
mpi->w,
|
||||
mpi->h,
|
||||
mpi->planes[0],
|
||||
mpi->stride[0]);
|
||||
|
||||
return VO_TRUE;
|
||||
}
|
||||
|
||||
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void draw_osd(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void flip_page (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int draw_frame(uint8_t * src[])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int query_format(uint32_t format)
|
||||
{
|
||||
switch(format){
|
||||
case IMGFMT_BGR15LE:
|
||||
case IMGFMT_BGR24:
|
||||
case IMGFMT_BGRA:
|
||||
return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void uninit(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void check_events(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int preinit(const char *arg)
|
||||
{
|
||||
if(arg) {
|
||||
mp_tmsg(MSGT_VO,MSGL_WARN, "[VO_TGA] Unknown subdevice: %s.\n",arg);
|
||||
return ENOSYS;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int control(uint32_t request, void *data)
|
||||
{
|
||||
switch (request) {
|
||||
case VOCTRL_DRAW_IMAGE:
|
||||
return draw_image(data);
|
||||
|
||||
case VOCTRL_QUERY_FORMAT:
|
||||
return query_format(*((uint32_t*)data));
|
||||
}
|
||||
return VO_NOTIMPL;
|
||||
}
|
Loading…
Reference in New Issue
Block a user