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

📄 ac3decoder.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_OUTPUT_AC3DECODER_H#define DXR3PLAYER_OUTPUT_AC3DECODER_H//------------------------------------------------------------------------------#include "AudioDecoder.h"#include <inttypes.h>extern "C" { #include <liba52/a52.h>}#include "util/AudioFormat.h"#include <cstdlib>#include <cassert>//------------------------------------------------------------------------------namespace output {//------------------------------------------------------------------------------/** * AC-3 Decoder. */class AC3Decoder : public AudioDecoder{private:    /**     * The size of the frame buffer. An AC-3 frame may be at most this     * many bytes (including synchronization info).     */    static const size_t maxFrameSize = 3840;    /**     * The size of the output buffer. An AC-3 frame is decoded to exactly     * this many bytes.     */    static const size_t outputLength = 6144;    /**     * Convert the given 32-bit integer representing a float value     * into a 16-bit integer.     */    static int16_t blah(int32_t i);    /**     * Convert the given array of float samples into an array of     * 16-bit integer samples.     */    static void float_to_int(float * _f, int16_t * s16, int num_channels);    /**     * The samples.     */    sample_t* samples;    /**     * Frame buffer.     */    unsigned char frameBuffer[maxFrameSize];    /**     * The offset into the frame being decoded.     */    size_t frameOffset;    /**     * The length of the current frame being decoded.     * Valid after the sync info (first 7 bytes of a frame) has been     * decoded.     */    size_t frameLength;    /**     * A52 State     */    a52_state_t a52State;    /**     * Output flags     */    int outputFlags;    /**     * The output level.     */    unsigned outputLevel;    /**     * Indicate if audio is enabled or not.     */    bool audioEnabled;    public:    /**     * Construct the AC-3 decoder.     *     * FIXME: remove the defautl value!!!     */    AC3Decoder(AudioProcessor* audioProcessor);    /**     * Reset the decoder.     */    virtual void reset();    /**     * @see AudioDecoder::decodePacket     */    virtual void decodePacket(const unsigned char* data,                              size_t length, pts_t packetPTS);public:    /**     * Get the output level. It is a number between 0 and 100.     */    unsigned getOutputLevel() const;        /**     * Set the output level.     */    void setOutputLevel(unsigned level);    /**     * Toggle the audio.     *     * @return true if the audio is enabled as a result of this call.     */    bool toggleAudio();private:    /**     * Check if the decoder is empty, i.e. the last frame has been     * completely decoded, and no new frame has started.'     */    bool isEmpty() const;    /**     * Decode the data in the given block.     *     * @return if a frame has been made available.     */    bool decode(const unsigned char*& data,                 const unsigned char* end);    /**     * Copy the data from the given address into the frame buffer,     * until the given target offset is reached.     */    void copy(const unsigned char*& data,              const unsigned char* end,              size_t targetOffset);    /**     * Set the format based on the flags and the given sample rate.     */    void setFormat(int flags, int sampleRate);    /**     * Decode the frame buffered.     */    bool decodeFrame();    /**     * Encode the frame buffered for hardware decoding.     */    bool prepareFrameForHardwareDecoding();};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline unsigned AC3Decoder::getOutputLevel() const{    return outputLevel;}//------------------------------------------------------------------------------inline void AC3Decoder::setOutputLevel(unsigned level){    assert(level<=100);    outputLevel = level;}//------------------------------------------------------------------------------} /* namespace output *///------------------------------------------------------------------------------#endif // DXR3PLAYER_OUTPUT_AC3DECODER_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

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