Mercurial > libavcore.hg
comparison parseutils.c @ 4:a821459410ee libavcore
Make VideoFrameRateAbbr contain a rational rather than two ints for
num and den. Simplify.
| author | stefano |
|---|---|
| date | Mon, 26 Jul 2010 23:12:45 +0000 |
| parents | af138a6c3924 |
| children | ae41a485a089 |
comparison
equal
deleted
inserted
replaced
| 3:af138a6c3924 | 4:a821459410ee |
|---|---|
| 29 int width, height; | 29 int width, height; |
| 30 } VideoSizeAbbr; | 30 } VideoSizeAbbr; |
| 31 | 31 |
| 32 typedef struct { | 32 typedef struct { |
| 33 const char *abbr; | 33 const char *abbr; |
| 34 int rate_num, rate_den; | 34 AVRational rate; |
| 35 } VideoRateAbbr; | 35 } VideoRateAbbr; |
| 36 | 36 |
| 37 static const VideoSizeAbbr video_size_abbrs[] = { | 37 static const VideoSizeAbbr video_size_abbrs[] = { |
| 38 { "ntsc", 720, 480 }, | 38 { "ntsc", 720, 480 }, |
| 39 { "pal", 720, 576 }, | 39 { "pal", 720, 576 }, |
| 73 { "hd720", 1280, 720 }, | 73 { "hd720", 1280, 720 }, |
| 74 { "hd1080", 1920,1080 }, | 74 { "hd1080", 1920,1080 }, |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 static const VideoRateAbbr video_rate_abbrs[]= { | 77 static const VideoRateAbbr video_rate_abbrs[]= { |
| 78 { "ntsc", 30000, 1001 }, | 78 { "ntsc", { 30000, 1001 } }, |
| 79 { "pal", 25, 1 }, | 79 { "pal", { 25, 1 } }, |
| 80 { "qntsc", 30000, 1001 }, /* VCD compliant NTSC */ | 80 { "qntsc", { 30000, 1001 } }, /* VCD compliant NTSC */ |
| 81 { "qpal", 25, 1 }, /* VCD compliant PAL */ | 81 { "qpal", { 25, 1 } }, /* VCD compliant PAL */ |
| 82 { "sntsc", 30000, 1001 }, /* square pixel NTSC */ | 82 { "sntsc", { 30000, 1001 } }, /* square pixel NTSC */ |
| 83 { "spal", 25, 1 }, /* square pixel PAL */ | 83 { "spal", { 25, 1 } }, /* square pixel PAL */ |
| 84 { "film", 24, 1 }, | 84 { "film", { 24, 1 } }, |
| 85 { "ntsc-film", 24000, 1001 }, | 85 { "ntsc-film", { 24000, 1001 } }, |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str) | 88 int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str) |
| 89 { | 89 { |
| 90 int i; | 90 int i; |
| 120 char *cp; | 120 char *cp; |
| 121 | 121 |
| 122 /* First, we check our abbreviation table */ | 122 /* First, we check our abbreviation table */ |
| 123 for (i = 0; i < n; ++i) | 123 for (i = 0; i < n; ++i) |
| 124 if (!strcmp(video_rate_abbrs[i].abbr, arg)) { | 124 if (!strcmp(video_rate_abbrs[i].abbr, arg)) { |
| 125 rate->num = video_rate_abbrs[i].rate_num; | 125 *rate = video_rate_abbrs[i].rate; |
| 126 rate->den = video_rate_abbrs[i].rate_den; | |
| 127 return 0; | 126 return 0; |
| 128 } | 127 } |
| 129 | 128 |
| 130 /* Then, we try to parse it as fraction */ | 129 /* Then, we try to parse it as fraction */ |
| 131 cp = strchr(arg, '/'); | 130 cp = strchr(arg, '/'); |
