[COMMON] media: mfc: use the rc_framerate for timestamp calculation
authorAyoung Sim <a.sim@samsung.com>
Fri, 22 Jun 2018 05:04:43 +0000 (14:04 +0900)
committerSunyoung Kang <sy0816.kang@samsung.com>
Mon, 23 Jul 2018 06:18:45 +0000 (15:18 +0900)
Change-Id: I8ebb3144da1098c3a8335ef03d973ac53e88a2ab
Signed-off-by: Ayoung Sim <a.sim@samsung.com>
drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h
drivers/media/platform/exynos/mfc/s5p_mfc_enc.c
drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c
drivers/media/platform/exynos/mfc/s5p_mfc_irq.c
drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c
drivers/media/platform/exynos/mfc/s5p_mfc_qos.h

index deee549e1a8b62aeb3d1890b75f2212d66cee036..be5790f037b16e06f20f4c78400518051c06ae12 100644 (file)
@@ -816,7 +816,6 @@ struct s5p_mfc_h264_enc_params {
        s8 loop_filter_beta;
        enum v4l2_mpeg_video_h264_entropy_mode entropy_mode;
        u8 _8x8_transform;
-       u32 rc_framerate;
        u8 rc_frame_qp;
        u8 rc_min_qp;
        u8 rc_max_qp;
@@ -874,7 +873,6 @@ struct s5p_mfc_mpeg4_enc_params {
        u16 vop_frm_delta;
        u8 rc_b_frame_qp;
        /* Common for MPEG4, H263 */
-       u32 rc_framerate;
        u8 rc_frame_qp;
        u8 rc_min_qp;
        u8 rc_max_qp;
@@ -890,7 +888,6 @@ struct s5p_mfc_mpeg4_enc_params {
  */
 struct s5p_mfc_vp9_enc_params {
        /* VP9 Only */
-       u32 rc_framerate;
        u8 vp9_version;
        u8 rc_min_qp;
        u8 rc_max_qp;
@@ -914,7 +911,6 @@ struct s5p_mfc_vp9_enc_params {
  */
 struct s5p_mfc_vp8_enc_params {
        /* VP8 Only */
-       u32 rc_framerate;
        u8 vp8_version;
        u8 rc_min_qp;
        u8 rc_max_qp;
@@ -942,7 +938,6 @@ struct s5p_mfc_hevc_enc_params {
        u8 level;
        u8 tier_flag;
        /* HEVC Only */
-       u32 rc_framerate;
        u8 rc_min_qp;
        u8 rc_max_qp;
        u8 rc_min_qp_p;
@@ -1017,6 +1012,7 @@ struct s5p_mfc_enc_params {
        u8 pad_cr;
        u8 rc_frame;
        u32 rc_bitrate;
+       u32 rc_framerate;
        u16 rc_reaction_coeff;
        u32 config_qp;
        u32 dynamic_qp;
index 87e7983aab966ca611777172abed0b65160a6bac..04636fd033011040b6a66ac98d219dab4cbeadd5 100644 (file)
@@ -1059,7 +1059,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl)
                p->rc_mb = ctrl->value;
                break;
        case V4L2_CID_MPEG_MFC51_VIDEO_H264_RC_FRAME_RATE:
-               p->codec.h264.rc_framerate = ctrl->value;
+               p->rc_framerate = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP:
                p->codec.h264.rc_frame_qp = ctrl->value;
@@ -1270,7 +1270,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl)
                p->codec.mpeg4.vop_frm_delta = ctrl->value;
                break;
        case V4L2_CID_MPEG_MFC51_VIDEO_H263_RC_FRAME_RATE:
-               p->codec.mpeg4.rc_framerate = ctrl->value;
+               p->rc_framerate = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP:
                p->codec.mpeg4.rc_frame_qp = ctrl->value;
@@ -1294,7 +1294,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl)
                p->codec.vp8.vp8_version = ctrl->value;
                break;
        case V4L2_CID_MPEG_MFC70_VIDEO_VP8_RC_FRAME_RATE:
-               p->codec.vp8.rc_framerate = ctrl->value;
+               p->rc_framerate = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_VP8_MIN_QP:
                p->codec.vp8.rc_min_qp = ctrl->value;
@@ -1366,7 +1366,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl)
                p->codec.vp9.vp9_version = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_VP9_RC_FRAME_RATE:
-               p->codec.vp9.rc_framerate = ctrl->value;
+               p->rc_framerate = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_VP9_MIN_QP:
                p->codec.vp9.rc_min_qp = ctrl->value;
@@ -1436,7 +1436,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl)
                p->codec.hevc.rc_b_frame_qp = ctrl->value;
                break;
        case V4L2_CID_MPEG_MFC90_VIDEO_HEVC_RC_FRAME_RATE:
-               p->codec.hevc.rc_framerate = ctrl->value;
+               p->rc_framerate = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP:
                p->codec.hevc.rc_min_qp = ctrl->value;
index 6cc8a21cfb893765ca5f0d7a144411aa002be0e5..bfc32339181757fc2c81d4421798e07788173339 100644 (file)
@@ -496,7 +496,7 @@ void s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
        p->rc_frame_delta = FRAME_DELTA_DEFAULT;
        reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE);
        reg &= ~(0xFFFF << 16);
-       reg |= p_264->rc_framerate << 16;
+       reg |= (p->rc_framerate << 16);
        reg &= ~(0xFFFF);
        reg |= p->rc_frame_delta & 0xFFFF;
        MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE);
@@ -738,7 +738,7 @@ void s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx)
        p->rc_frame_delta = FRAME_DELTA_DEFAULT;
        reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE);
        reg &= ~(0xFFFF << 16);
-       reg |= (p_mpeg4->rc_framerate << 16);
+       reg |= (p->rc_framerate << 16);
        reg &= ~(0xFFFF);
        reg |= (p->rc_frame_delta & 0xFFFF);
        MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE);
@@ -872,7 +872,7 @@ void s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx *ctx)
        p->rc_frame_delta = FRAME_DELTA_DEFAULT;
        reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE);
        reg &= ~(0xFFFF << 16);
-       reg |= (p_vp8->rc_framerate << 16);
+       reg |= (p->rc_framerate << 16);
        reg &= ~(0xFFFF);
        reg |= (p->rc_frame_delta & 0xFFFF);
        MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE);
@@ -1016,7 +1016,7 @@ void s5p_mfc_set_enc_params_vp9(struct s5p_mfc_ctx *ctx)
        p->rc_frame_delta = FRAME_DELTA_DEFAULT;
        reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE);
        reg &= ~(0xFFFF << 16);
-       reg |= (p_vp9->rc_framerate << 16);
+       reg |= (p->rc_framerate << 16);
        reg &= ~(0xFFFF);
        reg |= (p->rc_frame_delta & 0xFFFF);
        MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE);
@@ -1245,7 +1245,7 @@ void s5p_mfc_set_enc_params_hevc(struct s5p_mfc_ctx *ctx)
        p->rc_frame_delta = FRAME_DELTA_DEFAULT;
        reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE);
        reg &= ~(0xFFFF << 16);
-       reg |= (p_hevc->rc_framerate << 16);
+       reg |= (p->rc_framerate << 16);
        reg &= ~(0xFFFF);
        reg |= (p->rc_frame_delta & 0xFFFF);
        MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE);
index 4c7e141e01e75e76010fc8f61ce4ba16fa2dbeb4..b5d7eed6e79df6685b565984f0ff117e0167f62f 100644 (file)
@@ -728,8 +728,10 @@ leave_handle_frame:
 static void mfc_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *src_mb)
 {
        struct s5p_mfc_dev *dev;
+       struct s5p_mfc_enc *enc = ctx->enc_priv;
+       struct s5p_mfc_enc_params *p = &enc->params;
        struct s5p_mfc_buf *dst_mb;
-       u64 interval;
+       u32 interval;
        u64 start_timestamp;
        u64 new_timestamp;
 
@@ -745,14 +747,14 @@ static void mfc_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, struct s5p
        }
 
        start_timestamp = src_mb->vb.vb2_buf.timestamp;
-       interval = NSEC_PER_SEC / (ENC_DEFAULT_CAM_VIDEO_FPS / 1000);
+       interval = NSEC_PER_SEC / p->rc_framerate;
        if (debug_ts == 1)
-               mfc_info_ctx("[TS] %dfps, start timestamp: %lld, base interval: %lld\n",
-                               (ENC_DEFAULT_CAM_VIDEO_FPS / 1000), start_timestamp, interval);
+               mfc_info_ctx("[TS] %dfps, start timestamp: %lld, base interval: %d\n",
+                               p->rc_framerate, start_timestamp, interval);
 
        new_timestamp = start_timestamp + (interval * src_mb->done_index);
        if (debug_ts == 1)
-               mfc_info_ctx("[TS] new timestamp: %lld, interval: %lld\n",
+               mfc_info_ctx("[TS] new timestamp: %lld, interval: %d\n",
                                new_timestamp, interval * src_mb->done_index);
 
        /* Get the destination buffer */
index 530238e4f3915dff52f51ea19004b4ef641c9bdc..f8ce9b5d21b9e5d6f548166c043996049a0f5a93 100644 (file)
@@ -876,8 +876,10 @@ static void mfc_nal_q_get_enc_frame_buffer(struct s5p_mfc_ctx *ctx,
 static void mfc_nal_q_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *src_mb)
 {
        struct s5p_mfc_dev *dev;
+       struct s5p_mfc_enc *enc = ctx->enc_priv;
+       struct s5p_mfc_enc_params *p = &enc->params;
        struct s5p_mfc_buf *dst_mb;
-       u64 interval;
+       u32 interval;
        u64 start_timestamp;
        u64 new_timestamp;
 
@@ -893,14 +895,14 @@ static void mfc_nal_q_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, stru
        }
 
        start_timestamp = src_mb->vb.vb2_buf.timestamp;
-       interval = NSEC_PER_SEC / (ENC_DEFAULT_CAM_VIDEO_FPS / 1000);
+       interval = NSEC_PER_SEC / p->rc_framerate;
        if (debug_ts == 1)
-               mfc_info_ctx("[NALQ][TS] %dfps, start timestamp: %lld, base interval: %lld\n",
-                               (ENC_DEFAULT_CAM_VIDEO_FPS / 1000), start_timestamp, interval);
+               mfc_info_ctx("[NALQ][TS] %dfps, start timestamp: %lld, base interval: %d\n",
+                               p->rc_framerate, start_timestamp, interval);
 
        new_timestamp = start_timestamp + (interval * src_mb->done_index);
        if (debug_ts == 1)
-               mfc_info_ctx("[NALQ][TS] new timestamp: %lld, interval: %lld\n",
+               mfc_info_ctx("[NALQ][TS] new timestamp: %lld, interval: %d\n",
                                new_timestamp, interval * src_mb->done_index);
 
        /* Get the destination buffer */
index 9254657b7720431aa9022645d02964bd5aa3e07e..a733a60f529626285772f3d174f7080d8ea71b25 100644 (file)
@@ -19,7 +19,6 @@
 #define DEC_DEFAULT_FPS                        (240000)
 #define ENC_DEFAULT_FPS                        (240000)
 #define ENC_DEFAULT_CAM_CAPTURE_FPS    (60000)
-#define ENC_DEFAULT_CAM_VIDEO_FPS      (30000)
 
 #define MB_COUNT_PER_UHD_FRAME         32400
 #define MAX_FPS_PER_UHD_FRAME          120