[Mplayer-cvslog] CVS: main/libmpcodecs vd_hmblck.c,NONE,1.1 Makefile,1.98,1.99 img_format.c,1.6,1.7 img_format.h,1.11,1.12 vd.c,1.68,1.69

Arpi of Ize arpi at mplayerhq.hu
Wed Jun 18 02:34:37 CEST 2003


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

Modified Files:
	Makefile img_format.c img_format.h vd.c 
Added Files:
	vd_hmblck.c 
Log Message:
HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
based on patch by Alex <d18c7db at hotmail.com>


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

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

#include "vd_internal.h"

#define TEMP_BUF_SIZE (720*576)

static vd_info_t info = {
	"Hauppauge Macroblock/NV12 Decoder",
	"hmblck",
	"Alex <d18c7db at hotmail.com>, A'rpi",
	"Alex <d18c7db at hotmail.com>",
	"uncompressed"
};

LIBVD_EXTERN(hmblck)

static void de_macro_y(unsigned char* dst,unsigned char* src,int dstride,int w,int h){
    unsigned int y;
    // descramble Y plane
    for (y=0; y<h; y+=16) {
	unsigned int x;
        for (x=0; x<w; x+=16) {
	    unsigned int i;
            for (i=0; i<16; i++) {
                memcpy(dst + x + (y+i)*dstride, src, 16);
                src+=16;
            }
        }
    }
}

static void de_macro_uv(unsigned char* dstu,unsigned char* dstv,unsigned char* src,int dstride,int w,int h){
    unsigned int y;
    // descramble U/V plane
    for (y=0; y<h; y+=16) {
	unsigned int x;
        for (x=0; x<w; x+=8) {
	    unsigned int i;
            for (i=0; i<16; i++) {
		int idx=x + (y+i)*dstride;
		dstu[idx+0]=src[0]; dstv[idx+0]=src[1];
		dstu[idx+1]=src[2]; dstv[idx+1]=src[3];
		dstu[idx+2]=src[4]; dstv[idx+2]=src[5];
		dstu[idx+3]=src[6]; dstv[idx+3]=src[7];
		dstu[idx+4]=src[8]; dstv[idx+4]=src[9];
		dstu[idx+5]=src[10]; dstv[idx+5]=src[11];
		dstu[idx+6]=src[12]; dstv[idx+6]=src[13];
		dstu[idx+7]=src[14]; dstv[idx+7]=src[15];
                src+=16;
            }
        }
    }
}

/*************************************************************************
 * convert a nv12 buffer to yv12
 */
static int nv12_to_yv12(void *data, int len, mp_image_t* mpi) {
    unsigned int Y_size  = mpi->width * mpi->height;
    unsigned int UV_size = mpi->chroma_width * mpi->chroma_height;
    unsigned int idx;
    unsigned char *dst_Y = mpi->planes[0];
    unsigned char *dst_U = mpi->planes[1];
    unsigned char *dst_V = mpi->planes[2];
    unsigned char *src   = data + Y_size;

    // sanity check raw stream
    if ( (len != (Y_size + (UV_size<<1))) ) {
        mp_msg(MSGT_DECVIDEO, MSGL_ERR,
               "hmblck: Image size inconsistent with data size.\n");
        return 0;
    }
    if ( (mpi->width > 720) || (mpi->height > 576) ) {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,
               "hmblck: Image size is too big.\n");
        return 0;
    }
    if (mpi->num_planes != 3) {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,
               "hmblck: Incorrect number of image planes.\n");
        return 0;
    }

    // luma data is easy, just copy it
    memcpy(dst_Y, data, Y_size);

    // chroma data is interlaced UVUV... so deinterlace it
    for(idx=0; idx<UV_size; idx++ ) {
        *(dst_U + idx) = *(src + (idx<<1) + 0); 
        *(dst_V + idx) = *(src + (idx<<1) + 1);
    }
    return 1;
}

/*************************************************************************
 * 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){
    return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->format);
}
/*************************************************************************
 * uninit driver
 */
static void uninit(sh_video_t *sh){
}
/*************************************************************************
 * decode a frame
 */
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
    mp_image_t* mpi;

    if(len<=0) return NULL; // skipped frame

    mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
        sh->disp_w, sh->disp_h);
    if(!mpi) return NULL;

    if(sh->format == IMGFMT_HM12) {
        //if(!de_macro(sh, data, len, flags, mpi)) return NULL;
	de_macro_y(mpi->planes[0],data,mpi->stride[0],mpi->w,mpi->h);
	de_macro_uv(mpi->planes[1],mpi->planes[2],data+mpi->w*mpi->h,mpi->stride[1],mpi->w/2,mpi->h/2);
    } else {
	if(!nv12_to_yv12(data, len, mpi)) return NULL;
    }

    return mpi;
}
/*************************************************************************/

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- Makefile	8 Jun 2003 20:27:25 -0000	1.98
+++ Makefile	18 Jun 2003 00:34:34 -0000	1.99
@@ -10,7 +10,7 @@
 AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT)
 
 VIDEO_SRCS_LIB=vd_libmpeg2.c vd_nuv.c vd_lzo.c
-VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_huffyuv.c vd_mpegpes.c vd_svq1.c vd_lcl.c vd_mtga.c vd_sgi.c
+VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_hmblck.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_huffyuv.c vd_mpegpes.c vd_svq1.c vd_lcl.c vd_mtga.c vd_sgi.c
 VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_xanim.c vd_xvid.c vd_libdv.c vd_qtvideo.c vd_theora.c
 VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT)
 

Index: img_format.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/img_format.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- img_format.c	30 Jan 2003 09:14:58 -0000	1.6
+++ img_format.c	18 Jun 2003 00:34:34 -0000	1.7
@@ -32,6 +32,7 @@
 	case IMGFMT_422P: return("Planar 422P");
 	case IMGFMT_411P: return("Planar 411P");
 	case IMGFMT_NV12: return("Planar NV12");
+        case IMGFMT_HM12: return("Planar NV12 Macroblock");
 	case IMGFMT_IUYV: return("Packed IUYV");
 	case IMGFMT_IY41: return("Packed IY41");
 	case IMGFMT_IYU1: return("Packed IYU1");

Index: img_format.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/img_format.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- img_format.h	30 Jan 2003 09:14:58 -0000	1.11
+++ img_format.h	18 Jun 2003 00:34:34 -0000	1.12
@@ -49,6 +49,7 @@
 #define IMGFMT_444P 0x50343434
 #define IMGFMT_422P 0x50323234
 #define IMGFMT_411P 0x50313134
+#define IMGFMT_HM12 0x32314D48
 
 /* Packed YUV Formats */
 

Index: vd.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- vd.c	11 May 2003 18:29:07 -0000	1.68
+++ vd.c	18 Jun 2003 00:34:34 -0000	1.69
@@ -39,6 +39,7 @@
 extern vd_functions_t mpcodecs_vd_odivx;
 extern vd_functions_t mpcodecs_vd_divx4;
 extern vd_functions_t mpcodecs_vd_raw;
+extern vd_functions_t mpcodecs_vd_hmblck;
 extern vd_functions_t mpcodecs_vd_xanim;
 extern vd_functions_t mpcodecs_vd_msrle;
 extern vd_functions_t mpcodecs_vd_msvidc;
@@ -89,6 +90,7 @@
 #endif
         &mpcodecs_vd_lzo,
         &mpcodecs_vd_raw,
+        &mpcodecs_vd_hmblck,
         &mpcodecs_vd_msrle,
         &mpcodecs_vd_msvidc,
         &mpcodecs_vd_fli,



More information about the MPlayer-cvslog mailing list