libs: utils: vpx: Add utils vpx to handle VP8/9 misc things.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/188>
This commit is contained in:
He Junyan 2020-07-06 23:35:12 +08:00 committed by Víctor Manuel Jáquez Leal
parent 6022d97edf
commit ed55dd8df1
3 changed files with 130 additions and 0 deletions

View file

@ -0,0 +1,88 @@
/*
* gstvaapiutils_vpx.c - vpx related utilities
*
* Copyright (C) 2020 Intel Corporation
* Author: He Junyan <junyan.he@intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "gstvaapiutils_vpx.h"
struct map
{
guint value;
const gchar *name;
};
/* Profile string map */
static const struct map gst_vaapi_vp9_profile_map[] = {
/* *INDENT-OFF* */
{ GST_VAAPI_PROFILE_VP9_0, "0" },
{ GST_VAAPI_PROFILE_VP9_1, "1" },
{ GST_VAAPI_PROFILE_VP9_2, "2" },
{ GST_VAAPI_PROFILE_VP9_3, "3" },
{ 0, NULL }
/* *INDENT-ON* */
};
/* Lookup name in map */
static const struct map *
map_lookup_name (const struct map *m, const gchar * name)
{
g_return_val_if_fail (m != NULL, NULL);
if (!name)
return NULL;
for (; m->name != NULL; m++) {
if (strcmp (m->name, name) == 0)
return m;
}
return NULL;
}
/* Lookup value in map */
static const struct map *
map_lookup_value (const struct map *m, guint value)
{
g_return_val_if_fail (m != NULL, NULL);
for (; m->name != NULL; m++) {
if (m->value == value)
return m;
}
return NULL;
}
/** Returns GstVaapiProfile from a string representation */
GstVaapiProfile
gst_vaapi_utils_vp9_get_profile_from_string (const gchar * str)
{
const struct map *const m = map_lookup_name (gst_vaapi_vp9_profile_map, str);
return m ? (GstVaapiProfile) m->value : GST_VAAPI_PROFILE_UNKNOWN;
}
/** Returns a string representation for the supplied VP9 profile */
const gchar *
gst_vaapi_utils_vp9_get_profile_string (GstVaapiProfile profile)
{
const struct map *const m =
map_lookup_value (gst_vaapi_vp9_profile_map, profile);
return m ? m->name : NULL;
}

View file

@ -0,0 +1,40 @@
/*
* gstvaapiutils_vpx.h - vpx related utilities
*
* Copyright (C) 2020 Intel Corporation
* Author: He Junyan <junyan.he@intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef GST_VAAPI_UTILS_VPX_H
#define GST_VAAPI_UTILS_VPX_H
#include <gst/vaapi/gstvaapiprofile.h>
G_BEGIN_DECLS
/** Returns GstVaapiProfile from a string representation */
GstVaapiProfile
gst_vaapi_utils_vp9_get_profile_from_string (const gchar * str);
/** Returns a string representation for the supplied VP9 profile */
const gchar *
gst_vaapi_utils_vp9_get_profile_string (GstVaapiProfile profile);
G_END_DECLS
#endif /* GST_VAAPI_UTILS_VPX_H */

View file

@ -36,6 +36,7 @@ gstlibvaapi_sources = [
'gstvaapiutils_h265.c',
'gstvaapiutils_h26x.c',
'gstvaapiutils_mpeg2.c',
'gstvaapiutils_vpx.c',
'gstvaapivalue.c',
'gstvaapivideopool.c',
'gstvaapiwindow.c',
@ -71,6 +72,7 @@ gstlibvaapi_headers = [
'gstvaapiutils_h264.h',
'gstvaapiutils_h265.h',
'gstvaapiutils_mpeg2.h',
'gstvaapiutils_vpx.h',
'gstvaapivalue.h',
'gstvaapivideopool.h',
'gstvaapiwindow.h',