1
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:33:46 +01:00

cleanup - round 2.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8047 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
pontscho 2002-11-02 17:07:19 +00:00
parent e5f9c4e035
commit b91a0c5654
7 changed files with 173 additions and 142 deletions

View File

@ -15,7 +15,7 @@ endif
CFLAGS = $(OPTIMIZE) $(INCDIR) $(DEBUG)
SRCS = wm/ws.c wm/wsxdnd.c app.c interface.c cfg.c \
bitmap/bitmap.c bitmap/png/png.c \
bitmap/bitmap.c \
skin/skin.c skin/font.c skin/cut.c \
mplayer/mplayer.c mplayer/widgets.c mplayer/play.c \
mplayer/gtk/menu.c mplayer/gtk/mb.c mplayer/gtk/about.c mplayer/gtk/pl.c mplayer/gtk/sb.c mplayer/gtk/fs.c mplayer/gtk/opts.c mplayer/gtk/url.c mplayer/gtk/eq.c

View File

@ -3,8 +3,94 @@
#include <stdlib.h>
#include <string.h>
#include <png.h>
#include "../../mp_msg.h"
#include "bitmap.h"
int pngRead( unsigned char * fname,txSample * bf )
{
unsigned char header[8];
png_structp png;
png_infop info;
png_infop endinfo;
png_bytep * row_p;
png_bytep palette = NULL;
int color;
png_uint_32 i;
FILE *fp=fopen( fname,"rb" );
if ( !fp )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] file read error ( %s ).\n",fname );
return 1;
}
fread( header,1,8,fp );
if ( !png_check_sig( header,8 ) ) return 1;
png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
info=png_create_info_struct( png );
endinfo=png_create_info_struct( png );
png_init_io( png,fp );
png_set_sig_bytes( png,8 );
png_read_info( png,info );
png_get_IHDR( png,info,&bf->Width,&bf->Height,&bf->BPP,&color,NULL,NULL,NULL );
row_p=(png_bytep *)malloc( sizeof( png_bytep ) * bf->Height );
if ( !row_p )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] Not enough memory for row buffer.\n" );
return 2;
}
bf->Image=(png_bytep)malloc( png_get_rowbytes( png,info ) * bf->Height );
if ( !bf->Image )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] Not enough memory for image buffer.\n" );
return 2;
}
for ( i=0; i < bf->Height; i++ ) row_p[i]=&bf->Image[png_get_rowbytes( png,info ) * i];
png_read_image( png,row_p );
free( row_p );
#if 0
if ( color == PNG_COLOR_TYPE_PALETTE )
{
int cols;
png_get_PLTE( png,info,(png_colorp *)&palette,&cols );
}
#endif
if ( color&PNG_COLOR_MASK_ALPHA )
{
if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY_ALPHA ) bf->BPP*=2;
else bf->BPP*=4;
}
else
{
if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY ) bf->BPP*=1;
else bf->BPP*=3;
}
png_read_end( png,endinfo );
png_destroy_read_struct( &png,&info,&endinfo );
if ( fclose( fp ) != 0 )
{
free( bf->Image );
free( palette );
return 1;
}
bf->ImageSize=bf->Width * bf->Height * ( bf->BPP / 8 );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] filename: %s.\n",fname );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] size: %dx%d bits: %d\n",bf->Width,bf->Height,bf->BPP );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] imagesize: %lu\n",bf->ImageSize );
return 0;
}
int conv24to32( txSample * bf )
{
unsigned char * tmpImage;

View File

@ -11,9 +11,6 @@ typedef struct _txSample
char * Image;
} txSample;
#include "png/png.h"
#include "../../mp_msg.h"
extern int bpRead( char * fname, txSample * bf );
extern int conv24to32( txSample * bf );
extern void Convert32to1( txSample * in,txSample * out,int adaptivlimit );

View File

@ -3,8 +3,94 @@
#include <stdlib.h>
#include <string.h>
#include <png.h>
#include "../../mp_msg.h"
#include "bitmap.h"
int pngRead( unsigned char * fname,txSample * bf )
{
unsigned char header[8];
png_structp png;
png_infop info;
png_infop endinfo;
png_bytep * row_p;
png_bytep palette = NULL;
int color;
png_uint_32 i;
FILE *fp=fopen( fname,"rb" );
if ( !fp )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] file read error ( %s ).\n",fname );
return 1;
}
fread( header,1,8,fp );
if ( !png_check_sig( header,8 ) ) return 1;
png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
info=png_create_info_struct( png );
endinfo=png_create_info_struct( png );
png_init_io( png,fp );
png_set_sig_bytes( png,8 );
png_read_info( png,info );
png_get_IHDR( png,info,&bf->Width,&bf->Height,&bf->BPP,&color,NULL,NULL,NULL );
row_p=(png_bytep *)malloc( sizeof( png_bytep ) * bf->Height );
if ( !row_p )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] Not enough memory for row buffer.\n" );
return 2;
}
bf->Image=(png_bytep)malloc( png_get_rowbytes( png,info ) * bf->Height );
if ( !bf->Image )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] Not enough memory for image buffer.\n" );
return 2;
}
for ( i=0; i < bf->Height; i++ ) row_p[i]=&bf->Image[png_get_rowbytes( png,info ) * i];
png_read_image( png,row_p );
free( row_p );
#if 0
if ( color == PNG_COLOR_TYPE_PALETTE )
{
int cols;
png_get_PLTE( png,info,(png_colorp *)&palette,&cols );
}
#endif
if ( color&PNG_COLOR_MASK_ALPHA )
{
if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY_ALPHA ) bf->BPP*=2;
else bf->BPP*=4;
}
else
{
if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY ) bf->BPP*=1;
else bf->BPP*=3;
}
png_read_end( png,endinfo );
png_destroy_read_struct( &png,&info,&endinfo );
if ( fclose( fp ) != 0 )
{
free( bf->Image );
free( palette );
return 1;
}
bf->ImageSize=bf->Width * bf->Height * ( bf->BPP / 8 );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] filename: %s.\n",fname );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] size: %dx%d bits: %d\n",bf->Width,bf->Height,bf->BPP );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] imagesize: %lu\n",bf->ImageSize );
return 0;
}
int conv24to32( txSample * bf )
{
unsigned char * tmpImage;

View File

@ -11,9 +11,6 @@ typedef struct _txSample
char * Image;
} txSample;
#include "png/png.h"
#include "../../mp_msg.h"
extern int bpRead( char * fname, txSample * bf );
extern int conv24to32( txSample * bf );
extern void Convert32to1( txSample * in,txSample * out,int adaptivlimit );

View File

@ -1,126 +0,0 @@
#include <stdlib.h>
#include "./png.h"
#include <png.h>
typedef struct
{
unsigned int Width;
unsigned int Height;
unsigned int Depth;
unsigned int Alpha;
unsigned int Components;
unsigned char * Data;
unsigned char * Palette;
} pngRawInfo;
int pngLoadRawF( FILE *fp,pngRawInfo *pinfo )
{
unsigned char header[8];
png_structp png;
png_infop info;
png_infop endinfo;
png_bytep data;
png_bytep * row_p;
png_uint_32 width,height;
int depth,color;
png_uint_32 i;
if ( !pinfo ) return 1;
fread( header,1,8,fp );
if ( !png_check_sig( header,8 ) ) return 1;
png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
info=png_create_info_struct( png );
endinfo=png_create_info_struct( png );
png_init_io( png,fp );
png_set_sig_bytes( png,8 );
png_read_info( png,info );
png_get_IHDR( png,info,&width,&height,&depth,&color,NULL,NULL,NULL );
pinfo->Width=width;
pinfo->Height=height;
pinfo->Depth=depth;
data=( png_bytep ) malloc( png_get_rowbytes( png,info )*height );
row_p=( png_bytep * ) malloc( sizeof( png_bytep )*height );
for ( i=0; i < height; i++ ) row_p[i]=&data[png_get_rowbytes( png,info )*i];
png_read_image( png,row_p );
free( row_p );
if ( color == PNG_COLOR_TYPE_PALETTE )
{
int cols;
png_get_PLTE( png,info,( png_colorp * ) &pinfo->Palette,&cols );
}
else pinfo->Palette=NULL;
if ( color&PNG_COLOR_MASK_ALPHA )
{
if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY_ALPHA ) pinfo->Components=2;
else pinfo->Components=4;
pinfo->Alpha=8;
}
else
{
if ( color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY ) pinfo->Components=1;
else pinfo->Components=3;
pinfo->Alpha=0;
}
pinfo->Data=data;
png_read_end( png,endinfo );
png_destroy_read_struct( &png,&info,&endinfo );
return 0;
}
int pngLoadRaw( const char * filename,pngRawInfo * pinfo )
{
int result;
FILE *fp=fopen( filename,"rb" );
if ( !fp ) return 1;
result=pngLoadRawF( fp,pinfo );
if ( fclose( fp ) != 0 )
{
if ( result )
{
free( pinfo->Data );
free( pinfo->Palette );
}
return 1;
}
return 0;
}
int pngRead( unsigned char * fname,txSample * bf )
{
pngRawInfo raw;
if ( pngLoadRaw( fname,&raw ) )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] file read error ( %s ).\n",fname );
return 1;
}
bf->Width=raw.Width;
bf->Height=raw.Height;
bf->BPP=( raw.Depth * raw.Components );
bf->ImageSize=bf->Width * bf->Height * ( bf->BPP / 8 );
if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL )
{
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] Not enough memory for image buffer.\n" );
return 2;
}
memcpy( bf->Image,raw.Data,bf->ImageSize );
free( raw.Data );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] filename: %s.\n",fname );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] size: %dx%d bits: %d\n",bf->Width,bf->Height,bf->BPP );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[png] imagesize: %lu\n",bf->ImageSize );
return 0;
}

View File

@ -1,9 +0,0 @@
#ifndef __MYPNG
#define __MYPNG
#include "../bitmap.h"
extern int pngRead( unsigned char * fname, txSample * bf );
#endif