• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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_STAGEFRIGHT_C2PARAM_INTERNAL_H_
18 #define ANDROID_STAGEFRIGHT_C2PARAM_INTERNAL_H_
19 
20 #include <C2Param.h>
21 
22 struct C2_HIDE _C2ParamInspector {
GetOffset_C2ParamInspector23     inline static uint32_t GetOffset(const C2FieldDescriptor &fd) {
24         return fd._mFieldId._mOffset;
25     }
26 
SetOffset_C2ParamInspector27     inline static void SetOffset(C2FieldDescriptor &fd, uint32_t offset) {
28         fd._mFieldId._mOffset = offset;
29     }
30 
31     inline static uint32_t GetEndOffset(const C2FieldDescriptor &fd, uint32_t paramSize = 0) {
32         uint32_t endOffset = fd._mFieldId._mOffset + fd._mExtent * fd._mFieldId._mSize;
33         /// for flex parameters return paramSize if given
34         return fd._mExtent ? endOffset : std::max(endOffset, paramSize);
35     }
36 
GetSize_C2ParamInspector37     inline static uint32_t GetSize(const C2FieldDescriptor &fd) {
38         return fd._mFieldId._mSize;
39     }
40 
GetIndex_C2ParamInspector41     inline static uint32_t GetIndex(const C2ParamField &pf) {
42         return pf._mIndex;
43     }
44 
GetOffset_C2ParamInspector45     inline static uint32_t GetOffset(const C2ParamField &pf) {
46         return pf._mFieldId._mOffset;
47     }
48 
GetSize_C2ParamInspector49     inline static uint32_t GetSize(const C2ParamField &pf) {
50         return pf._mFieldId._mSize;
51     }
52 
GetOffset_C2ParamInspector53     inline static uint32_t GetOffset(const _C2FieldId &f) {
54         return f._mOffset;
55     }
56 
GetSize_C2ParamInspector57     inline static uint32_t GetSize(const _C2FieldId &f) {
58         return f._mSize;
59     }
60 
GetField_C2ParamInspector61     inline static _C2FieldId GetField(const C2FieldDescriptor &fd) {
62         return fd._mFieldId;
63     }
64 
GetAttrib_C2ParamInspector65     inline static uint32_t GetAttrib(const C2ParamDescriptor &pd) {
66         return pd._mAttrib;
67     }
68 
GetField_C2ParamInspector69     inline static _C2FieldId GetField(const C2ParamField &pf) {
70         return pf._mFieldId;
71     }
72 
73     inline static
CreateParamField_C2ParamInspector74     C2ParamField CreateParamField(C2Param::Index index, uint32_t offset, uint32_t size) {
75         return C2ParamField(index, offset, size);
76     }
77 
78     inline static
CreateParamField_C2ParamInspector79     C2ParamField CreateParamField(C2Param::Index index, _C2FieldId field) {
80         return C2ParamField(index, field._mOffset, field._mSize);
81     }
82 
83     inline static
TrimParam_C2ParamInspector84     void TrimParam(C2Param *param, uint32_t newSize) {
85         if (param && *param && param->size() > newSize && newSize >= sizeof(C2Param)) {
86             param->_mSize = newSize;
87         }
88     }
89 
AddNamedValues_C2ParamInspector90     inline static void AddNamedValues(
91             C2FieldDescriptor &fd, C2FieldDescriptor::NamedValuesType &&namedValues) {
92         fd._mNamedValues = std::move(namedValues);
93     }
94 
95     inline static
CreateStructDescriptor_C2ParamInspector96     C2StructDescriptor CreateStructDescriptor(C2Param::CoreIndex index,
97                                         std::vector<C2FieldDescriptor> &&fields) {
98         return C2StructDescriptor(index, std::move(fields));
99     }
100 
101     inline static
OffsetFieldDescriptor_C2ParamInspector102     C2FieldDescriptor OffsetFieldDescriptor(const C2FieldDescriptor &fd, size_t offset) {
103         return C2FieldDescriptor(fd, offset);
104     }
105 
106     // expose attributes
107     typedef C2ParamDescriptor::attrib_t attrib_t;
108 };
109 
110 #endif // ANDROID_STAGEFRIGHT_C2PARAM_INTERNAL_H_
111 
112