DxDecoderWrap.h
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef __DX__DxDecoderWrap__MODULE__
#define __DX__DxDecoderWrap__MODULE__
#include "../DxDecoder/DxDecoderInterface.h"
#include <cuda.h>
#include <cuda_runtime.h>
#include <builtin_types.h>
#include <cuviddec.h>
#include <memory>
#include "cuda_kernels.h"
#define DX_GPU_FRAME_DEFAULT_SIZE 1
typedef struct DxGPUFrame
{
void * frame;
unsigned int size;
unsigned int width;
unsigned int height;
unsigned long long timestamp;
}DxGPUFrame;
typedef struct DxGPUFrames
{
unsigned int size;
unsigned int read;
unsigned int write;
unsigned int width;
unsigned int height;
unsigned int counts;
DxGPUFrame * frames;
CRITICAL_SECTION cir;
}DxGPUFrames;
class DxDecoderWrap
{
public:
DxDecoderWrap( const DxConfig * cfg );
virtual ~DxDecoderWrap();
int DxOpenDecoder( const char * uri, unsigned int skip );
int DxCloseDecoder();
BOOL DxDecoderIsRun() const;
int DxGetFrameCount();
int DxGetResolution( int * width, int * height );
BOOL DxFrameIsEmpty() const;
int DxLockFrame( DxGPUFrame * frame );
void DxUnlockFrame();
int PauseDecoder();
int ResumeDecoder();
private:
static int DxDecoderLogCallback(
const void * userPtr,
DxLogLevel level,
const char * log,
unsigned int logLen
);
static void DxCUDADecoderCallback(
const void * userPtr,
void * buf,
unsigned int size,
unsigned long long timestamp
);
private:
BOOL m_bRun;
BOOL m_bReal;
BOOL m_bPause;
unsigned int m_skip;
unsigned int m_nums;
DxGPUFrames m_frames;
DxDecoderConfig m_cfg;
DxDecoderInterface * m_pDec;
unsigned char * m_out;
unsigned int m_outSize;
uint8_t * m_src_data[4];
int m_src_linesize[4];
int m_dst_linesize[4];
uint8_t * m_dst_data[4];
};
#endif