📄 spuhandler.h
字号:
// 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#ifndef DXR3PLAYER_OUTPUT_SPUHANDLER_H#define DXR3PLAYER_OUTPUT_SPUHANDLER_H//------------------------------------------------------------------------------#include "StateTracker.h"#include "dvd/spu/SPUBuffer.h"#include "dvd/spu/SPU.h"#include "dvd/spu/Picture.h"#include "sched/Schedulable.h"#include "sched/WaitCondition.h"#include "util/Area.h"#include "util/Reference.h"//------------------------------------------------------------------------------namespace dvd { namespace packet {class TimedDataBlockPacket;} /* namespace dvd::packet */ } /* namespace dvd *///------------------------------------------------------------------------------namespace output {//------------------------------------------------------------------------------class Timer;//------------------------------------------------------------------------------/** * Base class for SPU handlers. This class implements the processing * and timing of SPUs. Display should be the responsibility of * children. */class SPUHandler : public sched::Schedulable, public output::StateTracker::ButtonHandler{private: /** * The display controller. It maintains a list of SPU control * sequences and times their execution. */ class DisplayController : public sched::Schedulable { private: /** * Type for the control sequences. */ typedef std::list<dvd::spu::ControlSequence*, DefaultAllocatorTemplate<dvd::spu::ControlSequence*> > controlSequences_t; /** * The SPU handler the display controller belongs to. */ SPUHandler& spuHandler; /** * Indicate if only forced should be displayed. */ bool forcedOnly; /** * Condition for the control sequence having any elements. */ sched::WaitCondition hasControlSequences; /** * The control sequences. */ controlSequences_t controlSequences; public: /** * Construct the display controller */ DisplayController(SPUHandler& spuHandler); /** * Run the display controller. */ virtual void run(); /** * Reset the display controller. */ void reset(); /** * Set whether only forced SPUs should be displayed. */ void setForcedOnly(bool fo); /** * Add an SPU to the display controller */ void addSPU(dvd::spu::SPU& spu); }; friend class DisplayController;protected: /** * A display entity within the SPU */ typedef enum displayEntity_t { /// The picture itself PICTURE, /// The currently selected button, if any BUTTON };private: /** * The display controller. */ DisplayController displayController; /** * The queue to read SPU packets from. */ dvd::packet::PacketQueue& inputQueue; /** * The timer to use. */ Timer& timer; /** * Buffer for the SPU. */ dvd::spu::SPUBuffer spuBuffer; /** * PTS of the current SPU. */ pts_t spuPTS; /** * The current SPU. */ dvd::spu::SPU spu;private: /** * The current picture to show. */ Reference<dvd::spu::Picture> picture; /** * The visible area of the picture, if there is a picture. */ Area pictureVisibleArea; /** * Indicate if the current picture is forced. */ bool pictureForced; /** * The color index for the current picture. */ int pictureColor; /** * The contrast for the current picture. */ int pictureContrast; /** * Indicate if a button should be shown. */ bool showButton; /** * The visible area of the picture for the current button, if a * button is to be displayed. */ Area buttonVisibleArea; /** * The color index for the current button. */ int buttonColor; /** * The contrast for the current button. */ int buttonContrast; /** * Indicate if the current picture is a widescreen one. */ bool wideScreen;public: /** * Initialize the SPU handler. */ SPUHandler(dvd::packet::PacketQueue& inputQueue, Timer& timer); /** * Process the SPU packets. */ virtual void run(); /** * Reset the SPU handler. */ void reset(); /** * Indicate if the current screen is widescreen. */ void setWideScreen(bool ws); /** * Determine if we are using widescreen. */ bool isWideScreen() const; /** * Show the button with the given data. */ virtual void highlightButton(int color, int contrast, size_t top, size_t bottom, size_t left, size_t right); /** * Clear a button. */ virtual void clearButton();protected: /** * Check if there is something to display. */ bool isDisplayable(displayEntity_t displayEntity) const; /** * Get the start of the visible picture area. */ const unsigned char* getVisiblePictureData(displayEntity_t displayEntity, size_t& pictureWidth, size_t& startX, size_t& startY, size_t& width, size_t& height) const; /** * Get the color index for the given pixel value. */ size_t getColorIndex(displayEntity_t displayEntity, unsigned pixel) const; /** * Get the contrast for the given pixel value. */ size_t getContrast(displayEntity_t displayEntity, unsigned pixel) const;private: /** * Process the given data packet. */ void processDataPacket(Reference<dvd::packet::TimedDataBlockPacket>& packet); /** * Set the picture from the given control sequence. */ void setPicture(const dvd::spu::ControlSequence& controlSequence); /** * Reset the picture. */ void resetPicture(); /** * Get the visible area for the given display entity. */ const Area& getVisibleArea(displayEntity_t displayEntity) const; /** * Set the current palette to the given value. * To be defined by children! */ virtual void setPalette(const unsigned* palette) = 0; /** * Update the display. This default implementation does nothing, * but children may overwrite it. */ virtual void update();};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline bool SPUHandler::isWideScreen() const{ return wideScreen;}//------------------------------------------------------------------------------inline size_t SPUHandler::getColorIndex(displayEntity_t displayEntity, unsigned pixel) const{ int color = (displayEntity==PICTURE) ? pictureColor : buttonColor; return (color>>(pixel*4))&0x0f;}//------------------------------------------------------------------------------inline size_t SPUHandler::getContrast(displayEntity_t displayEntity, unsigned pixel) const{ int contrast = (displayEntity==PICTURE) ? pictureContrast : buttonContrast; return (contrast>>(pixel*4))&0x0f;}//------------------------------------------------------------------------------} /* namespace output *///------------------------------------------------------------------------------#endif // DXR3PLAYER_OUTPUT_SPUHANDLER_H// Local Variables:// mode: C++// c-basic-offset: 4// indent-tabs-mode: nil// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -