⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spuhandler.cc

📁 Linux下比较早的基于命令行的DVD播放器
💻 CC
字号:
//// Copyright (c) 2004 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// 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//------------------------------------------------------------------------------#include "SPUHandler.h"#include "output/SystemTimer.h"//------------------------------------------------------------------------------using output::sdl::SPUHandler;using output::SystemTimer;using dvd::packet::PacketQueue;//------------------------------------------------------------------------------inline unsigned SPUHandler::getColor(displayEntity_t displayEntity,                                      unsigned char pixel) const{    return palette[ getColorIndex(displayEntity, pixel) ];}//------------------------------------------------------------------------------//------------------------------------------------------------------------------SPUHandler::SPUHandler(PacketQueue& inputQueue, SystemTimer& timer) :    output::SPUHandler(inputQueue, timer){}//------------------------------------------------------------------------------void SPUHandler::embedInto(SDL_Overlay* overlay){    embedInto(PICTURE, overlay);    embedInto(BUTTON, overlay);}//------------------------------------------------------------------------------void SPUHandler::setPalette(const unsigned* palette){    memcpy(this->palette, palette, sizeof(this->palette));}//------------------------------------------------------------------------------void SPUHandler::embedInto(displayEntity_t displayEntity, SDL_Overlay* overlay){    if (!isDisplayable(displayEntity)) return;    size_t pictureWidth, startX, startY, spuWidth, spuHeight;    const unsigned char* pictureData =        getVisiblePictureData(displayEntity,                               pictureWidth, startX, startY, spuWidth, spuHeight);    if (isWideScreen()) {        startY -= 8;    }    size_t lineStart = overlay->w * startY + startX;    size_t chromaLineStart = (overlay->w/2) * (startY/2) + startX / 2;    for(size_t i = 0; i<spuHeight; ++i, lineStart+=overlay->w)     {        size_t yOffset = lineStart;        size_t uOffset = chromaLineStart;        size_t pictureLineNo = i;        if (isWideScreen()) {            pictureLineNo *= 3;            pictureLineNo += 2;            pictureLineNo /= 4;        }        const unsigned char* pictureLine = pictureData + pictureLineNo * pictureWidth;        for(size_t j = 0; j<spuWidth; j+=2,                 pictureLine+=2, yOffset+=2, ++uOffset)         {            unsigned char pixel0 = pictureLine[0];            unsigned contrast0 = getContrast(displayEntity, pixel0);            unsigned color0 = getColor(displayEntity, pixel0);            unsigned char pixel1 = pictureLine[1];            unsigned color1 = getColor(displayEntity, pixel1);            unsigned contrast1 = getContrast(displayEntity, pixel1);                        if (contrast0>0) {                unsigned y0 = (color0>>16)&0xff;                unsigned y1 = overlay->pixels[0][yOffset];                unsigned y = (y0*contrast0 + y1*(15-contrast0))/15;                overlay->pixels[0][yOffset] = y;            }            if (contrast1>0) {                unsigned y0 = (color1>>16)&0xff;                unsigned y1 = overlay->pixels[0][yOffset+1];                unsigned y = (y0*contrast1 + y1*(15-contrast1))/15;                overlay->pixels[0][yOffset+1] = y;            }                        if ((i%2)==0 && (contrast0>0 || contrast1>0)) {                unsigned c = (contrast0+contrast1)/2;                                unsigned u0 = (((color0>>8)&0xff) + ((color1>>8)&0xff))/2;                unsigned u1 = overlay->pixels[1][uOffset];                unsigned u = (u0*c + u1*(15-c))/15;                overlay->pixels[1][uOffset] = u;                unsigned v0 = (((color0>>0)&0xff) + ((color1>>0)&0xff))/2;                unsigned v1 = overlay->pixels[2][uOffset];                unsigned v = (v0*c + v1*(15-c))/15;                overlay->pixels[2][uOffset] = v;            }        }        if (i%2) {            chromaLineStart += overlay->w/2;        }    }}//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -