[Sumover-dev] [svn commit] r3953 - in vic/branches/mpeg4: . codec cpu video win32/ffmpeg win32/postproc

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Wed Dec 13 10:44:16 GMT 2006


Author: barz
Date: Wed Dec 13 10:43:06 2006
New Revision: 3953

Added:
   vic/branches/mpeg4/win32/postproc/
   vic/branches/mpeg4/win32/postproc/postprocess.h
Modified:
   vic/branches/mpeg4/codec/encoder-h264.cpp
   vic/branches/mpeg4/codec/x264encoder.cpp
   vic/branches/mpeg4/codec/x264encoder.h
   vic/branches/mpeg4/config_arch.h
   vic/branches/mpeg4/cpu/cpudetect.h
   vic/branches/mpeg4/module.cpp
   vic/branches/mpeg4/module.h
   vic/branches/mpeg4/render/color-swscale.cpp
   vic/branches/mpeg4/vic.vcproj
   vic/branches/mpeg4/video/deinterlace.cpp
   vic/branches/mpeg4/video/deinterlace.h
   vic/branches/mpeg4/win32/ffmpeg/common.h

Log:
add postproc/deinterlace support
reduce memcpy times for x264 encoder

Modified: vic/branches/mpeg4/codec/encoder-h264.cpp
==============================================================================
--- vic/branches/mpeg4/codec/encoder-h264.cpp	(original)
+++ vic/branches/mpeg4/codec/encoder-h264.cpp	Wed Dec 13 10:43:06 2006
@@ -4,11 +4,7 @@
 #include <math.h>
 #include <errno.h>
 #include <assert.h>
-#ifdef _WIN32
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
+#include <iostream>
 
 #include "inet.h"
 #include "net.h"
@@ -20,8 +16,7 @@
 
 #include "databuffer.h"
 #include "x264encoder.h"
-
-#include <iostream>
+#include "deinterlace.h"
 
 static Transmitter *tx;
 static RTP_BufferPool *pool;
@@ -47,11 +42,8 @@
     //UCHAR* bitstream;
 
     x264Encoder *enc;
-    DataBuffer *fIn;
     DataBuffer *fOut;
-    timeval timeStamp;
-    time_t prevTime;
-    unsigned short prevTimeMS;
+	Deinterlace deinterlacer;
 
     FILE *fptr;
 };
@@ -86,16 +78,13 @@
 H264Encoder::~H264Encoder()
 {
     delete enc;
-    delete fIn;
     delete fOut;
-    //fclose(fptr);
 }
 
 void H264Encoder::size(int w, int h)
 {
     debug_msg("H264: WxH %dx%d\n", w, h);
     Module::size(w, h);
-    fIn = new DataBuffer(w * h * 3 >> 1);
     fOut = new DataBuffer(w * h * 3 >> 1);
 }
 
@@ -148,23 +137,24 @@
     int frame_size = 0;
 
     tx->flush();
+
     if (!state) {
-	state = true;
-	size(vf->width_, vf->height_);
-	debug_msg("init x264 encoder with kbps:%d, fps:%d", kbps, fps);
-	enc->init(vf->width_, vf->height_, kbps, fps);
-	enc->setGOP(gop);
-	frame_size = vf->width_ * vf->height_;
-	//fptr = fopen("out.m4v", "w");
-	gettimeofday(&timeStamp, NULL);
-	prevTime = timeStamp.tv_sec;
-	prevTimeMS = timeStamp.tv_sec;
+	    state = true;
+	    size(vf->width_, vf->height_);
+	    debug_msg("init x264 encoder with kbps:%d, fps:%d", kbps, fps);
+	    enc->init(vf->width_, vf->height_, kbps, fps);
+	    enc->setGOP(gop);
+	    frame_size = vf->width_ * vf->height_;
+	    //fptr = fopen("out.m4v", "w");
     }
 
     frame_size = vf->width_ * vf->height_;
-    char *data = fIn->getData();
-    memcpy(data, vf->bp_, frame_size * 3 >> 1);
-    enc->encodeFrame(fIn);
+    // char *data = fIn->getData();
+    // memcpy(data, vf->bp_, frame_size * 3 >> 1);
+
+	deinterlacer.render(vf->bp_, vf->width_, vf->height_);
+	
+    enc->encodeFrame(vf->bp_);
 
     i_nal = enc->numNAL();
 
@@ -177,7 +167,7 @@
 	enc->getNALPacket(i, fOut);
 
 	sent_size += fOut->getDataSize();
-	data = fOut->getData();
+	char *data = fOut->getData();
 	//DEBUG
 	//fwrite(data, fOut->getFrameSize(), 1, fptr);
 

Modified: vic/branches/mpeg4/codec/x264encoder.cpp
==============================================================================
--- vic/branches/mpeg4/codec/x264encoder.cpp	(original)
+++ vic/branches/mpeg4/codec/x264encoder.cpp	Wed Dec 13 10:43:06 2006
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <inttypes.h>
+
 #include "x264encoder.h"
 #include "ffmpeg/avcodec.h"
 #include "databuffer.h"
@@ -33,8 +34,7 @@
 {
     x264 *enc = (x264 *) encoder;
     if (enc->h != NULL) {
-	x264_encoder_close(enc->h);
-	x264_picture_clean(&(enc->pic));
+	  x264_encoder_close(enc->h);
     }
     free(enc);
 }
@@ -82,45 +82,50 @@
     param->i_width = w;
     param->i_height = h;
 
-    x264_picture_alloc(&(enc->pic), X264_CSP_I420, param->i_width,
-		       param->i_height);
 
     x264_t *handle = x264_encoder_open(param);
     if (handle != NULL) {
-	enc->h = handle;
-	return true;
+	    enc->h = handle;
+	    return true;
     }
     else {
-	return false;
+	    return false;
     }
 }
 
-bool x264Encoder::encodeFrame(DataBuffer * in)
+bool x264Encoder::encodeFrame(uint8 *buf)
 {
     x264 *enc = (x264 *) encoder;
     x264_param_t *param = &(enc->param);
-    x264_picture_t *pic = &(enc->pic);
 
-    char *f = in->getData();
+
     int frame_size = param->i_width * param->i_height;
 
     //refresh 
     enc->i_nal = 0;
 
-    memcpy(pic->img.plane[0], f, frame_size);
-    memcpy(pic->img.plane[1], (f + frame_size), frame_size / 4);
-    memcpy(pic->img.plane[2], (f + frame_size * 5 / 4), frame_size / 4);
+    enc->pic.img.i_csp = X264_CSP_I420;
+	enc->pic.img.i_plane = 3;
+    enc->pic.i_type = X264_TYPE_AUTO;
+	enc->pic.img.i_stride[0] = param->i_width;
+	enc->pic.img.i_stride[1] = param->i_width/2;
+	enc->pic.img.i_stride[2] = param->i_width/2;
 
-    int result = x264_encoder_encode(enc->h, &(enc->nal), &(enc->i_nal), pic,
+
+    enc->pic.img.plane[0] = buf;
+    enc->pic.img.plane[1] = buf + frame_size;
+    enc->pic.img.plane[2] = buf + frame_size*5/4;
+
+    int result = x264_encoder_encode(enc->h, &(enc->nal), &(enc->i_nal), &(enc->pic),
 				     &(enc->pic_out));
 
     if (result < 0) {
-	isFrameEncoded = false;
-	return false;
+	  isFrameEncoded = false;
+	  return false;
     }
     else {
-	isFrameEncoded = true;
-	return true;
+	  isFrameEncoded = true;
+	  return true;
     }
 }
 

Modified: vic/branches/mpeg4/codec/x264encoder.h
==============================================================================
--- vic/branches/mpeg4/codec/x264encoder.h	(original)
+++ vic/branches/mpeg4/codec/x264encoder.h	Wed Dec 13 10:43:06 2006
@@ -1,6 +1,8 @@
 #ifndef _X264_ENCODER_H_
 #define _X264_ENCODER_H_
 
+typedef unsigned char uint8;
+
 class DataBuffer;
 class x264Encoder
 {
@@ -8,7 +10,7 @@
     x264Encoder();
     ~x264Encoder();
     bool init(int, int, int, int);
-    bool encodeFrame(DataBuffer *);
+    bool encodeFrame(uint8 *);
     int numNAL();
     bool getNALPacket(int, DataBuffer *);
     void setGOP(int);

Modified: vic/branches/mpeg4/config_arch.h
==============================================================================
--- vic/branches/mpeg4/config_arch.h	(original)
+++ vic/branches/mpeg4/config_arch.h	Wed Dec 13 10:43:06 2006
@@ -7,8 +7,16 @@
 
 #ifdef WIN32
 #define ARCH_X86
+#define RUNTIME_CPUDETECT
 #elif defined(WIN64)
 #define ARCH_X86_64
+#define RUNTIME_CPUDETECT
+#endif
+
+#ifdef ARCH_PPC
+#define HAVE_ALTIVEC_H
+#define ARCH_POWERPC
+#define HAVE_ALTIVEC
 #endif
 
 /* Only use during compliation */

Modified: vic/branches/mpeg4/cpu/cpudetect.h
==============================================================================
--- vic/branches/mpeg4/cpu/cpudetect.h	(original)
+++ vic/branches/mpeg4/cpu/cpudetect.h	Wed Dec 13 10:43:06 2006
@@ -3,6 +3,11 @@
 
 #include "config_arch.h"
 
+#ifdef __cplusplus
+extern "C" {
+
+#endif
+
 #define CPUTYPE_I386	3
 #define CPUTYPE_I486	4
 #define CPUTYPE_I586	5
@@ -74,6 +79,8 @@
 char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]);
 
 
-
+#ifdef __cplusplus
+}
+#endif
 #endif /* !CPUDETECT_H */
 

Modified: vic/branches/mpeg4/module.cpp
==============================================================================
--- vic/branches/mpeg4/module.cpp	(original)
+++ vic/branches/mpeg4/module.cpp	Wed Dec 13 10:43:06 2006
@@ -36,7 +36,6 @@
     "@(#) $Header$ (LBL)";
 #endif
 #include "module.h"
-// #include "deinterlace.h"
 
 char* Module::fttoa(int ft)
 {
@@ -130,7 +129,3 @@
 	return (Module::command(argc, argv));
 }
 
-void VideoFrame::deinterlace() {
-   // Deinterlace::Render(bp_, width_, height_);
-}
-

Modified: vic/branches/mpeg4/module.h
==============================================================================
--- vic/branches/mpeg4/module.h	(original)
+++ vic/branches/mpeg4/module.h	Wed Dec 13 10:43:06 2006
@@ -52,7 +52,6 @@
 	inline VideoFrame(u_int32_t ts, u_int8_t* bp, int w, int h,
 			  int layer) :
 		ts_(ts), bp_(bp), width_(w), height_(h), layer_(layer) { }
-	void deinterlace();
 
 	u_int32_t ts_;
 	u_int8_t* bp_;
@@ -63,10 +62,11 @@
 
 class YuvFrame : public VideoFrame {
     public:
-	inline YuvFrame(u_int32_t ts, u_int8_t* bp, u_int8_t* crvec,
+	    inline YuvFrame(u_int32_t ts, u_int8_t* bp, u_int8_t* crvec,
 			int w, int h, int layer=0) :
-		VideoFrame(ts, bp, w, h, layer), crvec_(crvec) {}
-	const u_int8_t* crvec_;
+			VideoFrame(ts, bp, w, h, layer), crvec_(crvec) {}
+
+	    const u_int8_t* crvec_;
 };
 
 class JpegFrame : public VideoFrame {

Modified: vic/branches/mpeg4/render/color-swscale.cpp
==============================================================================
--- vic/branches/mpeg4/render/color-swscale.cpp	(original)
+++ vic/branches/mpeg4/render/color-swscale.cpp	Wed Dec 13 10:43:06 2006
@@ -6,14 +6,9 @@
 #include "renderer.h"
 
 #include "config_arch.h"
-#ifdef WIN32
-#undef ARCH_X86
-#endif
 #include "ffmpeg/swscale.h"
 #include "ffmpeg/avutil.h"
-extern "C"{
 #include "cpu/cpudetect.h"
-}
 
 int available_cpu_flags = cpu_check();
 
@@ -113,7 +108,7 @@
 	    sws_src[1] = sws_src[0] + framesize_;
 	    sws_src[2] = sws_src[1] + framesize_/4;
 
-     	    sws_scale_ordered(sws_context, sws_src, sws_src_stride, 0, height_, sws_tar, sws_tar_stride);
+     	sws_scale_ordered(sws_context, sws_src, sws_src_stride, 0, height_, sws_tar, sws_tar_stride);
 	  }	
 	}
 protected:

Modified: vic/branches/mpeg4/vic.vcproj
==============================================================================
--- vic/branches/mpeg4/vic.vcproj	(original)
+++ vic/branches/mpeg4/vic.vcproj	Wed Dec 13 10:43:06 2006
@@ -499,7 +499,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="swscale-0.lib avutil-49.lib avcodec-51.lib libx264.lib tk84tsg.lib tcl84tsg.lib wsock32.lib Ws2_32.lib winmm.lib vfw32.lib uclmm.lib strmiids.lib quartz.lib Iphlpapi.lib Imm32.lib comctl32.lib"
+				AdditionalDependencies="swscale-0.lib avutil-49.lib avcodec-51.lib postproc-51.lib libx264.lib tk84tsg.lib tcl84tsg.lib wsock32.lib Ws2_32.lib winmm.lib vfw32.lib uclmm.lib strmiids.lib quartz.lib Iphlpapi.lib Imm32.lib comctl32.lib"
 				OutputFile=".\Debug_IPv6_XP/vic.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="TRUE"
@@ -14279,6 +14279,9 @@
 				RelativePath=".\video\crossbar.cpp">
 			</File>
 			<File
+				RelativePath=".\video\deinterlace.cpp">
+			</File>
+			<File
 				RelativePath="video\device.cpp">
 				<FileConfiguration
 					Name="Debug|Win32">
@@ -14580,6 +14583,9 @@
 					RelativePath="video\assistor-list.h">
 				</File>
 				<File
+					RelativePath=".\video\deinterlace.h">
+				</File>
+				<File
 					RelativePath="video\device-input.h">
 				</File>
 				<File
@@ -14594,13 +14600,6 @@
 			</Filter>
 		</Filter>
 		<Filter
-			Name="postproc"
-			Filter="">
-			<File
-				RelativePath=".\postproc\config.h">
-			</File>
-		</Filter>
-		<Filter
 			Name="cpu"
 			Filter="">
 			<File
@@ -14616,7 +14615,8 @@
 					<Tool
 						Name="VCCustomBuildTool"
 						Description="Assembling $(InputPath)"
-						CommandLine="nasmw.exe -f win32 -DPREFIX -o &quot;$(IntDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;"
+						CommandLine="nasmw.exe -f win32 -DPREFIX -o &quot;$(IntDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;
+"
 						Outputs="&quot;$(IntDir)\$(InputName).obj&quot;"/>
 				</FileConfiguration>
 			</File>

Modified: vic/branches/mpeg4/video/deinterlace.cpp
==============================================================================
--- vic/branches/mpeg4/video/deinterlace.cpp	(original)
+++ vic/branches/mpeg4/video/deinterlace.cpp	Wed Dec 13 10:43:06 2006
@@ -1,223 +1,64 @@
 #include "deinterlace.h"
 
 
-/*****************************************************************************
- * Local protypes
- *****************************************************************************/
-static void MergeGeneric(void *, const void *, const void *, size_t);
-#if defined(CAN_COMPILE_C_ALTIVEC)
-static void MergeAltivec(void *, const void *, const void *, size_t);
-#endif
-#if defined(CAN_COMPILE_MMX)
-static void MergeMMX(void *, const void *, const void *, size_t);
-#endif
-#if defined(CAN_COMPILE_SSE)
-static void MergeSSE2(void *, const void *, const void *, size_t);
-#endif
-#if defined(CAN_COMPILE_MMX) || defined(CAN_COMPILE_SSE)
-static void EndMMX(void);
-#endif
-
-// ***************************************************************
-static void (*Merge) (void *, const void *, const void *, size_t);
-static void (*EndMerge) (void);
-static uint8_t target[1280 * 1024 * 3 / 2];
-static int cpu_info;
-
-Deinterlace::Deinterlace()
-{
-    cpu_check();
-    init();
+extern "C"{
+#include "cpu/cpudetect.h"
 }
 
-void Deinterlace::cpu_check()
+int cpu_flags = cpu_check();
+
+Deinterlace::Deinterlace()
 {
-    cpu_info = CPU_CAPABILITY_SSE2;
+	context = NULL;
+	width_ = height_ = 0;
 }
 
-void Deinterlace::init()
+Deinterlace::~Deinterlace()
 {
-
-#if defined(CAN_COMPILE_C_ALTIVEC)
-    if (cpu_info & CPU_CAPABILITY_ALTIVEC) {
-	Merge = MergeAltivec;
-	EndMerge = NULL;
-    }
-#endif
-#if defined(CAN_COMPILE_SSE)
-    if (cpu_info & CPU_CAPABILITY_SSE2) {
-	Merge = MergeSSE2;
-	EndMerge = EndMMX;
-    }
-    else
-#endif
-#if defined(CAN_COMPILE_MMX)
-    if (cpu_info & CPU_CAPABILITY_MMX) {
-	Merge = MergeMMX;
-	EndMerge = EndMMX;
-    }
-    else
-#endif
-    {
-	Merge = MergeGeneric;
-	EndMerge = NULL;
-    }
+	if(context){
+		pp_free_context(context);
+		context = NULL;
+	}
 }
 
 
-static void MergeGeneric(void *_p_dest, const void *_p_s1,
-			 const void *_p_s2, size_t i_bytes)
+void Deinterlace::init(int width, int height)
 {
-    uint8_t *p_dest = (uint8_t *) _p_dest;
-    const uint8_t *p_s1 = (const uint8_t *) _p_s1;
-    const uint8_t *p_s2 = (const uint8_t *) _p_s2;
-    uint8_t *p_end = p_dest + i_bytes - 8;
-
-    while (p_dest < p_end) {
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-    }
-
-    p_end += 8;
-
-    while (p_dest < p_end) {
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-    }
-}
+	if(context){
+		pp_free_context(context);
+		context = NULL;
+	}
 
-#if defined(CAN_COMPILE_MMX)
-static void MergeMMX(void *_p_dest, const void *_p_s1, const void *_p_s2,
-		     size_t i_bytes)
-{
-    uint8_t *p_dest = (uint8_t *) _p_dest;
-    const uint8_t *p_s1 = (const uint8_t *) _p_s1;
-    const uint8_t *p_s2 = (const uint8_t *) _p_s2;
-    uint8_t *p_end = p_dest + i_bytes - 8;
-    while (p_dest < p_end) {
-	__asm__ __volatile__("movq %2,%%mm1;"
-			     "pavgb %1, %%mm1;"
-			     "movq %%mm1, %0":"=m"(*p_dest):"m"(*p_s1),
-			     "m"(*p_s2));
-	p_dest += 8;
-	p_s1 += 8;
-	p_s2 += 8;
-    }
-
-    p_end += 8;
-
-    while (p_dest < p_end) {
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-    }
-}
-#endif
+    int flags = 0;
+	flags |= (cpu_flags & FF_CPU_MMX ? PP_CPU_CAPS_MMX : 0);
+	flags |= (cpu_flags & FF_CPU_MMXEXT ? PP_CPU_CAPS_MMX2 : 0);
+	flags |= (cpu_flags & FF_CPU_3DNOW ? PP_CPU_CAPS_3DNOW : 0);
+	flags |= (cpu_flags & FF_CPU_ALTIVEC ? PP_CPU_CAPS_ALTIVEC : 0);
 
-#if defined(CAN_COMPILE_SSE)
-static void MergeSSE2(void *_p_dest, const void *_p_s1, const void *_p_s2,
-		      size_t i_bytes)
-{
-    uint8_t *p_dest = (uint8_t *) _p_dest;
-    const uint8_t *p_s1 = (const uint8_t *) _p_s1;
-    const uint8_t *p_s2 = (const uint8_t *) _p_s2;
-    while ((int) p_s1 % 16) {
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-    }
-    uint8_t *p_end = p_dest + i_bytes - 16;
-    while (p_dest < p_end) {
-	__asm__ __volatile__("movdqu %2,%%xmm1;"
-			     "pavgb %1, %%xmm1;"
-			     "movdqu %%xmm1, %0":"=m"(*p_dest):"m"(*p_s1),
-			     "m"(*p_s2));
-	p_dest += 16;
-	p_s1 += 16;
-	p_s2 += 16;
-    }
-
-    p_end += 16;
-
-    while (p_dest < p_end) {
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-    }
+	context = pp_get_context(width, height, PP_FORMAT_420 | flags);
+	mode = pp_get_mode_by_name_and_quality("de", 6);
 }
-#endif
 
-#if defined(CAN_COMPILE_MMX) || defined(CAN_COMPILE_SSE)
-static void EndMMX(void)
-{
-    __asm__ __volatile__("emms");
-}
-#endif
 
-#ifdef CAN_COMPILE_C_ALTIVEC
-static void MergeAltivec(void *_p_dest, const void *_p_s1,
-			 const void *_p_s2, size_t i_bytes)
+void Deinterlace::render(void *buf, int width, int height)
 {
-    uint8_t *p_dest = (uint8_t *) _p_dest;
-    const uint8_t *p_s1 = (const uint8_t *) _p_s1;
-    const uint8_t *p_s2 = (const uint8_t *) _p_s2;
-    uint8_t *p_end = p_dest + i_bytes - 16;
-
-    if (((int) p_s1 & 0xF) | ((int) p_s2 & 0xF) | ((int) p_dest & 0xF)) {
-	/* TODO Handle non 16-bytes aligned planes */
-	MergeGeneric(_p_dest, _p_s1, _p_s2, i_bytes);
-	return;
-    }
-
-    while (p_dest < p_end) {
-	vec_st(vec_avg(vec_ld(0, p_s1), vec_ld(0, p_s2)), 0, p_dest);
-	p_s1 += 16;
-	p_s2 += 16;
-	p_dest += 16;
-    }
-
-    p_end += 16;
-
-    while (p_dest < p_end) {
-	*p_dest++ = ((uint16_t) (*p_s1++) + (uint16_t) (*p_s2++)) >> 1;
-    }
-}
-#endif
+	if(width != width_ || height != height_){
+		init(width, height);
+	}
 
-//*******************************************************************
-void Deinterlace::RenderBlend(uint8_t * target, uint8_t * source, int w,
-			      int h)
-{
-    int i_plane;
+	srcStride[0] = width;
+	srcStride[1] = srcStride[2] = width/2;
 
-    /* Copy image and skip lines */
-    for (i_plane = 0; i_plane < 3; i_plane++) {
-	if (i_plane == 1) {
-	    w /= 2;
-	    h /= 2;
-	}
-	int framesize = w * h;
 
-	/* First line: simple copy */
-	memcpy(target, source, w);
-	uint8_t *p_in = source;
-	uint8_t *p_out = target + w;
-	uint8_t *p_out_end = target + framesize;
-
-	/* Remaining lines: mean value */
-	for (; p_out < p_out_end;) {
-	    Merge(p_out, p_in, p_in + w, w);
-	    p_out += w;
-	    p_in += w;
-	}
-	source += framesize;
-	target += framesize;
-    }
-    if (EndMerge)
-	EndMerge();
-}
+	int framesize = width*height;
+	src[0] = (uint8_t*)buf;
+	src[1] = src[0] + framesize;
+	src[2] = src[1] + framesize/4;
 
-void Deinterlace::Render(uint8_t * source, int w, int h)
-{
-    RenderBlend(target, source, w, h);
-    memcpy(source, target, w * h * 3 / 2);
+
+    pp_postprocess(src, srcStride,
+                   src, srcStride,
+                   width, height,
+                   NULL,  0,
+                   mode, context, 1);
 }

Modified: vic/branches/mpeg4/video/deinterlace.h
==============================================================================
--- vic/branches/mpeg4/video/deinterlace.h	(original)
+++ vic/branches/mpeg4/video/deinterlace.h	Wed Dec 13 10:43:06 2006
@@ -3,47 +3,28 @@
 
 #include <string.h>
 
-/*****************************************************************************
- * CPU capabilities
- *****************************************************************************/
-#define CPU_CAPABILITY_NONE    0
-#define CPU_CAPABILITY_486     (1<<0)
-#define CPU_CAPABILITY_586     (1<<1)
-#define CPU_CAPABILITY_PPRO    (1<<2)
-#define CPU_CAPABILITY_MMX     (1<<3)
-#define CPU_CAPABILITY_3DNOW   (1<<4)
-#define CPU_CAPABILITY_MMXEXT  (1<<5)
-#define CPU_CAPABILITY_SSE     (1<<6)
-#define CPU_CAPABILITY_SSE2    (1<<7)
-#define CPU_CAPABILITY_ALTIVEC (1<<16)
-#define CPU_CAPABILITY_FPU     (1<<31)
-//****************************************************************************
 typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-//****************************************************************************
+typedef  char int8_t;
 
-#define DEINTERLACE_DISCARD 1
-#define DEINTERLACE_MEAN    2
-#define DEINTERLACE_BLEND   3
-#define DEINTERLACE_BOB     4
-#define DEINTERLACE_LINEAR  5
-
-#ifndef WINDOWS
-#define CAN_COMPILE_SSE
-#define CAN_COMPILE_MMX
-#endif
-//****************************************************************************
-static class Deinterlace
+#include "cpu/cpudetect.h"
+#include <postproc/postprocess.h>
+
+// only used for YUV420
+class Deinterlace
 {
   public:
     Deinterlace();
-    static void Render(uint8_t * source, int w, int h);
-
-  protected:
-    void init();
-    void cpu_check();
-    static void RenderBlend(uint8_t * target, uint8_t * source, int w, int h);
+	~Deinterlace();
+    void init(int width, int height);
+	void render(void *buf, int width, int height);
+
+  private:
+    int width_, height_;
+	pp_mode_t	*mode;
+	pp_context_t	*context;
+	int srcStride[3];
+	uint8_t *src[3];
 
-} deinterlace;			// for gobal initialization
+};			
 
 #endif

Modified: vic/branches/mpeg4/win32/ffmpeg/common.h
==============================================================================
--- vic/branches/mpeg4/win32/ffmpeg/common.h	(original)
+++ vic/branches/mpeg4/win32/ffmpeg/common.h	Wed Dec 13 10:43:06 2006
@@ -26,6 +26,8 @@
 #ifndef COMMON_H
 #define COMMON_H
 
+#undef ARCH_X86
+
 #ifndef M_PI
 #define M_PI    3.14159265358979323846
 #endif

Added: vic/branches/mpeg4/win32/postproc/postprocess.h
==============================================================================
--- (empty file)
+++ vic/branches/mpeg4/win32/postproc/postprocess.h	Wed Dec 13 10:43:06 2006
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2001-2003 Michael Niedermayer (michaelni at gmx.at)
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef NEWPOSTPROCESS_H
+#define NEWPOSTPROCESS_H
+
+/**
+ * @file postprocess.h
+ * @brief
+ *     external api for the pp stuff
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LIBPOSTPROC_VERSION_INT ((51<<16)+(1<<8)+0)
+#define LIBPOSTPROC_VERSION     51.1.0
+#define LIBPOSTPROC_BUILD       LIBPOSTPROC_VERSION_INT
+
+#define LIBPOSTPROC_IDENT       "postproc" AV_STRINGIFY(LIBPOSTPROC_VERSION)
+
+#define PP_QUALITY_MAX 6
+
+#define QP_STORE_T int8_t
+
+typedef void pp_context_t;
+typedef void pp_mode_t;
+
+extern char *pp_help; ///< a simple help text
+
+void  pp_postprocess(uint8_t * src[3], int srcStride[3],
+                 uint8_t * dst[3], int dstStride[3],
+                 int horizontalSize, int verticalSize,
+                 QP_STORE_T *QP_store,  int QP_stride,
+                 pp_mode_t *mode, pp_context_t *ppContext, int pict_type);
+
+
+/**
+ * returns a pp_mode_t or NULL if an error occured
+ * name is the string after "-pp" on the command line
+ * quality is a number from 0 to PP_QUALITY_MAX
+ */
+pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality);
+void pp_free_mode(pp_mode_t *mode);
+
+pp_context_t *pp_get_context(int width, int height, int flags);
+void pp_free_context(pp_context_t *ppContext);
+
+#define PP_CPU_CAPS_MMX   0x80000000
+#define PP_CPU_CAPS_MMX2  0x20000000
+#define PP_CPU_CAPS_3DNOW 0x40000000
+#define PP_CPU_CAPS_ALTIVEC 0x10000000
+
+#define PP_FORMAT         0x00000008
+#define PP_FORMAT_420    (0x00000011|PP_FORMAT)
+#define PP_FORMAT_422    (0x00000001|PP_FORMAT)
+#define PP_FORMAT_411    (0x00000002|PP_FORMAT)
+#define PP_FORMAT_444    (0x00000000|PP_FORMAT)
+
+#define PP_PICT_TYPE_QP2  0x00000010 ///< MPEG2 style QScale
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif



More information about the Sumover-dev mailing list