diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index a2e161d12e6f91b0211f7e5e16fcfc59035db49a..0236eb422f91a0a415fafc77ec14e2acc52e8118 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3539,6 +3539,7 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
                 pic= remove_long(h, j);
                 if(pic) unreference_pic(h, pic, 0);
             }
+            s->current_picture_ptr->frame_num= 0;
             break;
         default: assert(0);
         }