Commit e7e5c74a authored by Sreerenj Balachandran's avatar Sreerenj Balachandran Committed by Gwenole Beauchesne

decoder: use GstVideoCodecState.

Use standard GstVideoCodecState throughout GstVaapiDecoder and expose
it with a new gst_vaapi_decoder_get_codec_state() function. This makes
it possible to drop picture size (width, height) information, framerate
(fps_n, fps_d) information, pixel aspect ratio (par_n, par_d) information,
and interlace mode (is_interlaced field).

This is a new API with backwards compatibility maintained. In particular,
gst_vaapi_decoder_get_caps() is still available.
Signed-off-by: default avatarSreerenj Balachandran <sreerenj.balachandran@intel.com>
Signed-off-by: default avatarGwenole Beauchesne <gwenole.beauchesne@intel.com>
parent 14a6e0f6
This diff is collapsed.
......@@ -131,6 +131,9 @@ gst_vaapi_decoder_get_type(void) G_GNUC_CONST;
GstVaapiCodec
gst_vaapi_decoder_get_codec(GstVaapiDecoder *decoder);
GstVideoCodecState *
gst_vaapi_decoder_get_codec_state(GstVaapiDecoder *decoder);
GstCaps *
gst_vaapi_decoder_get_caps(GstVaapiDecoder *decoder);
......
......@@ -76,6 +76,18 @@ G_BEGIN_DECLS
#define GST_VAAPI_DECODER_CODEC(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->codec
/**
* GST_VAAPI_DECODER_CODEC_STATE:
* @decoder: a #GstVaapiDecoder
*
* Macro that evaluates to the #GstVideoCodecState holding codec state
* for @decoder.
* This is an internal macro that does not do any run-time type check.
*/
#undef GST_VAAPI_DECODER_CODEC_STATE
#define GST_VAAPI_DECODER_CODEC_STATE(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->codec_state
/**
* GST_VAAPI_DECODER_CODEC_DATA:
* @decoder: a #GstVaapiDecoder
......@@ -86,7 +98,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DECODER_CODEC_DATA
#define GST_VAAPI_DECODER_CODEC_DATA(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->codec_data
GST_VAAPI_DECODER_CODEC_STATE(decoder)->codec_data
/**
* GST_VAAPI_DECODER_CODEC_FRAME:
......@@ -109,7 +121,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DECODER_WIDTH
#define GST_VAAPI_DECODER_WIDTH(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->width
GST_VAAPI_DECODER_CODEC_STATE(decoder)->info.width
/**
* GST_VAAPI_DECODER_HEIGHT:
......@@ -120,7 +132,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DECODER_HEIGHT
#define GST_VAAPI_DECODER_HEIGHT(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->height
GST_VAAPI_DECODER_CODEC_STATE(decoder)->info.height
/* End-of-Stream buffer */
#define GST_BUFFER_FLAG_EOS (GST_BUFFER_FLAG_LAST + 0)
......@@ -148,19 +160,11 @@ struct _GstVaapiDecoderPrivate {
VADisplay va_display;
GstVaapiContext *context;
VAContextID va_context;
GstCaps *caps;
GstVaapiCodec codec;
GstBuffer *codec_data;
guint width;
guint height;
guint fps_n;
guint fps_d;
guint par_n;
guint par_d;
GstVideoCodecState *codec_state;
GQueue *buffers;
GQueue *surfaces;
GstVaapiParserState parser_state;
guint is_interlaced : 1;
};
G_GNUC_INTERNAL
......@@ -187,6 +191,11 @@ gst_vaapi_decoder_set_pixel_aspect_ratio(
guint par_d
);
G_GNUC_INTERNAL
void
gst_vaapi_decoder_set_interlace_mode(GstVaapiDecoder *decoder,
GstVideoInterlaceMode mode);
G_GNUC_INTERNAL
void
gst_vaapi_decoder_set_interlaced(GstVaapiDecoder *decoder, gboolean interlaced);
......
......@@ -1133,15 +1133,15 @@ decode_codec_data(GstVaapiDecoderVC1 *decoder, GstBuffer *buffer)
if (!buf || buf_size == 0)
return GST_VAAPI_DECODER_STATUS_SUCCESS;
caps = GST_VAAPI_DECODER_CAST(decoder)->priv->caps;
structure = gst_caps_get_structure(caps, 0);
if (!gst_structure_get_int(structure, "width", &width) ||
!gst_structure_get_int(structure, "height", &height)) {
width = GST_VAAPI_DECODER_WIDTH(decoder);
height = GST_VAAPI_DECODER_HEIGHT(decoder);
if (!width || !height) {
GST_DEBUG("failed to parse size from codec-data");
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
}
caps = GST_VAAPI_DECODER_CODEC_STATE(decoder)->caps;
structure = gst_caps_get_structure(caps, 0);
if (!gst_structure_get_fourcc(structure, "format", &format)) {
GST_DEBUG("failed to parse profile from codec-data");
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC;
......
......@@ -210,7 +210,7 @@ gst_vaapi_profile_from_codec_data(GstVaapiCodec codec, GstBuffer *buffer)
* Return value: the #GstVaapiProfile describing the @caps
*/
GstVaapiProfile
gst_vaapi_profile_from_caps(GstCaps *caps)
gst_vaapi_profile_from_caps(const GstCaps *caps)
{
const GstVaapiProfileMap *m;
GstCaps *caps_test;
......
......@@ -134,7 +134,7 @@ GstVaapiProfile
gst_vaapi_profile(VAProfile profile);
GstVaapiProfile
gst_vaapi_profile_from_caps(GstCaps *caps);
gst_vaapi_profile_from_caps(const GstCaps *caps);
VAProfile
gst_vaapi_profile_get_va_profile(GstVaapiProfile profile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment