Index: encoder/slicetype.c =================================================================== --- encoder/slicetype.c (r‚vision 656) +++ encoder/slicetype.c (copie de travail) @@ -459,6 +459,14 @@ { frm = h->frames.next[bframes]; + /* Force intra frame when requested */ + if( h->i_intras && frm->i_frame == h->intras[h->i_current_intra]) + { + frm->i_type = X264_TYPE_IDR; + if (h->i_current_intra < h->i_intras-1) + h->i_current_intra++; + } + /* Limit GOP size */ if( frm->i_frame - h->frames.i_last_idr >= h->param.i_keyint_max ) { Index: encoder/encoder.c =================================================================== --- encoder/encoder.c (r‚vision 656) +++ encoder/encoder.c (copie de travail) @@ -101,7 +101,45 @@ } #endif +/* */ +static int x264_parse_intras( x264_t *h ) +{ + x264_param_t *param = &h->param; + if( param->psz_intras && !param->i_intras ) + { + char *p; + int i; + + param->i_intras = 1; + for( p = param->psz_intras; *p; p++ ) + param->i_intras += (*p == ','); + param->intras = x264_malloc( param->i_intras * sizeof(unsigned int) ); + p = param->psz_intras; + for( i = 0; i < param->i_intras; i++) + { + if ( 1 != sscanf(p, "%u", param->intras+i) ) + { + char *slash = strchr(p, ','); + if(slash) *slash = '\0'; + x264_log( h, X264_LOG_ERROR, "invalid index: \"%s\"\n", p ); + return -1; + } + else + { + printf("Will force %u as intra\n", param->intras[i]); + } + p = strchr(p, ',') + 1; + } + } + + h->i_intras = param->i_intras; + h->intras = x264_malloc( param->i_intras * sizeof(unsigned int) ); + memcpy( h->intras, param->intras, param->i_intras * sizeof(unsigned int) ); + + return 0; +} + /* Fill "default" values */ static void x264_slice_header_init( x264_t *h, x264_slice_header_t *sh, x264_sps_t *sps, x264_pps_t *pps, @@ -722,6 +760,12 @@ } #endif + if( x264_parse_intras( h ) < 0 ) + { + x264_free( h ); + return NULL; + } + return h; } Index: x264.c =================================================================== --- x264.c (r‚vision 656) +++ x264.c (copie de travail) @@ -213,6 +213,7 @@ " where