[FFmpeg-cvslog] avcodec/h264: Fix poc_lsb in open gop context

Nicolas Gaullier git at videolan.org
Tue Sep 10 13:29:14 EEST 2019


ffmpeg | branch: master | Nicolas Gaullier <nicolas.gaullier at arkena.com> | Tue Jul 23 14:08:59 2019 +0200| [cae5b36e207117f883fb0929a7cb1882807471b8] | committer: Paul B Mahol

avcodec/h264: Fix poc_lsb in open gop context

When no IDR nor mmco_reset is found, prev_poc_lsb is
undefined and shall not be assumed to be zero

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cae5b36e207117f883fb0929a7cb1882807471b8
---

 libavcodec/h264_parse.c | 2 ++
 libavcodec/h264dec.c    | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index 32a8af88e5..352ffea948 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -287,6 +287,8 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
 
     if (sps->poc_type == 0) {
         const int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
+        if (pc->prev_poc_lsb < 0)
+            pc->prev_poc_lsb =  pc->poc_lsb;
 
         if (pc->poc_lsb < pc->prev_poc_lsb &&
             pc->prev_poc_lsb - pc->poc_lsb >= max_poc_lsb / 2)
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 8d1bd16a8e..f12651fa3d 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -474,7 +474,7 @@ static void idr(H264Context *h)
     h->poc.prev_frame_num        =
     h->poc.prev_frame_num_offset = 0;
     h->poc.prev_poc_msb          = 1<<16;
-    h->poc.prev_poc_lsb          = 0;
+    h->poc.prev_poc_lsb          = -1;
     for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
         h->last_pocs[i] = INT_MIN;
 }



More information about the ffmpeg-cvslog mailing list