Mercurial > mplayer.hg
changeset 10689:c6c54f467984
TGA image output VO module
patch by Daniele Forghieri ( guru@digitalfantasy.it )
author | arpi |
---|---|
date | Sun, 24 Aug 2003 18:26:37 +0000 |
parents | c2331e3ef96a |
children | 164fda5feaa6 |
files | configure libvo/video_out.c libvo/vo_tga.c |
diffstat | 3 files changed, 267 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/configure Sun Aug 24 18:09:29 2003 +0000 +++ b/configure Sun Aug 24 18:26:37 2003 +0000 @@ -227,7 +227,8 @@ --enable-zr build with ZR360[56]7/ZR36060 support [autodetect] --enable-bl build with Blinkenlights support [disable] --enable-tdfxvid build with tdfx vid support [disable] - + --disable_tga disable targa output support [enable] + Audio output: --disable-ossaudio disable OSS sound support [autodetect] --disable-arts disable aRts sound support [autodetect] @@ -1120,6 +1121,7 @@ _3dfx=no _tdfxfb=no _tdfxvid=no +_tga=yes _directfb=auto _zr=auto _bl=no @@ -1318,6 +1320,8 @@ --enable-tdfxfb) _tdfxfb=yes ;; --disable-tdfxvid) _tdfxvid=no ;; --enable-tdfxvid) _tdfxvid=yes ;; + --disable-tga) _tga=no ;; + --enable-tga) _tga=yes ;; --disable-tdfxfb) _tdfxfb=no ;; --enable-directfb) _directfb=yes ;; --disable-directfb) _directfb=no ;; @@ -2591,6 +2595,17 @@ fi echores "$_tdfxfb" +echocheck "tga" +if test "$_tga" = yes ; then + _def_tga='#define HAVE_TGA 1' + _vosrc="$_vosrc vo_tga.c" + _vomodules="tga $_vomodules" +else + _def_tga='#undef HAVE_TGA' + _novomodules="tga $_novomodules" +fi +echores "$_tga" + echocheck "DirectFB headers presence" if test -z "$_inc_directfb" ; then for I in /usr/include /usr/local/include; do @@ -6065,6 +6080,7 @@ $_def_vesa $_def_xdpms $_def_aa +$_def_tga /* used by GUI: */ $_def_xshape
--- a/libvo/video_out.c Sun Aug 24 18:09:29 2003 +0000 +++ b/libvo/video_out.c Sun Aug 24 18:26:37 2003 +0000 @@ -104,6 +104,9 @@ #ifdef HAVE_TDFX_VID extern vo_functions_t video_out_tdfx_vid; #endif +#ifdef HAVE_TGA +extern vo_functions_t video_out_tga; +#endif vo_functions_t* video_out_drivers[] = { @@ -201,6 +204,9 @@ #if defined(CONFIG_VIDIX) && defined(HAVE_X11) &video_out_xvidix, #endif +#ifdef HAVE_TGA + &video_out_tga, +#endif NULL };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libvo/vo_tga.c Sun Aug 24 18:26:37 2003 +0000 @@ -0,0 +1,244 @@ +/* + * vo_tga.c: targa output + * + * this video output module write targa uncompressed file 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 file are loaded without problem from Gimp and ImageMagick but give an error + * with entice (a visualizer from the enlightenment package that use the imlib2 package). + * + * In 32 bit mode the alpha channel is set to 255 (0xff). I may not work with big endian + * machine (is probably enought to change the TGA_ALPHA32 from 0xff000000 to 0x000000ff). + * + * I need to fill the alpha channel because entice consider that alpha channel (and displays + * nothing, only the background!), but ImageMacick (the program display) or gimp doesn't + * care. + * + * maybe 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 ) + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <math.h> + +#include "config.h" +#include "video_out.h" +#include "video_out_internal.h" + +/* This must be changed for Motorola type processor ? */ +#define TGA_ALPHA32 0xff000000 + +static vo_info_t info = +{ + "Targa output", + "tga", + "Daniele Forghieri - guru@digitalfantasy.it", + "" +}; + + +LIBVO_EXTERN (tga) + +/* locals vars */ +static int frame_num = 0; +static void *line_buff; + +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; + if (bpp == 32) { + /* Setup the alpha channel for every pixel */ + while (dy-- > 0) { + uint32_t *d; + uint32_t *s; + int x; + + s = (uint32_t *)buf; + d = line_buff; + for(x = 0; x < dx; x++) { + *d++ = *s++ | TGA_ALPHA32; + } + if (fwrite(line_buff, wb, 1, fo) != 1) { + er = 4; + break; + } + buf += stride; + } + + } + else { + 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 uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format) +{ + /* buffer for alpha */ + if(line_buff){ free(line_buff); line_buff=NULL; } + if (format == (IMGFMT_BGR | 32)) { + line_buff = malloc(width * 4); + } + return 0; +} + +static void draw_osd(void) +{ +} + +static void flip_page (void) +{ + return; +} + +static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y) +{ + return -1; +} + +static uint32_t draw_frame(uint8_t * src[]) +{ + return -1; +} + +static uint32_t query_format(uint32_t format) +{ + switch(format){ + case IMGFMT_BGR|15: + case IMGFMT_BGR|24: + case IMGFMT_BGR|32: + return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; + } + return 0; +} + +static void uninit(void) +{ + if(line_buff){ free(line_buff); line_buff=NULL; } +} + +static void check_events(void) +{ +} + +static uint32_t preinit(const char *arg) +{ + if(arg) { + printf("vo_tga: Unknown subdevice: %s\n",arg); + return ENOSYS; + } + return 0; +} + +static uint32_t 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; +}