1 /* 2 * Copyright (c) 2022-2023 Shenzhen Kaihong DID 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 #ifndef CODEC_UTILS_H 17 #define CODEC_UTILS_H 18 19 #include <stdio.h> 20 #include <stdlib.h> 21 #include "hdf_types.h" 22 #include "codec_type.h" 23 #include "osal_mem.h" 24 25 #define MAX_FILE_NAME_LENGTH 256 26 #define TYPE_NAME_LENGTH 256 27 #define CODEC_NAME_ALIAS_NUM 2 28 #define CODEC_NAME_AVC_HW_DECODER "codec.avc.hardware.decoder" 29 #define CODEC_NAME_HEVC_HW_DECODER "codec.hevc.hardware.decoder" 30 #define CODEC_NAME_VP9_HW_DECODER "codec.vp9.hardware.decoder" 31 #define CODEC_NAME_VP8_HW_DECODER "codec.vp8.hardware.decoder" 32 #define CODEC_NAME_MPEG4_HW_DECODER "codec.mpeg4.hardware.decoder" 33 #define CODEC_NAME_AVC_HW_ENCODER "codec.avc.hardware.encoder" 34 #define CODEC_NAME_HEVC_HW_ENCODER "codec.hevc.hardware.encoder" 35 #define CODEC_NAME_VP9_HW_ENCODER "codec.vp9.hardware.encoder" 36 #define CODEC_NAME_VP8_HW_ENCODER "codec.vp8.hardware.encoder" 37 #define CODEC_NAME_MPEG4_HW_ENCODER "codec.mpeg4.hardware.encoder" 38 39 typedef struct { 40 char *codecName; 41 /* end of stream flag when set quit the loop */ 42 unsigned int loopEnd; 43 /* input and output */ 44 FILE *fpInput; 45 FILE *fpOutput; 46 int32_t frameNum; 47 uint32_t bufferSize; 48 uint32_t inputBufferCount; 49 uint32_t outputBufferCount; 50 CodecCallback cb; 51 } CodecEnvData; 52 53 /* For overall configure setup */ 54 typedef struct { 55 CodecType type; 56 char fileInput[MAX_FILE_NAME_LENGTH]; 57 char fileOutput[MAX_FILE_NAME_LENGTH]; 58 char codecName[TYPE_NAME_LENGTH]; 59 AvCodecMime mime; 60 int32_t width; 61 int32_t height; 62 int32_t fps; 63 PixelFormat pixFmt; 64 } CodecCmd; 65 66 typedef struct { 67 char *codecType[CODEC_NAME_ALIAS_NUM]; 68 char *codecName; 69 AvCodecMime mimeType; 70 } CodecTypeAndName; 71 72 int32_t ParseArguments(CodecCmd* cmd, int argc, char **argv); 73 void FreeParams(Param *params, int32_t paramCnt); 74 75 #endif // CODEC_UTILS_H 76