Scanner C++ API
intel_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/eval/evaluator.h"
19 #include "scanner/video/video_decoder.h"
20 
21 extern "C" {
22 #include "libavcodec/avcodec.h"
23 #include "libavfilter/avfilter.h"
24 #include "libavformat/avformat.h"
25 #include "libavformat/avio.h"
26 #include "libavutil/error.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/pixdesc.h"
29 #include "libswscale/swscale.h"
30 }
31 
32 #include <deque>
33 #include <vector>
34 
35 namespace scanner {
36 
39 class IntelVideoDecoder : public VideoDecoder {
40  public:
41  IntelVideoDecoder(int device_id, DeviceType output_type);
42 
44 
45  void configure(const InputFormat& metadata) override;
46 
47  bool feed(const u8* encoded_buffer, size_t encoded_size,
48  bool discontinuity = false) override;
49 
50  bool discard_frame() override;
51 
52  bool get_frame(u8* decoded_buffer, size_t decoded_size) override;
53 
54  int decoded_frames_buffered() override;
55 
56  void wait_until_frames_copied() override;
57 
58  private:
59  int device_id_;
60  DeviceType output_type_;
61  AVPacket packet_;
62  AVCodec* codec_;
63  AVCodecContext* cc_;
64 
65  InputFormat metadata_;
66  std::vector<u8> conversion_buffer_;
67  bool reset_context_;
68  SwsContext* sws_context_;
69 
70  std::vector<AVFrame*> frame_pool_;
71  std::deque<AVFrame*> decoded_frame_queue_;
72 };
73 }
IntelVideoDecoder.
Definition: intel_video_decoder.h:39
IntelVideoDecoder(int device_id, DeviceType output_type)
IntelVideoDecoder.
Definition: intel_video_decoder.cpp:39
Definition: database.cpp:36