@@ -79,7 +79,7 @@ typedef struct _Y4M_PARAMS
7979{
8080 int w ;
8181 int h ;
82- int fps ;
82+ XEVE_RATIONAL fps ;
8383 int color_format ;
8484 int bit_depth ;
8585}Y4M_INFO ;
@@ -216,7 +216,7 @@ static void print_config(ARGS_PARSER * args, XEVE_PARAM * param)
216216 }
217217 logv2 ("\twidth = %d\n" , param -> w );
218218 logv2 ("\theight = %d\n" , param -> h );
219- logv2 ("\tFPS = %d \n" , param -> fps );
219+ logv2 ("\tFPS = %.2f \n" , ( float ) param -> fps . num / param -> fps . den );
220220 logv2 ("\tintra picture period = %d\n" , param -> keyint );
221221 if (param -> rc_type == XEVE_RC_CRF )
222222 {
@@ -371,7 +371,7 @@ static int y4m_parse_tags(Y4M_INFO * y4m, char * tags)
371371 char * q ;
372372 char t_buff [20 ];
373373 int found_w = 0 , found_h = 0 , found_cf = 0 ;
374- int fps_n , fps_d , pix_ratio_n , pix_ratio_d , interlace ;
374+ int pix_ratio_n , pix_ratio_d , interlace ;
375375
376376 for (p = tags ;; p = q )
377377 {
@@ -404,8 +404,7 @@ static int y4m_parse_tags(Y4M_INFO * y4m, char * tags)
404404 }
405405 case 'F' :
406406 {
407- if (sscanf (p + 1 , "%d:%d" , & fps_n , & fps_d ) != 2 ) return XEVE_ERR ;
408- y4m -> fps = (int )((fps_n /(fps_d * 1.0 )) + 0.5 );
407+ if (sscanf (p + 1 , "%d:%d" , & y4m -> fps .num , & y4m -> fps .den ) != 2 ) return XEVE_ERR ;
409408 break ;
410409 }
411410 case 'I' :
@@ -540,7 +539,9 @@ static void y4m_update_param(ARGS_PARSER * args, Y4M_INFO * y4m, XEVE_PARAM * pa
540539{
541540 args -> set_int (args , "width" , y4m -> w );
542541 args -> set_int (args , "height" , y4m -> h );
543- args -> set_int (args , "fps" , y4m -> fps );
542+ char tmp_fps [256 ];
543+ sprintf (tmp_fps , "%d/%d" , y4m -> fps .num , y4m -> fps .den );
544+ args -> set_str (args , "fps" , tmp_fps );
544545 args -> set_int (args , "input-depth" , y4m -> bit_depth );
545546}
546547
@@ -571,6 +572,27 @@ static int kbps_str_to_int(char * str)
571572 return kbps ;
572573}
573574
575+ static int update_fps_param (ARGS_PARSER * args , XEVE_PARAM * param )
576+ {
577+ if (strpbrk (args -> fps , "/" ) != NULL )
578+ {
579+ sscanf (args -> fps , "%d/%d" , & param -> fps .num , & param -> fps .den );
580+ }
581+ else if (strpbrk (args -> fps , "." ) != NULL )
582+ {
583+ float tmp_fps = 0 ;
584+ sscanf (args -> fps , "%f" , & tmp_fps );
585+ param -> fps .num = tmp_fps * 10000 ;
586+ param -> fps .den = 10000 ;
587+ }
588+ else
589+ {
590+ sscanf (args -> fps , "%d" , & param -> fps .num );
591+ param -> fps .den = 1 ;
592+ }
593+ return XEVE_OK ;
594+ }
595+
574596static int update_rc_param (ARGS_PARSER * args , XEVE_PARAM * param )
575597{
576598 if (strlen (args -> bitrate ) > 0 )
@@ -775,7 +797,7 @@ static int vui_param_check(XEVE_PARAM * param)
775797 else if (param -> num_units_in_tick == 0 )
776798 {
777799 /*If num_units_in_tick is not present, set to fps, to propagate the coded fps */
778- param -> num_units_in_tick = param -> fps ;
800+ param -> num_units_in_tick = param -> fps . num / param -> fps . den ;
779801 param -> timing_info_present_flag = param -> timing_info_present_flag || 0 ;
780802 }
781803 else
@@ -1023,6 +1045,13 @@ int main(int argc, const char **argv)
10231045 /* coding color space should follow codec internal bit depth */
10241046 param -> cs = XEVE_CS_SET (color_format , param -> codec_bit_depth , 0 );
10251047
1048+ /* update rate controller parameters */
1049+ if (update_fps_param (args , param ))
1050+ {
1051+ logerr ("fps is not proper\n" );
1052+ ret = XEVE_ERR ; goto ERR ;
1053+ }
1054+
10261055 /* update rate controller parameters */
10271056 if (update_rc_param (args , param ))
10281057 {
@@ -1315,7 +1344,7 @@ int main(int argc, const char **argv)
13151344 total_time = total_time % 60 ;
13161345 int s = total_time ;
13171346 double curr_bitrate = bitrate ;
1318- curr_bitrate *= (param -> fps * 8 );
1347+ curr_bitrate *= (( double ) param -> fps . num / param -> fps . den * 8 );
13191348 curr_bitrate /= (encod_frames + 1 );
13201349 curr_bitrate /= 1000 ;
13211350 logv2 ("[ %d / %d frames ] [ %.2f frame/sec ] [ %.4f kbps ] [ %2dh %2dm %2ds ] \r"
@@ -1383,7 +1412,7 @@ int main(int argc, const char **argv)
13831412 logv3 (" PSNR U(dB) : %-5.4f\n" , psnr_avg [1 ]);
13841413 logv3 (" PSNR V(dB) : %-5.4f\n" , psnr_avg [2 ]);
13851414 logv3 (" Total bits(bits) : %.0f\n" , bitrate * 8 );
1386- bitrate *= (param -> fps * 8 );
1415+ bitrate *= (( double ) param -> fps . num / param -> fps . den * 8 );
13871416 bitrate /= pic_ocnt ;
13881417 bitrate /= 1000 ;
13891418
0 commit comments