[Mplayer-cvslog] CVS: main/libmpcodecs vd_libmpeg2.c,NONE,1.1 vd_mpng.c,NONE,1.1 Makefile,1.10,1.11 TODO,1.1,1.2 vd.c,1.13,1.14

Arpi of Ize arpi at mplayer.dev.hu
Sat Mar 9 03:18:35 CET 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mplayer:/var/tmp.root/cvs-serv25504

Modified Files:
	Makefile TODO vd.c 
Added Files:
	vd_libmpeg2.c vd_mpng.c 
Log Message:
mpng, libmpeg2 added, none of them finished :(

--- NEW FILE ---
#include <stdio.h>
#include <stdlib.h>

#include "config.h"
#include "mp_msg.h"

#include "vd_internal.h"

static vd_info_t info = 
{
	"MPEG 1/2 Video decoder",
	"libmpeg2",
	VFM_MPEG,
	"A'rpi",
	"Aaron & Walken",
	"native"
};

LIBVD_EXTERN(libmpeg2)

#include "libmpdemux/parse_es.h"

#include "libvo/video_out.h"
#include "libmpeg2/mpeg2.h"
#include "libmpeg2/mpeg2_internal.h"

extern picture_t *picture;	// exported from libmpeg2/decode.c

// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
    return CONTROL_UNKNOWN;
}

// init driver
static int init(sh_video_t *sh){
    mpeg2_init();
    picture->pp_options=0; //divx_quality;
    // send seq header to the decoder:  *** HACK ***
    mpeg2_decode_data(NULL,videobuffer,videobuffer+videobuf_len,0);
    mpeg2_allocate_image_buffers (picture);
    return 1;
}

// uninit driver
static void uninit(sh_video_t *sh){
    mpeg2_free_image_buffers (picture);
}

// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
    mp_image_t* mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_DRAW_CALLBACK,
	sh->disp_w, sh->disp_h);
    mpeg2_decode_data(sh->video_out, data, data+len,flags&3); // decode
    return mpi;
}


--- NEW FILE ---
#include <stdio.h>
#include <stdlib.h>

#include "config.h"
#include "mp_msg.h"

#ifdef HAVE_PNG

#include <png.h>

#include "bswap.h"
#include "postproc/rgb2rgb.h"
#include "libvo/fastmemcpy.h"

#include "vd_internal.h"

static vd_info_t info = {
	"PNG Images decoder",
	"mpng",
	VFM_MPNG,
	"A'rpi",
	".so, based on mpng.c",
	"uses libpng, 8bpp modes not supported yet"
};

LIBVD_EXTERN(mpng)

static unsigned int out_fmt=0;

static int last_w=-1;
static int last_h=-1;
static int last_c=-1;

// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
    return CONTROL_UNKNOWN;
}

// init driver
static int init(sh_video_t *sh){
    last_w=-1;
    return 1;
}

// uninit driver
static void uninit(sh_video_t *sh){
}

//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);

static int    pngPointer;
static int    pngLength;

static void pngReadFN( png_structp pngstr,png_bytep buffer,png_size_t size )
{
 char * p = pngstr->io_ptr;
 if(size>pngLength-pngPointer && pngLength>=pngPointer) size=pngLength-pngPointer;
 memcpy( buffer,(char *)&p[pngPointer],size );
 pngPointer+=size;
}

// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
    png_structp     png;
    png_infop       info;
    png_infop       endinfo;
//    png_bytep       data;
    png_bytep     * row_p;
    png_uint_32     png_width=0,png_height=0;
    char	  * palette = NULL;
    int             depth,color;
    png_uint_32     i;
    mp_image_t* mpi;

    if(len<=0) return NULL; // skipped frame
    
 png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
 info=png_create_info_struct( png );
 endinfo=png_create_info_struct( png );

 pngPointer=8;
 pngLength=len;
 png_set_read_fn( png,data,pngReadFN );
 png_set_sig_bytes( png,8 );
 png_read_info( png,info );
 png_get_IHDR( png,info,&png_width,&png_height,&depth,&color,NULL,NULL,NULL );

 png_set_bgr( png );

 switch( info->color_type ) {
   case PNG_COLOR_TYPE_GRAY_ALPHA:
      mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry gray scaled png with alpha channel not supported at moment.\n" );
      break;
   case PNG_COLOR_TYPE_GRAY:
   case PNG_COLOR_TYPE_PALETTE:
      out_fmt=IMGFMT_BGR8;
      break;
   case PNG_COLOR_TYPE_RGB_ALPHA:
      out_fmt=IMGFMT_BGR32;
      break;
   case PNG_COLOR_TYPE_RGB:
      out_fmt=IMGFMT_BGR24;
      break;
   default:
      mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry, unsupported PNG colorspace: %d.\n" ,info->color_type);
 }

 // (re)init libvo if image parameters changed (width/height/colorspace)
 if(last_w!=png_width || last_h!=png_height || last_c!=out_fmt){
    last_w=png_width; last_h=png_height; last_c=out_fmt;
    if(!out_fmt) return NULL;
    mpcodecs_config_vo(sh,png_width,png_height,out_fmt);
 }

#if 0
 switch( info->color_type )
  {
   case PNG_COLOR_TYPE_GRAY_ALPHA: printf( "[png] used GrayA -> stripping alpha channel\n" ); break;
   case PNG_COLOR_TYPE_GRAY:       printf( "[png] used Gray -> rgb\n" ); break;
   case PNG_COLOR_TYPE_PALETTE:    printf( "[png] used palette -> rgb\n" ); break;
   case PNG_COLOR_TYPE_RGB_ALPHA:  printf( "[png] used RGBA -> stripping alpha channel\n" ); break;
   case PNG_COLOR_TYPE_RGB:        printf( "[png] read rgb datas.\n" ); break;
  }
#endif

    mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, 
	png_width,png_height);
    if(!mpi) return NULL;

// Let's DECODE!
 row_p=(png_bytep*)malloc( sizeof( png_bytep ) * png_height );
//png_get_rowbytes( png,info ) 
 for ( i=0; i < png_height; i++ ) row_p[i]=mpi->planes[0] + mpi->stride[0]*i;
 png_read_image( png,row_p );
 free( row_p );
 
 //png_get_PLTE( png,info,(png_colorp*)&pal,&cols );
 
 png_read_end( png,endinfo );
 png_destroy_read_struct( &png,&info,&endinfo );

    return mpi;
}

#endif

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Makefile	8 Mar 2002 07:14:34 -0000	1.10
+++ Makefile	9 Mar 2002 02:18:33 -0000	1.11
@@ -3,7 +3,7 @@
 
 LIBNAME = libmpcodecs.a
 
-SRCS=dec_video.c vd.c vd_null.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_rle.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c
+SRCS=dec_video.c vd.c vd_null.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_rle.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_mpng.c vd_libmpeg2.c
 
 OBJS=$(SRCS:.c=.o)
 

Index: TODO
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/TODO,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TODO	8 Mar 2002 07:15:50 -0000	1.1
+++ TODO	9 Mar 2002 02:18:33 -0000	1.2
@@ -3,7 +3,11 @@
 - vo_config callbacks to ffmpeg, cinepak
 - better mpi support to xanim (now it's EXPORT but could be better)
 - fix initial postprocessing flags (divx_quality)
+- add common postprocessing filter support (export qscale array)
 - IP buffering for NUV
+- finish MPNG (8bpp support)
+- IPB buffering to libmpeg2
+- review authors
 
 DONE:
 #define VFM_CINEPAK 13
@@ -24,8 +28,6 @@
 #define VFM_ROQVIDEO 19
 #define VFM_CYUV 16
 #define VFM_NUV 15
-
-TODO:
-
 #define VFM_MPNG 21
 #define VFM_MPEG 1
+

Index: vd.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- vd.c	8 Mar 2002 07:14:34 -0000	1.13
+++ vd.c	9 Mar 2002 02:18:33 -0000	1.14
@@ -40,6 +40,8 @@
 extern vd_functions_t mpcodecs_vd_roqvideo;
 extern vd_functions_t mpcodecs_vd_cyuv;
 extern vd_functions_t mpcodecs_vd_nuv;
+extern vd_functions_t mpcodecs_vd_mpng;
+extern vd_functions_t mpcodecs_vd_libmpeg2;
 
 vd_functions_t* mpcodecs_vd_drivers[] = {
         &mpcodecs_vd_null,
@@ -73,6 +75,10 @@
 #ifdef USE_XANIM
         &mpcodecs_vd_xanim,
 #endif
+#ifdef HAVE_PNG
+        &mpcodecs_vd_mpng,
+#endif
+        &mpcodecs_vd_libmpeg2,
 	NULL
 };
 




More information about the MPlayer-cvslog mailing list