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

📄 mpegdecoder.h

📁 Linux下比较早的基于命令行的DVD播放器
💻 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, but now handles other// hardware as well. These files contain a (mostly) user-space driver // for the Unichrome board found on Via's EPIA motherboards.//// The information for implementing this driver has been gathered// from the following sources://// - The DirectFB Unichrome driver//   Copyright (c) 2003 Andreas Robinson, All rights reserved.//// - Andreas Robinson's MPEG-2 decoder for the Unichrome board.//   Copyright (c) 2003 Andreas Robinson, All rights reserved.//// - Via's Unichrome Framebuffer driver//   Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.//   Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.// 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_UNICHROME_MPEGDECODER_H#define DXR3PLAYER_UNICHROME_MPEGDECODER_H//------------------------------------------------------------------------------#include "mpeg/SequenceHeader.h"#include "mpeg/PictureHeader.h"#include "types.h"#include "enums.h"#include <cstdlib>//------------------------------------------------------------------------------namespace mpeg {class QuantMatrix;}//------------------------------------------------------------------------------namespace unichrome {//------------------------------------------------------------------------------class Unichrome;//------------------------------------------------------------------------------/** * Interface for the MPEG decoder of the Unichrome board. */class MPEGDecoder{public:    /**     * Various bits of information about a picture.     */    struct PictureInfo    {        /**         * The coding of the picture.         */        mpeg::PictureHeader::codingType_t codingType;        /**         * The number of fields in the picture.         */        size_t numFields;        /**         * The PTS of the picture. This is valid only for I-pictures.         */        pts_t pts;        /**         * Construct the picture info with default values.         */        PictureInfo();        /**         * Setup the picture info from the given sequence and picture         * header.         */        void setup(const mpeg::SequenceHeader& sequenceHeader,                   const mpeg::PictureHeader& pictureHeader,                   pts_t& packetPTS);        /**         * Reset the picture info to default values.         */        void reset();    };    private:    /**     * Constant for the invalid buffer.     */    static const size_t INVALID_BUFFER = (size_t)-1;    /**     * Default intra quantizer matrix.     */    static const unsigned char defaultIntraQMX[64];    /**     * Quantiser matrix scan order.     */    static const size_t quantMatrixScan[64];    /**     * Get the default quantiser matrix.     */    static const mpeg::QuantMatrix& getDefaultQuantMatrix();    /**     * Reference to the Unichrome object to use     */    Unichrome& unichrome;    /**     * The current aspect ratio to use. It should be noted that the     * aspect ratio of the MPEG stream is not taken into account,     * since it does not seem to be always correct for DVDs.     */    aspectRatio_t aspectRatio;        /**     * The base offset of the frame buffers used by the decoder.     */    size_t baseOffset;    /**     * The current sequence header.     */    mpeg::SequenceHeader sequenceHeader;    /**     * The aspect ratio used for the current sequence.     */    aspectRatio_t sequenceAspectRatio;    /**     * Indicate if the quantization matrix from the current sequence     * has already been loaded.     */    bool sequenceQuantMatrixLoaded;    /**     * The current picture header.     */    mpeg::PictureHeader pictureHeader;    /**     * Indicate if the current field is the second field.     */    bool isSecondField;    /**     * The frame buffers.     */    struct {        size_t yOffset;                size_t cbOffset;        size_t crOffset;    } frameBuffers[4];    /**     * Backward reference buffer.     */    size_t bwRefBuffer;    /**     * Forward reference buffer.     */    size_t fwRefBuffer;    /**     * Current B-frame buffer     */    size_t bBuffer;    /**     * Idle frame buffer          */    size_t idleBuffer;    /**     * Destination frame buffer          */    size_t destBuffer;    /**     * Display frame buffer          */    size_t displayBuffer;    /**     * The coding of the displayable buffer.     */    PictureInfo displayInfo;    /**     * The last I or P picture's buffer not yet shown.     */    size_t pendingIP;    /**     * The coding of the pending I or P picture.     */    PictureInfo pendingInfo;        /**     * The offset of the picture within the buffers.     * This is for luma, it must be divided by four for chroma.     */    size_t pictureOffset;    /**     * The PTS of the packet currently being processed.     */    pts_t packetPTS;    /**     * Indicate if only intra pictures should be decoded.     */    bool playIntra;    /**     * Indicate if slice data should be processed.     */    bool processSlice;public:    /**     * Construct the MPEG decoder.     */    MPEGDecoder(Unichrome& unichrome);    /**     * Reset the MPEG decoder.     */    void reset();    /**     * Flush the MPEG decoder.     */    void flush();    /**     * Set the aspect ratio. It will be used when the next sequence starts.     */    void setAspectRatio(aspectRatio_t ar);    /**     * Set if only intra pictures should be decoded.     */    void setPlayIntra(bool x);    /**     * Set the packet PTS to the given value.     */    void setPTS(pts_t pts);    /**     * Start a sequence.     */    void startSequence(const mpeg::SequenceHeader& header);    /**     * Set the given quantization matrix.     */    void setQuantMatrix(const mpeg::QuantMatrix& quantMatrix);    /**     * Start a picture.     */    void startPicture(const mpeg::PictureHeader& header);    /**     * Add a slice.     */    void addSlice(const unsigned char* slice, size_t length);    /**     * Notify the decoder that the sequence has ended. If there is a     * pending I or P frame, it will be made displayable.     */    void endSequence();    /**     * Check if we have a valid picture to show.     */    bool isDisplayable() const;    /**     * Get the picture info about the displayable picture. This is     * valid only if isDisplayable() return true.     */    const PictureInfo& getDisplayInfo() const;    /**     * Show the picture displayable.     * If no picture is displayable, that is an assertion failure.     */    void displayPicture();private:    /**     * Load the given quantizer matrix.     */    void loadQMX(const unsigned char* qmx);    /**     * Check if the MPEG decoder is busy or not.     */    bool isBusy();};//------------------------------------------------------------------------------} /* namespace unichrome *///------------------------------------------------------------------------------#endif // DXR3PLAYER_UNICHROME_MPEGDECODER_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

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