13d0407baSopenharmony_ci/*
23d0407baSopenharmony_ci * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
33d0407baSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43d0407baSopenharmony_ci * you may not use this file except in compliance with the License.
53d0407baSopenharmony_ci * You may obtain a copy of the License at
63d0407baSopenharmony_ci *
73d0407baSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
83d0407baSopenharmony_ci *
93d0407baSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103d0407baSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113d0407baSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123d0407baSopenharmony_ci * See the License for the specific language governing permissions and
133d0407baSopenharmony_ci * limitations under the License.
143d0407baSopenharmony_ci */
153d0407baSopenharmony_ci
163d0407baSopenharmony_ci#ifndef __MPI_ENC_UTILS_H__
173d0407baSopenharmony_ci#define __MPI_ENC_UTILS_H__
183d0407baSopenharmony_ci
193d0407baSopenharmony_ci#include <stdio.h>
203d0407baSopenharmony_ci
213d0407baSopenharmony_ci#include "rk_venc_cmd.h"
223d0407baSopenharmony_ci
233d0407baSopenharmony_citypedef struct MpiEncTestArgs_t {
243d0407baSopenharmony_ci    MppCodingType type;
253d0407baSopenharmony_ci    MppFrameFormat format;
263d0407baSopenharmony_ci
273d0407baSopenharmony_ci    signed int width;
283d0407baSopenharmony_ci    signed int height;
293d0407baSopenharmony_ci} MpiEncTestArgs;
303d0407baSopenharmony_ci
313d0407baSopenharmony_citypedef struct {
323d0407baSopenharmony_ci    // global flow control flag
333d0407baSopenharmony_ci    unsigned int frm_eos;
343d0407baSopenharmony_ci    unsigned int pkt_eos;
353d0407baSopenharmony_ci    signed int frame_count;
363d0407baSopenharmony_ci    RK_U64 stream_size;
373d0407baSopenharmony_ci
383d0407baSopenharmony_ci    // base flow context
393d0407baSopenharmony_ci    MppCtx ctx;
403d0407baSopenharmony_ci    MppApi *mpi;
413d0407baSopenharmony_ci    MppEncCfg cfg;
423d0407baSopenharmony_ci
433d0407baSopenharmony_ci    // input / output
443d0407baSopenharmony_ci    MppBufferGroup buf_grp;
453d0407baSopenharmony_ci    MppBuffer pkt_buf;
463d0407baSopenharmony_ci    MppEncSeiMode sei_mode;
473d0407baSopenharmony_ci    MppEncHeaderMode header_mode;
483d0407baSopenharmony_ci
493d0407baSopenharmony_ci    // paramter for resource malloc
503d0407baSopenharmony_ci    unsigned int width;
513d0407baSopenharmony_ci    unsigned int height;
523d0407baSopenharmony_ci    unsigned int hor_stride;
533d0407baSopenharmony_ci    unsigned int ver_stride;
543d0407baSopenharmony_ci    MppFrameFormat fmt;
553d0407baSopenharmony_ci    MppCodingType type;
563d0407baSopenharmony_ci    signed int num_frames;
573d0407baSopenharmony_ci
583d0407baSopenharmony_ci    // resources
593d0407baSopenharmony_ci    size_t frame_size;
603d0407baSopenharmony_ci
613d0407baSopenharmony_ci    unsigned int split_mode;
623d0407baSopenharmony_ci    unsigned int split_arg;
633d0407baSopenharmony_ci
643d0407baSopenharmony_ci    // rate control runtime parameter
653d0407baSopenharmony_ci
663d0407baSopenharmony_ci    signed int fps_in_flex;
673d0407baSopenharmony_ci    signed int fps_in_den;
683d0407baSopenharmony_ci    signed int fps_in_num;
693d0407baSopenharmony_ci    signed int fps_out_flex;
703d0407baSopenharmony_ci    signed int fps_out_den;
713d0407baSopenharmony_ci    signed int fps_out_num;
723d0407baSopenharmony_ci    signed int bps;
733d0407baSopenharmony_ci    signed int bps_max;
743d0407baSopenharmony_ci    signed int bps_min;
753d0407baSopenharmony_ci    signed int rc_mode;
763d0407baSopenharmony_ci    signed int gop_mode;
773d0407baSopenharmony_ci    signed int gop_len;
783d0407baSopenharmony_ci    signed int vi_len;
793d0407baSopenharmony_ci} MpiEncTestData;
803d0407baSopenharmony_ci
813d0407baSopenharmony_ciint hal_mpp_get_sps(void *ctx, unsigned char *buf, size_t *buf_size);
823d0407baSopenharmony_ciint hal_mpp_encode(void *ctx, int dma_fd, unsigned char *buf, size_t *buf_size);
833d0407baSopenharmony_ci
843d0407baSopenharmony_civoid *hal_mpp_ctx_create(MpiEncTestArgs *args);
853d0407baSopenharmony_civoid hal_mpp_ctx_delete(void *ctx);
863d0407baSopenharmony_ci
873d0407baSopenharmony_ci#endif /* __MPI_ENC_UTILS_H__ */
88