18 #include "scanner/api/kernel.h" 19 #include "scanner/util/common.h" 20 #include "scanner/util/queue.h" 21 #include "scanner/video/video_decoder.h" 24 #include <cuda_runtime.h> 25 #if CUDA_VERSION >= 9000 26 #include "scanner/video/nvidia/nvcuvid.h" 39 CUcontext cuda_context);
43 void configure(
const FrameInfo& metadata)
override;
45 bool feed(
const u8* encoded_buffer,
size_t encoded_size,
46 bool discontinuity =
false)
override;
48 bool discard_frame()
override;
50 bool get_frame(u8* decoded_buffer,
size_t decoded_size)
override;
52 int decoded_frames_buffered()
override;
54 void wait_until_frames_copied()
override;
57 static int cuvid_handle_video_sequence(
void* opaque, CUVIDEOFORMAT* format);
59 static int cuvid_handle_picture_decode(
void* opaque,
60 CUVIDPICPARAMS* picparams);
62 static int cuvid_handle_picture_display(
void* opaque,
63 CUVIDPARSERDISPINFO* dispinfo);
66 DeviceType output_type_;
67 CUcontext cuda_context_;
68 static const int max_output_frames_ = 32;
69 static const int max_mapped_frames_ = 8;
70 std::vector<cudaStream_t> streams_;
74 std::vector<char> metadata_packets_;
75 CUvideoparser parser_;
76 CUvideodecoder decoder_;
78 i32 last_displayed_frame_;
79 volatile i32 frame_in_use_[max_output_frames_];
80 volatile i32 undisplayed_frames_[max_output_frames_];
81 volatile i32 invalid_frames_[max_output_frames_];
83 std::mutex frame_queue_mutex_;
84 CUVIDPARSERDISPINFO frame_queue_[max_output_frames_];
85 i32 frame_queue_read_pos_;
86 i32 frame_queue_elements_;
88 CUdeviceptr mapped_frames_[max_mapped_frames_];
VideoDecoder.
Definition: video_decoder.h:38
Definition: database.cpp:36
FrameInfo.
Definition: frame.h:34
NVIDIAVideoDecoder.
Definition: nvidia_video_decoder.h:36