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

📄 ifo.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_IFO_H#define DXR3PLAYER_DVD_IFO_H//------------------------------------------------------------------------------#include "dvd/PGC.h"#include "dvd/Title.h"#include "dvd/File.h"#include "output/VideoAttributes.h"#include "util/AudioFormat.h"#include "enums.h"#include <libmpdvdkit/ifo_types.h>//------------------------------------------------------------------------------namespace dvd {//------------------------------------------------------------------------------/** * VOBU address map. */class VOBUAddressMap{private:    /**     * The low-level structure     */    const vobu_admap_t* vobu_admap;public:    /**     * Construct a VOBU address map.     */    VOBUAddressMap(const vobu_admap_t* vobu_admap);    /**     * Get the number of VOBUs     */    size_t getNumberOfVOBUs() const;    /**     * Get the first sector of the VOBU with the given number.     */    size_t getFirstSector(size_t vobuNo) const;};//------------------------------------------------------------------------------/** * Video stream attributes. */class VideoStreamAttributes{private:    /**     * The low-level structure.     */    const video_attr_t* video_attr;public:    /**     * Construct the object.     */    VideoStreamAttributes(const video_attr_t* video_attr);    /**     * Get the video stadard.     */    videoStandard_t getStandard() const;    /**     * Get the display aspect ratio.     */    aspectRatio_t getDisplayAspectRatio() const;    /**     * Get the aspect ratio.     */    aspectRatio_t getAspectRatio() const;    /**     * Get the display format.     */    displayFormat_t getDisplayFormat() const;    /**     * Set the attributes into the given object.     */    void set(output::VideoAttributes& attr) const;};//------------------------------------------------------------------------------/** * Audio stream attributes. */class AudioStreamAttributes{private:    /**     * The low-level structure.     */    const audio_attr_t* audio_attr;public:    /**     * Construct the object.     */    AudioStreamAttributes(const audio_attr_t* audio_attr);    /**     * Get the encoding     */    audioEncoding_t getEncoding() const;    /**     * Get the sample rate.     */    unsigned getSampleRate() const;    /**     * Get the number of channels.     */    unsigned getNumberOfChannels() const;    /**     * Get the language code.     */    unsigned getLanguageCode() const;    /**     * Set the attributes into the given object.     */    void set(AudioFormat& audioFormat) const;};//------------------------------------------------------------------------------/** * SPU stream attributes. */class SPUStreamAttributes{private:    /**     * The low-level structure.     */    const subp_attr_t* subp_attr;public:    /**     * Construct the object.     */    SPUStreamAttributes(const subp_attr_t* subp_attr);        /**     * Get the language code.     */    unsigned getLanguageCode();};//------------------------------------------------------------------------------/** * Class for an IFO */class IFO{public:    /**     * The maximal number of audio streams.     */    static const unsigned maxAudioStreams = 8;    /**     * The maximal number of SPU streams.     */    static const unsigned maxSPUStreams = 32;    /**     * Construct the given string into a language code.     */    static unsigned getLanguageCode(const char* str);protected:    /**     * The low-level structure     */    const ifo_handle_t* ifoHandle;public:    /**     * Construct an IFO.     */    IFO();    /**     * Destroy the IFO.      * FIXME: do we really need it to be virtual?     */    virtual ~IFO();    /**     * Reset the IFO from the given handle.     */    void reset(const ifo_handle_t* ifo = 0);    /**     * Get the IFO handle.     */    const ifo_handle_t* getHandle() const;    /**     * Check if the handle is valid.     */    operator bool() const;    /**     * Get the menu PGC table for the given language code if     * available, otherwise the first one.     */    PGCTable getMenuPGCTable(unsigned languageCode) const;    /**     * Get the VOBU address map for the menu     */    VOBUAddressMap getMenuVOBUAddressMap() const;    /**     * Get the video stream attributes.     */    virtual VideoStreamAttributes getVideoStreamAttributes(bool inMenu) const = 0;    /**     * Get the number of audio streams.     */    virtual unsigned getNumberOfAudioStreams(bool inMenu) const = 0;    /**     * Get the audio stream attributes.     */    virtual AudioStreamAttributes     getAudioStreamAttributes(bool inMenu, unsigned streamNo) const = 0;    /**     * Get the number of SPU streams.     */    virtual unsigned getNumberOfSPUStreams(bool inMenu) const = 0;    /**     * Get the SPU stream attributes.     */    virtual SPUStreamAttributes     getSPUStreamAttributes(bool inMenu, unsigned streamNo) const = 0;};//------------------------------------------------------------------------------/** * Video Manager IFO. */class VMG : public IFO{public:    /**     * Get the first-play PGC.     */    PGC getFirstPlayPGC() const;    /**     * Get the number of title sets.     */    unsigned getNumberOfTitleSets() const;    /**     * Get the title table.     */    TitleInfoTable getTitleInfoTable() const;    /**     * Get the title number for the given VTS and VTS title number.     *     * @return the title number or 0.     */    unsigned getTitleNumber(unsigned vtsNo, unsigned vtsTitleNo) const;    /**     * @see IFO::getVideoStreamAttributes     */    virtual VideoStreamAttributes getVideoStreamAttributes(bool inMenu) const;    /**     * @see IFO::getNumberOfAudioStreams     */    virtual unsigned getNumberOfAudioStreams(bool inMenu) const;    /**     * @see IFO::getAudioStreamAttributes     */    virtual AudioStreamAttributes     getAudioStreamAttributes(bool inMenu, unsigned streamNo) const;    /**     * @see IFO::getNumberOfSPUStreams     */    virtual unsigned getNumberOfSPUStreams(bool inMenu) const;    /**     * @see IFO::getSPUStreamAttributes     */    virtual SPUStreamAttributes     getSPUStreamAttributes(bool inMenu, unsigned streamNo) const;};//------------------------------------------------------------------------------/** * Video Title Set IFO. */class VTS : public IFO{public:    /**     * Get the PGC table of the VTS     */    PGCTable getPGCTable() const;    /**     * Get the title table of the VTS     */    TitleTable getTitleTable() const;    /**     * Get the part number for the given PGC and program number pair.     *     * @param vtsTitleNumber reference to a variable that will contain the     * VTS title number.     */    unsigned getPartNumber(unsigned pgcNo, unsigned programNo,                           unsigned& vtsTitleNumber) const;    /**     * Get the VTS VOBU address map.     */    VOBUAddressMap getVOBUAddressMap() const;    /**     * @see IFO::getVideoStreamAttributes     */    virtual VideoStreamAttributes getVideoStreamAttributes(bool inMenu) const;    /**     * @see IFO::getNumberOfAudioStreams     */    virtual unsigned getNumberOfAudioStreams(bool inMenu) const;    /**     * @see IFO::getAudioStreamAttributes     */    virtual AudioStreamAttributes     getAudioStreamAttributes(bool inMenu, unsigned streamNo) const;    /**     * @see IFO::getNumberOfSPUStreams     */    virtual unsigned getNumberOfSPUStreams(bool inMenu) const;    /**     * @see IFO::getSPUStreamAttributes     */    virtual SPUStreamAttributes     getSPUStreamAttributes(bool inMenu, unsigned streamNo) const;};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline VOBUAddressMap::VOBUAddressMap(const vobu_admap_t* vobu_admap) :    vobu_admap(vobu_admap){}//------------------------------------------------------------------------------inline size_t VOBUAddressMap::getNumberOfVOBUs() const{    return (vobu_admap->last_byte + 1 - VOBU_ADMAP_SIZE)/4;}//------------------------------------------------------------------------------inline size_t VOBUAddressMap::getFirstSector(size_t vobuNo) const{    assert(vobuNo<getNumberOfVOBUs());    return vobu_admap->vobu_start_sectors[vobuNo];}//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline VideoStreamAttributes::VideoStreamAttributes(const video_attr_t* video_attr) :    video_attr(video_attr){}//------------------------------------------------------------------------------inline void VideoStreamAttributes::set(output::VideoAttributes& attr) const{    attr.standard = getStandard();    attr.aspectRatio = getAspectRatio();}//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline AudioStreamAttributes::AudioStreamAttributes(const audio_attr_t* audio_attr) :    audio_attr(audio_attr){}//------------------------------------------------------------------------------inline unsigned AudioStreamAttributes::getSampleRate() const{    /// FIXME: do something with other values    return 48000;}//------------------------------------------------------------------------------inline unsigned AudioStreamAttributes::getNumberOfChannels() const{    return audio_attr->channels + 1;}//------------------------------------------------------------------------------inline unsigned AudioStreamAttributes::getLanguageCode() const{    return (audio_attr->lang_type==1) ? audio_attr->lang_code : 0xffff;}//------------------------------------------------------------------------------inline void AudioStreamAttributes::set(AudioFormat& audioFormat) const{    audioFormat.encoding = getEncoding();    audioFormat.sampleRate = getSampleRate();    audioFormat.numberOfChannels = getNumberOfChannels();}//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline SPUStreamAttributes::SPUStreamAttributes(const subp_attr_t* subp_attr) :    subp_attr(subp_attr){}    //------------------------------------------------------------------------------inline unsigned SPUStreamAttributes::getLanguageCode(){    return (subp_attr->type==1) ? subp_attr->lang_code : 0xffff;}//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline unsigned IFO::getLanguageCode(const char* str){    unsigned languageCode = (unsigned char)str[0];    languageCode <<= 8;    languageCode  |= (unsigned char)str[1];    return languageCode;}//------------------------------------------------------------------------------inline IFO::IFO() : ifoHandle(0){}//------------------------------------------------------------------------------inline IFO::operator bool() const{    return ifoHandle!=0;}//------------------------------------------------------------------------------inline const ifo_handle_t* IFO::getHandle() const{    return ifoHandle;}//------------------------------------------------------------------------------inline VOBUAddressMap IFO::getMenuVOBUAddressMap() const{    return VOBUAddressMap(ifoHandle->menu_vobu_admap);}//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline PGC VMG::getFirstPlayPGC() const{    return PGC(ifoHandle->first_play_pgc);}//------------------------------------------------------------------------------inline unsigned VMG::getNumberOfTitleSets() const{    return ifoHandle->vmgi_mat->vmg_nr_of_title_sets;}//------------------------------------------------------------------------------inline TitleInfoTable VMG::getTitleInfoTable() const{    return TitleInfoTable(ifoHandle->tt_srpt);}//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline PGCTable VTS::getPGCTable() const{    return PGCTable(ifoHandle->vts_pgcit);}//------------------------------------------------------------------------------inline TitleTable VTS::getTitleTable() const{    return TitleTable(ifoHandle->vts_ptt_srpt);}//------------------------------------------------------------------------------inline VOBUAddressMap VTS::getVOBUAddressMap() const{    return VOBUAddressMap(ifoHandle->vts_vobu_admap);}//------------------------------------------------------------------------------} /* namespace dvd *///------------------------------------------------------------------------------#endif // DXR3PLAYER_DVD_IFO_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

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