1 /* AV1
2 * Copyright (C) 2018 Wonchul Lee <chul0812@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include "gstav1utils.h"
25
26 typedef struct
27 {
28 enum aom_img_fmt aom_format;
29 GstVideoFormat gst_format;
30 } AomImageFormat;
31
32 static const AomImageFormat img_formats[] = {
33 {AOM_IMG_FMT_YV12, GST_VIDEO_FORMAT_YV12},
34 {AOM_IMG_FMT_I420, GST_VIDEO_FORMAT_I420},
35 {AOM_IMG_FMT_I422, GST_VIDEO_FORMAT_Y42B},
36 {AOM_IMG_FMT_I444, GST_VIDEO_FORMAT_Y444},
37 };
38
39 const char *
gst_av1_get_error_name(aom_codec_err_t status)40 gst_av1_get_error_name (aom_codec_err_t status)
41 {
42 switch (status) {
43 case AOM_CODEC_OK:
44 return "OK";
45 case AOM_CODEC_ERROR:
46 return "error";
47 case AOM_CODEC_MEM_ERROR:
48 return "mem error";
49 case AOM_CODEC_ABI_MISMATCH:
50 return "abi mismatch";
51 case AOM_CODEC_INCAPABLE:
52 return "incapable";
53 case AOM_CODEC_UNSUP_BITSTREAM:
54 return "unsupported bitstream";
55 case AOM_CODEC_UNSUP_FEATURE:
56 return "unsupported feature";
57 case AOM_CODEC_CORRUPT_FRAME:
58 return "corrupt frame";
59 case AOM_CODEC_INVALID_PARAM:
60 return "invalid parameter";
61 default:
62 return "unknown";
63 }
64 }
65
66 gint
gst_video_format_to_av1_img_format(GstVideoFormat format)67 gst_video_format_to_av1_img_format (GstVideoFormat format)
68 {
69 guint i;
70
71 for (i = 0; i < G_N_ELEMENTS (img_formats); i++)
72 if (img_formats[i].gst_format == format)
73 return img_formats[i].aom_format;
74
75 GST_WARNING ("av1 img format not found");
76 return -1;
77 }
78