• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2020 The Android Open Source Project
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 #ifndef COMPUTEPIPE_RUNNER_INPUT_FRAME
16 #define COMPUTEPIPE_RUNNER_INPUT_FRAME
17 
18 #include <cstdint>
19 #include <functional>
20 
21 #include "types/Status.h"
22 namespace android {
23 namespace automotive {
24 namespace computepipe {
25 namespace runner {
26 
27 typedef std::function<void(uint8_t[])> FrameDeleter;
28 /**
29  * Information about the input frame
30  */
31 struct FrameInfo {
32     uint32_t height;  // In pixels
33     uint32_t width;   // In pixels
34     PixelFormat format;
35     uint32_t stride;  // In bytes
36     int cameraId;
37 };
38 
39 /**
40  * Wrapper around the pixel data of the input frame
41  */
42 struct InputFrame {
43   public:
44     /**
45      * Take info about frame data. InputFrame does not take ownership of the data.
46      */
InputFrameInputFrame47     explicit InputFrame(uint32_t height, uint32_t width, PixelFormat format, uint32_t stride,
48                         const uint8_t* ptr) {
49         mInfo.height = height;
50         mInfo.width = width;
51         mInfo.format = format;
52         mInfo.stride = stride;
53         mDataPtr = ptr;
54     }
55 
56     /**
57      * This is an unsafe method, that a consumer should use to copy the
58      * underlying frame data
59      */
getFramePtrInputFrame60     const uint8_t* getFramePtr() const {
61         return mDataPtr;
62     }
getFrameInfoInputFrame63     FrameInfo getFrameInfo() const {
64         return mInfo;
65     }
66     /**
67      * Delete evil constructors
68      */
69     InputFrame() = delete;
70     InputFrame(const InputFrame&) = delete;
71     InputFrame& operator=(const InputFrame& f) = delete;
72     InputFrame(InputFrame&& f) = delete;
73     InputFrame& operator=(InputFrame&& f) = delete;
74 
75   private:
76     FrameInfo mInfo;
77     FrameDeleter mDeleter;
78     const uint8_t* mDataPtr;
79 };
80 
81 }  // namespace runner
82 }  // namespace computepipe
83 }  // namespace automotive
84 }  // namespace android
85 
86 #endif
87