xref: /OK3568_Linux_fs/external/mpp/utils/mpi_dec_utils.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2020 Rockchip Electronics Co. LTD
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 __MPI_DEC_UTILS_H__
18 #define __MPI_DEC_UTILS_H__
19 
20 #include <stdio.h>
21 #include "utils.h"
22 
23 #define MAX_FILE_NAME_LENGTH        256
24 #define MPI_DEC_STREAM_SIZE         (SZ_4K)
25 #define MPI_DEC_LOOP_COUNT          4
26 
27 typedef void* FileReader;
28 
29 typedef struct FileBufSlot_t {
30     RK_S32          index;
31     MppBuffer       buf;
32     size_t          size;
33     RK_U32          eos;
34     char            *data;
35 } FileBufSlot;
36 
37 /* For overall configure setup */
38 typedef struct MpiDecTestCmd_t {
39     char            file_input[MAX_FILE_NAME_LENGTH];
40     char            file_output[MAX_FILE_NAME_LENGTH];
41 
42     MppCodingType   type;
43     MppFrameFormat  format;
44     RK_U32          width;
45     RK_U32          height;
46 
47     RK_U32          have_input;
48     RK_U32          have_output;
49 
50     RK_U32          simple;
51     RK_S32          timeout;
52     RK_S32          frame_num;
53     size_t          pkt_size;
54     /* use for mpi_dec_multi_test */
55     RK_S32          nthreads;
56     // report information
57     size_t          max_usage;
58 
59     /* data for share */
60     FileReader      reader;
61     FpsCalc         fps;
62 
63     /* runtime log flag */
64     RK_U32          quiet;
65     RK_U32          trace_fps;
66     char            *file_slt;
67 } MpiDecTestCmd;
68 
69 extern OptionInfo mpi_dec_cmd[];
70 
71 RK_S32  mpi_dec_test_cmd_init(MpiDecTestCmd* cmd, int argc, char **argv);
72 RK_S32  mpi_dec_test_cmd_deinit(MpiDecTestCmd* cmd);
73 void    mpi_dec_test_cmd_options(MpiDecTestCmd* cmd);
74 
75 void    reader_init(FileReader* reader, char* file_in, MppCodingType type);
76 void    reader_deinit(FileReader reader);
77 
78 void    reader_start(FileReader reader);
79 void    reader_sync(FileReader reader);
80 void    reader_stop(FileReader reader);
81 
82 size_t  reader_size(FileReader reader);
83 MPP_RET reader_read(FileReader reader, FileBufSlot **buf);
84 MPP_RET reader_index_read(FileReader reader, RK_S32 index, FileBufSlot **buf);
85 void    reader_rewind(FileReader reader);
86 
87 void show_dec_fps(RK_S64 total_time, RK_S64 total_count, RK_S64 last_time, RK_S64 last_count);
88 
89 #endif
90