This allows an input qpfile to be used to force I-frames, for example.
The same can be done through the library interface.
Document the format of the qpfile in --longhelp and the forcing of frametypes in x264.h
Note that forcing B-frames and B-refs may not always have the intended result.
Patch partially by Steven Walters <kemuri9@gmail.com>.
if( !h->frames.last_nonb )
return;
frames[0] = h->frames.last_nonb;
- for( j = 0; h->frames.next[j]; j++ )
+ for( j = 0; h->frames.next[j] && h->frames.next[j]->i_type == X264_TYPE_AUTO; j++ )
frames[j+1] = h->frames.next[j];
keyint_limit = h->param.i_keyint_max - frames[0]->i_frame + h->frames.i_last_idr - 1;
num_frames = X264_MIN( j, keyint_limit );
frm->i_type = X264_TYPE_P;
}
- if( frm->i_type != X264_TYPE_AUTO && frm->i_type != X264_TYPE_B && frm->i_type != X264_TYPE_BREF )
- break;
-
- frm->i_type = X264_TYPE_B;
+ if( frm->i_type == X264_TYPE_AUTO ) frm->i_type = X264_TYPE_B;
+ else if( !IS_X264_TYPE_B( frm->i_type ) ) break;
}
}
" where <option> is either\n"
" q=<integer> (force QP)\n"
" or b=<float> (bitrate multiplier)\n" );
- H1( " --qpfile <string> Force frametypes and QPs\n" );
+ H1( " --qpfile <string> Force frametypes and QPs for some or all frames\n"
+ " Format of each line: framenumber frametype QP\n"
+ " QP of -1 lets x264 choose. Frametypes: I,i,P,B,b.\n" );
H0( "\n" );
H0( "Analysis:\n" );
H0( "\n" );
fprintf( stderr, "x264 [error]: can't open `%s'\n", optarg );
return -1;
}
- param->i_scenecut_threshold = -1;
- param->i_bframe_adaptive = X264_B_ADAPT_NONE;
break;
case OPT_THREAD_INPUT:
b_thread_input = 1;
typedef struct
{
- /* In: force picture type (if not auto) XXX: ignored for now
+ /* In: force picture type (if not auto)
+ * If x264 encoding parameters are violated in the forcing of picture types,
+ * x264 will correct the input picture type and log a warning.
+ * The quality of frametype decisions may suffer if a great deal of fine-grained
+ * mixing of auto and forced frametypes is done.
* Out: type of the picture encoded */
int i_type;
/* In: force quantizer for > 0 */