#ifndef __BASICLIBAV_H_INCL__ #define __BASICLIBAV_H_INCL__ #ifndef __linux__ #include #include #endif #include #include #include #include "basicTypes.h" #include "basicLogCollection.h" using namespace cv; #ifdef __linux__ #ifndef UINT64_C #define UINT64_C uint64_t #endif #endif #define _CRT_SECURE_NO_DEPRECIATE extern "C" { #include #include #include #include #include #include #include #include #include }; #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1) #define av_frame_alloc avcodec_alloc_frame #define av_frame_free avcodec_free_frame #define avcodec_free_context av_free #define AV_PIX_FMT_BGR24 PIX_FMT_BGR24 #endif #define CLEAR(x) memset(&(x), 0, sizeof(x)) #ifndef V4L2_PIX_FMT_H264 #define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4') /* H264 with start codes */ #endif extern bool _FFD_REGISTER_ALL_FLAG; #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 #define VIDEO_PICTURE_QUEUE_SIZE 30 #define BUFFER_ALIGN 32 //#define PROCESS_YUV420P #define PROCESS_BGR24 #define _NOAUDIO_ typedef std::vector< cv::Mat* > _FrameQueue; typedef float FrameAspectRatio; #define FAR_UNKNOWN .0f #define FAR_4X3 1.3333333333333333333333333333333f #define FAR_5X4 1.25f #define FAR_16X9 1.7777777777777777777777777777778f #define FAR_SQUARE 1.f typedef enum MedaLaneType{ ML_NONE = 0x00, ML_IN = 0x01, ML_OUT = 0x02, ML_IN_OUT = 0x03, ML_IMAGE = 0x04, ML_VIDEO = 0x08, ML_AUDIO = 0x10 } MedaLaneType; typedef enum AttachmentStatus{ AS_NONE = 0, AS_SOURCE = 1, AS_DESTINATION = 2, AS_BOTH = 3 } AttachmentStatus; typedef union MediaFormatInfo{ struct VIDEO_INFO{ /**** video ****/ //PixelFormat PixelFMT; int ImageWidth; int ImageHeight; int VideoFPS; }VIDEO_INFO; struct AUDIO_INFO{ /**** Audio ****/ AVSampleFormat AudioFMT; int AudioSPS; int AudioCHA; int no_use; }AUDIO_INFO; } MediaFormatInfo; typedef struct VideoPicture { cv::Mat *m_pTexture; int width; int height; /* source height & width */ bool allocated; } VideoPicture; typedef struct VideoState { #ifndef _NOAUDIO_ int m_iAudioStreamID; AVStream *m_pAudioStr; AVCodecContext *m_pAudioCtx; AVCodec *m_pAudioCodec; //_PacketQueue *m_pAudioQQ; uint8_t m_mAudioBuf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2]; unsigned int m_iAudioBufSize; unsigned int m_iAudioBufIndex; AVPacket m_mAudioPack; uint8_t *m_pAudioPktData; int m_iAudioPktSize; #endif int m_iVideoStreamID; AVStream *m_pVideoStr; AVFormatContext *m_pFormatCtx; AVDictionary *m_pFormatOpts; AVCodecContext *m_pCodecCtx; AVCodec *m_pVideoCodec; //VideoPicture m_mPictQ[VIDEO_PICTURE_QUEUE_SIZE]; //int m_iPictQSize; //int m_iPictQ_rindex; //int m_iPictQ_windex; char m_pFileName[MAX_PATH_LEN]; MediaStateStatus m_bStatus; } VideoState; FrameAspectRatio detectAspectRatio(int width, int height); bool initLibAV(void); #endif // __BASICLIBAV_H_INCL__