2012-01-26 08:48:11 +00:00
|
|
|
/*
|
|
|
|
* gstvaapidecoder_objects.c - VA decoder objects helpers
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-01-29 13:14:45 +00:00
|
|
|
* Copyright (C) 2011-2013 Intel Corporation
|
2012-01-26 08:48:11 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-01-30 17:12:59 +00:00
|
|
|
#include "sysdeps.h"
|
2012-01-26 08:48:11 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <gst/vaapi/gstvaapicontext.h>
|
|
|
|
#include "gstvaapidecoder_objects.h"
|
|
|
|
#include "gstvaapidecoder_priv.h"
|
2013-04-16 16:56:24 +00:00
|
|
|
#include "gstvaapisurfaceproxy_priv.h"
|
2012-01-26 08:48:11 +00:00
|
|
|
#include "gstvaapicompat.h"
|
|
|
|
#include "gstvaapiutils.h"
|
|
|
|
|
|
|
|
#define DEBUG 1
|
|
|
|
#include "gstvaapidebug.h"
|
|
|
|
|
|
|
|
#define GET_DECODER(obj) GST_VAAPI_DECODER_CAST((obj)->parent_instance.codec)
|
2013-05-06 12:07:17 +00:00
|
|
|
#define GET_CONTEXT(obj) GET_DECODER(obj)->context
|
|
|
|
#define GET_VA_DISPLAY(obj) GET_DECODER(obj)->va_display
|
|
|
|
#define GET_VA_CONTEXT(obj) GET_DECODER(obj)->va_context
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2013-07-15 15:43:34 +00:00
|
|
|
static inline void
|
|
|
|
gst_video_codec_frame_clear(GstVideoCodecFrame **frame_ptr)
|
|
|
|
{
|
|
|
|
if (!*frame_ptr)
|
|
|
|
return;
|
|
|
|
gst_video_codec_frame_unref(*frame_ptr);
|
|
|
|
*frame_ptr = NULL;
|
|
|
|
}
|
|
|
|
|
2012-01-26 08:48:11 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Pictures --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
GST_VAAPI_CODEC_DEFINE_TYPE(GstVaapiPicture, gst_vaapi_picture);
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2012-03-28 14:05:58 +00:00
|
|
|
enum {
|
|
|
|
GST_VAAPI_CREATE_PICTURE_FLAG_CLONE = 1 << 0,
|
|
|
|
GST_VAAPI_CREATE_PICTURE_FLAG_FIELD = 1 << 1,
|
|
|
|
};
|
|
|
|
|
2012-01-26 08:48:11 +00:00
|
|
|
static void
|
|
|
|
destroy_slice_cb(gpointer data, gpointer user_data)
|
|
|
|
{
|
2012-12-03 10:19:08 +00:00
|
|
|
GstVaapiMiniObject * const object = data;
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
gst_vaapi_mini_object_unref(object);
|
2012-01-26 08:48:11 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
void
|
2012-01-26 08:48:11 +00:00
|
|
|
gst_vaapi_picture_destroy(GstVaapiPicture *picture)
|
|
|
|
{
|
|
|
|
if (picture->slices) {
|
|
|
|
g_ptr_array_foreach(picture->slices, destroy_slice_cb, NULL);
|
|
|
|
g_ptr_array_free(picture->slices, TRUE);
|
|
|
|
picture->slices = NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)&picture->iq_matrix,
|
|
|
|
NULL);
|
|
|
|
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)&picture->huf_table,
|
|
|
|
NULL);
|
|
|
|
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)&picture->bitplane,
|
|
|
|
NULL);
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2012-01-26 14:28:42 +00:00
|
|
|
if (picture->proxy) {
|
2012-12-03 12:46:28 +00:00
|
|
|
gst_vaapi_surface_proxy_unref(picture->proxy);
|
2012-01-26 14:28:42 +00:00
|
|
|
picture->proxy = NULL;
|
|
|
|
}
|
2012-01-26 08:48:11 +00:00
|
|
|
picture->surface_id = VA_INVALID_ID;
|
|
|
|
picture->surface = NULL;
|
|
|
|
|
|
|
|
vaapi_destroy_buffer(GET_VA_DISPLAY(picture), &picture->param_id);
|
|
|
|
picture->param = NULL;
|
2012-12-13 14:34:10 +00:00
|
|
|
|
2013-07-15 15:43:34 +00:00
|
|
|
gst_video_codec_frame_clear(&picture->frame);
|
2013-06-11 13:11:34 +00:00
|
|
|
gst_vaapi_picture_replace(&picture->parent_picture, NULL);
|
2012-01-26 08:48:11 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
gboolean
|
2012-01-26 08:48:11 +00:00
|
|
|
gst_vaapi_picture_create(
|
|
|
|
GstVaapiPicture *picture,
|
|
|
|
const GstVaapiCodecObjectConstructorArgs *args
|
|
|
|
)
|
|
|
|
{
|
2012-01-30 09:15:32 +00:00
|
|
|
gboolean success;
|
|
|
|
|
2012-03-28 14:05:58 +00:00
|
|
|
if (args->flags & GST_VAAPI_CREATE_PICTURE_FLAG_CLONE) {
|
|
|
|
GstVaapiPicture * const parent_picture = GST_VAAPI_PICTURE(args->data);
|
|
|
|
|
2013-06-11 13:11:34 +00:00
|
|
|
picture->parent_picture = gst_vaapi_picture_ref(parent_picture);
|
|
|
|
|
2012-12-03 12:46:28 +00:00
|
|
|
picture->proxy = gst_vaapi_surface_proxy_ref(parent_picture->proxy);
|
2012-03-28 14:05:58 +00:00
|
|
|
picture->type = parent_picture->type;
|
|
|
|
picture->pts = parent_picture->pts;
|
2012-03-30 15:03:28 +00:00
|
|
|
picture->poc = parent_picture->poc;
|
2012-03-28 14:05:58 +00:00
|
|
|
|
|
|
|
// Copy all picture flags but "output"
|
|
|
|
GST_VAAPI_PICTURE_FLAG_SET(
|
|
|
|
picture,
|
|
|
|
GST_VAAPI_PICTURE_FLAGS(parent_picture) &
|
|
|
|
(GST_VAAPI_PICTURE_FLAG_SKIPPED |
|
|
|
|
GST_VAAPI_PICTURE_FLAG_REFERENCE |
|
|
|
|
GST_VAAPI_PICTURE_FLAG_INTERLACED |
|
2012-03-28 15:50:28 +00:00
|
|
|
GST_VAAPI_PICTURE_FLAG_FF |
|
2012-03-28 14:05:58 +00:00
|
|
|
GST_VAAPI_PICTURE_FLAG_TFF)
|
|
|
|
);
|
|
|
|
|
|
|
|
picture->structure = parent_picture->structure;
|
|
|
|
if ((args->flags & GST_VAAPI_CREATE_PICTURE_FLAG_FIELD) &&
|
|
|
|
GST_VAAPI_PICTURE_IS_INTERLACED(picture)) {
|
|
|
|
switch (picture->structure) {
|
|
|
|
case GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD:
|
|
|
|
picture->structure = GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD;
|
|
|
|
break;
|
|
|
|
case GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD:
|
|
|
|
picture->structure = GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD;
|
|
|
|
break;
|
|
|
|
}
|
2012-03-28 15:50:28 +00:00
|
|
|
GST_VAAPI_PICTURE_FLAG_UNSET(picture, GST_VAAPI_PICTURE_FLAG_FF);
|
2012-03-28 14:05:58 +00:00
|
|
|
}
|
2013-02-15 16:42:12 +00:00
|
|
|
|
|
|
|
if (parent_picture->has_crop_rect) {
|
|
|
|
picture->has_crop_rect = TRUE;
|
|
|
|
picture->crop_rect = parent_picture->crop_rect;
|
|
|
|
}
|
2012-03-28 14:05:58 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-12-03 10:19:08 +00:00
|
|
|
picture->type = GST_VAAPI_PICTURE_TYPE_NONE;
|
|
|
|
picture->pts = GST_CLOCK_TIME_NONE;
|
|
|
|
|
2012-03-28 14:05:58 +00:00
|
|
|
picture->proxy =
|
2013-04-03 09:37:44 +00:00
|
|
|
gst_vaapi_context_get_surface_proxy(GET_CONTEXT(picture));
|
2012-03-28 14:05:58 +00:00
|
|
|
if (!picture->proxy)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
picture->structure = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
|
2012-03-28 15:50:28 +00:00
|
|
|
GST_VAAPI_PICTURE_FLAG_SET(picture, GST_VAAPI_PICTURE_FLAG_FF);
|
2012-03-28 14:05:58 +00:00
|
|
|
}
|
2013-04-16 16:56:24 +00:00
|
|
|
picture->surface = GST_VAAPI_SURFACE_PROXY_SURFACE(picture->proxy);
|
|
|
|
picture->surface_id = GST_VAAPI_SURFACE_PROXY_SURFACE_ID(picture->proxy);
|
2012-01-31 10:34:17 +00:00
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
picture->param_id = VA_INVALID_ID;
|
2012-01-30 09:15:32 +00:00
|
|
|
success = vaapi_create_buffer(
|
2012-01-26 08:48:11 +00:00
|
|
|
GET_VA_DISPLAY(picture),
|
|
|
|
GET_VA_CONTEXT(picture),
|
|
|
|
VAPictureParameterBufferType,
|
|
|
|
args->param_size,
|
2012-01-30 09:15:32 +00:00
|
|
|
args->param,
|
|
|
|
&picture->param_id,
|
|
|
|
&picture->param
|
2012-01-26 08:48:11 +00:00
|
|
|
);
|
2012-01-30 09:15:32 +00:00
|
|
|
if (!success)
|
2012-01-26 08:48:11 +00:00
|
|
|
return FALSE;
|
2012-03-28 14:05:58 +00:00
|
|
|
picture->param_size = args->param_size;
|
2012-01-26 08:48:11 +00:00
|
|
|
|
|
|
|
picture->slices = g_ptr_array_new();
|
|
|
|
if (!picture->slices)
|
|
|
|
return FALSE;
|
2012-11-29 14:06:00 +00:00
|
|
|
|
2012-12-13 14:34:10 +00:00
|
|
|
picture->frame = gst_video_codec_frame_ref(
|
|
|
|
GST_VAAPI_DECODER_CODEC_FRAME(GET_DECODER(picture)));
|
2012-01-26 08:48:11 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GstVaapiPicture *
|
|
|
|
gst_vaapi_picture_new(
|
|
|
|
GstVaapiDecoder *decoder,
|
|
|
|
gconstpointer param,
|
|
|
|
guint param_size
|
|
|
|
)
|
|
|
|
{
|
|
|
|
GstVaapiCodecObject *object;
|
|
|
|
|
|
|
|
object = gst_vaapi_codec_object_new(
|
2012-12-03 10:19:08 +00:00
|
|
|
&GstVaapiPictureClass,
|
2012-01-26 08:48:11 +00:00
|
|
|
GST_VAAPI_CODEC_BASE(decoder),
|
|
|
|
param, param_size,
|
2012-12-03 10:19:08 +00:00
|
|
|
NULL, 0,
|
|
|
|
0
|
2012-01-26 08:48:11 +00:00
|
|
|
);
|
|
|
|
if (!object)
|
|
|
|
return NULL;
|
|
|
|
return GST_VAAPI_PICTURE_CAST(object);
|
|
|
|
}
|
|
|
|
|
2012-03-28 14:05:58 +00:00
|
|
|
GstVaapiPicture *
|
|
|
|
gst_vaapi_picture_new_field(GstVaapiPicture *picture)
|
|
|
|
{
|
2012-12-03 10:19:08 +00:00
|
|
|
GstVaapiDecoder * const decoder = GET_DECODER(picture);
|
|
|
|
GstVaapiCodecObject *object;
|
2012-03-28 14:05:58 +00:00
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
object = gst_vaapi_codec_object_new(
|
|
|
|
gst_vaapi_codec_object_get_class(&picture->parent_instance),
|
|
|
|
GST_VAAPI_CODEC_BASE(decoder),
|
|
|
|
NULL, picture->param_size,
|
|
|
|
picture, 0,
|
|
|
|
(GST_VAAPI_CREATE_PICTURE_FLAG_CLONE|
|
|
|
|
GST_VAAPI_CREATE_PICTURE_FLAG_FIELD)
|
|
|
|
);
|
|
|
|
if (!object)
|
2012-03-28 14:05:58 +00:00
|
|
|
return NULL;
|
2012-12-03 10:19:08 +00:00
|
|
|
return GST_VAAPI_PICTURE_CAST(object);
|
2012-03-28 14:05:58 +00:00
|
|
|
}
|
|
|
|
|
2012-01-26 08:48:11 +00:00
|
|
|
void
|
|
|
|
gst_vaapi_picture_add_slice(GstVaapiPicture *picture, GstVaapiSlice *slice)
|
|
|
|
{
|
|
|
|
g_return_if_fail(GST_VAAPI_IS_PICTURE(picture));
|
|
|
|
g_return_if_fail(GST_VAAPI_IS_SLICE(slice));
|
|
|
|
|
|
|
|
g_ptr_array_add(picture->slices, slice);
|
|
|
|
}
|
|
|
|
|
2012-02-13 09:10:35 +00:00
|
|
|
static gboolean
|
|
|
|
do_decode(VADisplay dpy, VAContextID ctx, VABufferID *buf_id, void **buf_ptr)
|
|
|
|
{
|
|
|
|
VAStatus status;
|
|
|
|
|
|
|
|
vaapi_unmap_buffer(dpy, *buf_id, buf_ptr);
|
|
|
|
|
|
|
|
status = vaRenderPicture(dpy, ctx, buf_id, 1);
|
|
|
|
if (!vaapi_check_status(status, "vaRenderPicture()"))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* XXX: vaRenderPicture() is meant to destroy the VA buffer implicitly */
|
|
|
|
vaapi_destroy_buffer(dpy, buf_id);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-26 08:48:11 +00:00
|
|
|
gboolean
|
|
|
|
gst_vaapi_picture_decode(GstVaapiPicture *picture)
|
|
|
|
{
|
|
|
|
GstVaapiIqMatrix *iq_matrix;
|
|
|
|
GstVaapiBitPlane *bitplane;
|
2012-02-09 16:21:04 +00:00
|
|
|
GstVaapiHuffmanTable *huf_table;
|
2012-01-26 08:48:11 +00:00
|
|
|
VADisplay va_display;
|
|
|
|
VAContextID va_context;
|
|
|
|
VAStatus status;
|
2012-02-13 09:10:35 +00:00
|
|
|
guint i;
|
2012-01-26 08:48:11 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail(GST_VAAPI_IS_PICTURE(picture), FALSE);
|
|
|
|
|
|
|
|
va_display = GET_VA_DISPLAY(picture);
|
|
|
|
va_context = GET_VA_CONTEXT(picture);
|
|
|
|
|
|
|
|
GST_DEBUG("decode picture 0x%08x", picture->surface_id);
|
|
|
|
|
|
|
|
status = vaBeginPicture(va_display, va_context, picture->surface_id);
|
|
|
|
if (!vaapi_check_status(status, "vaBeginPicture()"))
|
|
|
|
return FALSE;
|
|
|
|
|
2012-02-13 09:10:35 +00:00
|
|
|
if (!do_decode(va_display, va_context, &picture->param_id, &picture->param))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
iq_matrix = picture->iq_matrix;
|
|
|
|
if (iq_matrix && !do_decode(va_display, va_context,
|
|
|
|
&iq_matrix->param_id, &iq_matrix->param))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
bitplane = picture->bitplane;
|
|
|
|
if (bitplane && !do_decode(va_display, va_context,
|
|
|
|
&bitplane->data_id, (void **)&bitplane->data))
|
2012-01-26 08:48:11 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-02-09 16:21:04 +00:00
|
|
|
huf_table = picture->huf_table;
|
|
|
|
if (huf_table && !do_decode(va_display, va_context,
|
|
|
|
&huf_table->param_id,
|
|
|
|
(void **)&huf_table->param))
|
|
|
|
return FALSE;
|
|
|
|
|
2012-01-26 08:48:11 +00:00
|
|
|
for (i = 0; i < picture->slices->len; i++) {
|
|
|
|
GstVaapiSlice * const slice = g_ptr_array_index(picture->slices, i);
|
2012-02-13 09:10:35 +00:00
|
|
|
VABufferID va_buffers[2];
|
2012-01-26 08:48:11 +00:00
|
|
|
|
|
|
|
vaapi_unmap_buffer(va_display, slice->param_id, NULL);
|
|
|
|
va_buffers[0] = slice->param_id;
|
|
|
|
va_buffers[1] = slice->data_id;
|
|
|
|
|
2012-02-13 09:10:35 +00:00
|
|
|
status = vaRenderPicture(va_display, va_context, va_buffers, 2);
|
2012-01-26 08:48:11 +00:00
|
|
|
if (!vaapi_check_status(status, "vaRenderPicture()"))
|
|
|
|
return FALSE;
|
2012-02-13 09:10:35 +00:00
|
|
|
|
|
|
|
vaapi_destroy_buffer(va_display, &slice->param_id);
|
|
|
|
vaapi_destroy_buffer(va_display, &slice->data_id);
|
2012-01-26 08:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
status = vaEndPicture(va_display, va_context);
|
|
|
|
if (!vaapi_check_status(status, "vaEndPicture()"))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-06-11 13:11:34 +00:00
|
|
|
static gboolean
|
|
|
|
do_output(GstVaapiPicture *picture)
|
2012-01-26 08:48:11 +00:00
|
|
|
{
|
2013-04-16 16:56:24 +00:00
|
|
|
GstVideoCodecFrame * const out_frame = picture->frame;
|
2012-01-26 08:48:11 +00:00
|
|
|
GstVaapiSurfaceProxy *proxy;
|
2013-04-16 16:56:24 +00:00
|
|
|
guint flags = 0;
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2013-06-11 13:11:34 +00:00
|
|
|
if (GST_VAAPI_PICTURE_IS_OUTPUT(picture))
|
|
|
|
return TRUE;
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2012-01-31 10:34:17 +00:00
|
|
|
if (!picture->proxy)
|
|
|
|
return FALSE;
|
2012-01-26 13:54:31 +00:00
|
|
|
|
2012-12-13 14:34:10 +00:00
|
|
|
proxy = gst_vaapi_surface_proxy_ref(picture->proxy);
|
2013-02-15 16:42:12 +00:00
|
|
|
|
|
|
|
if (picture->has_crop_rect)
|
|
|
|
gst_vaapi_surface_proxy_set_crop_rect(proxy, &picture->crop_rect);
|
|
|
|
|
2012-12-13 14:34:10 +00:00
|
|
|
gst_video_codec_frame_set_user_data(out_frame,
|
|
|
|
proxy, (GDestroyNotify)gst_vaapi_mini_object_unref);
|
|
|
|
|
2013-01-03 12:05:47 +00:00
|
|
|
out_frame->pts = picture->pts;
|
2013-04-16 16:56:24 +00:00
|
|
|
|
2012-12-13 14:34:10 +00:00
|
|
|
if (GST_VAAPI_PICTURE_IS_SKIPPED(picture))
|
|
|
|
GST_VIDEO_CODEC_FRAME_FLAG_SET(out_frame,
|
|
|
|
GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY);
|
2013-04-16 16:56:24 +00:00
|
|
|
|
|
|
|
if (GST_VAAPI_PICTURE_IS_INTERLACED(picture)) {
|
|
|
|
flags |= GST_VAAPI_SURFACE_PROXY_FLAG_INTERLACED;
|
|
|
|
if (GST_VAAPI_PICTURE_IS_TFF(picture))
|
|
|
|
flags |= GST_VAAPI_SURFACE_PROXY_FLAG_TFF;
|
|
|
|
}
|
|
|
|
GST_VAAPI_SURFACE_PROXY_FLAG_SET(proxy, flags);
|
2012-12-13 14:34:10 +00:00
|
|
|
|
|
|
|
gst_vaapi_decoder_push_frame(GET_DECODER(picture), out_frame);
|
2013-07-15 15:43:34 +00:00
|
|
|
gst_video_codec_frame_clear(&picture->frame);
|
2012-12-13 14:34:10 +00:00
|
|
|
|
2012-03-28 12:28:26 +00:00
|
|
|
GST_VAAPI_PICTURE_FLAG_SET(picture, GST_VAAPI_PICTURE_FLAG_OUTPUT);
|
2012-01-26 13:54:31 +00:00
|
|
|
return TRUE;
|
2012-01-26 08:48:11 +00:00
|
|
|
}
|
|
|
|
|
2013-06-11 13:11:34 +00:00
|
|
|
gboolean
|
|
|
|
gst_vaapi_picture_output(GstVaapiPicture *picture)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail(GST_VAAPI_IS_PICTURE(picture), FALSE);
|
|
|
|
|
|
|
|
if (G_UNLIKELY(picture->parent_picture)) {
|
|
|
|
/* Emit the first field to GstVideoDecoder so that to release
|
|
|
|
the underlying GstVideoCodecFrame. However, mark this
|
|
|
|
picture as skipped so that to not display it */
|
|
|
|
GstVaapiPicture * const parent_picture = picture->parent_picture;
|
|
|
|
do {
|
|
|
|
if (!GST_VAAPI_PICTURE_IS_INTERLACED(parent_picture))
|
|
|
|
break;
|
|
|
|
if (!GST_VAAPI_PICTURE_IS_FIRST_FIELD(parent_picture))
|
|
|
|
break;
|
|
|
|
GST_VAAPI_PICTURE_FLAG_SET(parent_picture,
|
|
|
|
GST_VAAPI_PICTURE_FLAG_SKIPPED);
|
|
|
|
if (!do_output(parent_picture))
|
|
|
|
return FALSE;
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
return do_output(picture);
|
|
|
|
}
|
|
|
|
|
2013-02-15 16:42:12 +00:00
|
|
|
void
|
|
|
|
gst_vaapi_picture_set_crop_rect(GstVaapiPicture *picture,
|
|
|
|
const GstVaapiRectangle *crop_rect)
|
|
|
|
{
|
|
|
|
g_return_if_fail(GST_VAAPI_IS_PICTURE(picture));
|
|
|
|
|
|
|
|
picture->has_crop_rect = crop_rect != NULL;
|
|
|
|
if (picture->has_crop_rect)
|
|
|
|
picture->crop_rect = *crop_rect;
|
|
|
|
}
|
|
|
|
|
2012-01-26 08:48:11 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Slices --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
GST_VAAPI_CODEC_DEFINE_TYPE(GstVaapiSlice, gst_vaapi_slice);
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
void
|
2012-01-26 08:48:11 +00:00
|
|
|
gst_vaapi_slice_destroy(GstVaapiSlice *slice)
|
|
|
|
{
|
|
|
|
VADisplay const va_display = GET_VA_DISPLAY(slice);
|
|
|
|
|
|
|
|
vaapi_destroy_buffer(va_display, &slice->data_id);
|
|
|
|
vaapi_destroy_buffer(va_display, &slice->param_id);
|
|
|
|
slice->param = NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
gboolean
|
2012-01-26 08:48:11 +00:00
|
|
|
gst_vaapi_slice_create(
|
|
|
|
GstVaapiSlice *slice,
|
|
|
|
const GstVaapiCodecObjectConstructorArgs *args
|
|
|
|
)
|
|
|
|
{
|
|
|
|
VASliceParameterBufferBase *slice_param;
|
2012-01-30 09:15:32 +00:00
|
|
|
gboolean success;
|
2012-01-26 08:48:11 +00:00
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
slice->data_id = VA_INVALID_ID;
|
2012-01-30 09:15:32 +00:00
|
|
|
success = vaapi_create_buffer(
|
2012-01-26 08:48:11 +00:00
|
|
|
GET_VA_DISPLAY(slice),
|
|
|
|
GET_VA_CONTEXT(slice),
|
|
|
|
VASliceDataBufferType,
|
|
|
|
args->data_size,
|
2012-01-30 09:15:32 +00:00
|
|
|
args->data,
|
|
|
|
&slice->data_id,
|
|
|
|
NULL
|
2012-01-26 08:48:11 +00:00
|
|
|
);
|
2012-01-30 09:15:32 +00:00
|
|
|
if (!success)
|
2012-01-26 08:48:11 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-12-03 10:19:08 +00:00
|
|
|
slice->param_id = VA_INVALID_ID;
|
2012-01-30 09:15:32 +00:00
|
|
|
success = vaapi_create_buffer(
|
2012-01-26 08:48:11 +00:00
|
|
|
GET_VA_DISPLAY(slice),
|
|
|
|
GET_VA_CONTEXT(slice),
|
|
|
|
VASliceParameterBufferType,
|
|
|
|
args->param_size,
|
2012-01-30 09:15:32 +00:00
|
|
|
args->param,
|
|
|
|
&slice->param_id,
|
|
|
|
&slice->param
|
2012-01-26 08:48:11 +00:00
|
|
|
);
|
2012-01-30 09:15:32 +00:00
|
|
|
if (!success)
|
2012-01-26 08:48:11 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
slice_param = slice->param;
|
|
|
|
slice_param->slice_data_size = args->data_size;
|
|
|
|
slice_param->slice_data_offset = 0;
|
|
|
|
slice_param->slice_data_flag = VA_SLICE_DATA_FLAG_ALL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GstVaapiSlice *
|
|
|
|
gst_vaapi_slice_new(
|
|
|
|
GstVaapiDecoder *decoder,
|
|
|
|
gconstpointer param,
|
|
|
|
guint param_size,
|
|
|
|
const guchar *data,
|
|
|
|
guint data_size
|
|
|
|
)
|
|
|
|
{
|
|
|
|
GstVaapiCodecObject *object;
|
|
|
|
|
|
|
|
object = gst_vaapi_codec_object_new(
|
2012-12-03 10:19:08 +00:00
|
|
|
&GstVaapiSliceClass,
|
2012-01-26 08:48:11 +00:00
|
|
|
GST_VAAPI_CODEC_BASE(decoder),
|
|
|
|
param, param_size,
|
2012-12-03 10:19:08 +00:00
|
|
|
data, data_size,
|
|
|
|
0
|
2012-01-26 08:48:11 +00:00
|
|
|
);
|
|
|
|
return GST_VAAPI_SLICE_CAST(object);
|
|
|
|
}
|