You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.1 KiB
98 lines
2.1 KiB
#ifndef __VIDEO_INPUT_LIBAV_HEADER__
|
|
#define __VIDEO_INPUT_LIBAV_HEADER__
|
|
|
|
#include "video_in.h"
|
|
|
|
#include <stdarg.h>
|
|
|
|
extern "C"
|
|
{
|
|
#include <libavcodec/avcodec.h>
|
|
#include <libavdevice/avdevice.h>
|
|
#include <libavformat/avformat.h>
|
|
#include <libavutil/imgutils.h>
|
|
#include <libswscale/swscale.h>
|
|
};
|
|
|
|
#include "../core/exit_error_codes.h"
|
|
|
|
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
|
|
#define VIDEO_PICTURE_QUEUE_SIZE 30
|
|
#define BUFFER_ALIGN 32
|
|
|
|
// #define PROCESS_YUV420P
|
|
#define PROCESS_BGR24
|
|
|
|
// extern bool _FFD_REGISTER_ALL_FLAG;
|
|
|
|
typedef struct VideoPicture
|
|
{
|
|
cv::Mat * m_pTexture;
|
|
int width;
|
|
int height; /* source height & width */
|
|
bool allocated;
|
|
} VideoPicture;
|
|
|
|
typedef struct VideoState
|
|
{
|
|
AVFormatContext * m_pFormatCtx;
|
|
#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;
|
|
AVCodecContext * m_pVideoCtx;
|
|
AVCodec * m_pVideoCodec;
|
|
VideoPicture m_mPictQ[VIDEO_PICTURE_QUEUE_SIZE];
|
|
int m_iPictQSize;
|
|
int m_iPictQ_rindex;
|
|
int m_iPictQ_windex;
|
|
char m_pFileName[1024];
|
|
uint8_t m_bStatus;
|
|
// int quit;
|
|
} VideoState;
|
|
|
|
class _LIBAV_VideoInput : public _VideoInput
|
|
{
|
|
private:
|
|
|
|
VideoState * m_pVideoState;
|
|
AVFrame * m_pFrame;
|
|
AVFrame * m_pFrameBGR;
|
|
cv::Mat m_pMat;
|
|
cv::Mat m_pOMat;
|
|
uint8_t * m_pOut_buffer;
|
|
AVPacket * m_pPacket;
|
|
|
|
int m_iY_size;
|
|
struct SwsContext * img_convert_ctx;
|
|
// static void *m_tVideoProc(void *args);
|
|
#ifndef _NOAUDIO_
|
|
static void * m_tAudioProc(void * args);
|
|
#endif
|
|
bool initLBAV(void);
|
|
bool openSource(char * URI);
|
|
bool closeSource(void);
|
|
|
|
protected:
|
|
|
|
void m_fInputProc(void);
|
|
|
|
public:
|
|
|
|
_LIBAV_VideoInput();
|
|
_LIBAV_VideoInput(char * Source);
|
|
~_LIBAV_VideoInput();
|
|
};
|
|
|
|
#endif
|