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

📄 sector.h

📁 Linux下比较早的基于命令行的DVD播放器
💻 H
字号:
//// 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#ifndef DXR3PLAYER_DVD_DEMUX_SECTOR_H#define DXR3PLAYER_DVD_DEMUX_SECTOR_H//------------------------------------------------------------------------------#include "buffer/StaticBuffer.h"#include "buffer/WrapperBuffer.h"//------------------------------------------------------------------------------namespace dvd { namespace demux {//------------------------------------------------------------------------------const size_t SECTOR_SIZE = 2048;//------------------------------------------------------------------------------/** * The sector class (a wrapper around a sector buffer) */class Sector{private:    /**     * The buffer.     */    StaticBuffer<SECTOR_SIZE> buffer;public:    /**     * Get the pointer to the data.     */    const unsigned char* getData() const;    /**     * Get the data for writing.     */    unsigned char* getData();    /**     * Get the length of the data.     */    size_t getLength() const;    /**     * Look for the given PES header of the given length in the     * sector. It is assumed that the first three bytes are: 0x00,     * 0x00, 0x01.     *     * @param offset the offset to start the search at. Defaults to 0.     *     * @return the index of the first character after the header, or     * 0, if the header is not found (since the header should have      * a positive length, any correct value should be positive too).     */    template <size_t headerLength>    size_t findPESHeader(const unsigned char* header, size_t offset = 0) const;};//------------------------------------------------------------------------------/** * Sector reader. It is mainly a convenience class to hide * WrapperBufferReader. */class SectorReader : public WrapperBufferReader{public:    /**     * Construct a sector reader from the given sector.     */    explicit SectorReader(const Sector& sector);    /**     * Consturct a sector reader from the given data block. It is     * assumed to have a length of SECTOR_SIZE.     */    explicit SectorReader(const unsigned char* data);};//------------------------------------------------------------------------------/** * Sector bit reader. It is mainly a convenience class to hide * WrapperBufferReader. */class SectorBitReader : public WrapperBufferBitReader{public:    /**     * Construct a sector bit reader from the given sector.     */    explicit SectorBitReader(const Sector& sector);    /**     * Consturct a sector bot reader from the given data block. It is     * assumed to have a length of SECTOR_SIZE.     */    explicit SectorBitReader(const unsigned char* data);};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline const unsigned char* Sector::getData() const{    return buffer.getData();}//------------------------------------------------------------------------------inline unsigned char* Sector::getData(){    return buffer.getData();}//------------------------------------------------------------------------------inline size_t Sector::getLength() const{    return buffer.getLength();}//------------------------------------------------------------------------------template <size_t headerLength>inline size_t Sector::findPESHeader(const unsigned char* header, size_t offset) const{    const unsigned char* data = getData();    size_t headerIndex = 0;    size_t index = offset;    for(; index<SECTOR_SIZE && headerIndex<headerLength; ++index) {        if (data[index] == header[headerIndex]) {            ++headerIndex;        } else if (headerIndex!=2 || data[index]!=0) {            headerIndex = 0;        }    }    return (index<SECTOR_SIZE) ? index : 0;    }//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline SectorReader::SectorReader(const Sector& sector) {    setData(sector.getData(), SECTOR_SIZE);}//------------------------------------------------------------------------------inline SectorReader::SectorReader(const unsigned char* data){    setData(data, SECTOR_SIZE);}//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline SectorBitReader::SectorBitReader(const Sector& sector) {    setData(sector.getData(), SECTOR_SIZE);}//------------------------------------------------------------------------------inline SectorBitReader::SectorBitReader(const unsigned char* data){    setData(data, SECTOR_SIZE);}//------------------------------------------------------------------------------} /* namespace dvd::demux */ } /* namespace dvd *///------------------------------------------------------------------------------#endif // DXR3PLAYER_DVD_DEMUX_SECTOR_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

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