pass a pointer to the compressed frame header as a different variable. This is a preparation for the stateless encoder where the header is not in the same buffer with the data. Signed-off-by: Dafna Hirschfeld <dafna3@xxxxxxxxx> --- drivers/media/platform/vicodec/codec-v4l2-fwht.c | 9 ++++----- drivers/media/platform/vicodec/codec-v4l2-fwht.h | 3 ++- drivers/media/platform/vicodec/vicodec-core.c | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index 01e7f09efc4e..6a88c6defd1e 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -199,12 +199,12 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf, return 0; } -int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out, + struct fwht_cframe_hdr *p_hdr) { unsigned int size = state->stride * state->coded_height; unsigned int chroma_stride = state->stride; const struct v4l2_fwht_pixfmt_info *info = state->info; - struct fwht_cframe_hdr *p_hdr; struct fwht_cframe cf; struct fwht_raw_frame rf; u32 encoding; @@ -225,7 +225,7 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) cf.i_frame_qp = state->i_frame_qp; cf.p_frame_qp = state->p_frame_qp; - cf.rlc_data = (__be16 *)(p_out + sizeof(*p_hdr)); + cf.rlc_data = (__be16 *)p_out; encoding = fwht_encode_frame(&rf, &state->ref_frame, &cf, !state->gop_cnt, @@ -238,7 +238,6 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) if (++state->gop_cnt >= state->gop_size) state->gop_cnt = 0; - p_hdr = (struct fwht_cframe_hdr *)p_out; p_hdr->magic1 = FWHT_MAGIC1; p_hdr->magic2 = FWHT_MAGIC2; p_hdr->version = htonl(FWHT_VERSION); @@ -266,7 +265,7 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) p_hdr->ycbcr_enc = htonl(state->ycbcr_enc); p_hdr->quantization = htonl(state->quantization); p_hdr->size = htonl(cf.size); - return cf.size + sizeof(*p_hdr); + return cf.size; } int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.h b/drivers/media/platform/vicodec/codec-v4l2-fwht.h index 1a0d2a9f931a..e540cd58cf97 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -58,7 +58,8 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div, u32 pixenc, unsigned int start_idx); -int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out); +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out, + struct fwht_cframe_hdr *hdr); int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out); #endif diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index 52e8128d2d28..08073f914fd6 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -313,13 +313,18 @@ static int device_process(struct vicodec_ctx *ctx, if (ctx->is_enc) { struct vicodec_q_data *q_src; int comp_sz_or_errcode; + struct fwht_cframe_hdr *p_hdr = (struct fwht_cframe_hdr *) p_dst; + u8 *comp_buf = p_dst + sizeof(struct fwht_cframe_hdr); + q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); state->info = q_src->info; - comp_sz_or_errcode = v4l2_fwht_encode(state, p_src, p_dst); + comp_sz_or_errcode = v4l2_fwht_encode(state, p_src, comp_buf, + p_hdr); if (comp_sz_or_errcode < 0) return comp_sz_or_errcode; - vb2_set_plane_payload(&dst_vb->vb2_buf, 0, comp_sz_or_errcode); + vb2_set_plane_payload(&dst_vb->vb2_buf, 0, + comp_sz_or_errcode + sizeof(*p_hdr)); } else { struct vicodec_q_data *q_dst; unsigned int comp_frame_size = ntohl(ctx->state.header.size); -- 2.17.1