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

📄 processor.h

📁 Linux下比较早的基于命令行的DVD播放器
💻 H
字号:
//// Copyright (c) 2002 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_DVD_VM_PROCESSOR_H#define DXR3PLAYER_DVD_VM_PROCESSOR_H//------------------------------------------------------------------------------#include "dvd/vm/State.h"#include "dvd/vm/Instruction.h"#include "dvd/vm/Scheduler.h"//------------------------------------------------------------------------------namespace dvd { namespace vm {class TargetPosition;//------------------------------------------------------------------------------/** * The Virtual Machine processor. */class Processor{private:    /**     * Evaluate the given comparison     */    static bool evaluateComparison(Instruction::cmpOp_t cmpOp,                                   unsigned value1, unsigned value2);private:    /**     * The state of the virtual machine.     */    State state;    /**     * The instruction scheduler.     */    Scheduler scheduler;    /**     * The number of branches since the last query of this value.     */    unsigned numberOfBranches;public:    /**     * Construct the processor.     */    Processor(DVD* dvd);    /**     * Construct a processor with the given initial state.     */    Processor(const State& state);    /**     * Copy the given processor.     */    Processor(const Processor& other);    /**     * Get the current position.     */    const Position& getPosition() const;    /**     * Get the System Parameter Register file.     */    const SPRM& getSPRM() const;    /**     * Get the state of the processor.     */    const State& getState() const;    /**     * Set the processor's state to the given state.     */    void setState(const State& s);    /**     * Get the physical audio stream number based on the current     * position and register contents. If an audio language is forced,     * a suitable stream is searched for. If not forced or found, the     * ASTN register's value will be used to find a stream.     *     * @param logicalStream will contain the logical stream number for     * the stream found.     */    unsigned getAudioStreamNumber(unsigned& logicalStream) const;    /**     * Get the physical audio stream number (see getAudioStreamNumber(unsigned)).     */    unsigned getAudioStreamNumber() const;    /**     * Get the physical SPU stream number based on the current     * position and register contents. If an SPU language is forced,     * a suitable stream is searched for. If not forced or found, the     * SPSTN register's value will be used to find a stream.     *     * @param forcedOnly will be set to indicate that only forced SPUs     * are to be shown.     */    unsigned getSPUStreamNumber(aspectRatio_t aspectRatio,                                displayFormat_t displayFormat,                                bool& forcedOnly) const;    /**     * Reset the processor.     */    void reset();    /**     * Go to the first play PGC and start that.     */    void executeFirstPlayPGC();    /**     * Set the sector number.     */    void setSectorNumber(size_t sectorNumber);    /**     * Set the highlighted button number.     */    void setHighlightedButtonNumber(size_t buttonNo);    /**     * Finish the current cell and go to the next one.     *     * @return if there was a next cell. If not, the processor jumps     * to the first play PGC     */    bool nextCell(unsigned& stillTime);    /**     * Go to the previous cell. Cell commands are not played, neither     * are PGC post and pre commands.     *     * @return if there was a previous cell. If not, the position     * remains where it was     */    bool previousCell();    /**     * Enter the next program.     *     * @return if there was a next program and it was valid.     */    bool nextProgram();    /**     * Enter the previous program.     *     * @return if there was a previous program and it was valid.     */    bool previousProgram();    /**     * Repeat the current program.     *     * @return if the current program could be repeated     */    bool repeatProgram();    /**     * Enter the menu with the given ID.     *     * @param forced if true, and the current VTS does not have a menu     *               with the given ID, it will be searched for     *     * @return if the menu exists and it was entered     */    bool enterMenu(unsigned menuID, bool forced = false);    /**     * Go to the next angle.     *     * @return if there was a next angle and it was entered     */    bool nextAngle();    /**     * "Select" the next audio stream.     *     * @param reversed if true, the previous ("next in reversed     * order") audio stream will be selected     *     * @return if there was a next stream     */    bool nextAudioStream(bool reversed);    /**     * "Select" the next subpicture stream.     *     * @param reversed if true, the previous ("next in reversed     * order") subpicture stream will be selected     *     * @return if there was a next stream     */    bool nextSPUStream(bool reversed);    /**     * Execute the given instructions and any others that follow from     * them.     *     * @return if there was some jump during the execution of the     * instruction set.     */    void execute(const Instruction* instruction, size_t length = 1);    /**     * Clear the branch counter.     */    void clearBranches();    /**     * Determine if there have been any branches since queried last     * time.     */    bool hasBranched();private:    /**     * Map the given logical audio stream number to the corresponding     * physical stream number, and check if it matches the given     * language code. If found, set <tt>candidate</tt> to the physical     * stream number, unless it is already set. If it matches the     *  language code, return it, otherwise PGC::INVALID_STREAM_NUMBER.     *      * @param languageCode the 2-byte language code. If 0xffff, the     * language will fit     * @param ifo this is passed to avoid looking it up several times     * @param pgc this is passed to avoid looking it up several times     */    unsigned mapAudioStreamNumber(unsigned streamNo, unsigned languageCode,                                  const IFO* ifo, PGC pgc,                                  unsigned& candidate) const;    /**     * Map the given logical SPU stream number to the corresponding     * physical stream number, and check if it matches the given     * language code. If found, set <tt>candidate</tt> to the physical     * stream number, unless it is already set. If it matches the     * language code, return it, otherwise PGC::INVALID_STREAM_NUMBER.     *      * @param ifo this is passed to avoid looking it up several times     * @param pgc this is passed to avoid looking it up several times     * @param languageCode the 2-byte language code. If 0xffff, the     * language will fit     */    unsigned mapSPUStreamNumber(unsigned streamNo,                                 aspectRatio_t aspectRatio,                                displayFormat_t displayFormat,                                unsigned languageCode,                                const IFO* ifo, PGC pgc,                                unsigned& candidate) const;        /**     * Set the position to the given one.     */    void setPosition(const Position& position);    /**     * Process the given instruction and determine what to do next.     */    void process(const Instruction* instruction);    /**     * Execute the given special instruction     */    void executeSpecial(const Instruction* instruction);    /**     * Execute the given branch (link, jump or call) instruction     */    void executeBranch(const Instruction* instruction);    /**     * Execute the given link instruction.     */    void executeLink(const Instruction* instruction);    /**     * Execute the given link instruction without checking the conditions.     */    void executeLinkUnconditionally(const Instruction* instruction);    /**     * Link to the previous cell, i.e. set up the given target     * position to go to the previous cell, if any     *     * This has its own method, because it is used both by     * executeLinkSubset() and previousCell().     *     * @return if there was a previous cell, i.e. either one in the     * current PGC, or in a previous PGC      */    bool linkPreviousCell(TargetPosition& targetPosition);    /**     * Execute the given instruction if it is a link subset     * instruction.     */    void executeLinkSubset(const Instruction* instruction);    /**     * Execute the given jump or call instruction.     */    void executeJumpCall(const Instruction* instruction);    /**     * Execute a JumpSS or CallSS instruction.     */    void executeJumpCallSS(const Instruction* instruction,                            bool isJump);    /**     * Execute a JumpSS instruction.     */    void executeJumpSS(const Instruction* instruction);    /**     * Execute a CallSS instruction.     */    void executeCallSS(const Instruction* instruction);    /**     * Execute the given system register setting instruction     */    void executeSetSysReg(const Instruction* instruction);    /**     * Execute the given set instruction     */    void executeSet(const Instruction* instruction);    /**     * Execute the set operation in the instruction     */    bool executeSet(const Instruction* instruction,                     GPR& destRegister,                    unsigned sourceValue, Register* sourceRegister);    /**     * Execute the given set & conditional link instruction     */    void executeSetCLnk(const Instruction* instruction);    /**     * Execute the given set instruction, which is one combined with a     * (conditional) link instruction.     */    bool executeSetWithLink(const Instruction* instruction);    /**     * Execute the given conditional set & condition link instruction     */    void executeCSetCLnk(const Instruction* instruction);    /**     * Execute the given compare & set & link instruction     */    void executeCmpSetLnk(const Instruction* instruction);    /**     * Evaluate the condition version 1. This takes register 1 from     * operand 1 and register 2/constant from operand 2.     */    bool evaluateConditionV1(const Instruction* instruction) const;    /**     * Evaluate the condition version 2. This takes register 1 and 2 from     * operand 3.     */    bool evaluateConditionV2(const Instruction* instruction) const;    /**     * Evaluate the condition version 2. This takes register 1 form     * operand 1 and register / value 2 from operand 3.     */    bool evaluateConditionV3(const Instruction* instruction) const;    /**     * Evaluate the condition version 2. This takes register 1 form     * the instruction (from the CMD field) and register / value 2 from operand 2.     */    bool evaluateConditionV4(const Instruction* instruction) const;    /**     * Evaluate the condition of a special instruction.     */    bool evaluateSpecialCondition(const Instruction* instruction) const;    /**     * Evaluate the condition of a link instruction     */    bool evaluateLinkCondition(const Instruction* instruction) const;    /**     * Evaluate the condition of a jump/call instruction     */    bool evaluateJumpCallCondition(const Instruction* instruction) const;    /**     * Evaluate the condition of a set system register instruction     */    bool evaluateSetSysRegCondition(const Instruction* instruction) const;    /**     * Evaluate the condition of a set instruction     */    bool evaluateSetCondition(const Instruction* instruction) const;    /**     * Evaluate the condition of a set with a conditional link instruction     */    bool evaluateSetCLnkCondition(const Instruction* instruction) const;    /**     * Evaluate the condition of a conditional set with a conditional     * link instruction     */    bool evaluateCSetCLnkCondition(const Instruction* instruction) const;    /**     * Evaluate the condition of a compare, set and link instruction.     */    bool evaluateCmpSetLnkCondition(const Instruction* instruction) const;    friend class Scheduler;};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline Processor::Processor(const State& state) :    state(state),    scheduler(*this),    numberOfBranches(0){}//------------------------------------------------------------------------------inline Processor::Processor(const Processor& other) :    state(other.state),    scheduler(*this),    numberOfBranches(0){}//------------------------------------------------------------------------------inline unsigned Processor::getAudioStreamNumber() const{    unsigned logicalStream;    return getAudioStreamNumber(logicalStream);}//------------------------------------------------------------------------------inline const Position& Processor::getPosition() const{    return state.getPosition();}//------------------------------------------------------------------------------inline const SPRM& Processor::getSPRM() const{    return state.getSPRM();}//------------------------------------------------------------------------------inline const State& Processor::getState() const{    return state;}//------------------------------------------------------------------------------inline void Processor::setState(const State& s){    state = s;}//------------------------------------------------------------------------------inline void Processor::setSectorNumber(size_t sectorNumber){    state.setSectorNumber(sectorNumber);}//------------------------------------------------------------------------------inline void Processor::setHighlightedButtonNumber(size_t buttonNo){    state.setHighlightedButtonNumber(buttonNo);}//------------------------------------------------------------------------------} /* namespace dvd::vm */ } /* namespace dvd *///------------------------------------------------------------------------------#endif // DXR3PLAYER_DVD_VM_PROCESSOR_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

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