1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-20 22:02:59 +00:00

- removed YV12 support (builtin yv12->rgb conversion)

- removed built-in OSD rendering


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7927 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-10-26 16:05:47 +00:00
parent a614f0524d
commit 99820540ad

View File

@ -1,5 +1,3 @@
#define DISP
/* /*
* vo_png.c, Portable Network Graphics Renderer for Mplayer * vo_png.c, Portable Network Graphics Renderer for Mplayer
* *
@ -15,15 +13,10 @@
#include <errno.h> #include <errno.h>
#include <png.h> #include <png.h>
//#include "/usr/include/png.h"
#include "config.h" #include "config.h"
#include "video_out.h" #include "video_out.h"
#include "video_out_internal.h" #include "video_out_internal.h"
#include "sub.h"
#include "../postproc/rgb2rgb.h"
LIBVO_EXTERN (png) LIBVO_EXTERN (png)
@ -35,18 +28,8 @@ static vo_info_t vo_info =
"" ""
}; };
#define RGB 0
#define BGR 1
extern int verbose; extern int verbose;
int z_compression = Z_NO_COMPRESSION; int z_compression = Z_NO_COMPRESSION;
static int image_width;
static int image_height;
static int image_format;
static uint8_t *image_data=NULL;
static int bpp = 24;
static int cspace = RGB;
static int framenum = 0; static int framenum = 0;
struct pngdata { struct pngdata {
@ -55,39 +38,10 @@ struct pngdata {
png_infop info_ptr; png_infop info_ptr;
enum {OK,ERROR} status; enum {OK,ERROR} status;
}; };
static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
vo_draw_alpha_rgb24(w, h, src, srca, stride, image_data + 3 * (y0 * image_width + x0), 3 * image_width);
}
static uint32_t 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) config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
{ {
image_height = height;
image_width = width;
image_format = format;
//printf("Verbose level is %i\n", verbose);
switch(format) {
case IMGFMT_BGR24:
bpp = 24;
cspace = BGR;
break;
case IMGFMT_RGB24:
bpp = 24;
cspace = RGB;
break;
case IMGFMT_IYUV:
case IMGFMT_I420:
case IMGFMT_YV12:
bpp = 24;
cspace = BGR;
yuv2rgb_init(bpp,MODE_RGB);
image_data = malloc(image_width*image_height*3);
break;
default:
return 1;
}
if((z_compression >= 0) && (z_compression <= 9)) { if((z_compression >= 0) && (z_compression <= 9)) {
if(z_compression == 0) { if(z_compression == 0) {
@ -115,10 +69,10 @@ get_info(void)
} }
struct pngdata create_png (char * fname) struct pngdata create_png (char * fname, int image_width, int image_height, int swapped)
{ {
struct pngdata png; struct pngdata png;
/*png_structp png_ptr = png_create_write_struct /*png_structp png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn);*/ user_error_fn, user_warning_fn);*/
@ -174,14 +128,13 @@ struct pngdata create_png (char * fname)
if(verbose > 1) printf("PNG Write Info\n"); if(verbose > 1) printf("PNG Write Info\n");
png_write_info(png.png_ptr, png.info_ptr); png_write_info(png.png_ptr, png.info_ptr);
if(cspace) { if(swapped) {
if(verbose > 1) printf("PNG Set BGR Conversion\n"); if(verbose > 1) printf("PNG Set BGR Conversion\n");
png_set_bgr(png.png_ptr); png_set_bgr(png.png_ptr);
} }
png.status = OK; png.status = OK;
return png; return png;
} }
static uint8_t destroy_png(struct pngdata png) { static uint8_t destroy_png(struct pngdata png) {
@ -197,23 +150,18 @@ static uint8_t destroy_png(struct pngdata png) {
return 0; return 0;
} }
static uint32_t draw_frame(uint8_t * src[])
{
return -1;
}
static uint32_t draw_image(mp_image_t* mpi){ static uint32_t draw_image(mp_image_t* mpi){
char buf[100]; char buf[100];
int k, bppmul = bpp/8; int k;
struct pngdata png; struct pngdata png;
png_byte *row_pointers[image_height]; png_byte *row_pointers[mpi->h];
// if -dr or -slices then do nothing: // if -dr or -slices then do nothing:
if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE; if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
snprintf (buf, 100, "%08d.png", ++framenum); snprintf (buf, 100, "%08d.png", ++framenum);
png = create_png(buf); png = create_png(buf, mpi->w, mpi->h, mpi->flags&MP_IMGFLAG_SWAPPED);
if(png.status){ if(png.status){
printf("PNG Error in create_png\n"); printf("PNG Error in create_png\n");
@ -221,7 +169,7 @@ static uint32_t draw_image(mp_image_t* mpi){
} }
if(verbose > 1) printf("PNG Creating Row Pointers\n"); if(verbose > 1) printf("PNG Creating Row Pointers\n");
for ( k = 0; k < image_height; k++ ) for ( k = 0; k < mpi->h; k++ )
row_pointers[k] = mpi->planes[0]+mpi->stride[0]*k; row_pointers[k] = mpi->planes[0]+mpi->stride[0]*k;
//png_write_flush(png.png_ptr); //png_write_flush(png.png_ptr);
@ -235,56 +183,24 @@ static uint32_t draw_image(mp_image_t* mpi){
return VO_TRUE; return VO_TRUE;
} }
static void draw_osd(void) static void draw_osd(void){}
static void flip_page (void){}
static uint32_t draw_frame(uint8_t * src[])
{ {
if(image_data) vo_draw_text(image_width, image_height, draw_alpha); return -1;
}
static void flip_page (void)
{
char buf[100];
int k, bppmul = bpp/8;
struct pngdata png;
png_byte *row_pointers[image_height];
if((image_format == IMGFMT_YV12) || (image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420)) {
snprintf (buf, 100, "%08d.png", ++framenum);
png = create_png(buf);
if(png.status){
printf("PNG Error in create_png\n");
}
if(verbose > 1) printf("PNG Creating Row Pointers\n");
for ( k = 0; k < image_height; k++ ) row_pointers[k] = &image_data[image_width*k*bppmul];
//png_write_flush(png.png_ptr);
//png_set_flush(png.png_ptr, nrows);
if(verbose > 1) printf("PNG Writing Image Data\n");
png_write_image(png.png_ptr, row_pointers);
destroy_png(png);
}
} }
static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y ) static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )
{ {
uint8_t *dst = image_data + (image_width * y + x) * (bpp/8); return -1;
yuv2rgb(dst,src[0],src[1],src[2],w,h,image_width*(bpp/8),stride[0],stride[1]);
return 0;
} }
static uint32_t static uint32_t
query_format(uint32_t format) query_format(uint32_t format)
{ {
switch(format){ switch(format){
case IMGFMT_IYUV:
case IMGFMT_I420:
case IMGFMT_YV12:
return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE;
case IMGFMT_RGB|24: case IMGFMT_RGB|24:
case IMGFMT_BGR|24: case IMGFMT_BGR|24:
return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE; return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE;
@ -292,16 +208,9 @@ query_format(uint32_t format)
return 0; return 0;
} }
static void static void uninit(void){}
uninit(void)
{
if(image_data){ free(image_data);image_data=NULL;}
}
static void check_events(void){}
static void check_events(void)
{
}
static uint32_t preinit(const char *arg) static uint32_t preinit(const char *arg)
{ {