media_module: h265 fixed same frame being written to DPB multiple times [1/1]
authorPeng Yixin <yixin.peng@amlogic.com>
Mon, 7 Sep 2020 09:23:26 +0000 (17:23 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Mon, 12 Oct 2020 05:20:10 +0000 (22:20 -0700)
PD#SWPL-30901

Problem:
In stream mode, multiple frames are decoded in a decoding process,
but at last there is insufficient data. As a result, other frames
are stored in DPB except last frame. However, the next run will be
decode again and stored in DPB, which results in the same frame being
stored in DPB for many times and cause playback stuck.

Solution:
In this case, release all the frames stored in the DPB in this
decoding process to resolve this problem.

Verify:
U215

Change-Id: I1f1360467a5bfb364cde03268857922ca05b8d75
Signed-off-by: Peng Yixin <yixin.peng@amlogic.com>
drivers/frame_provider/decoder/h265/vh265.c

index 22b30c9a1e7980450f12c25bdf7766461295a41d..974c1448561d0e3436669fea6216fdaab62fd7ac 100644 (file)
@@ -2188,6 +2188,30 @@ static void restore_decode_state(struct hevc_state_s *hevc)
                release_aux_data(hevc, hevc->decoding_pic);
                hevc->decoding_pic = NULL;
        }
+       if (vdec_stream_based(vdec) &&
+               (hevc->decode_idx - hevc->decode_idx_bak > 1)) {
+               int i;
+               for (i = 0; i < MAX_REF_PIC_NUM; i++) {
+                       struct PIC_s *pic;
+                       pic = hevc->m_PIC[i];
+                       if (pic == NULL ||
+                               (pic->index == -1) ||
+                               (pic->BUF_index == -1) ||
+                               (pic->POC == INVALID_POC))
+                               continue;
+                       if ((hevc->decode_idx > hevc->decode_idx_bak) &&
+                                       pic->decode_idx != hevc->decode_idx) {
+                                       hevc_print(hevc, 0, "release error buffer\n");
+                                       pic->error_mark = 0;
+                                       pic->output_ready = 0;
+                                       pic->output_mark = 0;
+                                       pic->referenced = 0;
+                                       pic->POC = INVALID_POC;
+                                       put_mv_buf(hevc, pic);
+                                       release_aux_data(hevc, pic);
+                       }
+               }
+       }
        hevc->decode_idx = hevc->decode_idx_bak;
        hevc->m_pocRandomAccess = hevc->m_pocRandomAccess_bak;
        hevc->curr_POC = hevc->curr_POC_bak;