mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 17:16:50 +08:00
feat[kmpp]: Replace frame_infos with kmpp_frame
kernel patch: fix[mpp_vcodec]: Replace frame_infos with kmpp_frame Change-Id: Ie3b0358a7b79ad9755608f20b5b29175263b4dbb Signed-off-by: Yanjun Liao <yanjun.liao@rock-chips.com>
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
ENTRY(prefix, u32, rk_u32, chroma_location, FLAG_NONE, chroma_location) \
|
ENTRY(prefix, u32, rk_u32, chroma_location, FLAG_NONE, chroma_location) \
|
||||||
ENTRY(prefix, u32, rk_u32, fmt, FLAG_NONE, fmt) \
|
ENTRY(prefix, u32, rk_u32, fmt, FLAG_NONE, fmt) \
|
||||||
ENTRY(prefix, u32, rk_u32, buf_size, FLAG_NONE, buf_size) \
|
ENTRY(prefix, u32, rk_u32, buf_size, FLAG_NONE, buf_size) \
|
||||||
|
ENTRY(prefix, u32, rk_u32, buf_fd, FLAG_NONE, buf_fd) \
|
||||||
ENTRY(prefix, u32, rk_u32, is_gray, FLAG_NONE, is_gray) \
|
ENTRY(prefix, u32, rk_u32, is_gray, FLAG_NONE, is_gray) \
|
||||||
STRCT(prefix, shm, KmppShmPtr, buffer, FLAG_NONE, buffer) \
|
STRCT(prefix, shm, KmppShmPtr, buffer, FLAG_NONE, buffer) \
|
||||||
STRCT(prefix, st, MppFrameRational, sar, FLAG_NONE, sar)
|
STRCT(prefix, st, MppFrameRational, sar, FLAG_NONE, sar)
|
||||||
|
@@ -63,6 +63,7 @@ typedef struct KmppFrameImpl_t {
|
|||||||
*/
|
*/
|
||||||
KmppShmPtr buffer;
|
KmppShmPtr buffer;
|
||||||
size_t buf_size;
|
size_t buf_size;
|
||||||
|
RK_U32 buf_fd;
|
||||||
/*
|
/*
|
||||||
* frame buffer compression (FBC) information
|
* frame buffer compression (FBC) information
|
||||||
*
|
*
|
||||||
|
@@ -66,6 +66,7 @@ struct Kmpp_t {
|
|||||||
|
|
||||||
MppBufferGroup mPacketGroup;
|
MppBufferGroup mPacketGroup;
|
||||||
MppPacket mPacket;
|
MppPacket mPacket;
|
||||||
|
KmppFrame mKframe;
|
||||||
|
|
||||||
KmppOps *mApi;
|
KmppOps *mApi;
|
||||||
KmppObj mVencInitKcfg;
|
KmppObj mVencInitKcfg;
|
||||||
|
89
kmpp/kmpp.c
89
kmpp/kmpp.c
@@ -25,6 +25,7 @@
|
|||||||
#include "kmpp.h"
|
#include "kmpp.h"
|
||||||
#include "kmpp_obj.h"
|
#include "kmpp_obj.h"
|
||||||
#include "mpp_soc.h"
|
#include "mpp_soc.h"
|
||||||
|
#include "kmpp_frame.h"
|
||||||
#include "mpp_buffer_impl.h"
|
#include "mpp_buffer_impl.h"
|
||||||
#include "mpp_frame_impl.h"
|
#include "mpp_frame_impl.h"
|
||||||
#include "mpp_packet_impl.h"
|
#include "mpp_packet_impl.h"
|
||||||
@@ -166,6 +167,11 @@ static void clear(Kmpp *ctx)
|
|||||||
mpp_buffer_group_put(ctx->mPacketGroup);
|
mpp_buffer_group_put(ctx->mPacketGroup);
|
||||||
ctx->mPacketGroup = NULL;
|
ctx->mPacketGroup = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->mKframe) {
|
||||||
|
kmpp_frame_put(ctx->mKframe);
|
||||||
|
ctx->mKframe = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static MPP_RET start(Kmpp *ctx)
|
static MPP_RET start(Kmpp *ctx)
|
||||||
@@ -258,9 +264,9 @@ static MPP_RET get_frame(Kmpp *ctx, MppFrame *frame)
|
|||||||
|
|
||||||
static MPP_RET put_frame(Kmpp *ctx, MppFrame frame)
|
static MPP_RET put_frame(Kmpp *ctx, MppFrame frame)
|
||||||
{
|
{
|
||||||
KmppFrameInfos frame_info;
|
|
||||||
MppBuffer buf = NULL;
|
|
||||||
MPP_RET ret = MPP_OK;
|
MPP_RET ret = MPP_OK;
|
||||||
|
KmppShmPtr *ptr = NULL;
|
||||||
|
rk_s32 size;
|
||||||
|
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return MPP_ERR_VALUE;
|
return MPP_ERR_VALUE;
|
||||||
@@ -268,44 +274,61 @@ static MPP_RET put_frame(Kmpp *ctx, MppFrame frame)
|
|||||||
if (!ctx->mInitDone)
|
if (!ctx->mInitDone)
|
||||||
return MPP_ERR_INIT;
|
return MPP_ERR_INIT;
|
||||||
|
|
||||||
buf = mpp_frame_get_buffer(frame);
|
if (!__check_is_mpp_frame(frame)) {
|
||||||
memset(&frame_info, 0, sizeof(frame_info));
|
MppFrameImpl *impl = (MppFrameImpl *)frame;
|
||||||
frame_info.width = mpp_frame_get_width(frame);
|
|
||||||
frame_info.height = mpp_frame_get_height(frame);
|
|
||||||
frame_info.hor_stride = mpp_frame_get_hor_stride(frame);
|
|
||||||
frame_info.ver_stride = mpp_frame_get_ver_stride(frame);
|
|
||||||
frame_info.hor_stride_pixel = mpp_frame_get_hor_stride_pixel(frame);
|
|
||||||
frame_info.offset_x = mpp_frame_get_offset_x(frame);
|
|
||||||
frame_info.offset_y = mpp_frame_get_offset_y(frame);
|
|
||||||
frame_info.fmt = mpp_frame_get_fmt(frame);
|
|
||||||
frame_info.eos = mpp_frame_get_eos(frame);
|
|
||||||
frame_info.pts = mpp_frame_get_pts(frame);
|
|
||||||
frame_info.dts = mpp_frame_get_dts(frame);
|
|
||||||
if (buf)
|
|
||||||
frame_info.fd = mpp_buffer_get_fd(buf);
|
|
||||||
if (mpp_frame_has_meta(frame)) {
|
|
||||||
MppMeta meta = mpp_frame_get_meta(frame);
|
|
||||||
MppPacket packet = NULL;
|
|
||||||
|
|
||||||
mpp_meta_get_packet(meta, KEY_OUTPUT_PACKET, &packet);
|
if (ctx->mKframe == NULL)
|
||||||
ctx->mPacket = packet;
|
kmpp_frame_get(&ctx->mKframe);
|
||||||
|
|
||||||
/* set roi */
|
kmpp_frame_set_width(ctx->mKframe, impl->width);
|
||||||
{
|
kmpp_frame_set_height(ctx->mKframe, impl->height);
|
||||||
MppEncROICfg *roi_data = NULL;
|
kmpp_frame_set_hor_stride(ctx->mKframe, impl->hor_stride);
|
||||||
MppEncROICfgLegacy roi_data0;
|
kmpp_frame_set_ver_stride(ctx->mKframe, impl->ver_stride);
|
||||||
|
kmpp_frame_set_fmt(ctx->mKframe, impl->fmt);
|
||||||
|
kmpp_frame_set_eos(ctx->mKframe, impl->eos);
|
||||||
|
kmpp_frame_set_pts(ctx->mKframe, impl->pts);
|
||||||
|
kmpp_frame_set_dts(ctx->mKframe, impl->dts);
|
||||||
|
kmpp_frame_set_offset_x(ctx->mKframe, impl->offset_x);
|
||||||
|
kmpp_frame_set_offset_y(ctx->mKframe, impl->offset_y);
|
||||||
|
kmpp_frame_set_hor_stride_pixel(ctx->mKframe, impl->hor_stride_pixel);
|
||||||
|
|
||||||
mpp_meta_get_ptr(meta, KEY_ROI_DATA, (void**)&roi_data);
|
if (impl->buffer) {
|
||||||
if (roi_data) {
|
kmpp_frame_set_buf_fd(ctx->mKframe, mpp_buffer_get_fd(impl->buffer));
|
||||||
roi_data0.change = 1;
|
} else {
|
||||||
roi_data0.number = roi_data->number;
|
mpp_loge_f("kmpp put_frame buf is NULL\n");
|
||||||
memcpy(roi_data0.regions, roi_data->regions, roi_data->number * sizeof(MppEncROIRegion));
|
return MPP_NOK;
|
||||||
ctx->mApi->control(ctx, MPP_ENC_SET_ROI_CFG, &roi_data0);
|
}
|
||||||
|
|
||||||
|
if (mpp_frame_has_meta(frame)) {
|
||||||
|
MppMeta meta = mpp_frame_get_meta(frame);
|
||||||
|
MppPacket packet = NULL;
|
||||||
|
|
||||||
|
mpp_meta_get_packet(meta, KEY_OUTPUT_PACKET, &packet);
|
||||||
|
ctx->mPacket = packet;
|
||||||
|
|
||||||
|
/* set roi */
|
||||||
|
{
|
||||||
|
MppEncROICfg *roi_data = NULL;
|
||||||
|
MppEncROICfgLegacy roi_data0;
|
||||||
|
|
||||||
|
mpp_meta_get_ptr(meta, KEY_ROI_DATA, (void**)&roi_data);
|
||||||
|
if (roi_data) {
|
||||||
|
roi_data0.change = 1;
|
||||||
|
roi_data0.number = roi_data->number;
|
||||||
|
memcpy(roi_data0.regions, roi_data->regions, roi_data->number * sizeof(MppEncROIRegion));
|
||||||
|
ctx->mApi->control(ctx, MPP_ENC_SET_ROI_CFG, &roi_data0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptr = kmpp_obj_to_shm(ctx->mKframe);
|
||||||
|
size = kmpp_obj_to_shm_size(ctx->mKframe);
|
||||||
|
} else {
|
||||||
|
ptr = kmpp_obj_to_shm(frame);
|
||||||
|
size = kmpp_obj_to_shm_size(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mpp_vcodec_ioctl(ctx->mClientFd, VCODEC_CHAN_IN_FRM_RDY, 0, sizeof(frame_info), &frame_info);
|
ret = mpp_vcodec_ioctl(ctx->mClientFd, VCODEC_CHAN_IN_FRM_RDY, 0, size, ptr);
|
||||||
if (ret)
|
if (ret)
|
||||||
mpp_err("chan %d VCODEC_CHAN_IN_FRM_RDY failed\n", ctx->mChanId);
|
mpp_err("chan %d VCODEC_CHAN_IN_FRM_RDY failed\n", ctx->mChanId);
|
||||||
|
|
||||||
|
@@ -214,7 +214,7 @@ MppFrameStatus *mpp_frame_get_status(MppFrame frame);
|
|||||||
void mpp_frame_set_stopwatch_enable(MppFrame frame, RK_S32 enable);
|
void mpp_frame_set_stopwatch_enable(MppFrame frame, RK_S32 enable);
|
||||||
MppStopwatch mpp_frame_get_stopwatch(const MppFrame frame);
|
MppStopwatch mpp_frame_get_stopwatch(const MppFrame frame);
|
||||||
|
|
||||||
MPP_RET check_is_mpp_frame(void *pointer);
|
MPP_RET __check_is_mpp_frame(void *frame);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ MPP_SINGLETON(MPP_SGLN_FRAME, mpp_frame, mpp_frame_srv_init, mpp_frame_srv_deini
|
|||||||
|
|
||||||
MPP_RET _check_is_mpp_frame(const char *func, void *frame)
|
MPP_RET _check_is_mpp_frame(const char *func, void *frame)
|
||||||
{
|
{
|
||||||
if (frame && ((MppFrameImpl*)frame)->name == module_name)
|
if (!__check_is_mpp_frame(frame))
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
|
|
||||||
mpp_err("pointer %p failed on %s check mpp_frame\n", frame, func);
|
mpp_err("pointer %p failed on %s check mpp_frame\n", frame, func);
|
||||||
@@ -60,6 +60,14 @@ MPP_RET _check_is_mpp_frame(const char *func, void *frame)
|
|||||||
return MPP_NOK;
|
return MPP_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPP_RET __check_is_mpp_frame(void *frame)
|
||||||
|
{
|
||||||
|
if (frame && ((MppFrameImpl*)frame)->name == module_name)
|
||||||
|
return MPP_OK;
|
||||||
|
|
||||||
|
return MPP_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
MPP_RET mpp_frame_init(MppFrame *frame)
|
MPP_RET mpp_frame_init(MppFrame *frame)
|
||||||
{
|
{
|
||||||
MppFrameImpl *p;
|
MppFrameImpl *p;
|
||||||
|
Reference in New Issue
Block a user