From 6fa09e72ae21fa1b0ec06dff42c13d4cdbc94077 Mon Sep 17 00:00:00 2001 From: Sushant Date: Fri, 25 Sep 2026 19:20:27 +0530 Subject: [PATCH] libavc: reset i4_error_code to prevent early worker thread abort The recon and deblocking worker threads abort when ps_dec->i4_error_code is non-zero, a check added to fix a worker thread hang. The following cases could cause them to abort early: - ps_dec->i4_error_code was not cleared at the start of ih264d_video_decode(), so an error set during a previous decode call persisted across subsequent frames. - ih264d_process_intra_mb() sets ERROR_INTRAPRED when an intra prediction mode needs unavailable neighbors, although the mode is already replaced with mode 0 (vertical). Before that check, this error code was not read during decoding. Reset ps_dec->i4_error_code to 0 at the start of ih264d_video_decode() alongside ps_dec_op->u4_error_code, and stop setting ERROR_INTRAPRED. Bug: 548241521 Bug: 565823098 Flag: EXEMPT BUGFIX Test: atest CtsMediaV2TestCases:android.mediav2.cts.EncodeDecodeAccuracyTest#testEncodeDecodeAccuracyRGB atest MctsMediaV2TestCases atest MctsMediaDecoderTestCases atest MctsMediaCodecTestCases atest VtsHalMediaC2V1_0TargetVideoDecTest Change-Id: I191ea7a6f6bd027fd3719db6581703c790eb40f2 (cherry picked from commit cfc33cb8eb9394274d1ca7a1c3193800d9356faa) --- decoder/ih264d_api.c | 1 + decoder/ih264d_process_intra_mb.c | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c index 20cba70b..4f8f3793 100644 --- a/decoder/ih264d_api.c +++ b/decoder/ih264d_api.c @@ -2283,6 +2283,7 @@ WORD32 ih264d_video_decode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op) /* ! */ ps_dec->u4_ts = ps_dec_ip->u4_ts; + ps_dec->i4_error_code = 0; ps_dec_op->u4_error_code = 0; ps_dec_op->e_pic_type = IV_NA_FRAME; diff --git a/decoder/ih264d_process_intra_mb.c b/decoder/ih264d_process_intra_mb.c index aa30f55c..f3c84dc6 100644 --- a/decoder/ih264d_process_intra_mb.c +++ b/decoder/ih264d_process_intra_mb.c @@ -926,7 +926,6 @@ WORD32 ih264d_process_intra_mb(dec_struct_t * ps_dec, if((u1_err_code & u1_packed_modes) ^ u1_err_code) { u1_intrapred_mode = 0; - ps_dec->i4_error_code = ERROR_INTRAPRED; } } { @@ -1253,7 +1252,6 @@ WORD32 ih264d_process_intra_mb(dec_struct_t * ps_dec, if((u1_err_code & u1_packed_modes) ^ u1_err_code) { i1_intra_pred = 0; - ps_dec->i4_error_code = ERROR_INTRAPRED; } } @@ -1663,7 +1661,6 @@ WORD32 ih264d_process_intra_mb(dec_struct_t * ps_dec, if((u1_err_code & u1_packed_modes) ^ u1_err_code) { i1_intra_pred = 0; - ps_dec->i4_error_code = ERROR_INTRAPRED; } } } @@ -1780,7 +1777,6 @@ WORD32 ih264d_process_intra_mb(dec_struct_t * ps_dec, if((u1_err_code & u1_packed_modes) ^ u1_err_code) { u1_intra_chrom_pred_mode = 0; - ps_dec->i4_error_code = ERROR_INTRAPRED; } }