1 /* SPDX-License-Identifier: Apache-2.0 OR MIT */
2 /*
3 * Copyright (c) 2024 Rockchip Electronics Co., Ltd.
4 */
5
6 #define MODULE_TAG "vdpp_test"
7
8 #include <getopt.h>
9 #include <string.h>
10 #include <errno.h>
11
12 #include "mpp_mem.h"
13 #include "mpp_common.h"
14 #include "mpp_buffer.h"
15 #include "mpp_soc.h"
16
17 #include "utils.h"
18 #include "vdpp_api.h"
19
20 #define MAX_URL_LEN (256)
21
22 #define SHP_CFG_STRIDE (684)
23 #define DM_ZME_CFG_STRIDE (260)
24 #define ES_CFG_STRIDE (68)
25 #define YUV_MAX_SIZE (12582912) // 4096 * 2048 * 3 / 2
26 #define DCI_HIST_SIZE (10240) // (16*16*16*18/8/4 + 256) * 4
27
28 typedef struct VdppTestCfg_t {
29 MppFrameFormat src_format;
30 RK_U32 src_width;
31 RK_U32 src_height;
32 RK_U32 src_width_vir; // 16 align
33 RK_U32 src_height_vir; // 8 align
34 RK_U32 src_swa;
35
36 RK_U32 dst_width;
37 RK_U32 dst_height;
38 RK_U32 dst_width_vir;
39 RK_U32 dst_height_vir;
40 RK_U32 dst_fmt;
41 RK_U32 dst_swa;
42 RK_U32 yuv_out_diff;
43 RK_U32 dst_c_width;
44 RK_U32 dst_c_height;
45 RK_U32 dst_c_width_vir;
46 RK_U32 dst_c_height_vir;
47 /* high 16 bit: mask; low 3 bit: dmsr|es|sharp */
48 RK_U32 cfg_set;
49
50 char src_url[MAX_URL_LEN];
51 char dst_url[MAX_URL_LEN];
52 char dst_c_url[MAX_URL_LEN];
53 char hist_url[MAX_URL_LEN];
54 char hist_l_url[MAX_URL_LEN];
55 char hist_g_url[MAX_URL_LEN];
56 char slt_url[MAX_URL_LEN];
57
58 FILE *fp_src;
59 FILE *fp_dst;
60 FILE *fp_dst_c;
61 FILE *fp_hist;
62 FILE *fp_hist_l;
63 FILE *fp_hist_g;
64 FILE *fp_slt;
65
66 RK_U32 frame_num;
67
68 RK_U32 hist_mode_en;
69 } VdppTestCfg;
70
71 typedef struct {
72 MppFrameFormat format;
73 const char *name;
74 } MppFrameFormatInfo;
75
76 extern void mpp_show_color_format();
77
78 static OptionInfo vdpp_test_cmd[] = {
79 {"w", "src_width", "input image width"},
80 {"h", "src_height", "input image height"},
81 {"s", "src_swap", "input image UV swap"},
82 {"f", "src_format", "input image format in MppFrameFormat"},
83 {"i", "src_file", "input image file name"},
84 {"W", "dst_width", "output image width"},
85 {"H", "dst_height", "output image height"},
86 {"F", "dst_format", "output image format in ASCII string"},
87 {"S", "dst_swap", "output image UV swap"},
88 {"o", "dst_file", "output image file name"},
89 {"n", "frame_num", "frame number"},
90 {"m", "work_mode", "work_mode : 0 - vdpp, 1 - dci hist"},
91 {"Y", "packed_hist", "output packed hist file name"},
92 {"O", "dst_chroma_file", "output chroma file name"},
93 {"wi_vir", "src_width_vir", "input virtual width"},
94 {"hi_vir", "src_height_vir", "input virtual height"},
95 {"wo_vir", "dst_width_vir", "output virtual width"},
96 {"ho_vir", "dst_height_vir", "output virtual height"},
97 {"wo_uv", "dst_c_width", "output chroma width"},
98 {"ho_uv", "dst_c_height", "output chroma height"},
99 {"wo_uv_vir", "dst_c_width_vir", "output virtual chroma width"},
100 {"ho_uv_vir", "dst_c_height_vir", "output virtual chroma height"},
101 {"diff", "yuv_out_diff", "luma and chroma diff resolution flag"},
102 {"cfg_set", "cfg_set", "high 16 bit: mask; low 3 bit: dmsr|es|sharp"},
103 {"hist_l", "local_hist", "output local hist file name"},
104 {"hist_g", "global_hist", "output global hist file name"},
105 {"slt", "slt_file", "slt verify data file"},
106 };
107
vdpp_test_help()108 static void vdpp_test_help()
109 {
110 mpp_log("usage: vdpp_test [options]\n");
111 mpp_log("*******************************\n");
112 show_options(vdpp_test_cmd);
113 mpp_show_color_format();
114 mpp_log("*******************************\n");
115 mpp_log("supported ASCII format strings:\n");
116 mpp_log("1 - yuv444\n");
117 mpp_log("2 - yuv420 \n");
118 mpp_log("************ sample ***********\n");
119 mpp_log("vdpp_test -w 720 -h 480 -s 0 -i input.yuv -W 1920 -H 1080 -F yuv444 -S 0 -o output.yuv -n 1\n");
120 }
121
str_to_vdpp_fmt(const char * str)122 static RK_S32 str_to_vdpp_fmt(const char *str)
123 {
124 RK_S32 fmt = -1;
125
126 mpp_log("format %s\n", str);
127
128 if (!strcmp(str, "yuv420"))
129 fmt = VDPP_FMT_YUV420;
130 else if (!strcmp(str, "yuv444"))
131 fmt = VDPP_FMT_YUV444;
132 else
133 mpp_err("invalid format %s\n", str);
134
135 return fmt;
136 }
137
check_input_cmd(VdppTestCfg * cfg)138 static MPP_RET check_input_cmd(VdppTestCfg *cfg)
139 {
140 MPP_RET ret = MPP_OK;
141
142 if (cfg->fp_src == NULL) {
143 mpp_err("failed to open input file %s\n", cfg->src_url);
144 ret = MPP_NOK;
145 }
146
147 return ret;
148 }
149
get_src_frm_size(RK_S32 fmt,RK_U32 w,RK_U32 h)150 static inline size_t get_src_frm_size(RK_S32 fmt, RK_U32 w, RK_U32 h)
151 {
152 RK_S32 frame_size;
153
154 switch (fmt & MPP_FRAME_FMT_MASK) {
155 case MPP_FMT_YUV420SP:
156 case MPP_FMT_YUV420P: {
157 frame_size = w * h * 3 / 2;
158 } break;
159
160 case MPP_FMT_YUV422_YUYV :
161 case MPP_FMT_YUV422_YVYU :
162 case MPP_FMT_YUV422_UYVY :
163 case MPP_FMT_YUV422_VYUY :
164 case MPP_FMT_YUV422P :
165 case MPP_FMT_YUV422SP :
166 case MPP_FMT_RGB444 :
167 case MPP_FMT_BGR444 :
168 case MPP_FMT_RGB555 :
169 case MPP_FMT_BGR555 :
170 case MPP_FMT_RGB565 :
171 case MPP_FMT_BGR565 : {
172 frame_size = w * h * 2;
173 } break;
174 case MPP_FMT_RGB888 :
175 case MPP_FMT_BGR888 : {
176 frame_size = w * h * 3;
177 } break;
178 case MPP_FMT_RGB101010 :
179 case MPP_FMT_BGR101010 :
180 case MPP_FMT_ARGB8888 :
181 case MPP_FMT_ABGR8888 :
182 case MPP_FMT_BGRA8888 :
183 case MPP_FMT_RGBA8888 : {
184 frame_size = w * h * 4;
185 } break;
186 default: {
187 frame_size = w * h * 4;
188 } break;
189 }
190
191 return frame_size;
192 }
193
get_dst_frm_size(RK_S32 fmt,RK_U32 w,RK_U32 h)194 static inline size_t get_dst_frm_size(RK_S32 fmt, RK_U32 w, RK_U32 h)
195 {
196 switch (fmt) {
197 case VDPP_FMT_YUV444:
198 return w * h * 3;
199 case VDPP_FMT_YUV420:
200 return w * h * 3 / 2;
201 default:
202 mpp_err("warning: unsupported input format %d", fmt);
203 return 0;
204 }
205 }
206
vdpp_test_set_img(vdpp_com_ctx * ctx,RK_U32 w,RK_U32 h,VdppImg * img,RK_S32 fd,VdppCmd cmd)207 static void vdpp_test_set_img(vdpp_com_ctx *ctx, RK_U32 w, RK_U32 h,
208 VdppImg *img, RK_S32 fd, VdppCmd cmd)
209 {
210 RK_S32 y_size = w * h;
211
212 img->mem_addr = fd;
213 img->uv_addr = fd;
214 img->uv_off = y_size;
215
216 MPP_RET ret = ctx->ops->control(ctx->priv, cmd, img);
217 if (ret)
218 mpp_log_f("control %08x failed %d\n", cmd, ret);
219 }
220
vdpp_test(VdppTestCfg * cfg)221 void vdpp_test(VdppTestCfg *cfg)
222 {
223 vdpp_com_ctx* vdpp = rockchip_vdpp_api_alloc_ctx();
224 size_t srcfrmsize = get_src_frm_size(cfg->src_format, cfg->src_width_vir, cfg->src_height_vir);
225 size_t dstfrmsize = get_dst_frm_size(cfg->dst_fmt, cfg->dst_width_vir, cfg->dst_height_vir);
226 size_t dstfrmsize_c = cfg->dst_c_width_vir * cfg->dst_c_height_vir * 3;
227 MppBuffer srcbuf;
228 MppBuffer dstbuf;
229 MppBuffer dstbuf_c;
230 MppBuffer histbuf;
231 MppBuffer histbuf_l;
232 MppBuffer histbuf_g;
233 RK_U8 *psrc = NULL;
234 RK_U8 *pdst = NULL;
235 RK_U8 *pdst_c = NULL;
236 RK_U8 *phist = NULL;
237 RK_U8 *phist_l = NULL;
238 RK_U8 *phist_g = NULL;
239 RK_S32 fdsrc = -1;
240 RK_S32 fddst = -1;
241 RK_S32 fddst_c = -1;
242 RK_S32 fdhist = -1;
243 struct vdpp_api_params params;
244 RK_U32 is_vdpp2 = (mpp_get_soc_type() == ROCKCHIP_SOC_RK3576);
245 RK_U32 yuv_out_diff = (cfg->yuv_out_diff && is_vdpp2);
246
247 VdppImg imgsrc;
248 VdppImg imgdst;
249 VdppImg imgdst_c;
250
251 RK_U32 local_hist_size = RKVOP_PQ_PREPROCESS_HIST_SIZE_VERI * RKVOP_PQ_PREPROCESS_HIST_SIZE_HORI *
252 RKVOP_PQ_PREPROCESS_LOCAL_HIST_BIN_NUMS * sizeof(RK_U32);
253 RK_U32 global_hist_size = RKVOP_PQ_PREPROCESS_GLOBAL_HIST_BIN_NUMS * sizeof(RK_U32);
254
255 mpp_assert(vdpp);
256 MppBufferGroup memGroup;
257 MPP_RET ret = MPP_NOK;
258 RK_U32 cnt = 0;
259 DataCrc checkcrc;
260
261 memset(&checkcrc, 0, sizeof(checkcrc));
262 checkcrc.sum = mpp_malloc(RK_ULONG, 512);
263
264 ret = mpp_buffer_group_get_internal(&memGroup, MPP_BUFFER_TYPE_DRM);
265 if (MPP_OK != ret) {
266 mpp_err("memGroup mpp_buffer_group_get failed\n");
267 mpp_assert(0);
268 }
269
270 mpp_log("src w:h [%d:%d] stride [%d:%d] require buf %d",
271 cfg->src_width, cfg->src_height, cfg->src_width_vir, cfg->src_height_vir, srcfrmsize);
272 mpp_log("dst w:h [%d:%d] stride [%d:%d] require buf %d",
273 cfg->dst_width, cfg->dst_height, cfg->dst_width_vir, cfg->dst_height_vir, dstfrmsize);
274 mpp_buffer_get(memGroup, &srcbuf, srcfrmsize);
275 mpp_buffer_get(memGroup, &dstbuf, dstfrmsize);
276 mpp_buffer_get(memGroup, &histbuf, DCI_HIST_SIZE);
277 mpp_assert(srcbuf && dstbuf && histbuf);
278
279 mpp_buffer_get(memGroup, &histbuf_l, local_hist_size);
280 mpp_buffer_get(memGroup, &histbuf_g, global_hist_size);
281 mpp_assert(histbuf_l && histbuf_g);
282
283 psrc = mpp_buffer_get_ptr(srcbuf);
284 pdst = mpp_buffer_get_ptr(dstbuf);
285 phist = mpp_buffer_get_ptr(histbuf);
286 phist_l = mpp_buffer_get_ptr(histbuf_l);
287 phist_g = mpp_buffer_get_ptr(histbuf_g);
288
289 fdsrc = mpp_buffer_get_fd(srcbuf);
290 fddst = mpp_buffer_get_fd(dstbuf);
291 fdhist = mpp_buffer_get_fd(histbuf);
292
293 if (yuv_out_diff) {
294 mpp_log("dst chroma w:h [%d:%d] stride [%d:%d] require buf %d",
295 cfg->dst_c_width, cfg->dst_c_height, cfg->dst_c_width_vir, cfg->dst_c_height_vir, dstfrmsize_c);
296
297 mpp_buffer_get(memGroup, &dstbuf_c, dstfrmsize_c);
298 mpp_assert(dstbuf_c);
299
300 pdst_c = mpp_buffer_get_ptr(dstbuf_c);
301 fddst_c = mpp_buffer_get_fd(dstbuf_c);
302 }
303
304 vdpp->ops->init(&vdpp->priv);
305
306 /* use default dmsr and zme params */
307 /* set common params */
308 if (is_vdpp2) {
309 params.ptype = VDPP_PARAM_TYPE_COM2;
310 memset(¶ms.param, 0, sizeof(union vdpp_api_content));
311 params.param.com2.sfmt = cfg->src_format;
312 params.param.com2.src_width = cfg->src_width;
313 params.param.com2.src_height = cfg->src_height;
314 params.param.com2.src_width_vir = cfg->src_width_vir;
315 params.param.com2.src_height_vir = cfg->src_height_vir;
316 params.param.com2.sswap = cfg->src_swa;
317 params.param.com2.dfmt = cfg->dst_fmt;
318 params.param.com2.dst_width = cfg->dst_width;
319 params.param.com2.dst_height = cfg->dst_height;
320 params.param.com2.dst_width_vir = cfg->dst_width_vir;
321 params.param.com2.dst_height_vir = cfg->dst_height_vir;
322 if (yuv_out_diff) {
323 params.param.com2.yuv_out_diff = yuv_out_diff;
324 params.param.com2.dst_c_width = cfg->dst_c_width;
325 params.param.com2.dst_c_height = cfg->dst_c_height;
326 params.param.com2.dst_c_width_vir = cfg->dst_c_width_vir;
327 params.param.com2.dst_c_height_vir = cfg->dst_c_height_vir;
328 }
329 params.param.com2.dswap = cfg->dst_swa;
330 params.param.com2.hist_mode_en = cfg->hist_mode_en;
331 params.param.com2.cfg_set = cfg->cfg_set;
332 vdpp->ops->control(vdpp->priv, VDPP_CMD_SET_COM2_CFG, ¶ms);
333 } else {
334 params.ptype = VDPP_PARAM_TYPE_COM;
335 memset(¶ms.param, 0, sizeof(union vdpp_api_content));
336 params.param.com.src_width = cfg->src_width;
337 params.param.com.src_height = cfg->src_height;
338 params.param.com.sswap = cfg->src_swa;
339 params.param.com.dfmt = cfg->dst_fmt;
340 params.param.com.dst_width = cfg->dst_width;
341 params.param.com.dst_height = cfg->dst_height;
342 params.param.com.dswap = cfg->dst_swa;
343 vdpp->ops->control(vdpp->priv, VDPP_CMD_SET_COM_CFG, ¶ms);
344 }
345
346 {
347 RK_S32 cap = vdpp->ops->check_cap(vdpp->priv);
348
349 mpp_log("vdpp cap %d\n", cap);
350 }
351
352 while (1) {
353 if (srcfrmsize > fread(psrc, 1, srcfrmsize, cfg->fp_src)) {
354 mpp_log("source exhaused\n");
355 break;
356 }
357 if (cnt >= cfg->frame_num)
358 break;
359
360 /* notice the order of the input frames */
361 vdpp_test_set_img(vdpp, cfg->src_width_vir, cfg->src_height_vir,
362 &imgsrc, fdsrc, VDPP_CMD_SET_SRC);
363 vdpp_test_set_img(vdpp, cfg->dst_width_vir, cfg->dst_height_vir,
364 &imgdst, fddst, VDPP_CMD_SET_DST);
365 if (yuv_out_diff)
366 vdpp_test_set_img(vdpp, cfg->dst_c_width_vir, cfg->dst_c_height_vir,
367 &imgdst_c, fddst_c, VDPP_CMD_SET_DST_C);
368
369 if (is_vdpp2)
370 vdpp->ops->control(vdpp->priv, VDPP_CMD_SET_HIST_FD, &fdhist);
371
372 memset(pdst, 0, dstfrmsize);
373 memset(phist, 0, DCI_HIST_SIZE);
374
375 if (vdpp->ops->control(vdpp->priv, VDPP_CMD_RUN_SYNC, NULL)) {
376 mpp_err("found vdpp run error, exit!\n");
377 break;
378 }
379
380 cnt++;
381
382 if (cfg->fp_dst) {
383 if (dstfrmsize > fwrite(pdst, 1, dstfrmsize, cfg->fp_dst)) {
384 mpp_err("destination dump failed, errno %d %s\n", errno, strerror(errno));
385 break;
386 }
387 }
388
389 if (yuv_out_diff && cfg->fp_dst_c) {
390 if (dstfrmsize_c > fwrite(pdst_c, 1, dstfrmsize_c, cfg->fp_dst_c)) {
391 mpp_err("chroma dump failed, errno %d %s\n", errno, strerror(errno));
392 break;
393 }
394 }
395
396 if (cfg->fp_hist) {
397 if (DCI_HIST_SIZE > fwrite(phist, 1, DCI_HIST_SIZE, cfg->fp_hist)) {
398 mpp_err("packed hist dump err\n");
399 break;
400 }
401 }
402
403 memset(phist_l, 0, local_hist_size);
404 memset(phist_g, 0, global_hist_size);
405
406 dci_hist_info_parser(phist, (RK_U32 *)phist_l, (RK_U32 *)phist_g);
407
408 if (cfg->fp_hist_l) {
409 if (local_hist_size > fwrite(phist_l, 1, local_hist_size, cfg->fp_hist_l)) {
410 mpp_err("local hist dump err\n");
411 break;
412 }
413 }
414 if (cfg->fp_hist_g) {
415 if (global_hist_size > fwrite(phist_g, 1, global_hist_size, cfg->fp_hist_g)) {
416 mpp_err("global hist dump err\n");
417 break;
418 }
419 }
420
421 if (cfg->fp_slt) {
422 if (pdst && !cfg->hist_mode_en) {
423 calc_data_crc(pdst, dstfrmsize, &checkcrc);
424 write_data_crc(cfg->fp_slt, &checkcrc);
425
426 }
427
428 if (pdst_c && yuv_out_diff && !cfg->hist_mode_en) {
429 calc_data_crc(pdst_c, dstfrmsize_c, &checkcrc);
430 write_data_crc(cfg->fp_slt, &checkcrc);
431
432 }
433
434 if (phist) {
435 calc_data_crc(phist, DCI_HIST_SIZE, &checkcrc);
436 write_data_crc(cfg->fp_slt, &checkcrc);
437 }
438 }
439
440 }
441
442 mpp_buffer_put(srcbuf);
443 mpp_buffer_put(dstbuf);
444 mpp_buffer_put(histbuf);
445 if (histbuf_l)
446 mpp_buffer_put(histbuf_l);
447 if (histbuf_g)
448 mpp_buffer_put(histbuf_g);
449 if (yuv_out_diff)
450 mpp_buffer_put(dstbuf_c);
451
452 MPP_FREE(checkcrc.sum);
453
454 if (memGroup) {
455 mpp_buffer_group_put(memGroup);
456 memGroup = NULL;
457 }
458
459 vdpp->ops->deinit(vdpp->priv);
460
461 rockchip_vdpp_api_release_ctx(vdpp);
462 }
463
464 extern char *optarg;
465 extern int opterr;
466
main(int32_t argc,char ** argv)467 int32_t main(int32_t argc, char **argv)
468 {
469 VdppTestCfg cfg;
470 int32_t ch;
471 int32_t option_index = 0;
472
473 if (argc < 2) {
474 vdpp_test_help();
475 return 0;
476 }
477
478 memset(&cfg, 0, sizeof(cfg));
479 cfg.src_swa = VDPP_YUV_SWAP_SP_UV;
480 cfg.dst_fmt = VDPP_FMT_YUV444;
481 cfg.dst_swa = VDPP_YUV_SWAP_SP_UV;
482 cfg.hist_mode_en = 0;
483
484 /* get options */
485 opterr = 0;
486 /* not recommended if not familiar with HW */
487 static struct option long_options[] = {
488 {"wi_vir", required_argument, 0, 0 },
489 {"hi_vir", required_argument, 0, 0 },
490 {"wo_vir", required_argument, 0, 0 },
491 {"ho_vir", required_argument, 0, 0 },
492 {"wo_uv", required_argument, 0, 0 },
493 {"ho_uv", required_argument, 0, 0 },
494 {"wo_uv_vir", required_argument, 0, 0 },
495 {"ho_uv_vir", required_argument, 0, 0 },
496 {"diff", required_argument, 0, 0 },
497 {"cfg_set", required_argument, 0, 0 },
498 {"hist_l", required_argument, 0, 0 },
499 {"hist_g", required_argument, 0, 0 },
500 {"slt", required_argument, 0, 0 },
501 { 0, 0, 0, 0 },
502 };
503
504 while ((ch = getopt_long_only(argc, argv, "w:h:f:s:i:W:H:F:S:o:O:n:m:Y:", long_options, &option_index)) != -1) {
505 switch (ch) {
506 case 0: {
507 switch (option_index) {
508 case 0 : {
509 cfg.src_width_vir = atoi(optarg);
510 } break;
511 case 1 : {
512 cfg.src_height_vir = atoi(optarg);
513 } break;
514 case 2 : {
515 cfg.dst_width_vir = atoi(optarg);
516 } break;
517 case 3 : {
518 cfg.dst_height_vir = atoi(optarg);
519 } break;
520 case 4 : {
521 cfg.dst_c_width = atoi(optarg);
522 } break;
523 case 5 : {
524 cfg.dst_c_height = atoi(optarg);
525 } break;
526 case 6 : {
527 cfg.dst_c_width_vir = atoi(optarg);
528 } break;
529 case 7 : {
530 cfg.dst_c_height_vir = atoi(optarg);
531 } break;
532 case 8 : {
533 cfg.yuv_out_diff = atoi(optarg);
534 } break;
535 case 9 : {
536 cfg.cfg_set = strtol(optarg, NULL, 0);
537 } break;
538 case 10 : {
539 mpp_log("local hist name: %s\n", optarg);
540 strncpy(cfg.hist_l_url, optarg, sizeof(cfg.hist_l_url) - 1);
541 cfg.fp_hist_l = fopen(cfg.hist_l_url, "w+b");
542 } break;
543 case 11 : {
544 mpp_log("global hist name: %s\n", optarg);
545 strncpy(cfg.hist_g_url, optarg, sizeof(cfg.hist_g_url) - 1);
546 cfg.fp_hist_g = fopen(cfg.hist_g_url, "w+b");
547 } break;
548 case 12 : {
549 mpp_log("verify file: %s\n", optarg);
550 strncpy(cfg.slt_url, optarg, sizeof(cfg.slt_url) - 1);
551 cfg.fp_slt = fopen(cfg.slt_url, "w+b");
552 } break;
553 default : {
554 } break;
555 }
556 mpp_log("%s: %s", long_options[option_index].name, optarg);
557
558 } break;
559 case 'w': {
560 cfg.src_width = atoi(optarg);
561 } break;
562 case 'h': {
563 cfg.src_height = atoi(optarg);
564 } break;
565 case 'f': {
566 cfg.src_format = atoi(optarg);
567 } break;
568 case 's': {
569 cfg.src_swa = atoi(optarg);
570 } break;
571 case 'i': {
572 mpp_log("input filename: %s\n", optarg);
573 strncpy(cfg.src_url, optarg, sizeof(cfg.src_url) - 1);
574 cfg.fp_src = fopen(cfg.src_url, "rb");
575 } break;
576 case 'W': {
577 cfg.dst_width = atoi(optarg);
578 } break;
579 case 'H': {
580 cfg.dst_height = atoi(optarg);
581 } break;
582 case 'F': {
583 cfg.dst_fmt = str_to_vdpp_fmt(optarg);
584 } break;
585 case 'S': {
586 cfg.dst_swa = atoi(optarg);
587 } break;
588 case 'o': {
589 mpp_log("output filename: %s\n", optarg);
590 strncpy(cfg.dst_url, optarg, sizeof(cfg.dst_url) - 1);
591 cfg.fp_dst = fopen(cfg.dst_url, "w+b");
592 } break;
593 case 'O': {
594 mpp_log("output chroma filename: %s\n", optarg);
595 strncpy(cfg.dst_c_url, optarg, sizeof(cfg.dst_c_url) - 1);
596 cfg.fp_dst_c = fopen(cfg.dst_c_url, "w+b");
597 } break;
598 case 'n': {
599 cfg.frame_num = atoi(optarg);
600 } break;
601 case 'm': {
602 cfg.hist_mode_en = atoi(optarg);
603 } break;
604 case 'Y': {
605 mpp_log("output hist: %s\n", optarg);
606 strncpy(cfg.hist_url, optarg, sizeof(cfg.hist_url) - 1);
607 cfg.fp_hist = fopen(cfg.hist_url, "w+b");
608 } break;
609 default: {
610 } break;
611 }
612 }
613
614 /* set default vir stride */
615 if (!cfg.src_width_vir)
616 cfg.src_width_vir = MPP_ALIGN(cfg.src_width, 16);
617 if (!cfg.src_height_vir)
618 cfg.src_height_vir = MPP_ALIGN(cfg.src_height, 8);
619 if (!cfg.dst_width)
620 cfg.dst_width = cfg.src_width;
621 if (!cfg.dst_height)
622 cfg.dst_height = cfg.src_height;
623 if (!cfg.dst_width_vir)
624 cfg.dst_width_vir = MPP_ALIGN(cfg.dst_width, 16);
625 if (!cfg.dst_height_vir)
626 cfg.dst_height_vir = MPP_ALIGN(cfg.dst_height, 2);
627 if (cfg.yuv_out_diff) {
628 if (!cfg.dst_c_width)
629 cfg.dst_c_width = cfg.dst_width;
630 if (!cfg.dst_c_width_vir)
631 cfg.dst_c_width_vir = MPP_ALIGN(cfg.dst_c_width, 16);
632 if (!cfg.dst_c_height)
633 cfg.dst_c_height = cfg.dst_height;
634 if (!cfg.dst_c_height_vir)
635 cfg.dst_c_height_vir = MPP_ALIGN(cfg.dst_c_height, 2);
636 }
637 if (check_input_cmd(&cfg)) {
638 mpp_err("failed to pass cmd line check\n");
639 vdpp_test_help();
640 return -1;
641 }
642
643 vdpp_test(&cfg);
644
645 if (cfg.fp_src) {
646 fclose(cfg.fp_src);
647 cfg.fp_src = NULL;
648 }
649
650 if (cfg.fp_dst) {
651 fclose(cfg.fp_dst);
652 cfg.fp_dst = NULL;
653 }
654
655 if (cfg.fp_dst_c) {
656 fclose(cfg.fp_dst_c);
657 cfg.fp_dst_c = NULL;
658 }
659
660 if (cfg.fp_hist) {
661 fclose(cfg.fp_hist);
662 cfg.fp_hist = NULL;
663 }
664
665 if (cfg.fp_hist_l) {
666 fclose(cfg.fp_hist_l);
667 cfg.fp_hist_l = NULL;
668 }
669
670 if (cfg.fp_hist_g) {
671 fclose(cfg.fp_hist_g);
672 cfg.fp_hist_g = NULL;
673 }
674
675 if (cfg.fp_slt) {
676 fclose(cfg.fp_slt);
677 cfg.fp_slt = NULL;
678 }
679
680 return 0;
681 }
682