]> git.sesse.net Git - x264/commitdiff
Fix crash if the first frame is forced to a non-keyframe
authorAnton Mitrofanov <BugMaster@narod.ru>
Tue, 8 Jan 2013 21:29:49 +0000 (13:29 -0800)
committerFiona Glaser <fiona@x264.com>
Tue, 8 Jan 2013 21:30:50 +0000 (13:30 -0800)
This is obviously bad user input, but x264 shouldn't crash if it happens.

encoder/slicetype.c

index fc6b44f2b3d18147252dfa197973d67b1b878b4d..e471b8cde3584eb0f369533649c79e36d8451603 100644 (file)
@@ -1651,7 +1651,10 @@ void x264_slicetype_decide( x264_t *h )
             if( warn && h->param.b_open_gop )
                 warn &= frm->i_type != X264_TYPE_I;
             if( warn )
+            {
                 x264_log( h, X264_LOG_WARNING, "specified frame type (%d) at %d is not compatible with keyframe interval\n", frm->i_type, frm->i_frame );
+                frm->i_type = h->param.b_open_gop && h->lookahead->i_last_keyframe >= 0 ? X264_TYPE_I : X264_TYPE_IDR;
+            }
         }
         if( frm->i_type == X264_TYPE_I && frm->i_frame - h->lookahead->i_last_keyframe >= h->param.i_keyint_min )
         {