@@ -35,21 +35,37 @@ void ffPrintDisplay(FFDisplayOptions* options)
3535 {
3636 ffPrintLogoAndKey (FF_DISPLAY_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT );
3737
38- int index = 0 ;
38+ FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate () ;
3939 FF_LIST_FOR_EACH (FFDisplayResult , result , dsResult -> displays )
4040 {
4141 if (options -> compactType & FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT )
4242 {
43- if (index ++ ) putchar (' ' );
44- printf ("%ix%i" , result -> width , result -> height );
43+ ffStrbufAppendF (& buffer , "%ix%i" , result -> width , result -> height );
4544 }
46- if ( options -> compactType & FF_DISPLAY_COMPACT_TYPE_SCALED_BIT )
45+ else
4746 {
48- if (index ++ ) putchar (' ' );
49- printf ("%ix%i" , result -> scaledWidth , result -> scaledHeight );
47+ ffStrbufAppendF (& buffer , "%ix%i" , result -> scaledWidth , result -> scaledHeight );
48+ }
49+
50+ if (options -> compactType & FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT )
51+ {
52+ if (result -> refreshRate > 0 )
53+ {
54+ if (options -> preciseRefreshRate )
55+ ffStrbufAppendF (& buffer , " @ %gHz" , result -> refreshRate );
56+ else
57+ ffStrbufAppendF (& buffer , " @ %iHz" , (uint32_t ) (result -> refreshRate + 0.5 ));
58+ }
59+ ffStrbufAppendS (& buffer , ", " );
60+ }
61+ else
62+ {
63+ ffStrbufAppendC (& buffer , ' ' );
5064 }
5165 }
52- putchar ('\n' );
66+ ffStrbufTrimRight (& buffer , ' ' );
67+ ffStrbufTrimRight (& buffer , ',' );
68+ ffStrbufPutTo (& buffer , stdout );
5369 return ;
5470 }
5571
@@ -137,6 +153,8 @@ bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, co
137153 { "none" , FF_DISPLAY_COMPACT_TYPE_NONE },
138154 { "original" , FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT },
139155 { "scaled" , FF_DISPLAY_COMPACT_TYPE_SCALED_BIT },
156+ { "original-with-refresh-rate" , FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT | FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT },
157+ { "scaled-with-refresh-rate" , FF_DISPLAY_COMPACT_TYPE_SCALED_BIT | FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT },
140158 {},
141159 });
142160 return true;
@@ -182,6 +200,8 @@ void ffParseDisplayJsonObject(FFDisplayOptions* options, yyjson_val* module)
182200 { "none" , FF_DISPLAY_COMPACT_TYPE_NONE },
183201 { "original" , FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT },
184202 { "scaled" , FF_DISPLAY_COMPACT_TYPE_SCALED_BIT },
203+ { "original-with-refresh-rate" , FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT | FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT },
204+ { "scaled-with-refresh-rate" , FF_DISPLAY_COMPACT_TYPE_SCALED_BIT | FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT },
185205 {},
186206 });
187207 if (error )
@@ -226,7 +246,7 @@ void ffGenerateDisplayJsonConfig(FFDisplayOptions* options, yyjson_mut_doc* doc,
226246
227247 if (options -> compactType != defaultOptions .compactType )
228248 {
229- switch (options -> compactType )
249+ switch (( int ) options -> compactType )
230250 {
231251 case FF_DISPLAY_COMPACT_TYPE_NONE :
232252 yyjson_mut_obj_add_str (doc , module , "compactType" , "none" );
@@ -237,6 +257,12 @@ void ffGenerateDisplayJsonConfig(FFDisplayOptions* options, yyjson_mut_doc* doc,
237257 case FF_DISPLAY_COMPACT_TYPE_SCALED_BIT :
238258 yyjson_mut_obj_add_str (doc , module , "compactType" , "scaled" );
239259 break ;
260+ case FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT | FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT :
261+ yyjson_mut_obj_add_str (doc , module , "compactType" , "original-with-refresh-rate" );
262+ break ;
263+ case FF_DISPLAY_COMPACT_TYPE_SCALED_BIT | FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT :
264+ yyjson_mut_obj_add_str (doc , module , "compactType" , "scaled-with-refresh-rate" );
265+ break ;
240266 }
241267 }
242268
0 commit comments