[Mplayer-cvslog] CVS: main cyuv.c,NONE,1.1 codec-cfg.c,1.60,1.61 codec-cfg.h,1.34,1.35 dec_video.c,1.82,1.83 Makefile,1.133,1.134

Mike Melanson melanson at mplayer.dev.hu
Fri Jan 4 06:57:02 CET 2002


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

Modified Files:
	codec-cfg.c codec-cfg.h dec_video.c Makefile 
Added Files:
	cyuv.c 
Log Message:
integrated Tim Ferguson's native CYUV decoder


--- NEW FILE ---
/* ------------------------------------------------------------------------
 * Creative YUV Video Decoder
 *
 * Dr. Tim Ferguson, 2001.
 * For more details on the algorithm:
 *         http://www.csse.monash.edu.au/~timf/videocodec.html
 *
 * This is a very simple predictive coder.  A video frame is coded in YUV411
 * format.  The first pixel of each scanline is coded using the upper four
 * bits of its absolute value.  Subsequent pixels for the scanline are coded
 * using the difference between the last pixel and the current pixel (DPCM).
 * The DPCM values are coded using a 16 entry table found at the start of the
 * frame.  Thus four bits per component are used and are as follows:
 *     UY VY YY UY VY YY UY VY...
 * This code assumes the frame width will be a multiple of four pixels.  This
 * should probably be fixed.
 * ------------------------------------------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

/* ------------------------------------------------------------------------
 * This function decodes a buffer containing a CYUV encoded frame.
 *
 * buf - the input buffer to be decoded
 * size - the size of the input buffer
 * frame - the output frame buffer (UYVY format)
 * width - the width of the output frame
 * height - the height of the output frame
 * bit_per_pixel - ignored for now: may be used later for conversions.
 */
void decode_cyuv(unsigned char *buf, int size, unsigned char *frame, int width, int height, int bit_per_pixel)
{
int i, xpos, ypos, cur_Y = 0, cur_U = 0, cur_V = 0;
char *delta_y_tbl, *delta_c_tbl, *ptr;

	delta_y_tbl = buf + 16;
	delta_c_tbl = buf + 32;
	ptr = buf + (16 * 3);

	for(ypos = 0; ypos < height; ypos++)
		for(xpos = 0; xpos < width; xpos += 4)
			{
			if(xpos == 0)		/* first pixels in scanline */
				{
				cur_U = *(ptr++);
				cur_Y = (cur_U & 0x0f) << 4;
				cur_U = cur_U & 0xf0;
				*frame++ = cur_U;
				*frame++ = cur_Y;

				cur_V = *(ptr++);
				cur_Y = (cur_Y + delta_y_tbl[cur_V & 0x0f]) & 0xff;
				cur_V = cur_V & 0xf0;
				*frame++ = cur_V;
				*frame++ = cur_Y;
				}
			else			/* subsequent pixels in scanline */
				{
				i = *(ptr++);
				cur_U = (cur_U + delta_c_tbl[i >> 4]) & 0xff;
				cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
				*frame++ = cur_U;
				*frame++ = cur_Y;

				i = *(ptr++);
				cur_V = (cur_V + delta_c_tbl[i >> 4]) & 0xff;
				cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
				*frame++ = cur_V;
				*frame++ = cur_Y;
				}

			i = *(ptr++);
			cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
			*frame++ = cur_U;
			*frame++ = cur_Y;

			cur_Y = (cur_Y + delta_y_tbl[i >> 4]) & 0xff;
			*frame++ = cur_V;
			*frame++ = cur_Y;
			}
}


Index: codec-cfg.c
===================================================================
RCS file: /cvsroot/mplayer/main/codec-cfg.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- codec-cfg.c	1 Jan 2002 20:04:54 -0000	1.60
+++ codec-cfg.c	4 Jan 2002 05:56:52 -0000	1.61
@@ -240,6 +240,7 @@
 		"cinepak",
 		"qtrle",
 		"nuv",
+		"cyuv",
 		NULL
 	};
         char **drv=audioflag?audiodrv:videodrv;

Index: codec-cfg.h
===================================================================
RCS file: /cvsroot/mplayer/main/codec-cfg.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- codec-cfg.h	1 Jan 2002 20:04:54 -0000	1.34
+++ codec-cfg.h	4 Jan 2002 05:56:52 -0000	1.35
@@ -52,6 +52,7 @@
 #define VFM_CINEPAK 13
 #define VFM_QTRLE 14
 #define VFM_NUV 15
+#define VFM_CYUV 16
 
 #ifndef GUID_TYPE
 #define GUID_TYPE

Index: dec_video.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_video.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- dec_video.c	2 Jan 2002 17:11:49 -0000	1.82
+++ dec_video.c	4 Jan 2002 05:56:52 -0000	1.83
@@ -135,6 +135,25 @@
   int width,
   int height);
 
+void *decode_cinepak_init(void);
+
+void decode_cinepak(
+  void *context,
+  unsigned char *buf,
+  int size,
+  unsigned char *frame,
+  int width,
+  int height,
+  int bit_per_pixel);
+
+void decode_cyuv(
+  unsigned char *buf,
+  int size,
+  unsigned char *frame,
+  int width,
+  int height,
+  int bit_per_pixel);
+
 //**************************************************************************//
 //             The OpenDivX stuff:
 //**************************************************************************//
@@ -558,6 +577,12 @@
  case VFM_NUV:
     sh_video->our_out_buffer = (char *)memalign(64, sh_video->disp_w*sh_video->disp_h*3/2);
    break;
+ case VFM_CYUV: {
+   int bpp=((out_fmt&255)+7)/8;
+   sh_video->our_out_buffer =
+     (char*)memalign(64, sh_video->disp_w*sh_video->disp_h*3);
+   break;
+   }
  }
 }
   sh_video->inited=1;
@@ -831,6 +856,11 @@
         ((out_fmt&255)+7)/8);
     blit_frame = 3;
     break;
+ case VFM_CYUV:
+   decode_cyuv(start, in_size, sh_video->our_out_buffer,
+      sh_video->disp_w, sh_video->disp_h, (out_fmt==IMGFMT_YUY2)?16:(out_fmt&255));
+   blit_frame = 3;
+   break;
 } // switch
 //------------------------ frame decoded. --------------------
 

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -r1.133 -r1.134
--- Makefile	31 Dec 2001 15:29:46 -0000	1.133
+++ Makefile	4 Jan 2002 05:56:52 -0000	1.134
@@ -22,7 +22,7 @@
 # a BSD compatible 'install' program
 INSTALL = install
 
-SRCS_COMMON = adpcm.c xacodec.c cpudetect.c mp_msg.c ac3-iec958.c dec_audio.c dec_video.c msvidc.c cinepak.c fli.c qtrle.c codec-cfg.c cfgparser.c my_profile.c RTjpegN.c minilzo.c nuppelvideo.c
+SRCS_COMMON = cyuv.c adpcm.c xacodec.c cpudetect.c mp_msg.c ac3-iec958.c dec_audio.c dec_video.c msvidc.c cinepak.c fli.c qtrle.c codec-cfg.c cfgparser.c my_profile.c RTjpegN.c minilzo.c nuppelvideo.c
 SRCS_MENCODER = mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/img_format.c
 SRCS_MPLAYER = mplayer.c $(SRCS_COMMON) find_sub.c subreader.c lirc_mp.c mixer.c spudec.c
 




More information about the MPlayer-cvslog mailing list