Commit dc4a50a0 authored by Stefano Sabatini's avatar Stefano Sabatini

Remove reference to the "frame" term in variable names. Simpler and

more consistent with the function names.

Originally committed as revision 24522 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent afead106
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
typedef struct { typedef struct {
const char *abbr; const char *abbr;
int width, height; int width, height;
} VideoFrameSizeAbbr; } VideoSizeAbbr;
typedef struct { typedef struct {
const char *abbr; const char *abbr;
int rate_num, rate_den; int rate_num, rate_den;
} VideoFrameRateAbbr; } VideoRateAbbr;
static const VideoFrameSizeAbbr video_frame_size_abbrs[] = { static const VideoSizeAbbr video_size_abbrs[] = {
{ "ntsc", 720, 480 }, { "ntsc", 720, 480 },
{ "pal", 720, 576 }, { "pal", 720, 576 },
{ "qntsc", 352, 240 }, /* VCD compliant NTSC */ { "qntsc", 352, 240 }, /* VCD compliant NTSC */
...@@ -74,7 +74,7 @@ static const VideoFrameSizeAbbr video_frame_size_abbrs[] = { ...@@ -74,7 +74,7 @@ static const VideoFrameSizeAbbr video_frame_size_abbrs[] = {
{ "hd1080", 1920,1080 }, { "hd1080", 1920,1080 },
}; };
static const VideoFrameRateAbbr video_frame_rate_abbrs[]= { static const VideoRateAbbr video_rate_abbrs[]= {
{ "ntsc", 30000, 1001 }, { "ntsc", 30000, 1001 },
{ "pal", 25, 1 }, { "pal", 25, 1 },
{ "qntsc", 30000, 1001 }, /* VCD compliant NTSC */ { "qntsc", 30000, 1001 }, /* VCD compliant NTSC */
...@@ -88,42 +88,42 @@ static const VideoFrameRateAbbr video_frame_rate_abbrs[]= { ...@@ -88,42 +88,42 @@ static const VideoFrameRateAbbr video_frame_rate_abbrs[]= {
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str) int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
{ {
int i; int i;
int n = FF_ARRAY_ELEMS(video_frame_size_abbrs); int n = FF_ARRAY_ELEMS(video_size_abbrs);
char *p; char *p;
int frame_width = 0, frame_height = 0; int width = 0, height = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (!strcmp(video_frame_size_abbrs[i].abbr, str)) { if (!strcmp(video_size_abbrs[i].abbr, str)) {
frame_width = video_frame_size_abbrs[i].width; width = video_size_abbrs[i].width;
frame_height = video_frame_size_abbrs[i].height; height = video_size_abbrs[i].height;
break; break;
} }
} }
if (i == n) { if (i == n) {
p = str; p = str;
frame_width = strtol(p, &p, 10); width = strtol(p, &p, 10);
if (*p) if (*p)
p++; p++;
frame_height = strtol(p, &p, 10); height = strtol(p, &p, 10);
} }
if (frame_width <= 0 || frame_height <= 0) if (width <= 0 || height <= 0)
return AVERROR(EINVAL); return AVERROR(EINVAL);
*width_ptr = frame_width; *width_ptr = width;
*height_ptr = frame_height; *height_ptr = height;
return 0; return 0;
} }
int av_parse_video_rate(AVRational *frame_rate, const char *arg) int av_parse_video_rate(AVRational *rate, const char *arg)
{ {
int i; int i;
int n = FF_ARRAY_ELEMS(video_frame_rate_abbrs); int n = FF_ARRAY_ELEMS(video_rate_abbrs);
char *cp; char *cp;
/* First, we check our abbreviation table */ /* First, we check our abbreviation table */
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
if (!strcmp(video_frame_rate_abbrs[i].abbr, arg)) { if (!strcmp(video_rate_abbrs[i].abbr, arg)) {
frame_rate->num = video_frame_rate_abbrs[i].rate_num; rate->num = video_rate_abbrs[i].rate_num;
frame_rate->den = video_frame_rate_abbrs[i].rate_den; rate->den = video_rate_abbrs[i].rate_den;
return 0; return 0;
} }
...@@ -133,18 +133,18 @@ int av_parse_video_rate(AVRational *frame_rate, const char *arg) ...@@ -133,18 +133,18 @@ int av_parse_video_rate(AVRational *frame_rate, const char *arg)
cp = strchr(arg, ':'); cp = strchr(arg, ':');
if (cp) { if (cp) {
char *cpp; char *cpp;
frame_rate->num = strtol(arg, &cpp, 10); rate->num = strtol(arg, &cpp, 10);
if (cpp != arg || cpp == cp) if (cpp != arg || cpp == cp)
frame_rate->den = strtol(cp+1, &cpp, 10); rate->den = strtol(cp+1, &cpp, 10);
else else
frame_rate->num = 0; rate->num = 0;
} else { } else {
/* Finally we give up and parse it as double */ /* Finally we give up and parse it as double */
AVRational time_base = av_d2q(strtod(arg, 0), 1001000); AVRational time_base = av_d2q(strtod(arg, 0), 1001000);
frame_rate->den = time_base.den; rate->den = time_base.den;
frame_rate->num = time_base.num; rate->num = time_base.num;
} }
if (frame_rate->num <= 0 || frame_rate->den <= 0) if (rate->num <= 0 || rate->den <= 0)
return AVERROR(EINVAL); return AVERROR(EINVAL);
return 0; return 0;
} }
...@@ -30,24 +30,24 @@ ...@@ -30,24 +30,24 @@
* Parse str and put in width_ptr and height_ptr the detected values. * Parse str and put in width_ptr and height_ptr the detected values.
* *
* @param[in,out] width_ptr pointer to the variable which will contain the detected * @param[in,out] width_ptr pointer to the variable which will contain the detected
* frame width value * width value
* @param[in,out] height_ptr pointer to the variable which will contain the detected * @param[in,out] height_ptr pointer to the variable which will contain the detected
* frame height value * height value
* @param[in] str the string to parse: it has to be a string in the format * @param[in] str the string to parse: it has to be a string in the format
* width x height or a valid video frame size abbreviation. * width x height or a valid video size abbreviation.
* @return >= 0 on success, a negative error code otherwise * @return >= 0 on success, a negative error code otherwise
*/ */
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str); int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str);
/** /**
* Parse str and store the detected values in *frame_rate. * Parse str and store the detected values in *rate.
* *
* @param[in,out] frame_rate pointer to the AVRational which will contain the detected * @param[in,out] rate pointer to the AVRational which will contain the detected
* frame rate * frame rate
* @param[in] str the string to parse: it has to be a string in the format * @param[in] str the string to parse: it has to be a string in the format
* frame_rate_num / frame_rate_den, a float number or a valid video rate abbreviation * rate_num / rate_den, a float number or a valid video rate abbreviation
* @return >= 0 on success, a negative error code otherwise * @return >= 0 on success, a negative error code otherwise
*/ */
int av_parse_video_rate(AVRational *frame_rate, const char *str); int av_parse_video_rate(AVRational *rate, const char *str);
#endif /* AVCORE_PARSEUTILS_H */ #endif /* AVCORE_PARSEUTILS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment