author | Nanxin Qin <nanxin.qin@amlogic.com> | 2019-11-30 13:58:36 (GMT) |
---|---|---|
committer | Nanxin Qin <nanxin.qin@amlogic.com> | 2019-12-01 06:43:19 (GMT) |
commit | 7a99e7dc835ac4af78d749ac8d301997001c2efc (patch) | |
tree | 4badbc59a927a6815b31de530dc111e20a0de6c8 | |
parent | 9e4bad427bd58b19c9e1f8d5775b28a5ec7e4995 (diff) | |
download | media_modules-7a99e7dc835ac4af78d749ac8d301997001c2efc.zip media_modules-7a99e7dc835ac4af78d749ac8d301997001c2efc.tar.gz media_modules-7a99e7dc835ac4af78d749ac8d301997001c2efc.tar.bz2 |
v4l: fixed the issue of h264/h265 parser. [1/1]
PD#SWPL-17322
Problem:
1. when a frame inclued 2 or more sps and they are differnt
which cause to triggle event of resultion change infinite.
2. play the tiny stream maybe caused crash.
Solution:
1. fixed the issue of h264/h265 parser.
2. fixed the tiny es playback iusse.
Verify:
U212
Change-Id: I313991b13867b3c057225473e0407c05b20d799f
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
-rw-r--r-- | drivers/amvdec_ports/aml_vcodec_dec.c | 46 | ||||
-rw-r--r-- | drivers/amvdec_ports/decoder/vdec_h264_if.c | 23 | ||||
-rw-r--r-- | drivers/amvdec_ports/decoder/vdec_hevc_if.c | 17 |
3 files changed, 50 insertions, 36 deletions
diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c index d8671ab..5702039 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec.c +++ b/drivers/amvdec_ports/aml_vcodec_dec.c @@ -314,6 +314,11 @@ int get_fb_from_queue(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer **out_ flags = aml_vcodec_ctx_lock(ctx); + if (ctx->state == AML_STATE_ABORT) { + aml_vcodec_ctx_unlock(ctx, flags); + return -1; + } + dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); if (!dst_buf) { aml_vcodec_ctx_unlock(ctx, flags); @@ -763,23 +768,6 @@ out: return; } -void wait_vcodec_ending(struct aml_vcodec_ctx *ctx) -{ - struct aml_vcodec_dev *dev = ctx->dev; - - /* pause inject output data to vdec. */ - v4l2_m2m_job_pause(dev->m2m_dev_dec, ctx->m2m_ctx); - - /* flush worker. */ - flush_workqueue(dev->decode_workqueue); - - /* wait reset worker ending. */ - if (ctx->state == AML_STATE_RESET) { - wait_for_completion_timeout(&ctx->comp, - msecs_to_jiffies(200)); - } -} - static void aml_vdec_reset(struct aml_vcodec_ctx *ctx) { if (ctx->state == AML_STATE_ABORT) { @@ -814,6 +802,24 @@ out: return; } +void wait_vcodec_ending(struct aml_vcodec_ctx *ctx) +{ + struct aml_vcodec_dev *dev = ctx->dev; + + /* pause inject output data to vdec. */ + v4l2_m2m_job_pause(dev->m2m_dev_dec, ctx->m2m_ctx); + + /* flush worker. */ + flush_workqueue(dev->decode_workqueue); + + ctx->v4l_codec_ready = false; + ctx->v4l_codec_dpb_ready = false; + + /* stop decoder. */ + if (ctx->state > AML_STATE_INIT) + aml_vdec_reset(ctx); +} + void try_to_capture(struct aml_vcodec_ctx *ctx) { int ret = 0; @@ -1067,11 +1073,13 @@ static int vidioc_decoder_reqbufs(struct file *file, void *priv, void aml_vcodec_dec_release(struct aml_vcodec_ctx *ctx) { + ulong flags; + + flags = aml_vcodec_ctx_lock(ctx); ctx->state = AML_STATE_ABORT; - ctx->v4l_codec_ready = false; - ctx->v4l_codec_dpb_ready = false; aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_ABORT)", ctx->id, __func__); + aml_vcodec_ctx_unlock(ctx, flags); vdec_if_deinit(ctx); } diff --git a/drivers/amvdec_ports/decoder/vdec_h264_if.c b/drivers/amvdec_ports/decoder/vdec_h264_if.c index 3f2f2a2..3fdac28 100644 --- a/drivers/amvdec_ports/decoder/vdec_h264_if.c +++ b/drivers/amvdec_ports/decoder/vdec_h264_if.c @@ -796,22 +796,25 @@ static bool monitor_res_change(struct vdec_h264_inst *inst, u8 *buf, u32 size) if (type == NAL_H264_SPS) { ret = stream_parse(inst, p, len); - if (!ret && ((inst->vsi->cur_pic.coded_width != - inst->vsi->pic.coded_width || - inst->vsi->cur_pic.coded_height != - inst->vsi->pic.coded_height) || - (inst->vsi->pic.profile_idc != - inst->vsi->cur_pic.profile_idc))) { - pr_info("res change\n"); - inst->vsi->cur_pic = inst->vsi->pic; - return true; - } + if (ret) + break; } p += j; } p++; } + if (!ret && ((inst->vsi->cur_pic.coded_width != + inst->vsi->pic.coded_width || + inst->vsi->cur_pic.coded_height != + inst->vsi->pic.coded_height) || + (inst->vsi->pic.profile_idc != + inst->vsi->cur_pic.profile_idc))) { + pr_info("res change\n"); + inst->vsi->cur_pic = inst->vsi->pic; + return true; + } + return false; } diff --git a/drivers/amvdec_ports/decoder/vdec_hevc_if.c b/drivers/amvdec_ports/decoder/vdec_hevc_if.c index bc04176..7c1e5eb 100644 --- a/drivers/amvdec_ports/decoder/vdec_hevc_if.c +++ b/drivers/amvdec_ports/decoder/vdec_hevc_if.c @@ -568,19 +568,22 @@ static bool monitor_res_change(struct vdec_hevc_inst *inst, u8 *buf, u32 size) if (type == HEVC_NAL_SPS) { ret = stream_parse(inst, p, len); - if (!ret && (inst->vsi->cur_pic.coded_width != - inst->vsi->pic.coded_width || - inst->vsi->cur_pic.coded_height != - inst->vsi->pic.coded_height)) { - inst->vsi->cur_pic = inst->vsi->pic; - return true; - } + if (ret) + break; } p += j; } p++; } + if (!ret && (inst->vsi->cur_pic.coded_width != + inst->vsi->pic.coded_width || + inst->vsi->cur_pic.coded_height != + inst->vsi->pic.coded_height)) { + inst->vsi->cur_pic = inst->vsi->pic; + return true; + } + return false; } |