xref: /rockchip-linux_mpp/tools/resolution_test.sh (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1#!/usr/bin/env bash
2#########################################################################
3# File Name: resolution_test.sh
4# Author: LiHongjin
5# mail: vic.hong@rock-chips.com
6# Created Time: Mon 28 Apr 2025 08:39:38 AM CST
7#########################################################################
8
9# def test h265
10cmd_spec="h265"
11cmd_sv_file="false"
12cmd_log="false"
13cmd_debug="false"
14
15rsl_list="
164x4
178x8
1816x16
1932x32
2064x64
21640x360
22854x480
231280x720
241920x1080
252560x1440
263840x2160
2716384x8192
2816384x9384
2916384x10384
3016384x16384
3165472x65472
3265520x65520
33"
34
35spec_list="h264 h265 avs2 vp9 av1 jpeg"
36
37type_h264="7"
38type_h265="16777220"
39type_avs2="16777223"
40type_vp9="10"
41type_av1="16777224"
42type_jpeg="8"
43
44enc_tool="mpi_enc_test"
45dec_tool="mpi_dec_test"
46
47test_spec_rsl()
48{
49    cur_sp="$1"
50
51    echo
52    echo "==> cur spec: ${cur_sp}"
53
54    for cur_rsl in ${rsl_list}
55    do
56        enc_out_norm_path="/data/mpp_rsl_enc_norm_${cur_rsl}.${cur_sp}"
57        enc_out_kmpp_path="/data/mpp_rsl_enc_kmpp_${cur_rsl}.${cur_sp}"
58        dec_out_path="/data/mpp_rsl_dec_${cur_rsl}.${cur_sp}"
59        frm_cnt=5
60
61        enc_norm_res="--"
62        enc_kmpp_res="--"
63        dec_res="--"
64
65        width=${cur_rsl%x*}
66        height=${cur_rsl#*x}
67        quiet_para=""
68        [ "${cmd_log}" = "false" ] && quiet_para="> /dev/null 2>&1"
69        [ "${width}" -gt 8192 ] && frm_cnt=2
70        [ "${height}" -gt 8192 ] && frm_cnt=2
71        [ "${cur_sp}" = "jpeg" ] && frm_cnt=1
72
73        eval cur_type='$'type_${cur_sp}
74
75        # enc normal
76        [ -e "${enc_out_norm_path}" ] && rm ${enc_out_norm_path}
77        cur_enc_cmd="${enc_tool} -w ${width} -h ${height} -n ${frm_cnt} -t ${cur_type} -o ${enc_out_norm_path} -rc 2 ${quiet_para}"
78        [ ${cmd_debug} = "true" ] && echo "cur enc cmd: ${cur_enc_cmd}"
79        eval ${cur_enc_cmd}
80        [ "$?" -eq 0 ] && { enc_norm_res="pass"; } || { enc_norm_res="faile"; }
81        if [ -e ${enc_out_norm_path} ]; then
82            [ "`wc -c < ${enc_out_norm_path}`" -eq 0 ] && enc_norm_res="faile"
83        fi
84
85        # enc kmpp
86        [ -e "${enc_out_kmpp_path}" ] && rm ${enc_out_kmpp_path}
87        cur_enc_cmd="${enc_tool} -w ${width} -h ${height} -n ${frm_cnt} -t ${cur_type} -o ${enc_out_kmpp_path} -kmpp 1 ${quiet_para}"
88        [ ${cmd_debug} = "true" ] && echo "cur enc cmd: ${cur_enc_cmd}"
89        eval ${cur_enc_cmd}
90        [ "$?" -eq 0 ] && { enc_kmpp_res="pass"; } || { enc_kmpp_res="faile"; }
91        if [ -e ${enc_out_kmpp_path} ]; then
92            [ "`wc -c < ${enc_out_kmpp_path}`" -eq 0 ] && enc_kmpp_res="faile"
93        fi
94
95        # dec
96        if [ "${enc_norm_res}" = "pass" ]; then
97            [ -e "${dec_out_path}" ] && rm ${dec_out_path}
98            cur_dec_cmd="${dec_tool} -i ${enc_out_norm_path} -w ${width} -h ${height} -t ${cur_type} -o ${dec_out_path} ${quiet_para}"
99            [ ${cmd_debug} = "true" ] && echo "cur dec cmd: ${cur_dec_cmd}"
100            eval ${cur_dec_cmd}
101            [ "$?" -eq 0 ] && { dec_res="pass"; } || { dec_res="faile"; }
102            if [ -e ${dec_out_path} ]; then
103                [ "`wc -c < ${dec_out_path}`" -eq 0 ] && dec_res="faile"
104            fi
105        elif [ ${enc_kmpp_res} = "pass" ];  then
106            [ -e "${dec_out_path}" ] && rm ${dec_out_path}
107            cur_dec_cmd="${dec_tool} -i ${enc_out_kmpp_path} -w ${width} -h ${height} -t ${cur_type} -o ${dec_out_path} ${quiet_para}"
108            [ ${cmd_debug} = "true" ] && echo "cur dec cmd: ${cur_dec_cmd}"
109            eval ${cur_dec_cmd}
110            [ "$?" -eq 0 ] && { dec_res="pass"; } || { dec_res="faile"; }
111            if [ -e ${dec_out_path} ]; then
112                [ "`wc -c < ${dec_out_path}`" -eq 0 ] && dec_res="faile"
113            fi
114        fi
115
116        printf "rsl: %-12s  enc_norm %-5s  enc_kmpp %-5s  dec %-5s\n" ${cur_rsl} ${enc_norm_res} ${enc_kmpp_res} ${dec_res}
117
118        if [ "${cmd_sv_file}" = "false" ]; then
119            [ -e ${enc_out_norm_path} ] && rm ${enc_out_norm_path}
120            [ -e ${enc_out_kmpp_path} ] && rm ${enc_out_kmpp_path}
121            [ -e ${dec_out_path} ] && rm ${dec_out_path}
122        fi
123    done
124}
125
126usage()
127{
128    spec_info=""
129    for cur_sp in ${spec_list}
130    do
131        spec_info="${spec_info}|${cur_sp}"
132    done
133    spec_info="${spec_info}|all"
134    echo "<exe> <-s|--spec> <${spec_info}> [-q]"
135    echo "    -h|--help:  help info"
136    echo "    -s|--spec:  spec, ${spec_info}"
137    echo "    -sv|--save: save test file"
138    echo "    -l|--log:   exec mpp demo with log"
139    echo "    -d|--debug: dump debug info"
140}
141
142proc_paras()
143{
144    while [ $# -gt 0 ]; do
145        key="$1"
146        case ${key} in
147            -h|--help) usage; exit 0; ;;
148            -s|--spec) cmd_spec="$2"; shift; ;;
149            -sv|--save) cmd_sv_file="true"; ;;
150            -l|--log) cmd_log="true"; ;; -d|--debug) cmd_debug="true"; ;;
151            *) usage; exit 1 ;;
152        esac
153        shift # move to next para
154    done
155
156    # check spec
157    found=0
158    for cur_sp in ${spec_list}; do [ "${cmd_spec}" = "${cur_sp}" ] && { found=1; break; } done
159    [ "${cmd_spec}" = "all" ] && found=1
160    [ ${found} -eq 0 ] && { echo "unknow spec: ${cmd_spec}"; exit 1; }
161
162    # dump cmd info
163    echo "cmd spec:    ${cmd_spec}"
164    echo "cmd sv_file: ${cmd_sv_file}"
165    echo "cmd log:     ${cmd_log}"
166    echo "cmd debug:   ${cmd_debug}"
167}
168
169
170main()
171{
172    proc_paras $@
173    if [ ${cmd_spec} = "all" ]
174    then
175        for cur_sp in ${spec_list}; do test_spec_rsl ${cur_sp}; done
176    else
177        test_spec_rsl ${cmd_spec}
178    fi
179}
180
181main $@
182