?? output.h
字號(hào):
/* * Copyright (C) 2005-2008 gulikoza, mtrooper * * This program 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. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* $Id$ */#ifndef OUTPUT_ENUM#define OUTPUT_ENUMenum OUTPUT { OVERLAY = 0, GDI = 1, DDRAW = 2, OPENGL = 3 };#endif // OUTPUT_ENUM#ifdef USES_BASECLASS#ifndef OUTPUT_H#define OUTPUT_H// Deinterlace methods#include "deinterlace/Deinterlacer.h"#include "deinterlace/WeaveDeinterlacer.h"#include "deinterlace/DiscardDeinterlacer.h"#include "deinterlace/MeanDeinterlacer.h"#include "deinterlace/BlendDeinterlacer.h"#include "memcpy.h"#if (C_HAS_LIBPOSTPROC)#include "main.h"extern "C" {#include <postproc/postprocess.h>}#endif#define MODULE "Output"// Output method base classclass Output {private:protected: bool half; int width, height; SDL_Surface * surface; Uint32 format; Deinterlacer * deinterlacer; MEM_COPY MemCopy;#if (C_HAS_LIBPOSTPROC) deint ppDeint; pp_mode_t * ppMode; pp_context_t * ppContext; unsigned char * ppsrc[3]; unsigned char * ppdst[3];#endif void Render(unsigned char *ptr[], unsigned char *src[], deint * d) {#if (C_HAS_LIBPOSTPROC) if(sdl.ppEnabled) { if(SDL_memcmp(&ppDeint, d, sizeof(deint))) { SDL_memcpy(&ppDeint, d, sizeof(deint)); if(ppContext != NULL) { _aligned_free(ppsrc[0]); _aligned_free(ppsrc[1]); _aligned_free(ppsrc[2]); _aligned_free(ppdst[0]); _aligned_free(ppdst[1]); _aligned_free(ppdst[2]); pp_free_context(ppContext); } ppContext = pp_get_context(width, height, PP_FORMAT_420); LOG_MSG("Creating %dx%d PP buffers", d->width, d->height); ppsrc[0] = (unsigned char *)_aligned_malloc(ppDeint.dst_pitch[2] * ppDeint.height, 64); ppsrc[1] = (unsigned char *)_aligned_malloc(ppDeint.dst_pitch[0] * ppDeint.height>>1, 64); ppsrc[2] = (unsigned char *)_aligned_malloc(ppDeint.dst_pitch[1] * ppDeint.height>>1, 64); ppdst[0] = (unsigned char *)_aligned_malloc(ppDeint.dst_pitch[2] * ppDeint.height, 64); ppdst[1] = (unsigned char *)_aligned_malloc(ppDeint.dst_pitch[0] * ppDeint.height>>1, 64); ppdst[2] = (unsigned char *)_aligned_malloc(ppDeint.dst_pitch[1] * ppDeint.height>>1, 64); } unsigned char * tmp[3]; tmp[0] = ppsrc[1]; tmp[1] = ppsrc[2]; tmp[2] = ppsrc[0]; deinterlacer->Render(tmp, src, &ppDeint); // Postprocess wants YUV, we have UVY ppDeint.dst_pitch[0] = d->dst_pitch[2]; ppDeint.dst_pitch[2] = d->dst_pitch[1]; pp_postprocess(ppsrc, ppDeint.dst_pitch, ppdst, ppDeint.dst_pitch, ppDeint.width, ppDeint.height, NULL, 0, ppMode, ppContext, PP_FORMAT_420); ppDeint.dst_pitch[0] = d->dst_pitch[0]; ppDeint.dst_pitch[2] = d->dst_pitch[2]; // Copy to output MemCopy(ptr[2], ppdst[0], ppDeint.dst_pitch[2] * ppDeint.height); MemCopy(ptr[0], ppdst[1], ppDeint.dst_pitch[0] * (ppDeint.height>>1)); MemCopy(ptr[1], ppdst[2], ppDeint.dst_pitch[1] * (ppDeint.height>>1)); } else { deinterlacer->Render(ptr, src, d); }#else deinterlacer->Render(ptr, src, d);#endif }public: Output():half(false),surface(NULL),deinterlacer(NULL)#if (C_HAS_LIBPOSTPROC) ,ppMode(NULL),ppContext(NULL)#endif {#ifdef HAVE_ALTIVEC_H if(SDL_HasAltiVec()) { MemCopy = IPTV_memcpy; LOG_MSG("Using Altivec optimizations"); } else#endif#if (C_HOSTCPU == X86) || (C_HOSTCPU == X86_64) if(SDL_HasSSE2()) { MemCopy = sse_memcpy; LOG_MSG("Using SSE2 optimizations"); } else if(SDL_HasSSE()) { MemCopy = sse_memcpy; LOG_MSG("Using SSE optimizations"); } else if(SDL_Has3DNow()) { MemCopy = mmx_memcpy; LOG_MSG("Using 3DNow optimizations"); } else if(SDL_HasMMX()) { MemCopy = mmx_memcpy; LOG_MSG("Using MMX optimizations"); } else#endif { MemCopy = IPTV_memcpy; LOG_MSG("Using unoptimized copy"); }#if (C_HAS_LIBPOSTPROC) SDL_memset(&ppDeint, 0, sizeof(deint)); ppMode = pp_get_mode_by_name_and_quality((char*)sdl.ppMode.c_str(), 1);#endif } virtual int Create(int, int, Uint32, SDL_Surface *) = 0; virtual int CopyData(struct Buffer *) = 0; virtual int SwapBuffers(SDL_Rect *) = 0; virtual void Free(void) = 0; virtual void SetDeinterlace(char d) { if(deinterlacer) delete deinterlacer; LOG_MSG("Setting deinterlace mode: %d", d); switch (d) { case DEINT_WEAVE: deinterlacer = new WeaveDeinterlacer(); break; case DEINT_DISCARD: deinterlacer = new DiscardDeinterlacer(); break; case DEINT_MEAN: deinterlacer = new MeanDeinterlacer; break; case DEINT_BLEND: deinterlacer = new BlendDeinterlacer; break; } } virtual ~Output() { if(deinterlacer) delete deinterlacer; deinterlacer = NULL;#if (C_HAS_LIBPOSTPROC) if(ppContext != NULL) { _aligned_free(ppsrc[0]); _aligned_free(ppsrc[1]); _aligned_free(ppsrc[2]); _aligned_free(ppdst[0]); _aligned_free(ppdst[1]); _aligned_free(ppdst[2]); pp_free_context(ppContext); } pp_free_mode(ppMode);#endif }};#undef MODULE#include "overlay.h"#include "ddraw.h"#include "opengl.h"#endif // OUTPUT_H#endif // USES_BASECLASS
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -