Scanner C++ API
video_decoder.h
1 /* Copyright 2016 Carnegie Mellon University
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include "scanner/api/kernel.h"
19 #include "scanner/engine/metadata.h"
20 #include "scanner/util/common.h"
21 #include "scanner/util/profiler.h"
22 
23 #include <vector>
24 
25 namespace scanner {
26 namespace internal {
27 
28 class InputFormat;
29 
30 enum class VideoDecoderType {
31  NVIDIA,
32  INTEL,
33  SOFTWARE,
34 };
35 
38 class VideoDecoder {
39  public:
40  static std::vector<VideoDecoderType> get_supported_decoder_types();
41 
42  static bool has_decoder_type(VideoDecoderType type);
43 
44  static VideoDecoder* make_from_config(DeviceHandle device_handle,
45  i32 num_devices, VideoDecoderType type);
46 
47  virtual ~VideoDecoder(){};
48 
49  virtual void configure(const FrameInfo& metadata) = 0;
50 
51  virtual bool feed(const u8* encoded_buffer, size_t encoded_size,
52  bool discontinuity = false) = 0;
53 
54  virtual bool discard_frame() = 0;
55 
56  virtual bool get_frame(u8* decoded_buffer, size_t decoded_size) = 0;
57 
58  virtual int decoded_frames_buffered() = 0;
59 
60  virtual void wait_until_frames_copied() = 0;
61 
62  void set_profiler(Profiler* profiler);
63 
64  protected:
65  Profiler* profiler_ = nullptr;
66 };
67 }
68 }
Definition: profiler.h:40
VideoDecoder.
Definition: video_decoder.h:38
Definition: common.h:53
Definition: database.cpp:36
FrameInfo.
Definition: frame.h:34