[x264-devel] I/IDR frame type decision

Матвей Захарченко matvey.ff at gmail.com
Mon Jun 10 12:23:28 CEST 2019


Hi everyone!
I'm struggling to understand one piece of code:

    /* This is important psy-wise: if we have a non-scenecut keyframe,
     * there will be significant visual artifacts if the frames just before
     * go down in quality due to being referenced less, despite it being
     * more RD-optimal. */
    if( (h->param.analyse.b_psy && h->param.rc.b_mb_tree) ||
b_vbv_lookahead )
        num_frames = framecnt;
    else if( h->param.b_open_gop && num_frames < framecnt )
        num_frames++;
    else if( num_frames == 0 )
    {
        frames[1]->i_type = X264_TYPE_I;
        return;
    }

The line I don't get is this: frames[1]->i_type = X264_TYPE_I;
Why is is X264_TYPE_I but not X264_TYPE_KEYFRAME (which would then become I
or IDR depending on GOP settings like open/closed and min keyint)?
And it seems that it used to be like that before commit d020c4274:

@@ -1080,7 +1080,6 @@ void x264_slicetype_analyse( x264_t *h, int keyframe )
     orig_num_frames = num_frames = h->param.b_intra_refresh ? framecnt :
X264_MIN( framecnt, keyint_limit );

     x264_lowres_context_init( h, &a );
-    idr_frame_type = frames[1]->i_frame - h->lookahead->i_last_keyframe >=
h->param.i_keyint_min ? X264_TYPE_IDR : X264_TYPE_I;

     /* This is important psy-wise: if we have a non-scenecut keyframe,
      * there will be significant visual artifacts if the frames just before
@@ -1092,12 +1091,12 @@ void x264_slicetype_analyse( x264_t *h, int
keyframe )
     {
         frames[1]->i_type = X264_TYPE_P;
         if( h->param.i_scenecut_threshold && scenecut( h, &a, frames, 0,
1, 1, orig_num_frames ) )
-            frames[1]->i_type = idr_frame_type;
+            frames[1]->i_type = X264_TYPE_I;
         return;
     }
     else if( num_frames == 0 )
     {
-        frames[1]->i_type = idr_frame_type;
+        frames[1]->i_type = X264_TYPE_I;
         return;
     }

This code is located in encoder/slicetype.c.
Could anyone describe the reason why it is I but not KEYFRAME? Thank you.

Regards,
Matvey.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20190610/2cac1dca/attachment.html>


More information about the x264-devel mailing list