mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
utils: add new H.264 helper functions.
* Profiles: - gst_vaapi_utils_h264_get_profile(): Returns GstVaapiProfile from H.264 profile_idc value - gst_vaapi_utils_h264_get_profile_idc(): Returns H.264 profile_idc value from GstVaapiProfile * Chroma formats: - gst_vaapi_utils_h264_get_chroma_type(): Returns GstVaapiChromaType from H.264 chroma_format_idc value - gst_vaapi_utils_h264_get_chroma_format_idc(): Returns H.264 chroma_format_idc value from GstVaapiChromaType
This commit is contained in:
parent
44ead80f5f
commit
47dee4db96
4 changed files with 186 additions and 41 deletions
|
@ -69,6 +69,7 @@ libgstvaapi_source_c = \
|
||||||
gstvaapisurfacepool.c \
|
gstvaapisurfacepool.c \
|
||||||
gstvaapisurfaceproxy.c \
|
gstvaapisurfaceproxy.c \
|
||||||
gstvaapiutils.c \
|
gstvaapiutils.c \
|
||||||
|
gstvaapiutils_h264.c \
|
||||||
gstvaapivalue.c \
|
gstvaapivalue.c \
|
||||||
gstvaapivideopool.c \
|
gstvaapivideopool.c \
|
||||||
gstvaapiwindow.c \
|
gstvaapiwindow.c \
|
||||||
|
@ -120,6 +121,7 @@ libgstvaapi_source_priv_h = \
|
||||||
gstvaapisurface_priv.h \
|
gstvaapisurface_priv.h \
|
||||||
gstvaapisurfaceproxy_priv.h \
|
gstvaapisurfaceproxy_priv.h \
|
||||||
gstvaapiutils.h \
|
gstvaapiutils.h \
|
||||||
|
gstvaapiutils_h264.h \
|
||||||
gstvaapiversion.h \
|
gstvaapiversion.h \
|
||||||
gstvaapivideopool_priv.h \
|
gstvaapivideopool_priv.h \
|
||||||
gstvaapiwindow_priv.h \
|
gstvaapiwindow_priv.h \
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "gstvaapidecoder_priv.h"
|
#include "gstvaapidecoder_priv.h"
|
||||||
#include "gstvaapidisplay_priv.h"
|
#include "gstvaapidisplay_priv.h"
|
||||||
#include "gstvaapiobject_priv.h"
|
#include "gstvaapiobject_priv.h"
|
||||||
|
#include "gstvaapiutils_h264.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
@ -762,45 +763,6 @@ gst_vaapi_decoder_h264_create(GstVaapiDecoder *base_decoder)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
|
||||||
h264_get_profile(GstH264SPS *sps)
|
|
||||||
{
|
|
||||||
guint profile = 0;
|
|
||||||
|
|
||||||
switch (sps->profile_idc) {
|
|
||||||
case GST_H264_PROFILE_BASELINE:
|
|
||||||
profile = GST_VAAPI_PROFILE_H264_BASELINE;
|
|
||||||
break;
|
|
||||||
case GST_H264_PROFILE_MAIN:
|
|
||||||
profile = GST_VAAPI_PROFILE_H264_MAIN;
|
|
||||||
break;
|
|
||||||
case GST_H264_PROFILE_HIGH:
|
|
||||||
profile = GST_VAAPI_PROFILE_H264_HIGH;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
static guint
|
|
||||||
h264_get_chroma_type(GstH264SPS *sps)
|
|
||||||
{
|
|
||||||
guint chroma_type = 0;
|
|
||||||
|
|
||||||
switch (sps->chroma_format_idc) {
|
|
||||||
case 1:
|
|
||||||
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV422;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (!sps->separate_colour_plane_flag)
|
|
||||||
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV444;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return chroma_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstVaapiProfile
|
static GstVaapiProfile
|
||||||
get_profile(GstVaapiDecoderH264 *decoder, GstH264SPS *sps)
|
get_profile(GstVaapiDecoderH264 *decoder, GstH264SPS *sps)
|
||||||
{
|
{
|
||||||
|
@ -809,7 +771,7 @@ get_profile(GstVaapiDecoderH264 *decoder, GstH264SPS *sps)
|
||||||
GstVaapiProfile profile, profiles[2];
|
GstVaapiProfile profile, profiles[2];
|
||||||
guint i, n_profiles = 0;
|
guint i, n_profiles = 0;
|
||||||
|
|
||||||
profile = h264_get_profile(sps);
|
profile = gst_vaapi_utils_h264_get_profile(sps->profile_idc);
|
||||||
if (!profile)
|
if (!profile)
|
||||||
return GST_VAAPI_PROFILE_UNKNOWN;
|
return GST_VAAPI_PROFILE_UNKNOWN;
|
||||||
|
|
||||||
|
@ -857,7 +819,7 @@ ensure_context(GstVaapiDecoderH264 *decoder, GstH264SPS *sps)
|
||||||
priv->profile = profile;
|
priv->profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
chroma_type = h264_get_chroma_type(sps);
|
chroma_type = gst_vaapi_utils_h264_get_chroma_type(sps->chroma_format_idc);
|
||||||
if (!chroma_type || chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420) {
|
if (!chroma_type || chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420) {
|
||||||
GST_ERROR("unsupported chroma_format_idc %u", sps->chroma_format_idc);
|
GST_ERROR("unsupported chroma_format_idc %u", sps->chroma_format_idc);
|
||||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT;
|
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT;
|
||||||
|
|
127
gst-libs/gst/vaapi/gstvaapiutils_h264.c
Normal file
127
gst-libs/gst/vaapi/gstvaapiutils_h264.c
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* gstvaapiutils_h264.c - H.264 related utilities
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-2013 Intel Corporation
|
||||||
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@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 "sysdeps.h"
|
||||||
|
#include <gst/codecparsers/gsth264parser.h>
|
||||||
|
#include "gstvaapiutils_h264.h"
|
||||||
|
|
||||||
|
/** Returns GstVaapiProfile from H.264 profile_idc value */
|
||||||
|
GstVaapiProfile
|
||||||
|
gst_vaapi_utils_h264_get_profile (guint8 profile_idc)
|
||||||
|
{
|
||||||
|
GstVaapiProfile profile;
|
||||||
|
|
||||||
|
switch (profile_idc) {
|
||||||
|
case GST_H264_PROFILE_BASELINE:
|
||||||
|
profile = GST_VAAPI_PROFILE_H264_BASELINE;
|
||||||
|
break;
|
||||||
|
case GST_H264_PROFILE_MAIN:
|
||||||
|
profile = GST_VAAPI_PROFILE_H264_MAIN;
|
||||||
|
break;
|
||||||
|
case GST_H264_PROFILE_HIGH:
|
||||||
|
profile = GST_VAAPI_PROFILE_H264_HIGH;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert (0 && "unsupported profile_idc value");
|
||||||
|
profile = GST_VAAPI_PROFILE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns H.264 profile_idc value from GstVaapiProfile */
|
||||||
|
guint8
|
||||||
|
gst_vaapi_utils_h264_get_profile_idc (GstVaapiProfile profile)
|
||||||
|
{
|
||||||
|
guint8 profile_idc;
|
||||||
|
|
||||||
|
switch (profile) {
|
||||||
|
case GST_VAAPI_PROFILE_H264_BASELINE:
|
||||||
|
profile_idc = GST_H264_PROFILE_BASELINE;
|
||||||
|
break;
|
||||||
|
case GST_VAAPI_PROFILE_H264_MAIN:
|
||||||
|
profile_idc = GST_H264_PROFILE_MAIN;
|
||||||
|
break;
|
||||||
|
case GST_VAAPI_PROFILE_H264_HIGH:
|
||||||
|
profile_idc = GST_H264_PROFILE_HIGH;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert (0 && "unsupported GstVaapiProfile value");
|
||||||
|
profile_idc = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return profile_idc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns GstVaapiChromaType from H.264 chroma_format_idc value */
|
||||||
|
GstVaapiChromaType
|
||||||
|
gst_vaapi_utils_h264_get_chroma_type (guint chroma_format_idc)
|
||||||
|
{
|
||||||
|
GstVaapiChromaType chroma_type;
|
||||||
|
|
||||||
|
switch (chroma_format_idc) {
|
||||||
|
case 0:
|
||||||
|
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV400;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV422;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV444;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert (0 && "unsupported chroma_format_idc value");
|
||||||
|
chroma_type = (GstVaapiChromaType) 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return chroma_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns H.264 chroma_format_idc value from GstVaapiChromaType */
|
||||||
|
guint
|
||||||
|
gst_vaapi_utils_h264_get_chroma_format_idc (GstVaapiChromaType chroma_type)
|
||||||
|
{
|
||||||
|
guint chroma_format_idc;
|
||||||
|
|
||||||
|
switch (chroma_type) {
|
||||||
|
case GST_VAAPI_CHROMA_TYPE_YUV400:
|
||||||
|
chroma_format_idc = 0;
|
||||||
|
break;
|
||||||
|
case GST_VAAPI_CHROMA_TYPE_YUV420:
|
||||||
|
chroma_format_idc = 1;
|
||||||
|
break;
|
||||||
|
case GST_VAAPI_CHROMA_TYPE_YUV422:
|
||||||
|
chroma_format_idc = 2;
|
||||||
|
break;
|
||||||
|
case GST_VAAPI_CHROMA_TYPE_YUV444:
|
||||||
|
chroma_format_idc = 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert (0 && "unsupported GstVaapiChromaType value");
|
||||||
|
chroma_format_idc = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return chroma_format_idc;
|
||||||
|
}
|
54
gst-libs/gst/vaapi/gstvaapiutils_h264.h
Normal file
54
gst-libs/gst/vaapi/gstvaapiutils_h264.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* gstvaapiutils_h264.h - H.264 related utilities
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-2013 Intel Corporation
|
||||||
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@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_H264_H
|
||||||
|
#define GST_VAAPI_UTILS_H264_H
|
||||||
|
|
||||||
|
#include <va/va.h>
|
||||||
|
#include <gst/vaapi/gstvaapiprofile.h>
|
||||||
|
#include <gst/vaapi/gstvaapisurface.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* Returns GstVaapiProfile from H.264 profile_idc value */
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GstVaapiProfile
|
||||||
|
gst_vaapi_utils_h264_get_profile (guint8 profile_idc);
|
||||||
|
|
||||||
|
/* Returns H.264 profile_idc value from GstVaapiProfile */
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
guint8
|
||||||
|
gst_vaapi_utils_h264_get_profile_idc (GstVaapiProfile profile);
|
||||||
|
|
||||||
|
/* Returns GstVaapiChromaType from H.264 chroma_format_idc value */
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GstVaapiChromaType
|
||||||
|
gst_vaapi_utils_h264_get_chroma_type (guint chroma_format_idc);
|
||||||
|
|
||||||
|
/* Returns H.264 chroma_format_idc value from GstVaapiChromaType */
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
guint
|
||||||
|
gst_vaapi_utils_h264_get_chroma_format_idc (GstVaapiChromaType chroma_type);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GST_VAAPI_UTILS_H264_H */
|
Loading…
Reference in a new issue