• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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 #include "codec_component_capability.h"
17 #include <hdf_log.h>
18 #include <securec.h>
19 #include "codec_capability_parser.h"
20 
21 #define HDF_LOG_TAG codec_hdi_capability
22 
23 static CodecExInfoGroups g_codecExInfoGroups = {0};
24 
ClearExInfoData()25 int32_t ClearExInfoData()
26 {
27     return ClearExInfoGroup(&g_codecExInfoGroups);
28 }
29 
LoadExInfoData(const struct DeviceResourceNode * node)30 int32_t LoadExInfoData(const struct DeviceResourceNode *node)
31 {
32     return LoadCodecExInfoFromHcs(node, &g_codecExInfoGroups);
33 }
34 
GetBasicInfoByCompName(uint8_t * info,const char * compName)35 int32_t GetBasicInfoByCompName(uint8_t *info, const char *compName)
36 {
37     int32_t groupIndex;
38     int32_t infoIndex;
39     bool isFind = false;
40     CodecExInfoGroup *group = NULL;
41     CodecExInfo *exInfo = NULL;
42     CodecExInfo *exInfoDest = (CodecExInfo *)info;
43     CodecExInfoGroup *codeExInfoGroups[] = {
44         &(g_codecExInfoGroups.videoHwEncoderGroup), &(g_codecExInfoGroups.videoHwDecoderGroup),
45         &(g_codecExInfoGroups.audioHwEncoderGroup), &(g_codecExInfoGroups.audioHwDecoderGroup),
46         &(g_codecExInfoGroups.videoSwEncoderGroup), &(g_codecExInfoGroups.videoSwDecoderGroup),
47         &(g_codecExInfoGroups.audioSwEncoderGroup), &(g_codecExInfoGroups.audioSwDecoderGroup)
48     };
49 
50     for (groupIndex = 0; groupIndex < CODEC_CAPABLITY_GROUP_NUM; groupIndex++) {
51         group = codeExInfoGroups[groupIndex];
52         for (infoIndex = 0; infoIndex < group->num; infoIndex++) {
53             exInfo = &group->exInfo[infoIndex];
54             if (strcmp(compName, exInfo->compName) == 0) {
55                 memcpy_s(exInfoDest, sizeof(CodecExInfo), exInfo, sizeof(CodecExInfo));
56                 isFind = true;
57                 break;
58             }
59         }
60         if (isFind) {
61             break;
62         }
63     }
64 
65     return isFind ? HDF_SUCCESS : HDF_FAILURE;
66 }
67