summaryrefslogtreecommitdiff
authorNanxin Qin <nanxin.qin@amlogic.com>2020-03-11 11:19:37 (GMT)
committer Nanxin Qin <nanxin.qin@amlogic.com>2020-03-11 11:19:55 (GMT)
commit5652b4fcf60a146c23f7f2faa74d7185e70fad0a (patch)
tree76335929a22ada4c80936f59a463babb9e1145fa
parent2d55afcdb433e96b106ba4cc06dd49bf11ad92ea (diff)
downloadmedia_modules-5652b4fcf60a146c23f7f2faa74d7185e70fad0a.zip
media_modules-5652b4fcf60a146c23f7f2faa74d7185e70fad0a.tar.gz
media_modules-5652b4fcf60a146c23f7f2faa74d7185e70fad0a.tar.bz2
decoder: resolve UV revertion issue for NV12 [1/1]
PD#SWPL-21954 Problem: Vframe->type is not correctly set for NV12 Solution: Put NV12 format to vframe->type Verify: U212 with v4l2-uvm-test Change-Id: Ib20f583605e6acec3660d871f8cd6c0ef8022b83 Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
Diffstat
-rw-r--r--drivers/amvdec_ports/aml_vcodec_dec.c3
-rw-r--r--drivers/amvdec_ports/aml_vcodec_drv.h1
-rw-r--r--drivers/frame_provider/decoder/h264_multi/vmh264.c29
-rw-r--r--drivers/frame_provider/decoder/h265/vh265.c53
-rw-r--r--drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c16
-rw-r--r--drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c15
-rw-r--r--drivers/frame_provider/decoder/vp9/vvp9.c12
7 files changed, 93 insertions, 36 deletions
diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c
index 575c9a6..0cd6fb8 100644
--- a/drivers/amvdec_ports/aml_vcodec_dec.c
+++ b/drivers/amvdec_ports/aml_vcodec_dec.c
@@ -1874,6 +1874,9 @@ static int vidioc_vdec_g_fmt(struct file *file, void *priv,
return -EINVAL;
}
+ if (!V4L2_TYPE_IS_OUTPUT(f->type))
+ ctx->cap_pix_fmt = pix_mp->pixelformat;
+
v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT,
"%s, type: %u, planes: %u, fmt: %u\n",
__func__, f->type, f->fmt.pix_mp.num_planes,
diff --git a/drivers/amvdec_ports/aml_vcodec_drv.h b/drivers/amvdec_ports/aml_vcodec_drv.h
index 72505e5..aaac607 100644
--- a/drivers/amvdec_ports/aml_vcodec_drv.h
+++ b/drivers/amvdec_ports/aml_vcodec_drv.h
@@ -464,6 +464,7 @@ struct aml_vcodec_ctx {
int stop_cmd;
u32 display_count;
struct v4l_buff_pool cap_pool;
+ u32 cap_pix_fmt;
};
/**
diff --git a/drivers/frame_provider/decoder/h264_multi/vmh264.c b/drivers/frame_provider/decoder/h264_multi/vmh264.c
index 29e4346..a74382d 100644
--- a/drivers/frame_provider/decoder/h264_multi/vmh264.c
+++ b/drivers/frame_provider/decoder/h264_multi/vmh264.c
@@ -2619,6 +2619,8 @@ int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
struct vdec_h264_hw_s *hw = (struct vdec_h264_hw_s *)vdec->private;
struct vframe_s *vf = NULL;
int buffer_index = frame->buf_spec_num;
+ struct aml_vcodec_ctx * v4l2_ctx = hw->v4l2_ctx;
+ ulong nv_order = VIDTYPE_VIU_NV21;
int vf_count = 1;
int i;
int bForceInterlace = 0;
@@ -2629,6 +2631,14 @@ int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
__func__, buffer_index);
return -1;
}
+
+ /* swap uv */
+ if (hw->is_used_v4l) {
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12M))
+ nv_order = VIDTYPE_VIU_NV12;
+ }
+
if (force_disp_bufspec_num & 0x100) {
/*recycle directly*/
if (hw->buffer_spec[frame->buf_spec_num].used != 3 &&
@@ -2790,7 +2800,7 @@ int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
if (hw->double_write_mode) {
vf->type |= VIDTYPE_PROGRESSIVE
| VIDTYPE_VIU_FIELD;
- vf->type |= VIDTYPE_VIU_NV21;
+ vf->type |= nv_order;
if (hw->double_write_mode == 3)
vf->type |= VIDTYPE_COMPRESS;
@@ -2823,7 +2833,7 @@ int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
vf->compHeight = hw->frame_height;
} else {
vf->type = VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD |
- VIDTYPE_VIU_NV21;
+ nv_order;
vf->canvas0Addr = vf->canvas1Addr =
spec2canvas(&hw->buffer_spec[buffer_index]);
@@ -2855,7 +2865,7 @@ int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
if (bForceInterlace || is_interlace(frame)) {
vf->type =
VIDTYPE_INTERLACE_FIRST |
- VIDTYPE_VIU_NV21;
+ nv_order;
if (bForceInterlace) {
if (frame->frame != NULL && frame->frame->pic_struct == PIC_TOP_BOT) {
@@ -3855,10 +3865,19 @@ static struct vframe_s *vh264_vf_get(void *op_arg)
struct vframe_s *vf;
struct vdec_s *vdec = op_arg;
struct vdec_h264_hw_s *hw = (struct vdec_h264_hw_s *)vdec->private;
+ struct aml_vcodec_ctx * v4l2_ctx = hw->v4l2_ctx;
+ ulong nv_order = VIDTYPE_VIU_NV21;
if (!hw)
return NULL;
+ /* swap uv */
+ if (hw->is_used_v4l) {
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12M))
+ nv_order = VIDTYPE_VIU_NV12;
+ }
+
if (force_disp_bufspec_num & 0x100) {
int buffer_index = force_disp_bufspec_num & 0xff;
if (force_disp_bufspec_num & 0x200)
@@ -3889,7 +3908,7 @@ static struct vframe_s *vh264_vf_get(void *op_arg)
if (hw->double_write_mode) {
vf->type |= VIDTYPE_PROGRESSIVE
| VIDTYPE_VIU_FIELD;
- vf->type |= VIDTYPE_VIU_NV21;
+ vf->type |= nv_order;
if (hw->double_write_mode == 3)
vf->type |= VIDTYPE_COMPRESS;
@@ -3927,7 +3946,7 @@ static struct vframe_s *vh264_vf_get(void *op_arg)
}
} else {
vf->type = VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD |
- VIDTYPE_VIU_NV21;
+ nv_order;
vf->canvas0Addr = vf->canvas1Addr =
spec2canvas(&hw->buffer_spec[buffer_index]);
}
diff --git a/drivers/frame_provider/decoder/h265/vh265.c b/drivers/frame_provider/decoder/h265/vh265.c
index 64345e7..154fbf0 100644
--- a/drivers/frame_provider/decoder/h265/vh265.c
+++ b/drivers/frame_provider/decoder/h265/vh265.c
@@ -5376,8 +5376,8 @@ static void config_sao_hw(struct hevc_state_s *hevc, union param_u *params)
/* swap uv */
if (hevc->is_used_v4l) {
- if ((v4l2_ctx->q_data[AML_Q_DATA_DST].fmt->fourcc == V4L2_PIX_FMT_NV21) ||
- (v4l2_ctx->q_data[AML_Q_DATA_DST].fmt->fourcc == V4L2_PIX_FMT_NV21M))
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV21) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV21M))
data32 &= ~(1 << 8); /* NV21 */
else
data32 |= (1 << 8); /* NV12 */
@@ -5419,8 +5419,8 @@ static void config_sao_hw(struct hevc_state_s *hevc, union param_u *params)
/* swap uv */
if (hevc->is_used_v4l) {
- if ((v4l2_ctx->q_data[AML_Q_DATA_DST].fmt->fourcc == V4L2_PIX_FMT_NV21) ||
- (v4l2_ctx->q_data[AML_Q_DATA_DST].fmt->fourcc == V4L2_PIX_FMT_NV21M))
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV21) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV21M))
data32 |= (1 << 12); /* NV21 */
else
data32 &= ~(1 << 12); /* NV12 */
@@ -8663,7 +8663,16 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
struct vframe_s *vf = NULL;
int stream_offset = pic->stream_offset;
unsigned short slice_type = pic->slice_type;
+ ulong nv_order = VIDTYPE_VIU_NV21;
u32 frame_size = 0;
+ struct aml_vcodec_ctx * v4l2_ctx = hevc->v4l2_ctx;
+
+ /* swap uv */
+ if (hevc->is_used_v4l) {
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12M))
+ nv_order = VIDTYPE_VIU_NV12;
+ }
if (force_disp_pic_index & 0x100) {
/*recycle directly*/
@@ -8823,7 +8832,7 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
}
if (pic->double_write_mode) {
vf->type = VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD;
- vf->type |= VIDTYPE_VIU_NV21;
+ vf->type |= nv_order;
if ((pic->double_write_mode == 3) &&
(!(IS_8K_SIZE(pic->width, pic->height)))) {
@@ -8889,7 +8898,7 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
vf->bitdepth |= BITDEPTH_SAVING_MODE;
#else
vf->type = VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD;
- vf->type |= VIDTYPE_VIU_NV21;
+ vf->type |= nv_order;
vf->canvas0Addr = vf->canvas1Addr = spec2canvas(pic);
#endif
set_frame_info(hevc, vf, pic);
@@ -8990,14 +8999,14 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
if (pic->pic_struct == 3) {
vf->type = VIDTYPE_INTERLACE_TOP
- | VIDTYPE_VIU_NV21;
+ | nv_order;
vf2->type = VIDTYPE_INTERLACE_BOTTOM
- | VIDTYPE_VIU_NV21;
+ | nv_order;
} else {
vf->type = VIDTYPE_INTERLACE_BOTTOM
- | VIDTYPE_VIU_NV21;
+ | nv_order;
vf2->type = VIDTYPE_INTERLACE_TOP
- | VIDTYPE_VIU_NV21;
+ | nv_order;
}
hevc->vf_pre_count++;
decoder_do_frame_check(vdec, vf);
@@ -9035,18 +9044,18 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
if (pic->pic_struct == 5) {
vf->type = VIDTYPE_INTERLACE_TOP
- | VIDTYPE_VIU_NV21;
+ | nv_order;
vf2->type = VIDTYPE_INTERLACE_BOTTOM
- | VIDTYPE_VIU_NV21;
+ | nv_order;
vf3->type = VIDTYPE_INTERLACE_TOP
- | VIDTYPE_VIU_NV21;
+ | nv_order;
} else {
vf->type = VIDTYPE_INTERLACE_BOTTOM
- | VIDTYPE_VIU_NV21;
+ | nv_order;
vf2->type = VIDTYPE_INTERLACE_TOP
- | VIDTYPE_VIU_NV21;
+ | nv_order;
vf3->type = VIDTYPE_INTERLACE_BOTTOM
- | VIDTYPE_VIU_NV21;
+ | nv_order;
}
hevc->vf_pre_count++;
decoder_do_frame_check(vdec, vf);
@@ -9082,12 +9091,12 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
vf->height <<= 1;
if (pic->pic_struct == 9) {
vf->type = VIDTYPE_INTERLACE_TOP
- | VIDTYPE_VIU_NV21 | VIDTYPE_VIU_FIELD;
+ | nv_order | VIDTYPE_VIU_FIELD;
process_pending_vframe(hevc,
hevc->pre_bot_pic, 0);
} else {
vf->type = VIDTYPE_INTERLACE_BOTTOM |
- VIDTYPE_VIU_NV21 | VIDTYPE_VIU_FIELD;
+ nv_order | VIDTYPE_VIU_FIELD;
vf->index = (pic->index << 8) | 0xff;
process_pending_vframe(hevc,
hevc->pre_top_pic, 1);
@@ -9118,10 +9127,10 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
vf->height <<= 1;
if (pic->pic_struct == 11)
vf->type = VIDTYPE_INTERLACE_TOP |
- VIDTYPE_VIU_NV21 | VIDTYPE_VIU_FIELD;
+ nv_order | VIDTYPE_VIU_FIELD;
else {
vf->type = VIDTYPE_INTERLACE_BOTTOM |
- VIDTYPE_VIU_NV21 | VIDTYPE_VIU_FIELD;
+ nv_order | VIDTYPE_VIU_FIELD;
vf->index = (pic->index << 8) | 0xff;
}
decoder_do_frame_check(vdec, vf);
@@ -9155,14 +9164,14 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
case 1:
vf->height <<= 1;
vf->type = VIDTYPE_INTERLACE_TOP |
- VIDTYPE_VIU_NV21 | VIDTYPE_VIU_FIELD;
+ nv_order | VIDTYPE_VIU_FIELD;
process_pending_vframe(hevc, pic, 1);
hevc->pre_top_pic = pic;
break;
case 2:
vf->height <<= 1;
vf->type = VIDTYPE_INTERLACE_BOTTOM
- | VIDTYPE_VIU_NV21
+ | nv_order
| VIDTYPE_VIU_FIELD;
process_pending_vframe(hevc, pic, 0);
hevc->pre_bot_pic = pic;
diff --git a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
index 356506d..1a3ebf5 100644
--- a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
+++ b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
@@ -1500,15 +1500,21 @@ static int prepare_display_buf(struct vdec_mpeg12_hw_s *hw,
u32 index = pic->index;
u32 info = pic->buffer_info;
struct vdec_s *vdec = hw_to_vdec(hw);
+ struct aml_vcodec_ctx * v4l2_ctx = hw->v4l2_ctx;
+ ulong nv_order = VIDTYPE_VIU_NV21;
+
+ /* swap uv */
+ if (hw->is_used_v4l) {
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12M))
+ nv_order = VIDTYPE_VIU_NV12;
+ }
user_data_ready_notify(hw, pic->pts, pic->pts_valid);
-#ifdef NV21
- type = VIDTYPE_VIU_NV21;
-#endif
if (hw->frame_prog & PICINFO_PROG) {
field_num = 1;
- type |= VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD;
+ type |= VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD | nv_order;
} else {
#ifdef INTERLACE_SEQ_ALWAYS
/* once an interlace seq, force interlace, to make di easy. */
@@ -1547,7 +1553,7 @@ static int prepare_display_buf(struct vdec_mpeg12_hw_s *hw,
vf->duration_pulldown = (field_num == 3) ?
(vf->duration >> 1):0;
if (i > 0)
- type = VIDTYPE_VIU_NV21;
+ type = nv_order;
if (i == 1) /* second field*/
type |= (first_field_type == VIDTYPE_INTERLACE_TOP) ?
VIDTYPE_INTERLACE_BOTTOM : VIDTYPE_INTERLACE_TOP;
diff --git a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
index aff7852..15d8b4c 100644
--- a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
+++ b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
@@ -613,8 +613,17 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
{
struct vframe_s *vf = NULL;
struct vdec_s *vdec = hw_to_vdec(hw);
+ struct aml_vcodec_ctx * v4l2_ctx = hw->v4l2_ctx;
+ ulong nv_order = VIDTYPE_VIU_NV21;
int index = pic->index;
+ /* swap uv */
+ if (hw->is_used_v4l) {
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12M))
+ nv_order = VIDTYPE_VIU_NV12;
+ }
+
if (pic->pic_info & INTERLACE_FLAG) {
if (kfifo_get(&hw->newframe_q, &vf) == 0) {
mmpeg4_debug_print(DECODE_ID(hw), 0,
@@ -644,7 +653,7 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
vf->type = (pic->pic_info & TOP_FIELD_FIRST_FLAG) ?
VIDTYPE_INTERLACE_TOP : VIDTYPE_INTERLACE_BOTTOM;
#ifdef NV21
- vf->type |= VIDTYPE_VIU_NV21;
+ vf->type |= nv_order;
#endif
set_frame_info(hw, vf, pic->index);
@@ -696,7 +705,7 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
vf->type = (pic->pic_info & TOP_FIELD_FIRST_FLAG) ?
VIDTYPE_INTERLACE_BOTTOM : VIDTYPE_INTERLACE_TOP;
#ifdef NV21
- vf->type |= VIDTYPE_VIU_NV21;
+ vf->type |= nv_order;
#endif
set_frame_info(hw, vf, pic->index);
@@ -757,7 +766,7 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
pic->duration;
#ifdef NV21
vf->type = VIDTYPE_PROGRESSIVE |
- VIDTYPE_VIU_FIELD | VIDTYPE_VIU_NV21;
+ VIDTYPE_VIU_FIELD | nv_order;
#else
vf->type = VIDTYPE_PROGRESSIVE |
VIDTYPE_VIU_FIELD;
diff --git a/drivers/frame_provider/decoder/vp9/vvp9.c b/drivers/frame_provider/decoder/vp9/vvp9.c
index 1c7f96b..7075cd8 100644
--- a/drivers/frame_provider/decoder/vp9/vvp9.c
+++ b/drivers/frame_provider/decoder/vp9/vvp9.c
@@ -7073,11 +7073,14 @@ static int prepare_display_buf(struct VP9Decoder_s *pbi,
struct vdec_s *pvdec = hw_to_vdec(pbi);
int stream_offset = pic_config->stream_offset;
unsigned short slice_type = pic_config->slice_type;
+ struct aml_vcodec_ctx * v4l2_ctx = pbi->v4l2_ctx;
+ ulong nv_order = VIDTYPE_VIU_NV21;
u32 pts_valid = 0, pts_us64_valid = 0;
u32 pts_save;
u64 pts_us64_save;
u32 frame_size = 0;
+
if (debug & VP9_DEBUG_BUFMGR)
pr_info("%s index = %d\r\n", __func__, pic_config->index);
if (kfifo_get(&pbi->newframe_q, &vf) == 0) {
@@ -7085,6 +7088,13 @@ static int prepare_display_buf(struct VP9Decoder_s *pbi,
return -1;
}
+ /* swap uv */
+ if (pbi->is_used_v4l) {
+ if ((v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12) ||
+ (v4l2_ctx->cap_pix_fmt == V4L2_PIX_FMT_NV12M))
+ nv_order = VIDTYPE_VIU_NV12;
+ }
+
if (pic_config->double_write_mode)
set_canvas(pbi, pic_config);
@@ -7234,7 +7244,7 @@ static int prepare_display_buf(struct VP9Decoder_s *pbi,
if (pic_config->double_write_mode) {
vf->type = VIDTYPE_PROGRESSIVE |
VIDTYPE_VIU_FIELD;
- vf->type |= VIDTYPE_VIU_NV21;
+ vf->type |= nv_order;
if ((pic_config->double_write_mode == 3) &&
(!IS_8K_SIZE(pic_config->y_crop_width,
pic_config->y_crop_height))) {