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

📄 videohandler.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.// 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_OUTPUT_SDL_VIDEOHANDLER_H#define DXR3PLAYER_OUTPUT_SDL_VIDEOHANDLER_H//------------------------------------------------------------------------------#include "output/VideoAttributes.h"#include "sched/Schedulable.h"#include <SDL/SDL.h>#include <inttypes.h>extern "C" {#include <mpeg2dec/mpeg2.h>}//------------------------------------------------------------------------------namespace dvd { namespace packet {class PacketQueue;} /* namespace dvd::packet */ } /* namespace dvd *///------------------------------------------------------------------------------namespace output {class SystemTimer;}//------------------------------------------------------------------------------namespace output { namespace sdl {//------------------------------------------------------------------------------class SPUHandler;//------------------------------------------------------------------------------/** * Handler for the video strams. */class VideoHandler : public sched::Schedulable{private:    /**     * The input queue for video packets.     */    dvd::packet::PacketQueue& inputQueue;    /**     * The timer to use.     */    output::SystemTimer& timer;    /**     * The SPU handler to use.     */    SPUHandler& spuHandler;    /**     * MPEG-2 decoder structure.     */    mpeg2dec_t* mpeg2dec;    /**     * MPEG-2 info structure.     */    const mpeg2_info_t* mpeg2info;    /**     * The base PTS value. This is the PTS value corresponding to     * field 0 when we take into account the number of fields.     */    pts_t basePTS;    /**     * The PTS of the next I-frame.     */    pts_t nextIFramePTS;    /**     * The number of fields since basePTS.     */    size_t numFields;    /**     * Indicate if only intra frames should be played.     */    bool playIntra;    /**     * Indicate if only the first I-frame should be accepted.     */    bool nextOnlyIFrame;    /**     * Our current video attributes.     */    VideoAttributes videoAttributes;        /**     * The SDL screen surface.     */    SDL_Surface* screen;    /**     * SDL YUV overlay.     */    SDL_Overlay* overlay;    /**     * The height of the picture. The picture is always as wide      * as the overlay, but if it is widescreen, the overlay also     * has an aspect ratio of 4:3, but the picture is in the middle of     * it vertically.     */    size_t pictureHeight;    /**     * Indicate if we should display in full-screen or not.     */    bool isFullScreen;    /**     * The width of the window.     */    size_t windowWidth;    /**     * The height of the window     */    size_t windowHeight;    /**     * The width of the display.     */    size_t displayWidth;    /**     * The height of the display.     */    size_t displayHeight;    /**     * The current brightness. A value of 100 means no change.     */    size_t brightness;    /**     * The gamma ramp. Used only if brightness is not 100.     */    uint8_t gamma_y[256];    /**     * The frame buffers for the MPEG decoder.     */    uint8_t* frameBuffers[3][3];    /**     * The index of the buffer currently being displayed. If no buffer was     * displayed, this is 0.     */    uint8_t* const* currentBuffer;public:    /**     * Construct the video handler.     */    VideoHandler(dvd::packet::PacketQueue& inputQueue,                 output::SystemTimer& timer, SPUHandler& spuHandler);    /**     * Process the video packets.     */    virtual void run();    /**     * @see sched::Schedulable::printStatus     */    virtual void printStatus() const;    /**     * Set the flag wether only intra frames should be played.     */    void setPlayIntra(bool x);    /**     * Reset the video handler.     */    void reset();    /**     * Flush the video handler.     */    void flush();    /**     * Determine of the given video attributes are different from the     * current ones.     */    bool isDifferent(const VideoAttributes& attributes) const;    /**     * Set the given video attributes.     */    void setAttributes(const VideoAttributes& attributes);    /**     * Toggle the fullscreen display.     */    void toggleFullScreen();    /**     * Increase the brightness and return the new value.     */    unsigned increaseBrightness();    /**     * Decrease the brightness and return the new value.     */    unsigned decreaseBrightness();    /**     * Increase the contrast and return the new value.     */    unsigned increaseContrast();    /**     * Decrease the contrast and return the new value.     */    unsigned decreaseContrast();    /**     * Increase the saturation and return the new value.     */    unsigned increaseSaturation();    /**     * Decrease the saturation and return the new value.     */    unsigned decreaseSaturation();private:    /**     * Create the screen. The overlay will be recreated, if it exists.     */    void createScreen();        /**     * Setup the overlay.     */    void setupOverlay(size_t width, size_t height);    /**     * Destroy the screen. The overlay will be destroyed, if it exists.     */    void destroyScreen();        /**     * Parse the MPEG data.     */    void parseMPEG();    /**     * Draw the current frame into the given buffer.     */    void drawCurrentFrame();    /**     * Reeraw the current frame. It checks if both the overlay and the     * MPEG-2 buffers are present, then calls drawCurrentFrame(),     * followed by SDL_DisplayYUVOverlay.     */    void redrawCurrentFrame();    /**     * Check SDL events.     */    void checkEvents();    /**     * Setup the gamma ramp for the current brightness.     */    void setupGamma();};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline bool VideoHandler::isDifferent(const VideoAttributes& attributes) const{    return !(videoAttributes==attributes);}//------------------------------------------------------------------------------inline void VideoHandler::setPlayIntra(bool x){    playIntra = x;}//------------------------------------------------------------------------------} /* namespace output::sdl */ } /* namespace output *///------------------------------------------------------------------------------#endif // DXR3PLAYER_OUTPUT_SDL_VIDEOHANDLER_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

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