CHROMIUM: [media] rk3288-vpu: Add VP8 decoder to V4L2 API implementation
authorTomasz Figa <tfiga@chromium.org>
Fri, 9 Jan 2015 11:35:16 +0000 (20:35 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Jun 2016 11:50:37 +0000 (19:50 +0800)
This patch extends existing implementation of required V4L2 API calls
with code required for VP8 decoder.

BUG=chrome-os-partner:33728
TEST=video_encode_accelerator_unittest;video_decode_accelerator_unittest

Signed-off-by: ZhiChao Yu <zhichao.yu@rock-chips.com>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/239814
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Change-Id: I633687b7223c25f46d2373b964ceb1fe29f02b2f
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
drivers/media/platform/rk3288-vpu/rk3288_vpu_common.h
drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c

index 9e2634e14cf0d9486e0c2d464765613957479574..0ef96c3f186c5e03cf4fd086f669fff5e964e408 100644 (file)
@@ -197,6 +197,15 @@ struct rk3288_vpu_vp8e_run {
        const struct rk3288_vp8e_reg_params *reg_params;
 };
 
+/**
+ * struct rk3288_vpu_vp8d_run - per-run data specific to VP8 decoding.
+ * @frame_hdr: Pointer to a buffer containing per-run frame data which
+ *                     is needed by setting vpu register.
+ */
+struct rk3288_vpu_vp8d_run {
+       const struct v4l2_ctrl_vp8_frame_hdr *frame_hdr;
+};
+
 /**
  * struct rk3288_vpu_h264d_run - per-run data specific to H264 decoding.
  * @sps:               Pointer to a buffer containing H264 SPS.
@@ -231,6 +240,7 @@ struct rk3288_vpu_run {
        /* Specific for particular operating modes. */
        union {
                struct rk3288_vpu_vp8e_run vp8e;
+               struct rk3288_vpu_vp8d_run vp8d;
                struct rk3288_vpu_h264d_run h264d;
                /* Other modes will need different data. */
        };
index db8a1681ec22ba7356080e37893bbf4a4f73fc8a..cc0f9b3f060187384a3e9e75914ee407cb1ecb7f 100644 (file)
@@ -54,6 +54,12 @@ static struct rk3288_vpu_fmt formats[] = {
                .codec_mode = RK_VPU_CODEC_H264D,
                .num_planes = 1,
        },
+       {
+               .name = "Frames of VP8 Encoded Stream",
+               .fourcc = V4L2_PIX_FMT_VP8_FRAME,
+               .codec_mode = RK_VPU_CODEC_VP8D,
+               .num_planes = 1,
+       },
 };
 
 static struct rk3288_vpu_fmt *find_format(struct v4l2_format *f, bool bitstream)
@@ -78,6 +84,7 @@ enum {
        RK3288_VPU_DEC_CTRL_H264_SCALING_MATRIX,
        RK3288_VPU_DEC_CTRL_H264_SLICE_PARAM,
        RK3288_VPU_DEC_CTRL_H264_DECODE_PARAM,
+       RK3288_VPU_DEC_CTRL_VP8_FRAME_HDR,
 };
 
 static struct rk3288_vpu_control controls[] = {
@@ -123,6 +130,14 @@ static struct rk3288_vpu_control controls[] = {
                .elem_size = sizeof(struct v4l2_ctrl_h264_decode_param),
                .can_store = true,
        },
+       [RK3288_VPU_DEC_CTRL_VP8_FRAME_HDR] = {
+               .id = V4L2_CID_MPEG_VIDEO_VP8_FRAME_HDR,
+               .type = V4L2_CTRL_TYPE_PRIVATE,
+               .name = "VP8 Frame Header Parameters",
+               .max_stores = VIDEO_MAX_FRAME,
+               .elem_size = sizeof(struct v4l2_ctrl_vp8_frame_hdr),
+               .can_store = true,
+       },
 };
 
 static inline const void *get_ctrl_ptr(struct rk3288_vpu_ctx *ctx, unsigned id)
@@ -626,6 +641,7 @@ static int rk3288_vpu_dec_s_ctrl(struct v4l2_ctrl *ctrl)
        case V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX:
        case V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAM:
        case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAM:
+       case V4L2_CID_MPEG_VIDEO_VP8_FRAME_HDR:
                /* These controls are used directly. */
                break;
 
@@ -942,14 +958,21 @@ static void rk3288_vpu_dec_prepare_run(struct rk3288_vpu_ctx *ctx)
 
        v4l2_ctrl_apply_store(&ctx->ctrl_handler, src->config_store);
 
-       ctx->run.h264d.sps = get_ctrl_ptr(ctx, RK3288_VPU_DEC_CTRL_H264_SPS);
-       ctx->run.h264d.pps = get_ctrl_ptr(ctx, RK3288_VPU_DEC_CTRL_H264_PPS);
-       ctx->run.h264d.scaling_matrix = get_ctrl_ptr(ctx,
+       if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_H264_SLICE) {
+               ctx->run.h264d.sps = get_ctrl_ptr(ctx,
+                               RK3288_VPU_DEC_CTRL_H264_SPS);
+               ctx->run.h264d.pps = get_ctrl_ptr(ctx,
+                               RK3288_VPU_DEC_CTRL_H264_PPS);
+               ctx->run.h264d.scaling_matrix = get_ctrl_ptr(ctx,
                                RK3288_VPU_DEC_CTRL_H264_SCALING_MATRIX);
-       ctx->run.h264d.slice_param = get_ctrl_ptr(ctx,
+               ctx->run.h264d.slice_param = get_ctrl_ptr(ctx,
                                RK3288_VPU_DEC_CTRL_H264_SLICE_PARAM);
-       ctx->run.h264d.decode_param = get_ctrl_ptr(ctx,
+               ctx->run.h264d.decode_param = get_ctrl_ptr(ctx,
                                RK3288_VPU_DEC_CTRL_H264_DECODE_PARAM);
+       } else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_VP8_FRAME) {
+               ctx->run.vp8d.frame_hdr = get_ctrl_ptr(ctx,
+                               RK3288_VPU_DEC_CTRL_VP8_FRAME_HDR);
+       }
 }
 
 static void rk3288_vpu_dec_run_done(struct rk3288_vpu_ctx *ctx,