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

📄 umc_mpeg2_spl_base.h

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 H
字号:
/*//////////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/#ifndef __UMC_MPEG2_SPL_BASE_H__#define __UMC_MPEG2_SPL_BASE_H__#include "umc_mpeg2_spl_defs.h"#include "vm_time.h"#include "vm_semaphore.h"#include "umc_structures.h"#include "umc_splitter.h"#include "umc_cyclic_buffer.h"#include "umc_thread.h"#include "umc_media_data_ex.h"//Base MPEG2 splitter implements only buffering datanamespace UMC{#if defined (_ARM_) || defined (ARM) || defined (_WIN32_WCE)#define SMALL_MEMORY_USE#endif    class ElementaryStream    {    public:        ElementaryStream()            :m_uiStreamID(0),             m_uiStreamSubID(0),             m_uiProgramNum(0),             m_uiType(0),             m_AspectRatio(0),             m_FrameRateCode(0),             //m_uiProfileCode(0),             //m_uiLevelCode(0),             m_uiMode(0),             m_uiLanguageCode(0),             m_uiNumReadPackets(0),             m_uiSizeReadPackets(0)        {            memset(&m_audioStreamInfo, 0, sizeof(m_audioStreamInfo));            memset(&m_videoStreamInfo, 0, sizeof(m_videoStreamInfo));        }        //common fields        unsigned int m_uiStreamID;     //PS specific:                                       //it is stream ID                                       //E0 - EF for video                                       //C0 - DF for MPEG audio                                       //DB LPCM or AC3 DVD audio                                       //TS specific:                                       //video ID from PMSection        unsigned int m_uiStreamSubID;  //PS specific:                                       // stream sub ID                                       //for video and MPEG audio                                       //it's equal to stream ID                                       //A0 - A1 LPCM DVD audio                                       //80 - 8F AC3 DVD audio                                       //TS specific:                                       //audio ID from PMSection        unsigned int m_uiProgramNum;   //TS specific: Program Number                                       //zero for PS        unsigned int m_uiPMSecID;      //TS specific: Program Map Section ID                                       //zero for PS        unsigned int m_uiType;          //video, audio        unsigned int m_uiNumReadPackets;//packets count with this ID        unsigned int m_uiSizeReadPackets;//total read size with this ID        //Video fields, -1 for audio        unsigned int m_AspectRatio;     //definition TBD        unsigned int m_FrameRateCode;   //definition TBD        //unsigned int m_uiProfileCode;   //definition TBD, depend on        //unsigned int m_uiLevelCode;     //compression standard        //Audio fields, -1 for video        unsigned int m_uiMode;          //Stereo, Mono        unsigned int m_uiLanguageCode;  //definition TBD        AudioStreamInfo  m_audioStreamInfo;        VideoStreamInfo  m_videoStreamInfo;    };#define MAX_ES_COUNT 10    class MPEG2SplitterBase : public Splitter    {    public:    //////////////////Constructor/destructor////////////////        MPEG2SplitterBase();        virtual ~MPEG2SplitterBase();    /////////////////////Interface overrided functions////        virtual Status          Init                (SplitterParams& init);        virtual Status          Close               ();    //Close splitter        virtual Status          Run                 ();    //Run   splitter        virtual Status          Stop                ();    //Stop  splitter        virtual Status          GetNextVideoData    (MediaData* data, vm_var32 track_idx);        virtual Status          GetNextAudioData    (MediaData* data, vm_var32 track_idx);        virtual Status          CheckNextVideoData  (MediaData* data, vm_var32 track_idx);        virtual Status          CheckNextAudioData  (MediaData* data, vm_var32 track_idx);        // pos from 0.0 to 1.0        virtual Status          SetPosition(double pos);        // start_time and end time of new data segment are passed as parameters        virtual Status          SetPosition(double start_time, double end_time);        // return current position        virtual Status          GetPosition(double& pos);        virtual Status          SetRate(double rate);        virtual AudioStreamType GetAudioType(void);        virtual Status GetNextData(MediaData* data, vm_var32* stream_id);    protected:        bool            CheckFrameType        (MediaData* data, SPL_FRAME_TYPES  type);        //here must be implemented real packet processing,        //it is specific for each format        //this function witll return control if reading error        //or end of stream happen        Status virtual      ProcessPackets(int count = -1) = 0;        Status virtual      PlayBack        (unsigned int pid);        Status virtual      GetPrevGop      (unsigned int pid,                                             vm_sizet p_start,                                             vm_sizet &posIFrame,                                             vm_sizet &posPackege                                             )        {return UMC::UMC_NOT_IMPLEMENTED;}        Status virtual ProcessPackets_back  (unsigned int pid,                                             vm_sizet p_packege_start,                                             vm_sizet p_start,                                             vm_sizet p_end)       {return UMC::UMC_NOT_IMPLEMENTED;}        //read one packet (or size bytes of pure stream) and        //return control, for PS, TS streams size parameter must be 0        //returned UMC_OK means next frame was formed and ready        //to output        //UMC_NOT_ENOUGH_DATA means packed was processed but frame        //is not ready        //all other is errors        Status virtual      ProcessOnePacket(int size = 0) = 0;        //initialization of subprocessing, call before ProcessOnePacket        Status virtual      InitProcessing() = 0;        //de-initialization of subprocessing, call after ProcessOnePacket        Status virtual      CloseProcessing() = 0;        //here must be implemented pointer positioning to first        //valid start code after repositioning        Status virtual      MoveToNextSyncWord() = 0;        //forward search for main header in reverse playback        Status virtual      ForwardInit()        {return UMC_NOT_IMPLEMENTED;}        //forward search for frame in reverse playback        Status virtual      ForwardSearch()        {return UMC_NOT_IMPLEMENTED;}    protected:        //stream can contain more then 1 video&audio stream        //this will show how much programs mixed into        int                 m_inESCount;        ElementaryStream*   m_pESArray;        unsigned int        m_splitter_flags;        SystemStreamInfo    m_systemStreamInfo;        //request to terminate a splitter thread        bool                m_bStop;        //is internal thread finished reading data        //it can be used as end of stream flag:        //m_bReadingFinished = true and LockOutputBuffer        //returns UMC_NOT_ENOUGH_DATA means this, i.e.        //buffer empty and reading finished        bool                m_bReadingFinished;        //is user need reading video, for example        //video present in stream, but user asked only audio        bool                m_bIgnoreVideo;        //is user need reading audio, for example        //audio present in stream, but user asked only video        bool                m_bIgnoreAudio;        //user moved slider//        bool                m_bReposHappend;        //set if first audio packet was found        Event               m_eInitAudio;        //set if first audio packet was found        Event               m_eInitVideo;        //set if init was completed        Event               m_eInitComplete;        //set if init was completed        vm_semaphore        m_eVideoFrameCount;        //PTS for current packet, =-1 if is not valid        double              m_dCurrAudioPts;        //PTS for current packet, =-1 if is not valid        double              m_dCurrVideoPts;        //DTS for current packet, =-1 if is not valid        double              m_dCurrVideoDts;        //PTS for current packet, =-1 if is not valid        double              m_dPrevVideoPts;        //PTS for current packet, =-1 if is not valid        double              m_dDiffVideoPts;        //PTS for current packet, =-1 if is not valid        double              m_dBaseVideoPts;        //Current playback rate        double              m_dRate;        //Linear Buffer returns all data collected        //we need to cut to smaller piece        int                 m_uiOutputAudioSize;        unsigned int        m_MPEGASyncWord;        //copy of input user flags        unsigned int        m_lFlags;        //additional copy of flags        unsigned int        m_lFlagsReq;        //buffer for ready audio frames        MediaBuffer*        m_pAudioBuffer[2];        //copy returned audio for next release        MediaData           m_AudioPrevData[2];        //buffer for ready video frames        SampleBuffer*       m_pVideoBuffer;        //copy returned video for next release        MediaDataEx         m_VideoPrevData;        //buffer for ready aux video data        SampleBuffer*       m_pVideoAuxData;        //copy returned aux video for next release        MediaDataEx         m_VideoPrevAuxData;        Thread              SplitterThread;        unsigned int        m_uiEndian; // flag for swapping                                        //0 no swap, 1 - 2 bytes swap                                        //2 - 4 bytes swap        //reset all collected data and start reading from        //new stream position//        bool                m_bPrepareForReposition;        Event               m_eWaitNewPosition;        //number of choosed video ES        int                 m_iChoosedVideo;        //number of choosed audio ES        int                 m_iChoosedAudio[2];        unsigned int        m_uiCurrInputBuffNum;        unsigned int        m_uiCurrOutBuffNum;        unsigned int        m_uiVideoFrameCount;        unsigned int        m_uiAudioFrameCount[2];        unsigned int        m_uiLastPosition;        double              m_dLastPts;        double              m_dFirstPts;        // saved statistic for backward motion        vm_sizet        m_uiMAXGOPLength;        /*vm_sizet      m_uiPosCurrPacket;         // point to start of current packege.        vm_sizet        m_uiPosPacketWithGOPStart; // point to start of packege which has I frame.        vm_sizet        m_uiPosPrevPacket;         // point to start of previous packege if start_picture_code is placed in the end of this packege.        vm_sizet        m_uiPosPrevFrame;        vm_sizet        m_uiPosLastIFrame;        bool            m_bSaveStatistic;*/         SPL_FRAME_TYPES     m_frame_types;    protected:        //void                  ResetStatistic       ();        //use it in case of changing position in stream        virtual void            FlushBuffers    ();        //put audio data to buffer        //swapFlag must be 0, if no swapping needed        virtual Status          FillAudioBuffer(int iLength,                                      unsigned int uiSwapFlag);        //put video data to buffer        //swapFlag must be 0, if no swapping needed        virtual Status          FillVideoBuffer (int iLength,                                      unsigned int uiSwapFlag);        //wait untill:        //1 output frame available or eos        //2 user stop signal        virtual Status          WaitForVideoFrame();        virtual Status          WaitForAudioFrame();       //fill MediaData with current frame        virtual Status          GetVideoFrame(MediaDataEx* data);        virtual Status          GetAudioFrame(MediaData* data);        //free returned buffer if possible for writing        //and switch to next buffer        virtual Status          SwitchToNextVideoFrame();        virtual Status          SwitchToNextAudioFrame();        //check for the last buffer in sequence        virtual bool            IsLastVideoFrame();        virtual bool            IsLastAudioFrame();        //buffer initialization        virtual Status          InitVideoFrameBuffer();        virtual Status          InitAudioFrameBuffer();        //start from this to understand type of stream:        //TS, PS, pure etc        virtual Status          DetectSequence();        virtual bool            IfFrameRequared();        //this expansion splitter abilities with new stream        //formats which unsupported by this class        //overload this function to check other formats        //if operation was successful next basic field must be filled:        //m_sSplInfo.m_splitter_flags;        //m_bIgnoreVideo;        //m_bIgnoreAudio;        //m_sSplInfo.m_system_info.stream_type;        //m_sSplInfo.m_audio_info.stream_type;        //by default it returns not UMC_OK and nothing does        virtual Status          CheckMoreFormats();        void                    StoreLastPositionAndPTS(double time, vm_sizet byte_offset);    protected:        //swap every 2 bytes from ptr, inplace        static void             Swap2Bytes(unsigned char* ptr, int size);        //swap every 4 bytes from ptr, inplace        static void             Swap4Bytes(unsigned char* ptr, int size);        //swap every 2 bytes from ptr        static void             Swap2Bytes(unsigned char* inptr,                                        unsigned char* outptr, int size);        //swap every 4 bytes from ptr        static void             Swap4Bytes(unsigned char* inptr,                                        unsigned char* outptr, int size);        //to run splitter thread        friend    unsigned int   SplitterThreadProc(void* u)        {            return ((UMC::MPEG2SplitterBase*)u)->SingleSplitterThread();        }        friend    unsigned int   SplitterReverseThreadProc(void* u)        {            return ((UMC::MPEG2SplitterBase*)u)->SingleReverseSplitterThread();        }        //splitter thread itself        unsigned int            SingleSplitterThread    ();        unsigned int            SingleReverseSplitterThread();    };} // namespace UMC#endif /* __UMC_MPEG2_SPL_BASE_H__ */

⌨️ 快捷键说明

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