aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-31 17:10:10 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-19 22:14:13 +0200
commit9c8aeacf82a872e1703efdfd2822a4f2d6324c9a (patch)
tree5f738c9da8d7396e7b5213876e08cf0c44de583f
parent63139f62f35944b9abd42505bf13a740676978e9 (diff)
downloadffmpeg-9c8aeacf82a872e1703efdfd2822a4f2d6324c9a.tar.gz
avutil: add av_get_colorspace_name()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/utils.c21
-rw-r--r--libavutil/frame.c16
-rw-r--r--libavutil/frame.h6
-rw-r--r--libavutil/version.h2
4 files changed, 29 insertions, 16 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 7ca2044a6c..e3f7ee27cf 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2631,6 +2631,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
case AVMEDIA_TYPE_VIDEO:
if (enc->pix_fmt != AV_PIX_FMT_NONE) {
char detail[256] = "(";
+ const char *colorspace_name;
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %s",
av_get_pix_fmt_name(enc->pix_fmt));
@@ -2640,21 +2641,11 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
if (enc->color_range != AVCOL_RANGE_UNSPECIFIED)
av_strlcatf(detail, sizeof(detail),
enc->color_range == AVCOL_RANGE_MPEG ? "tv, ": "pc, ");
- if (enc->colorspace<9U) {
- static const char *name[] = {
- "GBR",
- "bt709",
- NULL,
- NULL,
- "fcc",
- "bt470bg",
- "smpte170m",
- "smpte240m",
- "YCgCo",
- };
- if (name[enc->colorspace])
- av_strlcatf(detail, sizeof(detail), "%s, ", name[enc->colorspace]);
- }
+
+ colorspace_name = av_get_colorspace_name(enc->colorspace);
+ if (colorspace_name)
+ av_strlcatf(detail, sizeof(detail), "%s, ", colorspace_name);
+
if (strlen(detail) > 1) {
detail[strlen(detail) - 2] = 0;
av_strlcatf(buf, buf_size, "%s)", detail);
diff --git a/libavutil/frame.c b/libavutil/frame.c
index b0fdd49ade..0ce84d2a51 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -70,6 +70,22 @@ int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type)
return f->qp_table_buf->data;
}
+const char *av_get_colorspace_name(enum AVColorSpace val)
+{
+ static const char *name[] = {
+ [AVCOL_SPC_RGB] = "GBR",
+ [AVCOL_SPC_BT709] = "bt709",
+ [AVCOL_SPC_FCC] = "fcc",
+ [AVCOL_SPC_BT470BG] = "bt470bg",
+ [AVCOL_SPC_SMPTE170M] = "smpte170m",
+ [AVCOL_SPC_SMPTE240M] = "smpte240m",
+ [AVCOL_SPC_YCOCG] = "YCgCo",
+ };
+ if (val < 0 || val >= FF_ARRAY_ELEMS(name))
+ return NULL;
+ return name[val];
+}
+
static void get_frame_defaults(AVFrame *frame)
{
if (frame->extended_data != frame->data)
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 3313703f0c..f0a57037e8 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -509,6 +509,12 @@ enum AVColorRange av_frame_get_color_range(const AVFrame *frame);
void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val);
/**
+ * Get the name of a colorspace.
+ * @return a static string identifying the colorspace; can be NULL.
+ */
+const char *av_get_colorspace_name(enum AVColorSpace val);
+
+/**
* Allocate an AVFrame and set its fields to default values. The resulting
* struct must be freed using av_frame_free().
*
diff --git a/libavutil/version.h b/libavutil/version.h
index c143589f6f..057e9f1328 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -75,7 +75,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 44
+#define LIBAVUTIL_VERSION_MINOR 45
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \