@@ -21,6 +21,8 @@ use std::fmt;
2121pub enum Resolution {
2222 /// Keep original resolution with specified dimensions
2323 Original ( ( u32 , u32 ) ) ,
24+ /// 480p resolution (480x640 pixels)
25+ P480 ,
2426 /// 720p resolution (1280x720 pixels)
2527 P720 ,
2628 /// 1080p resolution (1920x1080 pixels)
@@ -64,6 +66,10 @@ impl Resolution {
6466 pub fn dimensions ( & self , original_width : u32 , original_height : u32 ) -> ( u32 , u32 ) {
6567 match self {
6668 Resolution :: Original ( _) => ( original_width, original_height) ,
69+ Resolution :: P480 => Self :: calculate_scaled_dimensions (
70+ ( original_width, original_height) ,
71+ Resolution :: P480 . to_dimension ( ) ,
72+ ) ,
6773 Resolution :: P720 => Self :: calculate_scaled_dimensions (
6874 ( original_width, original_height) ,
6975 Resolution :: P720 . to_dimension ( ) ,
@@ -174,14 +180,16 @@ impl Resolution {
174180 /// assert!(matches!(res, Resolution::Original((800, 600))));
175181 /// ```
176182 pub fn preference_resolution ( width : u32 , height : u32 ) -> Self {
177- if width >= 2160 {
183+ if height >= 2160 {
178184 Resolution :: P4K
179- } else if width >= 1440 {
185+ } else if height >= 1440 {
180186 Resolution :: P2K
181- } else if width >= 1080 {
187+ } else if height >= 1080 {
182188 Resolution :: P1080
183- } else if width >= 720 {
189+ } else if height >= 720 {
184190 Resolution :: P720
191+ } else if height >= 480 {
192+ Resolution :: P480
185193 } else {
186194 Resolution :: Original ( ( width, height) )
187195 }
@@ -210,6 +218,7 @@ impl Resolution {
210218 Resolution :: P2K => ( 2560 , 1440 ) ,
211219 Resolution :: P1080 => ( 1920 , 1080 ) ,
212220 Resolution :: P720 => ( 1280 , 720 ) ,
221+ Resolution :: P480 => ( 640 , 480 ) ,
213222 }
214223 }
215224}
@@ -231,6 +240,7 @@ impl fmt::Display for Resolution {
231240 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
232241 match self {
233242 Resolution :: Original ( ( w, h) ) => write ! ( f, "Original({}x{})" , w, h) ,
243+ Resolution :: P480 => write ! ( f, "480p (640x480)" ) ,
234244 Resolution :: P720 => write ! ( f, "720p (1280x720)" ) ,
235245 Resolution :: P1080 => write ! ( f, "1080p (1920x1080)" ) ,
236246 Resolution :: P2K => write ! ( f, "2K (2560x1440)" ) ,
0 commit comments