Commit 16060f7e authored by Tiffany Lin's avatar Tiffany Lin Committed by Mauro Carvalho Chehab

[media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder

This patch add copying timestamp and timecode from src buffer to dst buffer
Signed-off-by: default avatarTiffany Lin <tiffany.lin@mediatek.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 91ae0e1e
...@@ -868,7 +868,8 @@ static int mtk_venc_encode_header(void *priv) ...@@ -868,7 +868,8 @@ static int mtk_venc_encode_header(void *priv)
{ {
struct mtk_vcodec_ctx *ctx = priv; struct mtk_vcodec_ctx *ctx = priv;
int ret; int ret;
struct vb2_buffer *dst_buf; struct vb2_buffer *src_buf, *dst_buf;
struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
struct mtk_vcodec_mem bs_buf; struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result; struct venc_done_result enc_result;
...@@ -901,6 +902,15 @@ static int mtk_venc_encode_header(void *priv) ...@@ -901,6 +902,15 @@ static int mtk_venc_encode_header(void *priv)
mtk_v4l2_err("venc_if_encode failed=%d", ret); mtk_v4l2_err("venc_if_encode failed=%d", ret);
return -EINVAL; return -EINVAL;
} }
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
if (src_buf) {
src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
dst_buf->timestamp = src_buf->timestamp;
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
} else {
mtk_v4l2_err("No timestamp for the header buffer.");
}
ctx->state = MTK_STATE_HEADER; ctx->state = MTK_STATE_HEADER;
dst_buf->planes[0].bytesused = enc_result.bs_size; dst_buf->planes[0].bytesused = enc_result.bs_size;
...@@ -993,7 +1003,7 @@ static void mtk_venc_worker(struct work_struct *work) ...@@ -993,7 +1003,7 @@ static void mtk_venc_worker(struct work_struct *work)
struct mtk_vcodec_mem bs_buf; struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result; struct venc_done_result enc_result;
int ret, i; int ret, i;
struct vb2_v4l2_buffer *vb2_v4l2; struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
/* check dst_buf, dst_buf may be removed in device_run /* check dst_buf, dst_buf may be removed in device_run
* to stored encdoe header so we need check dst_buf and * to stored encdoe header so we need check dst_buf and
...@@ -1033,9 +1043,14 @@ static void mtk_venc_worker(struct work_struct *work) ...@@ -1033,9 +1043,14 @@ static void mtk_venc_worker(struct work_struct *work)
ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME, ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
&frm_buf, &bs_buf, &enc_result); &frm_buf, &bs_buf, &enc_result);
vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf); src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
dst_buf->timestamp = src_buf->timestamp;
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
if (enc_result.is_key_frm) if (enc_result.is_key_frm)
vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME; dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
if (ret) { if (ret) {
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment