Mercurial > libavcodec.hg
comparison utils.c @ 5176:82f7eaa32f46 libavcodec
split frame rate and frame size abbreviation into two structures
patch by Stefano Sabatini: [stefano sabatini-lala poste it]
author | benoit |
---|---|
date | Thu, 21 Jun 2007 07:46:48 +0000 |
parents | 4dbe6578f811 |
children | 431eef69a62f |
comparison
equal
deleted
inserted
replaced
5175:830576859f71 | 5176:82f7eaa32f46 |
---|---|
1347 } | 1347 } |
1348 return fd; /* success */ | 1348 return fd; /* success */ |
1349 } | 1349 } |
1350 | 1350 |
1351 typedef struct { | 1351 typedef struct { |
1352 const char *abv; | 1352 const char *abbr; |
1353 int width, height; | 1353 int width, height; |
1354 int frame_rate, frame_rate_base; | 1354 } VideoFrameSizeAbbr; |
1355 } AbvEntry; | 1355 |
1356 | 1356 typedef struct { |
1357 static AbvEntry frame_abvs[] = { | 1357 const char *abbr; |
1358 { "ntsc", 720, 480, 30000, 1001 }, | 1358 int rate_num, rate_den; |
1359 { "pal", 720, 576, 25, 1 }, | 1359 } VideoFrameRateAbbr; |
1360 { "qntsc", 352, 240, 30000, 1001 }, /* VCD compliant NTSC */ | 1360 |
1361 { "qpal", 352, 288, 25, 1 }, /* VCD compliant PAL */ | 1361 static VideoFrameSizeAbbr video_frame_size_abbrs[] = { |
1362 { "sntsc", 640, 480, 30000, 1001 }, /* square pixel NTSC */ | 1362 { "ntsc", 720, 480 }, |
1363 { "spal", 768, 576, 25, 1 }, /* square pixel PAL */ | 1363 { "pal", 720, 576 }, |
1364 { "film", 352, 240, 24, 1 }, | 1364 { "qntsc", 352, 240 }, /* VCD compliant NTSC */ |
1365 { "ntsc-film", 352, 240, 24000, 1001 }, | 1365 { "qpal", 352, 288 }, /* VCD compliant PAL */ |
1366 { "sqcif", 128, 96, 0, 0 }, | 1366 { "sntsc", 640, 480 }, /* square pixel NTSC */ |
1367 { "qcif", 176, 144, 0, 0 }, | 1367 { "spal", 768, 576 }, /* square pixel PAL */ |
1368 { "cif", 352, 288, 0, 0 }, | 1368 { "film", 352, 240 }, |
1369 { "4cif", 704, 576, 0, 0 }, | 1369 { "ntsc-film", 352, 240 }, |
1370 { "qqvga", 160, 120, 0, 0 }, | 1370 { "sqcif", 128, 96 }, |
1371 { "qvga", 320, 240, 0, 0 }, | 1371 { "qcif", 176, 144 }, |
1372 { "vga", 640, 480, 0, 0 }, | 1372 { "cif", 352, 288 }, |
1373 { "svga", 800, 600, 0, 0 }, | 1373 { "4cif", 704, 576 }, |
1374 { "xga", 1024, 768, 0, 0 }, | 1374 { "qqvga", 160, 120 }, |
1375 { "uxga", 1600,1200, 0, 0 }, | 1375 { "qvga", 320, 240 }, |
1376 { "qxga", 2048,1536, 0, 0 }, | 1376 { "vga", 640, 480 }, |
1377 { "sxga", 1280,1024, 0, 0 }, | 1377 { "svga", 800, 600 }, |
1378 { "qsxga", 2560,2048, 0, 0 }, | 1378 { "xga", 1024, 768 }, |
1379 { "hsxga", 5120,4096, 0, 0 }, | 1379 { "uxga", 1600,1200 }, |
1380 { "wvga", 852, 480, 0, 0 }, | 1380 { "qxga", 2048,1536 }, |
1381 { "wxga", 1366, 768, 0, 0 }, | 1381 { "sxga", 1280,1024 }, |
1382 { "wsxga", 1600,1024, 0, 0 }, | 1382 { "qsxga", 2560,2048 }, |
1383 { "wuxga", 1920,1200, 0, 0 }, | 1383 { "hsxga", 5120,4096 }, |
1384 { "woxga", 2560,1600, 0, 0 }, | 1384 { "wvga", 852, 480 }, |
1385 { "wqsxga", 3200,2048, 0, 0 }, | 1385 { "wxga", 1366, 768 }, |
1386 { "wquxga", 3840,2400, 0, 0 }, | 1386 { "wsxga", 1600,1024 }, |
1387 { "whsxga", 6400,4096, 0, 0 }, | 1387 { "wuxga", 1920,1200 }, |
1388 { "whuxga", 7680,4800, 0, 0 }, | 1388 { "woxga", 2560,1600 }, |
1389 { "cga", 320, 200, 0, 0 }, | 1389 { "wqsxga", 3200,2048 }, |
1390 { "ega", 640, 350, 0, 0 }, | 1390 { "wquxga", 3840,2400 }, |
1391 { "hd480", 852, 480, 0, 0 }, | 1391 { "whsxga", 6400,4096 }, |
1392 { "hd720", 1280, 720, 0, 0 }, | 1392 { "whuxga", 7680,4800 }, |
1393 { "hd1080", 1920,1080, 0, 0 }, | 1393 { "cga", 320, 200 }, |
1394 { "ega", 640, 350 }, | |
1395 { "hd480", 852, 480 }, | |
1396 { "hd720", 1280, 720 }, | |
1397 { "hd1080", 1920,1080 }, | |
1394 }; | 1398 }; |
1395 | 1399 |
1400 static VideoFrameRateAbbr video_frame_rate_abbrs[]= { | |
1401 { "ntsc", 30000, 1001 }, | |
1402 { "pal", 25, 1 }, | |
1403 { "qntsc", 30000, 1001 }, /* VCD compliant NTSC */ | |
1404 { "qpal", 25, 1 }, /* VCD compliant PAL */ | |
1405 { "sntsc", 30000, 1001 }, /* square pixel NTSC */ | |
1406 { "spal", 25, 1 }, /* square pixel PAL */ | |
1407 { "film", 24, 1 }, | |
1408 { "ntsc-film", 24000, 1001 }, | |
1409 }; | |
1410 | |
1396 int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) | 1411 int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) |
1397 { | 1412 { |
1398 int i; | 1413 int i; |
1399 int n = sizeof(frame_abvs) / sizeof(AbvEntry); | 1414 int n = sizeof(video_frame_size_abbrs) / sizeof(VideoFrameSizeAbbr); |
1400 const char *p; | 1415 const char *p; |
1401 int frame_width = 0, frame_height = 0; | 1416 int frame_width = 0, frame_height = 0; |
1402 | 1417 |
1403 for(i=0;i<n;i++) { | 1418 for(i=0;i<n;i++) { |
1404 if (!strcmp(frame_abvs[i].abv, str)) { | 1419 if (!strcmp(video_frame_size_abbrs[i].abbr, str)) { |
1405 frame_width = frame_abvs[i].width; | 1420 frame_width = video_frame_size_abbrs[i].width; |
1406 frame_height = frame_abvs[i].height; | 1421 frame_height = video_frame_size_abbrs[i].height; |
1407 break; | 1422 break; |
1408 } | 1423 } |
1409 } | 1424 } |
1410 if (i == n) { | 1425 if (i == n) { |
1411 p = str; | 1426 p = str; |
1422 } | 1437 } |
1423 | 1438 |
1424 int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg) | 1439 int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg) |
1425 { | 1440 { |
1426 int i; | 1441 int i; |
1442 int n = sizeof(video_frame_rate_abbrs) / sizeof(VideoFrameRateAbbr); | |
1427 char* cp; | 1443 char* cp; |
1428 | 1444 |
1429 /* First, we check our abbreviation table */ | 1445 /* First, we check our abbreviation table */ |
1430 for (i = 0; i < sizeof(frame_abvs)/sizeof(*frame_abvs); ++i) | 1446 for (i = 0; i < n; ++i) |
1431 if (!strcmp(frame_abvs[i].abv, arg)) { | 1447 if (!strcmp(video_frame_rate_abbrs[i].abbr, arg)) { |
1432 frame_rate->num = frame_abvs[i].frame_rate; | 1448 frame_rate->num = video_frame_rate_abbrs[i].rate_num; |
1433 frame_rate->den = frame_abvs[i].frame_rate_base; | 1449 frame_rate->den = video_frame_rate_abbrs[i].rate_den; |
1434 return 0; | 1450 return 0; |
1435 } | 1451 } |
1436 | 1452 |
1437 /* Then, we try to parse it as fraction */ | 1453 /* Then, we try to parse it as fraction */ |
1438 cp = strchr(arg, '/'); | 1454 cp = strchr(arg, '/'); |