这是我的main函数:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <pthread.h>
#include <sys/time.h>
#include "simple_mpp.h"
#define CAMERA1_ENABLE
#define CAMERA2_ENABLE
#define CAMERA3_ENABLE
#ifdef CAMERA1_ENABLE
FILE* camera1_file = NULL;
void camera1_data_handler(unsigned int idx, unsigned int len, unsigned char* buf)
{
printf("camera1_data_handler, idx[%d] len[%d]\n", idx, len);
if (camera1_file == NULL) {
camera1_file = fopen("camera1_data.h265", "wb");
}
fwrite(buf, len, 1, camera1_file);
}
#endif
#ifdef CAMERA2_ENABLE
FILE* camera2_file = NULL;
void camera2_data_handler(unsigned int idx, unsigned int len, unsigned char* buf)
{
printf("camera2_data_handler, idx[%d] len[%d]\n", idx, len);
if (camera2_file == NULL) {
camera2_file = fopen("camera2_data.h265", "wb");
}
fwrite(buf, len, 1, camera2_file);
}
#endif
#ifdef CAMERA3_ENABLE
FILE* camera3_file = NULL;
void camera3_data_handler(unsigned int idx, unsigned int len, unsigned char* buf)
{
printf("camera3_data_handler, idx[%d] len[%d]\n", idx, len);
if (camera3_file == NULL) {
camera3_file = fopen("camera3_data.h265", "wb");
}
fwrite(buf, len, 1, camera3_file);
}
#endif
static int loop_run_flag;
static void signal_handler(int signal)
{
printf("signal [%d] exit.\n", signal);
loop_run_flag = 0;
}
int main(int argc, char *argv[])
{
loop_run_flag = 1;
signal(SIGINT, signal_handler); // crtc + c
signal(SIGTERM, signal_handler); // killall
simple_mpp_vb_init(3);
#ifdef CAMERA1_ENABLE
simple_mpp_config_t config1 = {0};
config1.ch = 0;
config1.dev = 0;
config1.width = 1280;
config1.height = 720;
config1.sensor_type = GC2093_MIPI_CSI2_1920X1080_30FPS_10BIT_LINEAR;
config1.bitrate = 4000;
simple_mpp_init(&config1);
#endif
#ifdef CAMERA2_ENABLE
simple_mpp_config_t config2 = {0};
config2.ch = 1;
config2.dev = 1;
config2.width = 1280;
config2.height = 720;
config2.sensor_type = GC2093_MIPI_CSI1_1920X1080_30FPS_10BIT_LINEAR;
config2.bitrate = 4000;
simple_mpp_init(&config2);
#endif
#ifdef CAMERA3_ENABLE
simple_mpp_config_t config3 = {0};
config3.ch = 2;
config3.dev = 2;
config3.width = 1280;
config3.height = 720;
config3.sensor_type = GC2093_MIPI_CSI0_1920X1080_30FPS_10BIT_LINEAR;
config3.bitrate = 4000;
simple_mpp_init(&config3);
#endif
while (loop_run_flag) {
#ifdef CAMERA1_ENABLE
simple_mpp_recv(&config1, camera1_data_handler);
#endif
#ifdef CAMERA2_ENABLE
simple_mpp_recv(&config2, camera2_data_handler);
#endif
#ifdef CAMERA3_ENABLE
simple_mpp_recv(&config3, camera3_data_handler);
#endif
}
#ifdef CAMERA1_ENABLE
simple_mpp_deinit(&config1);
if (camera1_file != NULL) {
fclose(camera1_file);
}
#endif
#ifdef CAMERA2_ENABLE
simple_mpp_deinit(&config2);
if (camera2_file!= NULL) {
fclose(camera2_file);
}
#endif
#ifdef CAMERA3_ENABLE
simple_mpp_deinit(&config3);
if (camera3_file!= NULL) {
fclose(camera3_file);
}
#endif
simple_mpp_vb_deinit();
return 0;
}
这是我封装的MPP库头文件:
#ifndef SIMPLE_MPP_H
#define SIMPLE_MPP_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "k_module.h"
#include "k_sensor_comm.h"
#include "k_type.h"
#include "k_vb_comm.h"
#include "k_video_comm.h"
#include "k_sys_comm.h"
#include "mpi_vb_api.h"
#include "mpi_venc_api.h"
#include "mpi_sys_api.h"
#include "mpi_sensor_api.h"
#include "k_venc_comm.h"
#include "mpi_vvi_api.h"
typedef enum
{
VENC_SAMPLE_STATUS_IDLE = 0,
VENC_SAMPLE_STATUS_INIT,
VENC_SAMPLE_STATUS_START,
VENC_SAMPLE_STATUS_BINDED,
VENC_SAMPLE_STATUS_UNBINDED,
VENC_SAMPLE_STATUE_RUNING,
VENC_SAMPLE_STATUS_STOPED,
VENC_SAMPLE_STATUS_BUTT
} simple_mpp_status_t;
typedef struct {
k_vicap_sensor_type sensor_type;
int width;
int height;
unsigned int bitrate;
// int chnum;
int ch;
int dev;
simple_mpp_status_t status;
unsigned int frame_cnt;
} simple_mpp_config_t;
int simple_mpp_vb_init(int ch_cnt);
int simple_mpp_vb_deinit();
int simple_mpp_init(simple_mpp_config_t* config);
int simple_mpp_deinit(simple_mpp_config_t* config);
int simple_mpp_recv(simple_mpp_config_t* config, void (*frame_handler)(unsigned int idx, unsigned int len, unsigned char* buf));
#endif//SIMPLE_MPP_H
当我执行编译后的文件,只拿一路相机数据的时候是没有问题的,但当我同时拿3路相机数据的时候就失败了,报错如下:
msh />cd sd
msh />cd sdcard/
msh /sdcard>ls
Directory /sdcard:
app <DIR>
revision.txt 503
start.sh 72
sensor_capture_run 2550800
camera_capture_run 2540976
camera2_data.h265 7361540
msh /sdcard>./cam
camera_capture_run
camera2_data.h265
msh /sdcard>./camera_c
msh /sdcard>./camera_capture_run
-----------venc sample test------------------------
venc create chn 0
venc start chn 0
<0>[6] [vi] wait stop timeout
[tuning] dev: 0
acq_win.width: 1920
acq_win.height: 1080
pipe_ctrl: 9
sensor_fd: 6
sensor_type: 23
sensor_name: gc2093_csi2
database_name: gc2093-1920x1080
buffer_num: 0
buffer_size: 0
[tuning] chn: 0
out_win.width: 1280
out_win.height: 720
bit_width: 0
pix_format: 5
buffer_num: 6
buffer_size: 1384448
yraw_size: 0
uv_size: 0
v_size: 0
block_type: 1
wait_time: 500
chn_enable: 1
isp_3dnr_en is 1 g_isp_dev_ctx[dev_num].dev_attr.pipe_ctrl.bits.dnr3_enable is 0
VsiCamDeviceCreate hw:0-vt:0 created!
kd_mpi_isp_set_output_chn_format, width(1280), height(720), pix_format(5)
[dw] init, version May 20 2025 00:06:18
venc bind venc and sensor
venc create chn 1
venc start chn 1
sys queue no space to push data
<3>[9] [Func]:venc_input_enqueue [Line]:417 [Info]:venc_input_enqueue>failed
[tuning] dev: 1
acq_win.width: 1920
acq_win.height: 1080
pipe_ctrl: 9
sensor_fd: 11
sensor_type: 19
sensor_name: gc2093_csi1
database_name: gc2093-1920x1080
buffer_num: 0
buffer_size: 0
[tuning] chn: 0
out_win.width: 0
out_win.height: 0
bit_width: 0
pix_format: 0
buffer_num: 0
buffer_size: 0
yraw_size: 0
uv_size: 0
v_size: 0
block_type: 0
wait_time: 0
chn_enable: 0
isp_3dnr_en is 1 g_isp_dev_ctx[dev_num].dev_attr.pipe_ctrl.bits.dnr3_enable is 0
oslayer assert /builds/maix_sw/k230_sdk/src/big/mpp/userapps/src/vicap/src/isp/sdk/units/oslayer/source/oslayer_generic.c, 357 pQueue == NULL
[E/DBG] [FATAL ERROR] Exception 13:Load Page Fault
[E/DBG] scause:0x000000000000000d,stval:0x000000000000005c,sepc:0x0000000200091344
--------------Dump Registers-----------------
Function Registers:
ra(x1) = 0x0000000200091340()
user_sp(x2) = 0x000000010082edd0()
gp(x3) = 0x0000000000000000()
tp(x4) = 0x000000010082efe8()
Temporary Registers:
t0(x5) = 0x0000000000000084()
t1(x6) = 0x0000000000000007()
t2(x7) = 0x0000000000000050()
t3(x28) = 0x0000000000000072()
t4(x29) = 0x000000000000008f()
t5(x30) = 0x000000000000000e()
t6(x31) = 0x000000000000000e()
Saved Registers:
s0/fp(x8) = 0x000000010082ee00()
s1(x9) = 0x000000010082eee0()
s2(x18) = 0x000000010082efe8()
s3(x19) = 0x00000002ffffe458()
s4(x20) = 0x000000000000000c()
s5(x21) = 0x0000000000000000()
s6(x22) = 0x0000000200091ca8()
s7(x23) = 0x00000003000f77e0()
s8(x24) = 0x000000010082ef08()
s9(x25) = 0x000000020025ac00()
s10(x26) = 0x00000002ffffe5d8()
s11(x27) = 0x000000010080c000()
Function Arguments Registers:
a0(x10) = 0x0000000000000016()
a1(x11) = 0x0000000000000001()
a2(x12) = 0x0000000000000000()
a3(x13) = 0x000000000000000c()
a4(x14) = 0x0000000000000030()
a5(x15) = 0x0000000000000000()
a6(x16) = 0x0000000000000000()
a7(x17) = 0x0000000000000000()
sstatus = 0x8000000200046620
Supervisor Interrupt Disabled
Last Time Supervisor Interrupt Enabled
Last Privilege is User Mode
Permit to Access User Page
Not Permit to Read Executable-only Page
satp = 0x80000000000047c6
Current Page Table(Physical) = 0x00000000047c6000
Current ASID = 0x0000000000000000
Mode = Page-based 39-bit Virtual Addressing Mode
-----------------Dump OK---------------------
riscv64-unknown-linux-musl-addr2line -e camera_capture_run -a -f 0000000200091340 00000002001dcb84 0000000200091cd2 000000020021c552Unhandled Exception 13:Load Page Fault
scause:0x000000000000000d,stval:0xfffffffffffffff8,sepc:0x000000000019bc60
--------------Dump Registers-----------------
Function Registers:
ra(x1) = 0x000000000019bc8e()
user_sp(x2) = 0x0000000000411318()
gp(x3) = 0x0000000000401e58()
tp(x4) = 0x000000010082efe8()
Temporary Registers:
t0(x5) = 0x0000000000411220()
t1(x6) = 0x00000000004e45b0()
t2(x7) = 0x0000000000000080()
t3(x28) = 0x00000000003ceb80()
t4(x29) = 0x0000000000000030()
t5(x30) = 0x0000000000000000()
t6(x31) = 0x0000000000411228()
Saved Registers:
s0/fp(x8) = 0x0000000000411368()
s1(x9) = 0x000000000000000d()
s2(x18) = 0x0000000200091344()
s3(x19) = 0x00000000004113d8()
s4(x20) = 0x000000000000005c()
s5(x21) = 0x0000000000000000()
s6(x22) = 0x0000000200091ca8()
s7(x23) = 0x00000003000f77e0()
s8(x24) = 0x000000010082ef08()
s9(x25) = 0x000000020025ac00()
s10(x26) = 0x00000002ffffe5d8()
s11(x27) = 0x000000010080c000()
Function Arguments Registers:
a0(x10) = 0x0000000000000011()
a1(x11) = 0x0000000000000032()
a2(x12) = 0x00000000004e45a8()
a3(x13) = 0x00000000c0007000()
a4(x14) = 0x0000000000000000()
a5(x15) = 0xfffffffffffffff8()
a6(x16) = 0x00000000004e45b9()
a7(x17) = 0x0000000000000032()
sstatus = 0x8000000200044700
Supervisor Interrupt Disabled
Last Time Supervisor Interrupt Disabled
Last Privilege is Supervisor Mode
Permit to Access User Page
Not Permit to Read Executable-only Page
satp = 0x80000000000047c6
Current Page Table(Physical) = 0x00000000047c6000
Current ASID = 0x0000000000000000
Mode = Page-based 39-bit Virtual Addressing Mode
-----------------Dump OK---------------------
--------------Thread list--------------
current thread: camera_capture_run
PID CMD thread pri status sp stack size max used left tick error
---- -------------------- -------------------- --- ------- ---------- ---------- ------ ---------- ---
kernel vpu_task 12 suspend 0x000004f8 0x00002000 34% 0x00000002 -09
kernel cmd_thread 6 suspend 0x00000558 0x00005000 12% 0x00000001 -09
kernel xmit_thread 7 suspend 0x00000528 0x00005000 06% 0x0000000a -09
kernel usbh_rtl8152_rx 15 suspend 0x00000598 0x00001000 41% 0x0000000a -09
kernel dwc2_lo_prio_bh 1 suspend 0x000004f8 0x00005000 06% 0x00000009 000
kernel dwc2_hi_prio_bh 0 suspend 0x000004f8 0x00005000 06% 0x00000008 000
kernel dwc2 16 suspend 0x000004f8 0x00005000 06% 0x0000000a 000
kernel sdio_irq 4 suspend 0x000004f8 0x00002800 29% 0x00000006 -09
kernel mtp 16 suspend 0x00000508 0x00005000 20% 0x00000006 -09
kernel mtp_inty 16 suspend 0x000007a8 0x00005000 13% 0x0000000a -09
kernel usbh_hub0 14 suspend 0x000005a8 0x00001000 48% 0x00000006 -09
kernel tshell 20 ready 0x000008b8 0x00014000 04% 0x00000001 -02
kernel thermal_detect_threa 29 suspend 0x000004d8 0x00002800 13% 0x0000000a -09
kernel auto_load_thread 29 suspend 0x00000498 0x00002800 12% 0x0000000a 000
kernel sys workq 17 suspend 0x00000598 0x00005000 07% 0x0000000a -09
kernel wlan 15 suspend 0x000004f8 0x00001000 31% 0x0000000a 000
kernel mmcsd_detect 22 suspend 0x00000558 0x00008000 09% 0x00000014 -09
kernel tcpip 10 suspend 0x00000578 0x00002800 14% 0x00000014 -09
kernel etx 12 suspend 0x00000538 0x00002800 13% 0x00000010 -09
kernel erx 12 suspend 0x00000558 0x00002800 18% 0x00000010 -09
kernel tsystem 30 suspend 0x000004f8 0x00004000 08% 0x00000020 -09
kernel tidle0 31 ready 0x00000448 0x00004000 06% 0x00000016 000
kernel timer 4 suspend 0x000004d8 0x00004000 14% 0x00000009 -09
2 ./camera_capture_run camera_capture_run 0 running 0x00000950 0x00004000 25% 0x000000bb 022
2 ./camera_capture_run camera_capture_run 0 suspend 0x00000900 0x00004000 24% 0x0000009a 000
2 ./camera_capture_run camera_capture_run 0 suspend 0x00000900 0x00004000 24% 0x000000c5 000
2 ./camera_capture_run camera_capture_run 0 suspend 0x00000900 0x00004000 24% 0x000000c8 000
2 ./camera_capture_run camera_capture_run 0 suspend 0x00000900 0x00004000 24% 0x000000c8 000
2 ./camera_capture_run camera_capture_run 0 suspend 0x00000900 0x00004000 24% 0x000000c4 000
2 ./camera_capture_run camera_capture_run 0 ready 0x00000900 0x00004000 25% 0x000000be -02
2 ./camera_capture_run camera_capture_run 0 suspend 0x00000900 0x00004000 24% 0x000000c8 000
2 ./camera_capture_run camera_capture_run 0 suspend 0x00000900 0x00004000 24% 0x000000c8 000
2 ./camera_capture_run camera_capture_run 0 ready 0x00000950 0x00004000 24% 0x000000c2 000
2 ./camera_capture_run camera_capture_run 25 ready 0x00000428 0x00004000 25% 0x00000045 000
--------------Backtrace--------------
riscv64-unknown-linux-musl-addr2line -e rtthread.elf -a -f 000000000019bc5c
请问我的代码对mpp的使用流程有什么问题吗