libs: decoder: AV1: Add the av1 decoder support.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/191>
This commit is contained in:
He Junyan 2020-08-27 21:46:41 +08:00
parent 46c1f3875a
commit 0a34b6882e
8 changed files with 1375 additions and 1 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,47 @@
/*
* gstvaapidecoder_av1.h - AV1 decoder
*
* Copyright (C) 2019-2020 Intel Corporation
* Author: Junyan He <junyan.he@hotmail.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_DECODER_AV1_H
#define GST_VAAPI_DECODER_AV1_H
#include <gst/vaapi/gstvaapidecoder.h>
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DECODER_AV1 \
(gst_vaapi_decoder_av1_get_type ())
#define GST_VAAPI_DECODER_AV1(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DECODER_AV1, GstVaapiDecoderAV1))
#define GST_VAAPI_IS_DECODER_AV1(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DECODER_AV1))
typedef struct _GstVaapiDecoderAV1 GstVaapiDecoderAV1;
GType
gst_vaapi_decoder_av1_get_type (void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_av1_new (GstVaapiDisplay * display, GstCaps * caps);
G_END_DECLS
#endif /* GST_VAAPI_DECODER_AV1_H */

View file

@ -71,6 +71,7 @@ static const GstVaapiCodecMap gst_vaapi_codecs[] = {
{GST_VAAPI_CODEC_VP8, "vp8"},
{GST_VAAPI_CODEC_H265, "h265"},
{GST_VAAPI_CODEC_VP9, "vp9"},
{GST_VAAPI_CODEC_AV1, "av1"},
{0,}
};
@ -154,6 +155,12 @@ static const GstVaapiProfileMap gst_vaapi_profiles[] = {
"video/x-vp9", "2"},
{GST_VAAPI_PROFILE_VP9_3, VAProfileVP9Profile3,
"video/x-vp9", "3"},
#if VA_CHECK_VERSION(1,8,0)
{GST_VAAPI_PROFILE_AV1_0, VAProfileAV1Profile0,
"video/x-av1", "0"},
{GST_VAAPI_PROFILE_AV1_1, VAProfileAV1Profile1,
"video/x-av1", "1"},
#endif
{0,}
};

View file

@ -42,6 +42,7 @@ G_BEGIN_DECLS
* @GST_VAAPI_CODEC_JPEG: JPEG (ITU-T 81)
* @GST_VAAPI_CODEC_H265: H.265 aka MPEG-H Part 2 (ITU-T H.265)
* @GST_VAAPI_CODEC_VP9: VP9 (libvpx)
* @GST_VAAPI_CODEC_AV1: AV1 (aom)
*
* The set of all codecs for #GstVaapiCodec.
*/
@ -57,6 +58,7 @@ typedef enum {
GST_VAAPI_CODEC_VP8 = GST_MAKE_FOURCC('V','P','8',0),
GST_VAAPI_CODEC_H265 = GST_MAKE_FOURCC('2','6','5',0),
GST_VAAPI_CODEC_VP9 = GST_MAKE_FOURCC('V','P','9',0),
GST_VAAPI_CODEC_AV1 = GST_MAKE_FOURCC('A','V','1',0),
} GstVaapiCodec;
/**
@ -142,6 +144,10 @@ typedef enum {
* VP9 prfile 2, bitdepth=10/12, 420
* @GST_VAAPI_PROFILE_VP9_3:
* VP9 prfile 3 bitdepth=10/12, 422/444/440/RGB
* @GST_VAAPI_PROFILE_AV1_0:
* AV1 prfile 0, bitdepth=8/10, 420/400
* @GST_VAAPI_PROFILE_AV1_1:
* AV1 prfile 1 bitdepth=8/10, 444
*
* The set of all profiles for #GstVaapiProfile.
*/
@ -196,6 +202,9 @@ typedef enum {
GST_VAAPI_PROFILE_VP9_1 = GST_VAAPI_MAKE_PROFILE(VP9,2),
GST_VAAPI_PROFILE_VP9_2 = GST_VAAPI_MAKE_PROFILE(VP9,3),
GST_VAAPI_PROFILE_VP9_3 = GST_VAAPI_MAKE_PROFILE(VP9,4),
GST_VAAPI_PROFILE_AV1_0 = GST_VAAPI_MAKE_PROFILE(AV1,1),
GST_VAAPI_PROFILE_AV1_1 = GST_VAAPI_MAKE_PROFILE(AV1,2),
} GstVaapiProfile;
/**

View file

@ -255,6 +255,10 @@ string_of_VAProfile (VAProfile profile)
MAP (VP9Profile1);
MAP (VP9Profile2);
MAP (VP9Profile3);
#if VA_CHECK_VERSION(1,8,0)
MAP (AV1Profile0);
MAP (AV1Profile1);
#endif
#undef MAP
default:
break;

View file

@ -110,6 +110,11 @@ if USE_VP9_ENCODER
gstlibvaapi_headers += 'gstvaapiencoder_vp9.h'
endif
if USE_AV1_DECODER
gstlibvaapi_sources += 'gstvaapidecoder_av1.c'
gstlibvaapi_headers += 'gstvaapidecoder_av1.h'
endif
if USE_DRM
gstlibvaapi_sources += [
'gstvaapidisplay_drm.c',

View file

@ -44,6 +44,9 @@
#include <gst/vaapi/gstvaapidecoder_vp8.h>
#include <gst/vaapi/gstvaapidecoder_h265.h>
#include <gst/vaapi/gstvaapidecoder_vp9.h>
#if USE_AV1_DECODER
#include <gst/vaapi/gstvaapidecoder_av1.h>
#endif
#define GST_PLUGIN_NAME "vaapidecode"
#define GST_PLUGIN_DESC "A VA-API based video decoder"
@ -75,6 +78,7 @@ static const char gst_vaapidecode_sink_caps_str[] =
GST_CAPS_CODEC("video/x-wmv")
GST_CAPS_CODEC("video/x-vp8")
GST_CAPS_CODEC("video/x-vp9")
GST_CAPS_CODEC("video/x-av1")
;
static const char gst_vaapidecode_src_caps_str[] =
@ -118,6 +122,7 @@ static const GstVaapiDecoderMap vaapi_decode_map[] = {
{GST_VAAPI_CODEC_VP8, GST_RANK_PRIMARY, "vp8", "video/x-vp8", NULL},
{GST_VAAPI_CODEC_VP9, GST_RANK_PRIMARY, "vp9", "video/x-vp9", NULL},
{GST_VAAPI_CODEC_H265, GST_RANK_PRIMARY, "h265", "video/x-h265", NULL},
{GST_VAAPI_CODEC_AV1, GST_RANK_PRIMARY, "av1", "video/x-av1", NULL},
{0 /* the rest */ , GST_RANK_PRIMARY + 1, NULL,
gst_vaapidecode_sink_caps_str, NULL},
};
@ -979,6 +984,11 @@ gst_vaapidecode_create (GstVaapiDecode * decode, GstCaps * caps)
case GST_VAAPI_CODEC_VP9:
decode->decoder = gst_vaapi_decoder_vp9_new (dpy, caps);
break;
#if USE_AV1_DECODER
case GST_VAAPI_CODEC_AV1:
decode->decoder = gst_vaapi_decoder_av1_new (dpy, caps);
break;
#endif
default:
decode->decoder = NULL;
break;
@ -1547,7 +1557,7 @@ gst_vaapidecode_class_init (GstVaapiDecodeClass * klass)
"Gwenole Beauchesne <gwenole.beauchesne@intel.com>, "
"Halley Zhao <halley.zhao@intel.com>, "
"Sreerenj Balachandran <sreerenj.balachandran@intel.com>, "
"Wind Yuan <feng.yuan@intel.com>");
"Wind Yuan <feng.yuan@intel.com>, Junyan He <junyan.he@intel.com>");
g_free (longname);
g_free (description);

View file

@ -115,6 +115,7 @@ endif
USE_ENCODERS = get_option('with_encoders') != 'no'
USE_VP9_ENCODER = USE_ENCODERS and cc.has_header('va/va_enc_vp9.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
USE_AV1_DECODER = cc.has_header('va/va_dec_av1.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
USE_DRM = libva_drm_dep.found() and libdrm_dep.found() and libudev_dep.found() and get_option('with_drm') != 'no'
USE_EGL = gmodule_dep.found() and egl_dep.found() and GLES_VERSION_MASK != 0 and get_option('with_egl') != 'no'
@ -166,6 +167,7 @@ cdata.set10('USE_EGL', USE_EGL)
cdata.set10('USE_ENCODERS', USE_ENCODERS)
cdata.set10('USE_GLX', USE_GLX)
cdata.set10('USE_VP9_ENCODER', USE_VP9_ENCODER)
cdata.set10('USE_AV1_DECODER', USE_AV1_DECODER)
cdata.set10('USE_WAYLAND', USE_WAYLAND)
cdata.set10('USE_X11', USE_X11)
cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))