?? controlsequence.cc
字號:
//// Copyright (c) 2003 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 "ControlSequence.h"#include "SPUBuffer.h"#include "util/Log.h"#include <cassert>//------------------------------------------------------------------------------using dvd::spu::ControlSequence;//------------------------------------------------------------------------------ControlSequence::ControlSequence() : delay(0), pts(INVALID_PTS), displayCommand(NONE), color(-1), contrast(-1), picture(new Picture()){ colorAndContrastChange.length = 0; colorAndContrastChange.data = 0;}//------------------------------------------------------------------------------ControlSequence::~ControlSequence(){ delete[] colorAndContrastChange.data;}//------------------------------------------------------------------------------size_t ControlSequence::decode(SPUBufferBitReader& reader){ delay = reader.read16(); size_t nextOffset = reader.read16(); size_t topFieldOffset = 0, bottomFieldOffset = 0; unsigned char command = reader.read(); while(command!=CMD_END) { switch(command) { case CMD_FORCED_START_DISPLAY: assert(displayCommand==NONE); displayCommand = FORCED_START; break; case CMD_START_DISPLAY: assert(displayCommand==NONE); displayCommand = START; break; case CMD_STOP_DISPLAY: assert(displayCommand==NONE); displayCommand = STOP; break; case CMD_SET_COLOR: assert(color==-1); color = reader.read16(); break; case CMD_SET_CONTRAST: assert(contrast==-1); contrast = reader.read16(); break; case CMD_SET_DISPLAY_AREA: picture->setArea(reader); break; case CMD_SET_PIXEL_OFFSETS: assert(topFieldOffset==0 && bottomFieldOffset==0); topFieldOffset = reader.read16(); bottomFieldOffset = reader.read16(); break; case CMD_CHANGE_COLOR_AND_CONTRAST: changeColorAndContrast(reader); break; default: assert(0); } command = reader.read(); } if (topFieldOffset!=0 || bottomFieldOffset!=0) { reader.setOffset(topFieldOffset); picture->decodeTopField(reader, contrast); reader.setOffset(bottomFieldOffset); picture->decodeBottomField(reader, contrast); } return nextOffset;}//------------------------------------------------------------------------------size_t ControlSequence::encodePixelData(DynamicBufferBitWriter& writer, size_t& topFieldLength) const{ return picture->encode(writer, topFieldLength);}//------------------------------------------------------------------------------void ControlSequence::encodeCommands(DynamicBufferBitWriter& writer, size_t topFieldOffset, size_t bottomFieldOffset, bool isLast) const{ size_t startOffset = writer.getOffset(); writer.write16(delay); writer.write16(startOffset); switch(displayCommand) { case NONE: break; case FORCED_START: writer.write(CMD_FORCED_START_DISPLAY); break; case START: writer.write(CMD_START_DISPLAY); break; case STOP: writer.write(CMD_STOP_DISPLAY); break; default: assert(0); } if (color>=0) { writer.write(CMD_SET_COLOR); writer.write16((unsigned)color); } if (contrast>=0) { writer.write(CMD_SET_CONTRAST); writer.write16((unsigned)contrast); } if (picture->isValid()) { writer.write(CMD_SET_PIXEL_OFFSETS); writer.write16(topFieldOffset); writer.write16(bottomFieldOffset); writer.write(CMD_SET_DISPLAY_AREA); writer.writeBits(picture->getXOffset(), 12); writer.writeBits(picture->getXOffset() + picture->getWidth() - 1, 12); writer.writeBits(picture->getYOffset(), 12); writer.writeBits(picture->getYOffset() + picture->getHeight() - 1, 12); } if (colorAndContrastChange.length>0) { writer.write16(colorAndContrastChange.length+2); writer.write(colorAndContrastChange.data, colorAndContrastChange.length); } writer.write(CMD_END); size_t endOffset = writer.getOffset(); if (!isLast) { writer.setOffset(startOffset+2); writer.write16(endOffset); writer.setOffset(endOffset); }}//------------------------------------------------------------------------------void ControlSequence::changeColorAndContrast(SPUBufferBitReader& reader){ assert(colorAndContrastChange.length==0 && colorAndContrastChange.data==0); colorAndContrastChange.length = reader.read16() - 2; colorAndContrastChange.data = new unsigned char[colorAndContrastChange.length]; reader.read(colorAndContrastChange.data, colorAndContrastChange.length);}//------------------------------------------------------------------------------//------------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -