blob: f5beb8f322dbd23d50117ad34f4b7b61e239d14e [file] [log] [blame]
Fyodor Kyslovdd7d5992024-11-05 21:40:16 +00001/*
2 * Copyright (C) 2024 The Android Open Source Project
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#ifndef ANDROID_C2_SOFT_APV_DEC_H_
18#define ANDROID_C2_SOFT_APV_DEC_H_
19
20#include <media/stagefright/foundation/ColorUtils.h>
21
22#include <SimpleC2Component.h>
23#include <inttypes.h>
24#include <atomic>
25
26#include "oapv.h"
27#include <C2SoftApvCommon.h>
28
29typedef unsigned int UWORD32;
30
31typedef enum {
32 IV_CHROMA_NA = 0xFFFFFFFF,
33 IV_YUV_420P = 0x1,
34 IV_YUV_422P = 0x2,
35 IV_420_UV_INTL = 0x3,
36 IV_YUV_422IBE = 0x4,
37 IV_YUV_422ILE = 0x5,
38 IV_YUV_444P = 0x6,
39 IV_YUV_411P = 0x7,
40 IV_GRAY = 0x8,
41 IV_RGB_565 = 0x9,
42 IV_RGB_24 = 0xa,
43 IV_YUV_420SP_UV = 0xb,
44 IV_YUV_420SP_VU = 0xc,
45 IV_YUV_422SP_UV = 0xd,
46 IV_YUV_422SP_VU = 0xe
47
48} IV_COLOR_FORMAT_T;
49
50typedef struct {
51 /**
52 * u4_size of the structure
53 */
54 UWORD32 u4_size;
55
56 /**
57 * Pointer to the API function pointer table of the codec
58 */
59 void* pv_fxns;
60
61 /**
62 * Pointer to the handle of the codec
63 */
64 void* pv_codec_handle;
65} iv_obj_t;
66
67namespace android {
68
Fyodor Kyslov3fea66b2024-11-08 18:32:26 +000069struct C2SoftApvDec final : public SimpleC2Component {
Fyodor Kyslovdd7d5992024-11-05 21:40:16 +000070 class IntfImpl;
71
72 C2SoftApvDec(const char* name, c2_node_id_t id, const std::shared_ptr<IntfImpl>& intfImpl);
73 virtual ~C2SoftApvDec();
74
75 // From SimpleC2Component
76 c2_status_t onInit() override;
77 c2_status_t onStop() override;
78 void onReset() override;
79 void onRelease() override;
80 c2_status_t onFlush_sm() override;
81 void process(const std::unique_ptr<C2Work>& work,
82 const std::shared_ptr<C2BlockPool>& pool) override;
83 c2_status_t drain(uint32_t drainMode, const std::shared_ptr<C2BlockPool>& pool) override;
84
85 private:
86 status_t createDecoder();
87 status_t initDecoder();
88 bool isConfigured() const;
89 void drainDecoder();
90 status_t setFlushMode();
91 status_t resetDecoder();
92 void resetPlugin();
93 status_t deleteDecoder();
94 void finishWork(uint64_t index, const std::unique_ptr<C2Work>& work,
95 const std::shared_ptr<C2GraphicBlock>& block);
96 void drainRingBuffer(const std::unique_ptr<C2Work>& work,
97 const std::shared_ptr<C2BlockPool>& pool, bool eos);
98 c2_status_t drainInternal(uint32_t drainMode, const std::shared_ptr<C2BlockPool>& pool,
99 const std::unique_ptr<C2Work>& work);
100
101 status_t outputBuffer(const std::shared_ptr<C2BlockPool>& pool,
102 const std::unique_ptr<C2Work>& work);
103
104 std::shared_ptr<IntfImpl> mIntf;
105 iv_obj_t* mDecHandle;
106 uint8_t* mOutBufferFlush;
107 IV_COLOR_FORMAT_T mIvColorformat;
108 uint32_t mOutputDelay;
109 bool mHeaderDecoded;
110 std::atomic_uint64_t mOutIndex;
111 std::shared_ptr<C2GraphicBlock> mOutBlock;
112
113 std::shared_ptr<C2StreamPixelFormatInfo::output> mPixelFormatInfo;
114
115 std::shared_ptr<C2StreamPictureSizeInfo::input> mSize;
116 uint32_t mHalPixelFormat;
117 uint32_t mWidth;
118 uint32_t mHeight;
119 bool mSignalledOutputEos;
120 bool mSignalledError;
121
122 oapvd_t oapvdHandle;
123 oapvm_t oapvmHandle;
124 oapvd_cdesc_t cdesc;
125 oapv_frms_t ofrms;
126
127 int outputCsp;
128
129 C2_DO_NOT_COPY(C2SoftApvDec);
130};
131
132} // namespace android
133
134#endif