Apollo  6.0
Open source self driving car software
h265_decoder.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #pragma once
18 
19 #include <vector>
20 
21 extern "C" {
22 #include <libavcodec/avcodec.h>
23 #include <libavformat/avformat.h>
24 #include <libavutil/imgutils.h>
25 #include <libswscale/swscale.h>
26 }
27 
28 namespace apollo {
29 namespace drivers {
30 namespace video {
31 
36 class H265Decoder {
37  public:
38  enum class DecodingResult {
39  SUCCESS,
40  FATAL,
41  WARN,
42  };
43 
44  public:
45  H265Decoder() = default;
46 
47  // Init decoder by acquiring resources
48  bool Init();
49 
50  // Process frames according to input data, and output converted data
51  DecodingResult Process(const uint8_t* indata, const int32_t insize,
52  std::vector<uint8_t>* outdata) const;
53 
54  // Destructor, releasing the resources
55  ~H265Decoder() { Release(); }
56 
57  // Getter of codec_ctx_h265_
58  AVCodecContext* GetCodecCtxH265() const { return codec_ctx_h265_; }
59 
60  private:
61  void Release();
62 
63  AVCodecContext* codec_ctx_h265_ = nullptr;
64  AVCodecContext* codec_ctx_jpeg_ = nullptr;
65  AVFrame* yuv_frame_ = nullptr;
66 };
67 
68 } // namespace video
69 } // namespace drivers
70 } // namespace apollo
DecodingResult
Definition: h265_decoder.h:38
AVCodecContext * GetCodecCtxH265() const
Definition: h265_decoder.h:58
DecodingResult Process(const uint8_t *indata, const int32_t insize, std::vector< uint8_t > *outdata) const
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
H265Decoder is a class to actually decode videos.
Definition: h265_decoder.h:36
~H265Decoder()
Definition: h265_decoder.h:55