-
Notifications
You must be signed in to change notification settings - Fork 1
/
VideoDecoder.h
executable file
·98 lines (76 loc) · 2.56 KB
/
VideoDecoder.h
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
94
95
96
97
98
/*
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related documentation outside the terms of the EULA
* is strictly prohibited.
*
*/
#ifndef NV_VIDEODECODER_H
#define NV_VIDEODECODER_H
// CUDA Header includes
#include "dynlink_cuda.h" // <cuda.h>
#include "dynlink_cuviddec.h" // <cuviddec.h>
#include "dynlink_nvcuvid.h" // <nvcuvid.h>
#define MAX_FRAME_COUNT 2
// Wrapper class around the CUDA Video Decoding API.
//
class VideoDecoder
{
public:
explicit
VideoDecoder(const CUVIDEOFORMAT &rVideoFormat, CUcontext &rContext,
cudaVideoCreateFlags eCreateFlags, CUvideoctxlock &ctx);
~VideoDecoder();
// Get the code-type currently used.
cudaVideoCodec
codec()
const;
cudaVideoChromaFormat
chromaFormat()
const;
// Maximum number of decode surfaces used by decoder.
unsigned long
maxDecodeSurfaces()
const;
unsigned long
frameWidth()
const;
unsigned long
frameHeight()
const;
unsigned long
targetWidth()
const;
unsigned long
targetHeight()
const;
int GetColorDepth() const {
return oVideoDecodeCreateInfo_.bitDepthMinus8 + 8;
}
int GetNumBytesPerSample() const {
return oVideoDecodeCreateInfo_.bitDepthMinus8 == 0 ? 1 : 2;
}
CUresult
decodePicture(CUVIDPICPARAMS *pPictureParameters, CUcontext *pContext = NULL);
CUresult
mapFrame(int iPictureIndex, CUdeviceptr *ppDevice, unsigned int *nPitch, CUVIDPROCPARAMS *pVideoProcessingParameters);
CUresult
unmapFrame(CUdeviceptr pDevice);
private:
// Default constructor. Don't implement.
VideoDecoder();
// Copy constructor. Don't implement.
VideoDecoder(const VideoDecoder &);
// Assignment operator. Don't implement.
void
operator= (const VideoDecoder &);
CUVIDDECODECREATEINFO oVideoDecodeCreateInfo_;
CUvideodecoder oDecoder_;
cudaVideoCreateFlags m_VideoCreateFlags;
CUcontext m_Context;
CUvideoctxlock m_VidCtxLock;
};
#endif // NV_VIDEODECODER_H