avutil/pixdesc: Use av_strstart where appropriate

It makes the intent clearer and allows to avoid calculating the strlen
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2021-02-24 03:26:36 +01:00
parent 3d79ce0c29
commit 114603d0b9
1 changed files with 11 additions and 22 deletions

View File

@ -2702,11 +2702,13 @@ static int get_color_type(const AVPixFmtDescriptor *desc) {
if(desc->nb_components == 1 || desc->nb_components == 2)
return FF_COLOR_GRAY;
if(desc->name && !strncmp(desc->name, "yuvj", 4))
return FF_COLOR_YUV_JPEG;
if (desc->name) {
if (av_strstart(desc->name, "yuvj", NULL))
return FF_COLOR_YUV_JPEG;
if(desc->name && !strncmp(desc->name, "xyz", 3))
return FF_COLOR_XYZ;
if (av_strstart(desc->name, "xyz", NULL))
return FF_COLOR_XYZ;
}
if(desc->flags & AV_PIX_FMT_FLAG_RGB)
return FF_COLOR_RGB;
@ -2907,8 +2909,7 @@ int av_color_range_from_name(const char *name)
int i;
for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
size_t len = strlen(color_range_names[i]);
if (!strncmp(color_range_names[i], name, len))
if (av_strstart(name, color_range_names[i], NULL))
return i;
}
@ -2926,13 +2927,10 @@ int av_color_primaries_from_name(const char *name)
int i;
for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) {
size_t len;
if (!color_primaries_names[i])
continue;
len = strlen(color_primaries_names[i]);
if (!strncmp(color_primaries_names[i], name, len))
if (av_strstart(name, color_primaries_names[i], NULL))
return i;
}
@ -2950,13 +2948,10 @@ int av_color_transfer_from_name(const char *name)
int i;
for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) {
size_t len;
if (!color_transfer_names[i])
continue;
len = strlen(color_transfer_names[i]);
if (!strncmp(color_transfer_names[i], name, len))
if (av_strstart(name, color_transfer_names[i], NULL))
return i;
}
@ -2974,13 +2969,10 @@ int av_color_space_from_name(const char *name)
int i;
for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) {
size_t len;
if (!color_space_names[i])
continue;
len = strlen(color_space_names[i]);
if (!strncmp(color_space_names[i], name, len))
if (av_strstart(name, color_space_names[i], NULL))
return i;
}
@ -2998,13 +2990,10 @@ int av_chroma_location_from_name(const char *name)
int i;
for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) {
size_t len;
if (!chroma_location_names[i])
continue;
len = strlen(chroma_location_names[i]);
if (!strncmp(chroma_location_names[i], name, len))
if (av_strstart(name, chroma_location_names[i], NULL))
return i;
}