Hello, I was trying to implement mode 3: pure external mode. Here is my code snippet:
static MPP_RET mjpeg_dec_one(MjpegDecoder *dec, MppBuffer jpeg_buf, size_t jpeg_size)
{
MppPacket packet = NULL;
MppFrame frame_out = NULL;
MppMeta meta;
MPP_RET ret;
if (!jpeg_buf || !jpeg_size)
return MPP_NOK;
ret = mpp_packet_init_with_buffer(&packet, jpeg_buf);
if (ret)
return ret;
mpp_packet_set_length(packet, jpeg_size);
meta = mpp_packet_get_meta(packet);
if (meta)
mpp_meta_set_frame(meta, KEY_OUTPUT_FRAME, dec->frame);
ret = dec->mpi->decode_put_packet(dec->ctx, packet);
if (ret) {
mpp_packet_deinit(&packet);
return ret;
}
ret = dec->mpi->decode_get_frame(dec->ctx, &frame_out);
mpp_packet_deinit(&packet);
if (ret || !frame_out)
return MPP_NOK;
if (mpp_frame_get_errinfo(frame_out))
return MPP_NOK;
mpp_buffer_sync_ro_begin(mpp_frame_get_buffer(frame_out));
return MPP_OK;
}
Main loop:
while (frame_count < MAX_FRAMES) {
size_t jpeg_size;
MppBuffer jpeg_buf;
MppBuffer out_buf;
cam_idx = camera_source_get_frame(cam);
if (cam_idx < 0)
break;
jpeg_size = camera_frame_size(cam, cam_idx);
jpeg_buf = camera_frame_to_buf(cam, cam_idx);
if (jpeg_size > 0 && jpeg_buf) {
if (mjpeg_dec_one(&dec, jpeg_buf, jpeg_size) == MPP_OK) {
out_buf = mpp_frame_get_buffer(dec.frame);
printf("frame %d: mjpeg %zu -> %ux%u fmt %d drm_fd %d\n",
frame_count, jpeg_size,
mpp_frame_get_width(dec.frame),
mpp_frame_get_height(dec.frame),
mpp_frame_get_fmt(dec.frame),
out_buf ? mpp_buffer_get_fd(out_buf) : -1);
frame_count++;
} else {
fprintf(stderr, "decode failed on frame %d (jpeg %zu bytes)\n",
frame_count, jpeg_size);
}
}
camera_source_put_frame(cam, cam_idx);
}
But I am getting this error:
mpp[187219]: hal_jpegd_rkv: decode result: failed, irq 0x0000214d
decode failed on frame 109 (jpeg 269463 bytes)
I think my issue is pretty similar to this one: #76
What am I doing wrong or this is a bug?
I've tried to implement the same logic with ffmpeg and there weren't any errors, but I am trying to eliminate overhead so pure mpp is preferable.
Hello, I was trying to implement mode 3: pure external mode. Here is my code snippet:
Main loop:
But I am getting this error:
mpp[187219]: hal_jpegd_rkv: decode result: failed, irq 0x0000214d
decode failed on frame 109 (jpeg 269463 bytes)
I think my issue is pretty similar to this one: #76
What am I doing wrong or this is a bug?
I've tried to implement the same logic with ffmpeg and there weren't any errors, but I am trying to eliminate overhead so pure mpp is preferable.