Mercurial > libavcodec.hg
comparison utils.c @ 12280:fbc6fc80e6c6 libavcodec
Deprecate av_parse_video_frame_size() and av_parse_video_frame_rate()
in favor of the newly added corresponding functions
av_parse_video_size() and av_parse_video_rate() defined in
libavcore/parseutils.h.
This change also adds a linking-time dependency of libavcodec and of
libavfilter on libavcore.
author | stefano |
---|---|
date | Mon, 26 Jul 2010 23:12:28 +0000 |
parents | b8a0924d6e42 |
children | 035ca6548e29 |
comparison
equal
deleted
inserted
replaced
12279:7fb91885433c | 12280:fbc6fc80e6c6 |
---|---|
1090 *s = v; | 1090 *s = v; |
1091 n++; | 1091 n++; |
1092 return n; | 1092 return n; |
1093 } | 1093 } |
1094 | 1094 |
1095 typedef struct { | 1095 #if LIBAVCODEC_VERSION_MAJOR < 53 |
1096 const char *abbr; | 1096 #include "libavcore/parseutils.h" |
1097 int width, height; | |
1098 } VideoFrameSizeAbbr; | |
1099 | |
1100 typedef struct { | |
1101 const char *abbr; | |
1102 int rate_num, rate_den; | |
1103 } VideoFrameRateAbbr; | |
1104 | |
1105 static const VideoFrameSizeAbbr video_frame_size_abbrs[] = { | |
1106 { "ntsc", 720, 480 }, | |
1107 { "pal", 720, 576 }, | |
1108 { "qntsc", 352, 240 }, /* VCD compliant NTSC */ | |
1109 { "qpal", 352, 288 }, /* VCD compliant PAL */ | |
1110 { "sntsc", 640, 480 }, /* square pixel NTSC */ | |
1111 { "spal", 768, 576 }, /* square pixel PAL */ | |
1112 { "film", 352, 240 }, | |
1113 { "ntsc-film", 352, 240 }, | |
1114 { "sqcif", 128, 96 }, | |
1115 { "qcif", 176, 144 }, | |
1116 { "cif", 352, 288 }, | |
1117 { "4cif", 704, 576 }, | |
1118 { "16cif", 1408,1152 }, | |
1119 { "qqvga", 160, 120 }, | |
1120 { "qvga", 320, 240 }, | |
1121 { "vga", 640, 480 }, | |
1122 { "svga", 800, 600 }, | |
1123 { "xga", 1024, 768 }, | |
1124 { "uxga", 1600,1200 }, | |
1125 { "qxga", 2048,1536 }, | |
1126 { "sxga", 1280,1024 }, | |
1127 { "qsxga", 2560,2048 }, | |
1128 { "hsxga", 5120,4096 }, | |
1129 { "wvga", 852, 480 }, | |
1130 { "wxga", 1366, 768 }, | |
1131 { "wsxga", 1600,1024 }, | |
1132 { "wuxga", 1920,1200 }, | |
1133 { "woxga", 2560,1600 }, | |
1134 { "wqsxga", 3200,2048 }, | |
1135 { "wquxga", 3840,2400 }, | |
1136 { "whsxga", 6400,4096 }, | |
1137 { "whuxga", 7680,4800 }, | |
1138 { "cga", 320, 200 }, | |
1139 { "ega", 640, 350 }, | |
1140 { "hd480", 852, 480 }, | |
1141 { "hd720", 1280, 720 }, | |
1142 { "hd1080", 1920,1080 }, | |
1143 }; | |
1144 | |
1145 static const VideoFrameRateAbbr video_frame_rate_abbrs[]= { | |
1146 { "ntsc", 30000, 1001 }, | |
1147 { "pal", 25, 1 }, | |
1148 { "qntsc", 30000, 1001 }, /* VCD compliant NTSC */ | |
1149 { "qpal", 25, 1 }, /* VCD compliant PAL */ | |
1150 { "sntsc", 30000, 1001 }, /* square pixel NTSC */ | |
1151 { "spal", 25, 1 }, /* square pixel PAL */ | |
1152 { "film", 24, 1 }, | |
1153 { "ntsc-film", 24000, 1001 }, | |
1154 }; | |
1155 | 1097 |
1156 int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) | 1098 int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) |
1157 { | 1099 { |
1158 int i; | 1100 return av_parse_video_size(width_ptr, height_ptr, str); |
1159 int n = FF_ARRAY_ELEMS(video_frame_size_abbrs); | |
1160 char *p; | |
1161 int frame_width = 0, frame_height = 0; | |
1162 | |
1163 for(i=0;i<n;i++) { | |
1164 if (!strcmp(video_frame_size_abbrs[i].abbr, str)) { | |
1165 frame_width = video_frame_size_abbrs[i].width; | |
1166 frame_height = video_frame_size_abbrs[i].height; | |
1167 break; | |
1168 } | |
1169 } | |
1170 if (i == n) { | |
1171 p = str; | |
1172 frame_width = strtol(p, &p, 10); | |
1173 if (*p) | |
1174 p++; | |
1175 frame_height = strtol(p, &p, 10); | |
1176 } | |
1177 if (frame_width <= 0 || frame_height <= 0) | |
1178 return -1; | |
1179 *width_ptr = frame_width; | |
1180 *height_ptr = frame_height; | |
1181 return 0; | |
1182 } | 1101 } |
1183 | 1102 |
1184 int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg) | 1103 int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg) |
1185 { | 1104 { |
1186 int i; | 1105 return av_parse_video_rate(frame_rate, arg); |
1187 int n = FF_ARRAY_ELEMS(video_frame_rate_abbrs); | 1106 } |
1188 char* cp; | 1107 #endif |
1189 | |
1190 /* First, we check our abbreviation table */ | |
1191 for (i = 0; i < n; ++i) | |
1192 if (!strcmp(video_frame_rate_abbrs[i].abbr, arg)) { | |
1193 frame_rate->num = video_frame_rate_abbrs[i].rate_num; | |
1194 frame_rate->den = video_frame_rate_abbrs[i].rate_den; | |
1195 return 0; | |
1196 } | |
1197 | |
1198 /* Then, we try to parse it as fraction */ | |
1199 cp = strchr(arg, '/'); | |
1200 if (!cp) | |
1201 cp = strchr(arg, ':'); | |
1202 if (cp) { | |
1203 char* cpp; | |
1204 frame_rate->num = strtol(arg, &cpp, 10); | |
1205 if (cpp != arg || cpp == cp) | |
1206 frame_rate->den = strtol(cp+1, &cpp, 10); | |
1207 else | |
1208 frame_rate->num = 0; | |
1209 } | |
1210 else { | |
1211 /* Finally we give up and parse it as double */ | |
1212 AVRational time_base = av_d2q(strtod(arg, 0), 1001000); | |
1213 frame_rate->den = time_base.den; | |
1214 frame_rate->num = time_base.num; | |
1215 } | |
1216 if (!frame_rate->num || !frame_rate->den) | |
1217 return -1; | |
1218 else | |
1219 return 0; | |
1220 } | |
1221 | 1108 |
1222 int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){ | 1109 int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){ |
1223 int i; | 1110 int i; |
1224 for(i=0; i<size && !(tab[i][0]==a && tab[i][1]==b); i++); | 1111 for(i=0; i<size && !(tab[i][0]==a && tab[i][1]==b); i++); |
1225 return i; | 1112 return i; |