diff --git a/configure.ac b/configure.ac index ca8bddf9fd..43bcbc0475 100644 --- a/configure.ac +++ b/configure.ac @@ -2054,51 +2054,6 @@ AG_GST_CHECK_FEATURE(DVB, [DVB Source], dvb, [ ], [HAVE_DVB="no"]) ]) -dnl *** vdpau *** -translit(dnm, m, l) AM_CONDITIONAL(USE_VDPAU, true) -AG_GST_CHECK_FEATURE(VDPAU, [VDPAU], vdpau, [ - VDPAU_CFLAGS= - VDPAU_LIBS=-lvdpau - HAVE_VDPAU=no - - PKG_CHECK_MODULES(VDPAU, vdpau, [HAVE_VDPAU="yes"], - [ - if test "$HAVE_VDPAU" = "no"; then - saved_CPPFLAGS="$CPPFLAGS" - AC_CHECK_HEADER([vdpau/vdpau.h], [HAVE_VDPAU_H=yes]) - - if test -z "$HAVE_VDPAU_H"; then - dnl Didn't find VDPAU header straight away. - dnl Try /usr/include/nvidia. Need to clear caching vars first - AC_MSG_NOTICE([VDPAU header not in standard path. Checking /usr/include/nvidia]) - unset ac_cv_header_vdpau_vdpau_h - unset ac_cv_header_vdpau_vdpau_x11_h - VDPAU_CFLAGS="-I/usr/include/nvidia" - VDPAU_LIBS="-L/usr/lib/nvidia -lvdpau" - CPPFLAGS="$VDPAU_CFLAGS $saved_CPPFLAGS" - AC_CHECK_HEADER([vdpau/vdpau.h], [HAVE_VDPAU_H=yes]) - fi - - AC_CHECK_HEADER([vdpau/vdpau_x11.h], [HAVE_VDPAU_X11_H=yes]) - - if test "x$HAVE_VDPAU_H" = "xyes" -a "x$HAVE_VDPAU_X11_H" = "xyes"; then - dnl Found the headers - look for the lib - AC_MSG_NOTICE([VDPAU headers found. Checking libraries]) - saved_LIBS="$LIBS" - LIBS="$VDPAU_LIBS $saved_LIBS" - AC_CHECK_LIB(vdpau,vdp_device_create_x11,[HAVE_VDPAU="yes"]) - LIBS="$saved_LIBS" - fi - fi - ]) - - if test "$HAVE_VDPAU" = "yes"; then - AC_MSG_NOTICE([Found up to date VDPAU installation]) - AC_SUBST(VDPAU_CFLAGS) - AC_SUBST(VDPAU_LIBS) - fi -]) - dnl *** sbc *** translit(dnm, m, l) AM_CONDITIONAL(USE_SBC, true) AG_GST_CHECK_FEATURE(SBC, [SBC bluetooth audio codec], sbc, [ @@ -2318,7 +2273,6 @@ AM_CONDITIONAL(USE_SRTP, false) AM_CONDITIONAL(USE_SRT, false) AM_CONDITIONAL(USE_GME, false) AM_CONDITIONAL(USE_DVB, false) -AM_CONDITIONAL(USE_VDPAU, false) AM_CONDITIONAL(USE_SBC, false) AM_CONDITIONAL(USE_ZBAR, false) AM_CONDITIONAL(USE_RSVG, false) @@ -2539,7 +2493,6 @@ sys/opensles/Makefile sys/shm/Makefile sys/tinyalsa/Makefile sys/uvch264/Makefile -sys/vdpau/Makefile sys/wasapi/Makefile sys/winks/Makefile sys/winscreencap/Makefile diff --git a/docs/plugins/gst_plugins_cache.json b/docs/plugins/gst_plugins_cache.json index 4b1f22b307..a3e55f1b79 100644 --- a/docs/plugins/gst_plugins_cache.json +++ b/docs/plugins/gst_plugins_cache.json @@ -47188,54 +47188,6 @@ "source": "gst-plugins-bad", "url": "Unknown package origin" }, - "vdpau": { - "description": "Various elements utilizing VDPAU", - "elements": { - "vdpaumpegdec": { - "author": "Carl-Anton Ingmarsson ", - "description": "Decode mpeg stream with vdpau", - "hierarchy": [ - "GstVdpMpegDec", - "GstVdpDecoder", - "GstVideoDecoder", - "GstElement", - "GstObject", - "GInitiallyUnowned", - "GObject" - ], - "klass": "Decoder", - "long-name": "VDPAU Mpeg Decoder", - "pad-templates": { - "sink": { - "caps": "video/mpeg:\n mpegversion: [ 1, 2 ]\n systemstream: false\n", - "direction": "sink", - "presence": "always" - }, - "src": { - "caps": "video/x-raw(memory:VdpVideoSurface):\n format: { YV12 }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-raw:\n format: { YV12 }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n", - "direction": "src", - "presence": "always" - } - }, - "properties": { - "display": { - "blurb": "X Display name", - "construct": true, - "construct-only": false, - "default": "NULL", - "type-name": "gchararray", - "writable": true - } - }, - "rank": "none" - } - }, - "filename": "gstvdpau", - "license": "LGPL", - "package": "GStreamer Bad Plug-ins git", - "source": "gst-plugins-bad", - "url": "Unknown package origin" - }, "videofiltersbad": { "description": "Video filters in gst-plugins-bad", "elements": { diff --git a/meson_options.txt b/meson_options.txt index 0c30c253d6..5531d70e73 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -144,7 +144,6 @@ option('teletext', type : 'feature', value : 'auto', description : 'Teletext plu option('tinyalsa', type : 'feature', value : 'auto', description : 'TinyALSA plugin') option('ttml', type : 'feature', value : 'auto', description : 'TTML subtitle parser and renderer plugin') option('uvch264', type : 'feature', value : 'auto', description : 'UVC compliant H.264 camera source plugin') -option('vdpau', type : 'feature', value : 'auto', description : 'Nvidia VDPAU plugin') option('voaacenc', type : 'feature', value : 'auto', description : 'AAC audio encoder plugin') option('voamrwbenc', type : 'feature', value : 'auto', description : 'AMR-WB audio encoder plugin') option('vulkan', type : 'feature', value : 'auto', description : 'Vulkan video sink plugin') diff --git a/sys/Makefile.am b/sys/Makefile.am index 42523b4b44..8365bd2947 100644 --- a/sys/Makefile.am +++ b/sys/Makefile.am @@ -82,12 +82,6 @@ else OPENSLES_DIR= endif -if USE_VDPAU -VDPAU_DIR=vdpau -else -VDPAU_DIR= -endif - if USE_WINSCREENCAP WINSCREENCAP_DIR=winscreencap else @@ -124,10 +118,10 @@ else MSDK_DIR= endif -SUBDIRS = $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(BLUEZ_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTSOUND_DIR) $(WINKS_DIR) $(DVB_DIR) $(FBDEV_DIR) $(IPCPIPELINE_DIR) $(KMS_DIR) $(OPENSLES_DIR) $(SHM_DIR) $(UVCH264_DIR) $(VDPAU_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR) $(NVDEC_DIR) $(NVENC_DIR) $(TINYALSA_DIR) $(MSDK_DIR) +SUBDIRS = $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(BLUEZ_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTSOUND_DIR) $(WINKS_DIR) $(DVB_DIR) $(FBDEV_DIR) $(IPCPIPELINE_DIR) $(KMS_DIR) $(OPENSLES_DIR) $(SHM_DIR) $(UVCH264_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR) $(NVDEC_DIR) $(NVENC_DIR) $(TINYALSA_DIR) $(MSDK_DIR) DIST_SUBDIRS = androidmedia applemedia bluez d3dvideosink decklink directsound dvb fbdev ipcpipeline kms dshowdecwrapper dshowsrcwrapper dshowvideosink \ - opensles shm uvch264 vdpau wasapi winks winscreencap \ + opensles shm uvch264 wasapi winks winscreencap \ nvdec nvenc tinyalsa msdk include $(top_srcdir)/common/parallel-subdirs.mak diff --git a/sys/meson.build b/sys/meson.build index ba717da7da..a42e872fd2 100644 --- a/sys/meson.build +++ b/sys/meson.build @@ -16,7 +16,6 @@ subdir('opensles') subdir('shm') subdir('tinyalsa') subdir('uvch264') -subdir('vdpau') subdir('wasapi') subdir('winks') subdir('winscreencap') diff --git a/sys/vdpau/Makefile.am b/sys/vdpau/Makefile.am deleted file mode 100644 index dd6263f3d4..0000000000 --- a/sys/vdpau/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -plugin_LTLIBRARIES = libgstvdpau.la - -libgstvdpau_la_SOURCES = \ - gstvdpau.c \ - gstvdputils.c \ - gstvdpvideomemory.c \ - gstvdpvideobufferpool.c \ - gstvdpdevice.c \ - gstvdpdecoder.c \ - mpeg/gstvdpmpegdec.c - # \ - # h264/gsth264dpb.c \ - # h264/gstvdph264dec.c - - -libgstvdpau_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ - $(GST_CFLAGS) $(X11_CFLAGS) $(VDPAU_CFLAGS) - -libgstvdpau_la_LIBADD = \ - $(top_builddir)/gst-libs/gst/codecparsers/libgstcodecparsers-$(GST_API_VERSION).la \ - $(GST_LIBS) $(GST_BASE_LIBS) \ - $(GST_PLUGINS_BASE_LIBS) $(X11_LIBS) -lgstvideo-$(GST_API_VERSION) \ - $(VDPAU_LIBS) $(LIBM) - -libgstvdpau_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) - -noinst_HEADERS = \ - gstvdputils.h \ - gstvdpvideomemory.h \ - gstvdpvideobufferpool.h \ - gstvdpdevice.h \ - gstvdpdecoder.h \ - gstvdpoutputbuffer.h \ - gstvdpvideopostprocess.h \ - gstvdpsink.h \ - mpeg/gstvdpmpegdec.h \ - mpeg4/mpeg4util.h \ - mpeg4/gstmpeg4frame.h \ - mpeg4/gstvdpmpeg4dec.h - - # h264/gsth264dpb.h \ - # h264/gstvdph264dec.h - diff --git a/sys/vdpau/gstvdpau.c b/sys/vdpau/gstvdpau.c deleted file mode 100644 index 49207e5071..0000000000 --- a/sys/vdpau/gstvdpau.c +++ /dev/null @@ -1,49 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - - -#include - -#include "gstvdpdevice.h" -#include "gstvdpvideomemory.h" -#include "gstvdpoutputbuffer.h" -#include "gstvdpdecoder.h" - -#include "mpeg/gstvdpmpegdec.h" -/* #include "h264/gstvdph264dec.h" */ -#include "mpeg4/gstvdpmpeg4dec.h" -#include "gstvdpvideopostprocess.h" -#include "gstvdpsink.h" - -static gboolean -vdpau_init (GstPlugin * vdpau_plugin) -{ - gboolean ret; - - /* do this so debug categories get created */ - gst_vdp_device_get_type (); - gst_vdp_decoder_get_type (); - gst_vdp_video_memory_init (); - - /* Before giving these elements a rank again, make sure they pass at - * least the generic/states test when there's no device available */ - ret = gst_element_register (vdpau_plugin, "vdpaumpegdec", - GST_RANK_NONE, GST_TYPE_VDP_MPEG_DEC); - /* ret &= gst_element_register (vdpau_plugin, "vdpauh264dec", */ - /* GST_RANK_NONE, GST_TYPE_VDP_H264_DEC); */ - /* gst_element_register (vdpau_plugin, "vdpaumpeg4dec", */ - /* GST_RANK_NONE, GST_TYPE_VDP_MPEG4_DEC); */ - /* gst_element_register (vdpau_plugin, "vdpauvideopostprocess", */ - /* GST_RANK_NONE, GST_TYPE_VDP_VIDEO_POST_PROCESS); */ - /* gst_element_register (vdpau_plugin, "vdpausink", */ - /* GST_RANK_NONE, GST_TYPE_VDP_SINK); */ - - return ret; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - vdpau, - "Various elements utilizing VDPAU", - vdpau_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/sys/vdpau/gstvdpdecoder.c b/sys/vdpau/gstvdpdecoder.c deleted file mode 100644 index c3892f235c..0000000000 --- a/sys/vdpau/gstvdpdecoder.c +++ /dev/null @@ -1,369 +0,0 @@ -/* GStreamer -* -* Copyright (C) 2009 Carl-Anton Ingmarsson . -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 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 -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public -* License along with this library; if not, write to the -* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -* Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstvdpdecoder.h" -#include "gstvdpvideomemory.h" -#include "gstvdpvideobufferpool.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_decoder_debug); -#define GST_CAT_DEFAULT gst_vdp_decoder_debug - -#define DEBUG_INIT \ - GST_DEBUG_CATEGORY_INIT (gst_vdp_decoder_debug, "vdpdecoder", 0, \ - "VDPAU decoder base class"); -#define gst_vdp_decoder_parent_class parent_class -G_DEFINE_TYPE_WITH_CODE (GstVdpDecoder, gst_vdp_decoder, GST_TYPE_VIDEO_DECODER, - DEBUG_INIT); - -enum -{ - PROP_0, - PROP_DISPLAY -}; - -void -gst_vdp_decoder_post_error (GstVdpDecoder * decoder, GError * error) -{ - GstMessage *message; - - g_return_if_fail (GST_IS_VDP_DECODER (decoder)); - g_return_if_fail (decoder != NULL); - - message = gst_message_new_error (GST_OBJECT (decoder), error, NULL); - gst_element_post_message (GST_ELEMENT (decoder), message); - g_error_free (error); -} - - -GstFlowReturn -gst_vdp_decoder_render (GstVdpDecoder * vdp_decoder, VdpPictureInfo * info, - guint n_bufs, VdpBitstreamBuffer * bufs, GstVideoCodecFrame * frame) -{ - GstFlowReturn ret; - - VdpStatus status; - - GstVdpVideoMemory *vmem; -#ifndef GST_DISABLE_GST_DEBUG - GstClockTime before, after; -#endif - - GST_DEBUG_OBJECT (vdp_decoder, "n_bufs:%d, frame:%d", n_bufs, - frame->system_frame_number); - - ret = - gst_video_decoder_allocate_output_frame (GST_VIDEO_DECODER (vdp_decoder), - frame); - if (ret != GST_FLOW_OK) - goto fail_alloc; - - vmem = (GstVdpVideoMemory *) gst_buffer_get_memory (frame->output_buffer, 0); - if (!vmem - || !gst_memory_is_type ((GstMemory *) vmem, - GST_VDP_VIDEO_MEMORY_ALLOCATOR)) - goto no_mem; - - GST_DEBUG_OBJECT (vdp_decoder, "Calling VdpDecoderRender()"); -#ifndef GST_DISABLE_GST_DEBUG - before = gst_util_get_timestamp (); -#endif - status = - vdp_decoder->device->vdp_decoder_render (vdp_decoder->decoder, - vmem->surface, info, n_bufs, bufs); -#ifndef GST_DISABLE_GST_DEBUG - after = gst_util_get_timestamp (); -#endif - if (status != VDP_STATUS_OK) - goto decode_error; - - GST_DEBUG_OBJECT (vdp_decoder, "VdpDecoderRender() took %" GST_TIME_FORMAT, - GST_TIME_ARGS (after - before)); - - return GST_FLOW_OK; - -decode_error: - GST_ELEMENT_ERROR (vdp_decoder, RESOURCE, READ, - ("Could not decode"), - ("Error returned from vdpau was: %s", - vdp_decoder->device->vdp_get_error_string (status))); - - gst_video_decoder_drop_frame (GST_VIDEO_DECODER (vdp_decoder), frame); - - return GST_FLOW_ERROR; - -fail_alloc: - { - GST_WARNING_OBJECT (vdp_decoder, "Failed to get an output frame"); - return ret; - } - -no_mem: - { - GST_ERROR_OBJECT (vdp_decoder, "Didn't get VdpVideoSurface backed buffer"); - return GST_FLOW_ERROR; - } -} - -GstFlowReturn -gst_vdp_decoder_init_decoder (GstVdpDecoder * vdp_decoder, - VdpDecoderProfile profile, guint32 max_references, - GstVideoCodecState * output_state) -{ - GstVdpDevice *device; - - VdpStatus status; - - device = vdp_decoder->device; - - if (vdp_decoder->decoder != VDP_INVALID_HANDLE) { - status = device->vdp_decoder_destroy (vdp_decoder->decoder); - if (status != VDP_STATUS_OK) - goto destroy_decoder_error; - } - - GST_DEBUG_OBJECT (vdp_decoder, - "device:%u, profile:%d, width:%d, height:%d, max_references:%d", - device->device, profile, output_state->info.width, - output_state->info.height, max_references); - - status = device->vdp_decoder_create (device->device, profile, - output_state->info.width, output_state->info.height, max_references, - &vdp_decoder->decoder); - if (status != VDP_STATUS_OK) - goto create_decoder_error; - - return GST_FLOW_OK; - -destroy_decoder_error: - GST_ELEMENT_ERROR (vdp_decoder, RESOURCE, READ, - ("Could not destroy vdpau decoder"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - - return GST_FLOW_ERROR; - -create_decoder_error: - GST_ELEMENT_ERROR (vdp_decoder, RESOURCE, READ, - ("Could not create vdpau decoder"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - - return GST_FLOW_ERROR; -} - -static gboolean -gst_vdp_decoder_decide_allocation (GstVideoDecoder * video_decoder, - GstQuery * query) -{ - GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (video_decoder); - GstCaps *outcaps; - GstBufferPool *pool = NULL; - guint size, min = 0, max = 0; - GstStructure *config; - GstVideoInfo vinfo; - gboolean update_pool; - - gst_query_parse_allocation (query, &outcaps, NULL); - gst_video_info_init (&vinfo); - gst_video_info_from_caps (&vinfo, outcaps); - - if (gst_query_get_n_allocation_pools (query) > 0) { - gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); - size = MAX (size, vinfo.size); - update_pool = TRUE; - } else { - pool = NULL; - size = vinfo.size; - min = max = 0; - - update_pool = FALSE; - } - - if (pool == NULL - || !gst_buffer_pool_has_option (pool, - GST_BUFFER_POOL_OPTION_VDP_VIDEO_META)) { - if (pool) - gst_object_unref (pool); - /* no pool or pool doesn't support GstVdpVideoMeta, we can make our own */ - GST_DEBUG_OBJECT (video_decoder, - "no pool or doesn't support GstVdpVideoMeta, making new pool"); - pool = gst_vdp_video_buffer_pool_new (vdp_decoder->device); - } - - /* now configure */ - config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set_params (config, outcaps, size, min, max); - gst_buffer_pool_config_add_option (config, - GST_BUFFER_POOL_OPTION_VDP_VIDEO_META); - gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); - gst_buffer_pool_set_config (pool, config); - - if (update_pool) - gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max); - else - gst_query_add_allocation_pool (query, pool, size, min, max); - - if (pool) - gst_object_unref (pool); - - return TRUE; - -} - -static gboolean -gst_vdp_decoder_start (GstVideoDecoder * video_decoder) -{ - GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (video_decoder); - GError *err = NULL; - - GST_DEBUG_OBJECT (video_decoder, "Starting"); - - vdp_decoder->device = gst_vdp_get_device (vdp_decoder->display, &err); - if (G_UNLIKELY (!vdp_decoder->device)) - goto device_error; - - vdp_decoder->decoder = VDP_INVALID_HANDLE; - - return TRUE; - -device_error: - gst_vdp_decoder_post_error (vdp_decoder, err); - return FALSE; -} - -static gboolean -gst_vdp_decoder_stop (GstVideoDecoder * video_decoder) -{ - GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (video_decoder); - - if (vdp_decoder->decoder != VDP_INVALID_HANDLE) { - GstVdpDevice *device = vdp_decoder->device; - VdpStatus status; - - status = device->vdp_decoder_destroy (vdp_decoder->decoder); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_decoder, RESOURCE, READ, - ("Could not destroy vdpau decoder"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - return FALSE; - } - } - - g_object_unref (vdp_decoder->device); - - return TRUE; -} - -static void -gst_vdp_decoder_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (object); - - switch (prop_id) { - case PROP_DISPLAY: - g_value_set_string (value, vdp_decoder->display); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_vdp_decoder_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (object); - - switch (prop_id) { - case PROP_DISPLAY: - g_free (vdp_decoder->display); - vdp_decoder->display = g_value_dup_string (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_vdp_decoder_finalize (GObject * object) -{ - GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (object); - - g_free (vdp_decoder->display); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gst_vdp_decoder_init (GstVdpDecoder * vdp_decoder) -{ - -} - -static void -gst_vdp_decoder_class_init (GstVdpDecoderClass * klass) -{ - GObjectClass *object_class; - GstVideoDecoderClass *video_decoder_class; - GstElementClass *element_class; - - GstCaps *src_caps; - GstPadTemplate *src_template; - - object_class = G_OBJECT_CLASS (klass); - element_class = GST_ELEMENT_CLASS (klass); - video_decoder_class = GST_VIDEO_DECODER_CLASS (klass); - - object_class->get_property = gst_vdp_decoder_get_property; - object_class->set_property = gst_vdp_decoder_set_property; - object_class->finalize = gst_vdp_decoder_finalize; - - video_decoder_class->start = gst_vdp_decoder_start; - video_decoder_class->stop = gst_vdp_decoder_stop; - video_decoder_class->decide_allocation = gst_vdp_decoder_decide_allocation; - - GST_FIXME ("Actually create srcpad template from hw capabilities"); - src_caps = - gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES - (GST_CAPS_FEATURE_MEMORY_VDPAU, - "{ YV12 }") ";" GST_VIDEO_CAPS_MAKE ("{ YV12 }")); - src_template = - gst_pad_template_new (GST_VIDEO_DECODER_SRC_NAME, GST_PAD_SRC, - GST_PAD_ALWAYS, src_caps); - - gst_element_class_add_pad_template (element_class, src_template); - - if (src_caps) - gst_caps_unref (src_caps); - - g_object_class_install_property (object_class, - PROP_DISPLAY, g_param_spec_string ("display", "Display", "X Display name", - NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); -} diff --git a/sys/vdpau/gstvdpdecoder.h b/sys/vdpau/gstvdpdecoder.h deleted file mode 100644 index e35e0e71ba..0000000000 --- a/sys/vdpau/gstvdpdecoder.h +++ /dev/null @@ -1,76 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2009 Carl-Anton Ingmarsson . - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_VDP_DECODER_H__ -#define __GST_VDP_DECODER_H__ - -#include -#include - -#include - -#include "gstvdpdevice.h" - -G_BEGIN_DECLS - -#define GST_TYPE_VDP_DECODER (gst_vdp_decoder_get_type()) -#define GST_VDP_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VDP_DECODER, GstVdpDecoder)) -#define GST_VDP_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VDP_DECODER, GstVdpDecoderClass)) -#define GST_VDP_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VDP_DECODER, GstVdpDecoderClass)) -#define GST_IS_VDP_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VDP_DECODER)) -#define GST_IS_VDP_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VDP_DECODER)) - -typedef struct _GstVdpDecoder GstVdpDecoder; -typedef struct _GstVdpDecoderClass GstVdpDecoderClass; - - -struct _GstVdpDecoder { - GstVideoDecoder video_decoder; - - GstVdpDevice *device; - VdpDecoder decoder; - - GstVideoInfo info; - - /* properties */ - gchar *display; -}; - -struct _GstVdpDecoderClass { - GstVideoDecoderClass video_decoder_class; -}; - -void -gst_vdp_decoder_post_error (GstVdpDecoder * decoder, GError * error); - -GstFlowReturn -gst_vdp_decoder_render (GstVdpDecoder * vdp_decoder, VdpPictureInfo *info, - guint n_bufs, VdpBitstreamBuffer *bufs, GstVideoCodecFrame *frame); - -GstFlowReturn -gst_vdp_decoder_init_decoder (GstVdpDecoder * vdp_decoder, - VdpDecoderProfile profile, guint32 max_references, - GstVideoCodecState *output_state); - -GType gst_vdp_decoder_get_type (void); - -G_END_DECLS - -#endif /* __GST_VDP_DECODER_H__ */ diff --git a/sys/vdpau/gstvdpdevice.c b/sys/vdpau/gstvdpdevice.c deleted file mode 100644 index 57d8b34425..0000000000 --- a/sys/vdpau/gstvdpdevice.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex - * with newer GLib versions (>= 2.31.0) */ -#define GLIB_DISABLE_DEPRECATION_WARNINGS - -#include "gstvdpdevice.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_device_debug); -#define GST_CAT_DEFAULT gst_vdp_device_debug - -#define DEBUG_INIT(bla) \ -GST_DEBUG_CATEGORY_INIT (gst_vdp_device_debug, "vdpdevice", 0, "VDPAU device object"); - -enum -{ - PROP_0, - PROP_DISPLAY -}; - -G_DEFINE_TYPE_WITH_CODE (GstVdpDevice, gst_vdp_device, G_TYPE_OBJECT, - DEBUG_INIT ()); - -static gboolean -gst_vdp_device_open (GstVdpDevice * device, GError ** error) -{ - gint screen; - VdpStatus status; - gint i; - - typedef struct - { - gint id; - void *func; - } VdpFunction; - - VdpFunction vdp_function[] = { - {VDP_FUNC_ID_DEVICE_DESTROY, &device->vdp_device_destroy}, - {VDP_FUNC_ID_VIDEO_SURFACE_CREATE, - &device->vdp_video_surface_create}, - {VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, - &device->vdp_video_surface_destroy}, - {VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES, - &device->vdp_video_surface_query_capabilities}, - {VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES, - &device->vdp_video_surface_query_ycbcr_capabilities}, - {VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR, - &device->vdp_video_surface_get_bits_ycbcr}, - {VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR, - &device->vdp_video_surface_put_bits_ycbcr}, - {VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, - &device->vdp_video_surface_get_parameters}, - {VDP_FUNC_ID_DECODER_CREATE, &device->vdp_decoder_create}, - {VDP_FUNC_ID_DECODER_RENDER, &device->vdp_decoder_render}, - {VDP_FUNC_ID_DECODER_DESTROY, &device->vdp_decoder_destroy}, - {VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES, - &device->vdp_decoder_query_capabilities}, - {VDP_FUNC_ID_DECODER_GET_PARAMETERS, - &device->vdp_decoder_get_parameters}, - {VDP_FUNC_ID_VIDEO_MIXER_CREATE, &device->vdp_video_mixer_create}, - {VDP_FUNC_ID_VIDEO_MIXER_DESTROY, &device->vdp_video_mixer_destroy}, - {VDP_FUNC_ID_VIDEO_MIXER_RENDER, &device->vdp_video_mixer_render}, - {VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES, - &device->vdp_video_mixer_set_feature_enables}, - {VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES, - &device->vdp_video_mixer_set_attribute_values}, - {VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, &device->vdp_output_surface_create}, - {VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, &device->vdp_output_surface_destroy}, - {VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES, - &device->vdp_output_surface_query_capabilities}, - {VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE, - &device->vdp_output_surface_get_bits_native}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11, - &device->vdp_presentation_queue_target_create_x11}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY, - &device->vdp_presentation_queue_target_destroy}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE, - &device->vdp_presentation_queue_create}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY, - &device->vdp_presentation_queue_destroy}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY, - &device->vdp_presentation_queue_display}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, - &device->vdp_presentation_queue_block_until_surface_idle}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR, - &device->vdp_presentation_queue_set_background_color}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS, - &device->vdp_presentation_queue_query_surface_status} - }; - - GST_DEBUG_OBJECT (device, "Opening the device for display '%s'", - device->display_name); - - device->display = XOpenDisplay (device->display_name); - if (!device->display) - goto create_display_error; - - screen = DefaultScreen (device->display); - status = - vdp_device_create_x11 (device->display, screen, &device->device, - &device->vdp_get_proc_address); - if (status != VDP_STATUS_OK) - goto create_device_error; - - status = device->vdp_get_proc_address (device->device, - VDP_FUNC_ID_GET_ERROR_STRING, (void **) &device->vdp_get_error_string); - if (status != VDP_STATUS_OK) - goto get_error_string_error; - - for (i = 0; i < G_N_ELEMENTS (vdp_function); i++) { - status = device->vdp_get_proc_address (device->device, - vdp_function[i].id, vdp_function[i].func); - - if (status != VDP_STATUS_OK) - goto function_error; - } - - GST_DEBUG_OBJECT (device, "Succesfully opened the device"); - - return TRUE; - -create_display_error: - g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, - "Could not open X display with name: %s", device->display_name); - return FALSE; - -create_device_error: - g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, - "Could not create VDPAU device for display: %s", device->display_name); - return FALSE; - -get_error_string_error: - g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, - "Could not get vdp_get_error_string function pointer from VDPAU"); - return FALSE; - -function_error: - g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, - "Could not get function pointer from VDPAU, error returned was: %s", - device->vdp_get_error_string (status)); - return FALSE; -} - -static GstVdpDevice * -gst_vdp_device_new (const gchar * display_name, GError ** error) -{ - GstVdpDevice *device; - - device = g_object_new (GST_TYPE_VDP_DEVICE, "display", display_name, NULL); - - if (!gst_vdp_device_open (device, error)) { - g_object_unref (device); - return NULL; - } - - return device; -} - -static void -gst_vdp_device_init (GstVdpDevice * device) -{ - device->display_name = NULL; - device->display = NULL; - device->device = VDP_INVALID_HANDLE; - device->vdp_decoder_destroy = NULL; -} - -static void -gst_vdp_device_finalize (GObject * object) -{ - GstVdpDevice *device = (GstVdpDevice *) object; - - if (device->device != VDP_INVALID_HANDLE && device->vdp_decoder_destroy) { - device->vdp_device_destroy (device->device); - device->device = VDP_INVALID_HANDLE; - } - - if (device->display) { - XCloseDisplay (device->display); - device->display = NULL; - } - - g_free (device->display_name); - device->display_name = NULL; - - G_OBJECT_CLASS (gst_vdp_device_parent_class)->finalize (object); -} - -static void -gst_vdp_device_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstVdpDevice *device; - - g_return_if_fail (GST_IS_VDP_DEVICE (object)); - - device = (GstVdpDevice *) object; - - switch (prop_id) { - case PROP_DISPLAY: - device->display_name = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_vdp_device_get_property (GObject * object, guint prop_id, GValue * value, - GParamSpec * pspec) -{ - GstVdpDevice *device; - - g_return_if_fail (GST_IS_VDP_DEVICE (object)); - - device = (GstVdpDevice *) object; - - switch (prop_id) { - case PROP_DISPLAY: - g_value_set_string (value, device->display_name); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_vdp_device_class_init (GstVdpDeviceClass * klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = gst_vdp_device_finalize; - object_class->get_property = gst_vdp_device_get_property; - object_class->set_property = gst_vdp_device_set_property; - - g_object_class_install_property (object_class, - PROP_DISPLAY, - g_param_spec_string ("display", - "Display", - "X Display Name", - "", G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); -} - -typedef struct -{ - GHashTable *hash_table; - GMutex mutex; -} GstVdpDeviceCache; - -static void -device_destroyed_cb (gpointer data, GObject * object) -{ - GstVdpDeviceCache *device_cache = data; - GHashTableIter iter; - gpointer device; - - GST_DEBUG ("Removing object from hash table"); - - g_mutex_lock (&device_cache->mutex); - - g_hash_table_iter_init (&iter, device_cache->hash_table); - while (g_hash_table_iter_next (&iter, NULL, &device)) { - if (device == object) { - g_hash_table_iter_remove (&iter); - break; - } - } - - g_mutex_unlock (&device_cache->mutex); -} - -GstVdpDevice * -gst_vdp_get_device (const gchar * display_name, GError ** error) -{ - static gsize once = 0; - static GstVdpDeviceCache device_cache; - GstVdpDevice *device; - - GST_DEBUG ("display_name '%s'", display_name); - - if (g_once_init_enter (&once)) { - device_cache.hash_table = - g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - g_mutex_init (&device_cache.mutex); - - g_once_init_leave (&once, 1); - } - - g_mutex_lock (&device_cache.mutex); - - if (display_name) - device = g_hash_table_lookup (device_cache.hash_table, display_name); - else - device = g_hash_table_lookup (device_cache.hash_table, ""); - - if (!device) { - GST_DEBUG ("No cached device, creating a new one"); - device = gst_vdp_device_new (display_name, error); - if (device) { - g_object_weak_ref (G_OBJECT (device), device_destroyed_cb, &device_cache); - if (display_name) - g_hash_table_insert (device_cache.hash_table, g_strdup (display_name), - device); - else - g_hash_table_insert (device_cache.hash_table, g_strdup (""), device); - } else - GST_ERROR ("Could not create GstVdpDevice !"); - } else - g_object_ref (device); - - g_mutex_unlock (&device_cache.mutex); - - return device; -} diff --git a/sys/vdpau/gstvdpdevice.h b/sys/vdpau/gstvdpdevice.h deleted file mode 100644 index 431435e412..0000000000 --- a/sys/vdpau/gstvdpdevice.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GST_VDP_DEVICE_H_ -#define _GST_VDP_DEVICE_H_ - -#include -#include -#include - -#include - -G_BEGIN_DECLS - -#define GST_TYPE_VDP_DEVICE (gst_vdp_device_get_type ()) -#define GST_VDP_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_DEVICE, GstVdpDevice)) -#define GST_VDP_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_DEVICE, GstVdpDeviceClass)) -#define GST_IS_VDP_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_DEVICE)) -#define GST_IS_VDP_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_DEVICE)) -#define GST_VDP_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_DEVICE, GstVdpDeviceClass)) - -typedef struct _GstVdpDeviceClass GstVdpDeviceClass; -typedef struct _GstVdpDevice GstVdpDevice; - -struct _GstVdpDeviceClass -{ - GObjectClass parent_class; -}; - -struct _GstVdpDevice -{ - GObject object; - - gchar *display_name; - Display *display; - VdpDevice device; - - VdpDeviceDestroy *vdp_device_destroy; - VdpGetProcAddress *vdp_get_proc_address; - VdpGetErrorString *vdp_get_error_string; - - VdpVideoSurfaceCreate *vdp_video_surface_create; - VdpVideoSurfaceDestroy *vdp_video_surface_destroy; - VdpVideoSurfaceQueryCapabilities *vdp_video_surface_query_capabilities; - VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *vdp_video_surface_query_ycbcr_capabilities; - VdpVideoSurfaceGetParameters *vdp_video_surface_get_parameters; - VdpVideoSurfaceGetBitsYCbCr *vdp_video_surface_get_bits_ycbcr; - VdpVideoSurfacePutBitsYCbCr *vdp_video_surface_put_bits_ycbcr; - - VdpDecoderCreate *vdp_decoder_create; - VdpDecoderDestroy *vdp_decoder_destroy; - VdpDecoderRender *vdp_decoder_render; - VdpDecoderQueryCapabilities *vdp_decoder_query_capabilities; - VdpDecoderGetParameters *vdp_decoder_get_parameters; - - VdpVideoMixerCreate *vdp_video_mixer_create; - VdpVideoMixerDestroy *vdp_video_mixer_destroy; - VdpVideoMixerRender *vdp_video_mixer_render; - VdpVideoMixerSetFeatureEnables *vdp_video_mixer_set_feature_enables; - VdpVideoMixerSetAttributeValues *vdp_video_mixer_set_attribute_values; - - VdpOutputSurfaceCreate *vdp_output_surface_create; - VdpOutputSurfaceDestroy *vdp_output_surface_destroy; - VdpOutputSurfaceQueryCapabilities *vdp_output_surface_query_capabilities; - VdpOutputSurfaceGetBitsNative *vdp_output_surface_get_bits_native; - - VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11; - VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy; - - VdpPresentationQueueCreate *vdp_presentation_queue_create; - VdpPresentationQueueDestroy *vdp_presentation_queue_destroy; - VdpPresentationQueueDisplay *vdp_presentation_queue_display; - VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle; - VdpPresentationQueueSetBackgroundColor *vdp_presentation_queue_set_background_color; - VdpPresentationQueueQuerySurfaceStatus *vdp_presentation_queue_query_surface_status; -}; - -GType gst_vdp_device_get_type (void); - -GstVdpDevice *gst_vdp_get_device (const gchar *display_name, GError **error); - -G_END_DECLS - -#endif /* _GST_VDP_DEVICE_H_ */ diff --git a/sys/vdpau/gstvdpoutputbuffer.c b/sys/vdpau/gstvdpoutputbuffer.c deleted file mode 100644 index 11385936e2..0000000000 --- a/sys/vdpau/gstvdpoutputbuffer.c +++ /dev/null @@ -1,406 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstvdpoutputbuffer.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_output_buffer_debug); -#define GST_CAT_DEFAULT gst_vdp_output_buffer_debug - -#define DEBUG_INIT(bla) \ -GST_DEBUG_CATEGORY_INIT (gst_vdp_output_buffer_debug, "vdpoutputbuffer", 0, "VDPAU output buffer"); - -GstVdpOutputBuffer * -gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format, - gint width, gint height, GError ** error) -{ - GstVdpOutputBuffer *buffer; - VdpStatus status; - VdpOutputSurface surface; - - status = - device->vdp_output_surface_create (device->device, rgba_format, width, - height, &surface); - if (status != VDP_STATUS_OK) - goto create_error; - - buffer = - (GstVdpOutputBuffer *) gst_mini_object_new (GST_TYPE_VDP_OUTPUT_BUFFER); - - buffer->device = g_object_ref (device); - buffer->rgba_format = rgba_format; - buffer->width = width; - buffer->height = height; - - buffer->surface = surface; - - return buffer; - -create_error: - g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ, - "Couldn't create a VdpOutputSurface, error returned from vdpau was: %s", - device->vdp_get_error_string (status)); - return NULL; -} - -static GObjectClass *gst_vdp_output_buffer_parent_class; - -static void -gst_vdp_output_buffer_finalize (GstVdpOutputBuffer * buffer) -{ - GstVdpDevice *device; - VdpStatus status; - - if (gst_vdp_buffer_revive (GST_VDP_BUFFER_CAST (buffer))) - return; - - device = buffer->device; - - status = device->vdp_output_surface_destroy (buffer->surface); - if (status != VDP_STATUS_OK) - GST_ERROR - ("Couldn't destroy the buffers VdpOutputSurface, error returned was: %s", - device->vdp_get_error_string (status)); - - g_object_unref (buffer->device); - - GST_MINI_OBJECT_CLASS (gst_vdp_output_buffer_parent_class)->finalize - (GST_MINI_OBJECT (buffer)); -} - -static void -gst_vdp_output_buffer_init (GstVdpOutputBuffer * buffer, gpointer g_class) -{ - buffer->device = NULL; - buffer->surface = VDP_INVALID_HANDLE; -} - -static void -gst_vdp_output_buffer_class_init (gpointer g_class, gpointer class_data) -{ - GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class); - - gst_vdp_output_buffer_parent_class = g_type_class_peek_parent (g_class); - - mini_object_class->finalize = (GstMiniObjectFinalizeFunction) - gst_vdp_output_buffer_finalize; -} - - -GType -gst_vdp_output_buffer_get_type (void) -{ - static GType _gst_vdp_output_buffer_type; - - if (G_UNLIKELY (_gst_vdp_output_buffer_type == 0)) { - static const GTypeInfo info = { - sizeof (GstBufferClass), - NULL, - NULL, - gst_vdp_output_buffer_class_init, - NULL, - NULL, - sizeof (GstVdpOutputBuffer), - 0, - (GInstanceInitFunc) gst_vdp_output_buffer_init, - NULL - }; - _gst_vdp_output_buffer_type = g_type_register_static (GST_TYPE_VDP_BUFFER, - "GstVdpOutputBuffer", &info, 0); - - DEBUG_INIT (); - } - return _gst_vdp_output_buffer_type; -} - -typedef struct -{ - VdpRGBAFormat format; - GstStaticCaps caps; -} GstVdpOutputBufferFormats; - -GstVdpOutputBufferFormats rgba_formats[] = { - {VDP_RGBA_FORMAT_A8, - GST_STATIC_CAPS ("video/x-raw-rgb, " - "bpp = (int)8, " - "depth = (int)8, " - "endianness = (int)4321, " - "red_mask = (int)0x00, " - "green_mask = (int)0x00, " - "blue_mask = (int)0x00, " "alpha_mask = (int)0xff")}, - {VDP_RGBA_FORMAT_B10G10R10A2, - GST_STATIC_CAPS ("video/x-raw-rgb, " - "bpp = (int)32, " - "depth = (int)30, " - "endianness = (int)4321, " - "red_mask = (int)0x000003fc, " - "green_mask = (int)0x003ff000, " - "blue_mask = (int)0xffc00000, " "alpha_mask = (int)0x00000003")}, - {VDP_RGBA_FORMAT_B8G8R8A8, - GST_STATIC_CAPS ("video/x-raw-rgb, " - "bpp = (int)32, " - "depth = (int)24, " - "endianness = (int)4321, " - "red_mask = (int)0x0000ff00, " - "green_mask = (int)0x00ff0000, " - "blue_mask = (int)0xff000000, " "alpha_mask = (int)0x000000ff")}, - {VDP_RGBA_FORMAT_R10G10B10A2, - GST_STATIC_CAPS ("video/x-raw-rgb, " - "bpp = (int)32, " - "depth = (int)30, " - "endianness = (int)4321, " - "red_mask = (int)0xffc00000, " - "green_mask = (int)0x003ff000, " - "blue_mask = (int)0x000003fc, " "alpha_mask = (int)0x00000003")}, - {VDP_RGBA_FORMAT_R8G8B8A8, - GST_STATIC_CAPS ("video/x-raw-rgb, " - "bpp = (int)32, " - "depth = (int)24, " - "endianness = (int)4321, " - "red_mask = (int)0xff000000, " - "green_mask = (int)0x00ff0000, " - "blue_mask = (int)0x0000ff00, " "alpha_mask = (int)0x000000ff")}, -}; - - -GstCaps * -gst_vdp_output_buffer_get_template_caps (void) -{ - GstCaps *caps, *rgb_caps; - gint i; - - caps = gst_caps_new_empty (); - rgb_caps = gst_caps_new_empty (); - - for (i = 0; i < G_N_ELEMENTS (rgba_formats); i++) { - GstCaps *format_caps; - - format_caps = gst_caps_new_simple ("video/x-vdpau-output", - "rgba-format", G_TYPE_INT, rgba_formats[i].format, - "width", GST_TYPE_INT_RANGE, 1, 8192, - "height", GST_TYPE_INT_RANGE, 1, 8192, NULL); - gst_caps_append (caps, format_caps); - - format_caps = gst_static_caps_get (&rgba_formats[i].caps); - format_caps = gst_caps_copy (format_caps); - gst_caps_set_simple (format_caps, - "width", GST_TYPE_INT_RANGE, 1, 8192, - "height", GST_TYPE_INT_RANGE, 1, 8192, NULL); - gst_caps_append (rgb_caps, format_caps); - - } - - gst_caps_append (caps, rgb_caps); - - return caps; -} - -GstCaps * -gst_vdp_output_buffer_get_allowed_caps (GstVdpDevice * device) -{ - GstCaps *caps, *rgb_caps; - gint i; - - g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL); - - caps = gst_caps_new_empty (); - rgb_caps = gst_caps_new_empty (); - - for (i = 0; i < G_N_ELEMENTS (rgba_formats); i++) { - VdpStatus status; - VdpBool is_supported; - guint max_w, max_h; - - status = device->vdp_output_surface_query_capabilities (device->device, - rgba_formats[i].format, &is_supported, &max_w, &max_h); - if (status != VDP_STATUS_OK && status != VDP_STATUS_INVALID_RGBA_FORMAT) { - GST_ERROR_OBJECT (device, - "Could not get query VDPAU output surface capabilites, " - "Error returned from vdpau was: %s", - device->vdp_get_error_string (status)); - - goto error; - } - - if (is_supported) { - GstCaps *format_caps; - - format_caps = gst_caps_new_simple ("video/x-vdpau-output", - "rgba-format", G_TYPE_INT, rgba_formats[i].format, - "width", GST_TYPE_INT_RANGE, 1, max_w, - "height", GST_TYPE_INT_RANGE, 1, max_h, NULL); - gst_caps_append (caps, format_caps); - - format_caps = gst_static_caps_get (&rgba_formats[i].caps); - format_caps = gst_caps_copy (format_caps); - gst_caps_set_simple (format_caps, - "width", GST_TYPE_INT_RANGE, 1, 8192, - "height", GST_TYPE_INT_RANGE, 1, 8192, NULL); - gst_caps_append (rgb_caps, format_caps); - } - } - - gst_caps_append (caps, rgb_caps); - -error: - - return caps; -} - -gboolean -gst_vdp_caps_to_rgba_format (GstCaps * caps, VdpRGBAFormat * rgba_format) -{ - GstStructure *structure; - gint c_bpp, c_depth, c_endianness, c_red_mask, c_green_mask, c_blue_mask, - c_alpha_mask; - - gint i; - - g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); - - if (!gst_caps_is_fixed (caps)) - return FALSE; - - structure = gst_caps_get_structure (caps, 0); - if (!gst_structure_has_name (structure, "video/x-raw-rgb")) - return FALSE; - - if (!gst_structure_get_int (structure, "bpp", &c_bpp) || - !gst_structure_get_int (structure, "depth", &c_depth) || - !gst_structure_get_int (structure, "endianness", &c_endianness) || - !gst_structure_get_int (structure, "red_mask", &c_red_mask) || - !gst_structure_get_int (structure, "green_mask", &c_green_mask) || - !gst_structure_get_int (structure, "blue_mask", &c_blue_mask) || - !gst_structure_get_int (structure, "alpha_mask", &c_alpha_mask)) - return FALSE; - - for (i = 0; i < G_N_ELEMENTS (rgba_formats); i++) { - gint bpp, depth, endianness, red_mask, green_mask, blue_mask, alpha_mask; - - GstCaps *rgb_caps = gst_static_caps_get (&rgba_formats[i].caps); - structure = gst_caps_get_structure (rgb_caps, 0); - - gst_structure_get_int (structure, "bpp", &bpp); - gst_structure_get_int (structure, "depth", &depth); - gst_structure_get_int (structure, "endianness", &endianness); - gst_structure_get_int (structure, "red_mask", &red_mask); - gst_structure_get_int (structure, "green_mask", &green_mask); - gst_structure_get_int (structure, "blue_mask", &blue_mask); - gst_structure_get_int (structure, "alpha_mask", &alpha_mask); - - if (c_bpp == bpp && c_depth == depth && c_endianness == endianness && - c_red_mask == red_mask && c_green_mask == green_mask && - c_blue_mask == blue_mask && c_alpha_mask == alpha_mask) { - gst_caps_unref (rgb_caps); - *rgba_format = rgba_formats[i].format; - return TRUE; - } - - gst_caps_unref (rgb_caps); - } - - return FALSE; -} - -gboolean -gst_vdp_output_buffer_calculate_size (GstVdpOutputBuffer * output_buf, - guint * size) -{ - g_return_val_if_fail (GST_IS_VDP_OUTPUT_BUFFER (output_buf), FALSE); - - switch (output_buf->rgba_format) { - case VDP_RGBA_FORMAT_A8: - { - *size = output_buf->width * output_buf->height; - break; - } - - case VDP_RGBA_FORMAT_B10G10R10A2: - case VDP_RGBA_FORMAT_B8G8R8A8: - case VDP_RGBA_FORMAT_R10G10B10A2: - case VDP_RGBA_FORMAT_R8G8B8A8: - { - *size = output_buf->width * output_buf->height * 4; - break; - } - - default: - g_assert_not_reached (); - return FALSE; - } - - return TRUE; -} - -gboolean -gst_vdp_output_buffer_download (GstVdpOutputBuffer * output_buf, - GstBuffer * outbuf, GError ** error) -{ - guint8 *data[1]; - guint32 stride[1]; - GstVdpDevice *device; - VdpOutputSurface surface; - VdpStatus status; - - g_return_val_if_fail (GST_IS_VDP_OUTPUT_BUFFER (output_buf), FALSE); - - switch (output_buf->rgba_format) { - case VDP_RGBA_FORMAT_A8: - { - stride[0] = output_buf->width; - break; - } - - case VDP_RGBA_FORMAT_B10G10R10A2: - case VDP_RGBA_FORMAT_B8G8R8A8: - case VDP_RGBA_FORMAT_R10G10B10A2: - case VDP_RGBA_FORMAT_R8G8B8A8: - { - stride[0] = output_buf->width * 4; - break; - } - - default: - return FALSE; - } - - device = output_buf->device; - surface = output_buf->surface; - data[0] = GST_BUFFER_DATA (outbuf); - - GST_LOG_OBJECT (output_buf, "Entering vdp_output_surface_get_bits_native"); - status = - device->vdp_output_surface_get_bits_native (surface, NULL, (void *) data, - stride); - GST_LOG_OBJECT (output_buf, - "Got status %d from vdp_output_get_bits_native", status); - - if (G_UNLIKELY (status != VDP_STATUS_OK)) { - g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ, - "Couldn't get data from vdpau, error returned from vdpau was: %s", - device->vdp_get_error_string (status)); - return FALSE; - } - - return TRUE; -} diff --git a/sys/vdpau/gstvdpoutputbuffer.h b/sys/vdpau/gstvdpoutputbuffer.h deleted file mode 100644 index de556f9cb4..0000000000 --- a/sys/vdpau/gstvdpoutputbuffer.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GST_VDP_OUTPUT_BUFFER_H_ -#define _GST_VDP_OUTPUT_BUFFER_H_ - -#include - -#include "gstvdpdevice.h" - -GType gst_vdpau_output_meta_api_get_type (void); - -const GstMetaInfo * gst_vdpau_output_meta_get_info (void); - -#define GST_VDPAU_OUTPUT_META_GET(buf) ((GstVdpauMeta *)gst_buffer_get_meta(buf,gst_vdpau_output_meta_api_get_type())) -#define GST_VDPAU_OUTPUT_META_ADD(buf) ((GstVdpauMeta *)gst_buffer_add_meta(buf,gst_vdpau_output_meta_get_info(),NULL)) - -struct _GstVdpauOutputMeta { - GstMeta meta; - - /* FIXME : Check we actually need all of this */ - GstVdpDevice *device; - VdpRGBAFormat rgba_format; - gint width, height; - - VdpOutputSurface surface; -}; - -#if 0 -/* FIXME : Replace with GST_VIDEO_FORMAT... and GST_VIDEO_CHROMA_... */ -GstCaps *gst_vdp_output_buffer_get_template_caps (void); -GstCaps *gst_vdp_output_buffer_get_allowed_caps (GstVdpDevice *device); -gboolean gst_vdp_caps_to_rgba_format (GstCaps *caps, VdpRGBAFormat *rgba_format); - -gboolean gst_vdp_output_buffer_calculate_size (GstVdpOutputBuffer *output_buf, guint *size); -/* FIXME : Replace with map/unmap */ -gboolean gst_vdp_output_buffer_download (GstVdpOutputBuffer *output_buf, GstBuffer *outbuf, GError **error); - -#define GST_VDP_OUTPUT_CAPS \ - "video/x-vdpau-output, " \ - "rgba-format = (int)[0,4], " \ - "width = (int)[1,8192], " \ - "height = (int)[1,8192]" -#endif -#endif diff --git a/sys/vdpau/gstvdpoutputbufferpool.c b/sys/vdpau/gstvdpoutputbufferpool.c deleted file mode 100644 index 8657773ce5..0000000000 --- a/sys/vdpau/gstvdpoutputbufferpool.c +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -/* - * gst-plugins-bad - * Copyright (C) Carl-Anton Ingmarsson 2010 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "gstvdpdevice.h" -#include "gstvdpoutputbuffer.h" - -#include "gstvdpoutputbufferpool.h" - - -struct _GstVdpOutputBufferPool -{ - GstVdpBufferPool buffer_pool; - - VdpRGBAFormat rgba_format; - guint width, height; -}; - -G_DEFINE_TYPE (GstVdpOutputBufferPool, gst_vdp_output_buffer_pool, - GST_TYPE_VDP_BUFFER_POOL); - -GstVdpBufferPool * -gst_vdp_output_buffer_pool_new (GstVdpDevice * device) -{ - g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL); - - return g_object_new (GST_TYPE_VDP_OUTPUT_BUFFER_POOL, "device", device, NULL); -} - -static gboolean -parse_caps (const GstCaps * caps, VdpChromaType * rgba_format, gint * width, - gint * height) -{ - GstStructure *structure; - - structure = gst_caps_get_structure (caps, 0); - - if (!gst_structure_get_int (structure, "rgba-format", (gint *) rgba_format)) - return FALSE; - if (!gst_structure_get_int (structure, "width", width)) - return FALSE; - if (!gst_structure_get_int (structure, "height", height)) - return FALSE; - - return TRUE; -} - -static gboolean -gst_vdp_output_buffer_pool_check_caps (GstVdpBufferPool * bpool, - const GstCaps * caps) -{ - GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool); - - VdpChromaType rgba_format; - gint width, height; - - if (!parse_caps (caps, &rgba_format, &width, &height)) - return FALSE; - - if (rgba_format != opool->rgba_format || width != opool->width || - height != opool->height) - return FALSE; - - return TRUE; -} - -static gboolean -gst_vdp_output_buffer_pool_set_caps (GstVdpBufferPool * bpool, - const GstCaps * caps, gboolean * clear_bufs) -{ - GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool); - - VdpChromaType rgba_format; - gint width, height; - - if (!parse_caps (caps, &rgba_format, &width, &height)) - return FALSE; - - if (rgba_format != opool->rgba_format || width != opool->width || - height != opool->height) - *clear_bufs = TRUE; - else - *clear_bufs = FALSE; - - opool->rgba_format = rgba_format; - opool->width = width; - opool->height = height; - - return TRUE; -} - -static GstVdpBuffer * -gst_vdp_output_buffer_pool_alloc_buffer (GstVdpBufferPool * bpool, - GError ** error) -{ - GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool); - GstVdpDevice *device; - - device = gst_vdp_buffer_pool_get_device (bpool); - return GST_VDP_BUFFER_CAST (gst_vdp_output_buffer_new (device, - opool->rgba_format, opool->width, opool->height, error)); -} - -static void -gst_vdp_output_buffer_pool_finalize (GObject * object) -{ - /* TODO: Add deinitalization code here */ - - G_OBJECT_CLASS (gst_vdp_output_buffer_pool_parent_class)->finalize (object); -} - -static void -gst_vdp_output_buffer_pool_init (GstVdpOutputBufferPool * opool) -{ - opool->rgba_format = -1; - opool->width = 0; - opool->height = 0; -} - -static void -gst_vdp_output_buffer_pool_class_init (GstVdpOutputBufferPoolClass * klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GstVdpBufferPoolClass *buffer_pool_class = GST_VDP_BUFFER_POOL_CLASS (klass); - - buffer_pool_class->alloc_buffer = gst_vdp_output_buffer_pool_alloc_buffer; - buffer_pool_class->set_caps = gst_vdp_output_buffer_pool_set_caps; - buffer_pool_class->check_caps = gst_vdp_output_buffer_pool_check_caps; - - object_class->finalize = gst_vdp_output_buffer_pool_finalize; -} diff --git a/sys/vdpau/gstvdpoutputbufferpool.h b/sys/vdpau/gstvdpoutputbufferpool.h deleted file mode 100644 index 1c4e93b2de..0000000000 --- a/sys/vdpau/gstvdpoutputbufferpool.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -/* - * gst-plugins-bad - * Copyright (C) Carl-Anton Ingmarsson 2010 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GST_VDP_OUTPUT_BUFFER_POOL_H_ -#define _GST_VDP_OUTPUT_BUFFER_POOL_H_ - -#include - -G_BEGIN_DECLS - -#define GST_TYPE_VDP_OUTPUT_BUFFER_POOL (gst_vdp_output_buffer_pool_get_type ()) -#define GST_VDP_OUTPUT_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPool)) -#define GST_VDP_OUTPUT_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPoolClass)) -#define GST_IS_VDP_OUTPUT_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL)) -#define GST_IS_VDP_OUTPUT_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_OUTPUT_BUFFER_POOL)) -#define GST_VDP_OUTPUT_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPoolClass)) - -typedef struct _GstVdpOutputBufferPool GstVdpOutputBufferPool; -typedef struct _GstVdpOutputBufferPoolClass GstVdpOutputBufferPoolClass; - -struct _GstVdpOutputBufferPoolClass -{ - GstVdpBufferPoolClass buffer_pool_class; -}; - -GstVdpBufferPool *gst_vdp_output_buffer_pool_new (GstVdpDevice *device); - -GType gst_vdp_output_buffer_pool_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* _GST_VDP_OUTPUT_BUFFER_POOL_H_ */ diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c deleted file mode 100644 index 1533c04a3a..0000000000 --- a/sys/vdpau/gstvdpsink.c +++ /dev/null @@ -1,1505 +0,0 @@ -/* GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * Copyright (C) 2005 Julien Moutte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex - * with newer GLib versions (>= 2.31.0) */ -#define GLIB_DISABLE_DEPRECATION_WARNINGS - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* Our interfaces */ -#include -#include - -#include - -/* Debugging category */ -#include - -#include "gstvdpoutputbuffer.h" -#include "gstvdpoutputbufferpool.h" - -/* Object header */ -#include "gstvdpsink.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_sink_debug); -#define GST_CAT_DEFAULT gst_vdp_sink_debug - -typedef struct -{ - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long input_mode; - unsigned long status; -} -MotifWmHints, MwmHints; - -#define MWM_HINTS_DECORATIONS (1L << 1) - -static void gst_vdp_sink_expose (GstXOverlay * overlay); - -enum -{ - PROP_0, - PROP_DISPLAY, - PROP_SYNCHRONOUS, - PROP_PIXEL_ASPECT_RATIO, - PROP_HANDLE_EVENTS, - PROP_HANDLE_EXPOSE -}; - -static GstVideoSinkClass *parent_class = NULL; - -/* the capabilities of the inputs and outputs. - * - * describe the real formats here. - */ -static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VDP_OUTPUT_CAPS)); - -#define DEBUG_INIT(bla) \ -GST_DEBUG_CATEGORY_INIT (gst_vdp_sink_debug, "vdpausink", 0, "VDPAU video sink"); - -/* ============================================================= */ -/* */ -/* Private Methods */ -/* */ -/* ============================================================= */ - -/* X11 stuff */ - -static gboolean -gst_vdp_sink_window_decorate (VdpSink * vdp_sink, GstVdpWindow * window) -{ - Atom hints_atom = None; - MotifWmHints *hints; - - g_return_val_if_fail (GST_IS_VDP_SINK (vdp_sink), FALSE); - g_return_val_if_fail (window != NULL, FALSE); - - g_mutex_lock (vdp_sink->x_lock); - - hints_atom = XInternAtom (vdp_sink->device->display, "_MOTIF_WM_HINTS", 1); - if (hints_atom == None) { - g_mutex_unlock (vdp_sink->x_lock); - return FALSE; - } - - hints = g_malloc0 (sizeof (MotifWmHints)); - - hints->flags |= MWM_HINTS_DECORATIONS; - hints->decorations = 1 << 0; - - XChangeProperty (vdp_sink->device->display, window->win, - hints_atom, hints_atom, 32, PropModeReplace, - (guchar *) hints, sizeof (MotifWmHints) / sizeof (long)); - - XSync (vdp_sink->device->display, FALSE); - - g_mutex_unlock (vdp_sink->x_lock); - - g_free (hints); - - return TRUE; -} - -static void -gst_vdp_sink_window_set_title (VdpSink * vdp_sink, - GstVdpWindow * window, const gchar * media_title) -{ - if (media_title) { - g_free (vdp_sink->media_title); - vdp_sink->media_title = g_strdup (media_title); - } - if (window) { - /* we have a window */ - if (window->internal) { - XTextProperty xproperty; - const gchar *app_name; - const gchar *title = NULL; - gchar *title_mem = NULL; - - /* set application name as a title */ - app_name = g_get_application_name (); - - if (app_name && vdp_sink->media_title) { - title = title_mem = g_strconcat (vdp_sink->media_title, " : ", - app_name, NULL); - } else if (app_name) { - title = app_name; - } else if (vdp_sink->media_title) { - title = vdp_sink->media_title; - } - - if (title) { - if ((XStringListToTextProperty (((char **) &title), 1, - &xproperty)) != 0) { - XSetWMName (vdp_sink->device->display, window->win, &xproperty); - XFree (xproperty.value); - } - - g_free (title_mem); - } - } - } -} - -static void -gst_vdp_sink_window_setup_vdpau (VdpSink * vdp_sink, GstVdpWindow * window) -{ - GstVdpDevice *device = vdp_sink->device; - VdpStatus status; - VdpColor color = { 0, }; - - status = device->vdp_presentation_queue_target_create_x11 (device->device, - window->win, &window->target); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, - ("Could not create presentation target"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - } - - status = - device->vdp_presentation_queue_create (device->device, window->target, - &window->queue); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, - ("Could not create presentation queue"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - } - - status = - device->vdp_presentation_queue_set_background_color (window->queue, - &color); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, - ("Could not set background color"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - } -} - -/* This function handles a GstVdpWindow creation */ -static GstVdpWindow * -gst_vdp_sink_window_new (VdpSink * vdp_sink, gint width, gint height) -{ - GstVdpDevice *device = vdp_sink->device; - GstVdpWindow *window = NULL; - - Window root; - gint screen_num; - gulong black; - - g_return_val_if_fail (GST_IS_VDP_SINK (vdp_sink), NULL); - - window = g_new0 (GstVdpWindow, 1); - - window->width = width; - window->height = height; - window->internal = TRUE; - - g_mutex_lock (vdp_sink->x_lock); - - screen_num = DefaultScreen (device->display); - root = DefaultRootWindow (device->display); - black = XBlackPixel (device->display, screen_num); - - window->win = XCreateSimpleWindow (vdp_sink->device->display, - root, 0, 0, window->width, window->height, 0, 0, black); - - /* We have to do that to prevent X from redrawing the background on - ConfigureNotify. This takes away flickering of video when resizing. */ - XSetWindowBackgroundPixmap (vdp_sink->device->display, window->win, None); - - /* set application name as a title */ - gst_vdp_sink_window_set_title (vdp_sink, window, NULL); - - if (vdp_sink->handle_events) { - Atom wm_delete; - - XSelectInput (vdp_sink->device->display, window->win, ExposureMask | - StructureNotifyMask | PointerMotionMask | KeyPressMask | - KeyReleaseMask | ButtonPressMask | ButtonReleaseMask); - - /* Tell the window manager we'd like delete client messages instead of - * being killed */ - wm_delete = - XInternAtom (vdp_sink->device->display, "WM_DELETE_WINDOW", False); - (void) XSetWMProtocols (vdp_sink->device->display, window->win, &wm_delete, - 1); - } - - XMapRaised (vdp_sink->device->display, window->win); - - XSync (vdp_sink->device->display, FALSE); - - g_mutex_unlock (vdp_sink->x_lock); - - gst_vdp_sink_window_decorate (vdp_sink, window); - gst_vdp_sink_window_setup_vdpau (vdp_sink, window); - - gst_x_overlay_got_window_handle (GST_X_OVERLAY (vdp_sink), - (guintptr) window->win); - - return window; -} - -/* This function destroys a GstVdpWindow */ -static void -gst_vdp_sink_window_destroy (VdpSink * vdp_sink, GstVdpWindow * window) -{ - g_return_if_fail (window != NULL); - g_return_if_fail (GST_IS_VDP_SINK (vdp_sink)); - - g_mutex_lock (vdp_sink->x_lock); - - /* If we did not create that window we just free the GC and let it live */ - if (window->internal) - XDestroyWindow (vdp_sink->device->display, window->win); - else - XSelectInput (vdp_sink->device->display, window->win, 0); - - XSync (vdp_sink->device->display, FALSE); - - g_mutex_unlock (vdp_sink->x_lock); - - g_free (window); -} - -static void -gst_vdp_sink_window_update_geometry (VdpSink * vdp_sink, GstVdpWindow * window) -{ - XWindowAttributes attr; - - g_return_if_fail (window != NULL); - g_return_if_fail (GST_IS_VDP_SINK (vdp_sink)); - - /* Update the window geometry */ - g_mutex_lock (vdp_sink->x_lock); - - XGetWindowAttributes (vdp_sink->device->display, window->win, &attr); - - window->width = attr.width; - window->height = attr.height; - - g_mutex_unlock (vdp_sink->x_lock); -} - -/* This function handles XEvents that might be in the queue. It generates - GstEvent that will be sent upstream in the pipeline to handle interactivity - and navigation.*/ -static void -gst_vdp_sink_handle_xevents (VdpSink * vdp_sink) -{ - XEvent e; - guint pointer_x = 0, pointer_y = 0; - gboolean pointer_moved = FALSE; - gboolean exposed = FALSE, configured = FALSE; - - g_return_if_fail (GST_IS_VDP_SINK (vdp_sink)); - - /* Then we get all pointer motion events, only the last position is - interesting. */ - g_mutex_lock (vdp_sink->flow_lock); - g_mutex_lock (vdp_sink->x_lock); - while (XCheckWindowEvent (vdp_sink->device->display, - vdp_sink->window->win, PointerMotionMask, &e)) { - g_mutex_unlock (vdp_sink->x_lock); - g_mutex_unlock (vdp_sink->flow_lock); - - switch (e.type) { - case MotionNotify: - pointer_x = e.xmotion.x; - pointer_y = e.xmotion.y; - pointer_moved = TRUE; - break; - default: - break; - } - g_mutex_lock (vdp_sink->flow_lock); - g_mutex_lock (vdp_sink->x_lock); - } - - if (pointer_moved) { - g_mutex_unlock (vdp_sink->x_lock); - g_mutex_unlock (vdp_sink->flow_lock); - - GST_DEBUG ("vdp_sink pointer moved over window at %d,%d", - pointer_x, pointer_y); - gst_navigation_send_mouse_event (GST_NAVIGATION (vdp_sink), - "mouse-move", 0, pointer_x, pointer_y); - - g_mutex_lock (vdp_sink->flow_lock); - g_mutex_lock (vdp_sink->x_lock); - } - - /* We get all remaining events on our window to throw them upstream */ - while (XCheckWindowEvent (vdp_sink->device->display, - vdp_sink->window->win, - KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask, &e)) { - KeySym keysym; - - /* We lock only for the X function call */ - g_mutex_unlock (vdp_sink->x_lock); - g_mutex_unlock (vdp_sink->flow_lock); - - switch (e.type) { - case ButtonPress: - /* Mouse button pressed/released over our window. We send upstream - events for interactivity/navigation */ - GST_DEBUG ("vdp_sink button %d pressed over window at %d,%d", - e.xbutton.button, e.xbutton.x, e.xbutton.x); - gst_navigation_send_mouse_event (GST_NAVIGATION (vdp_sink), - "mouse-button-press", e.xbutton.button, e.xbutton.x, e.xbutton.y); - break; - case ButtonRelease: - GST_DEBUG ("vdp_sink button %d release over window at %d,%d", - e.xbutton.button, e.xbutton.x, e.xbutton.x); - gst_navigation_send_mouse_event (GST_NAVIGATION (vdp_sink), - "mouse-button-release", e.xbutton.button, e.xbutton.x, e.xbutton.y); - break; - case KeyPress: - case KeyRelease: - /* Key pressed/released over our window. We send upstream - events for interactivity/navigation */ - GST_DEBUG ("vdp_sink key %d pressed over window at %d,%d", - e.xkey.keycode, e.xkey.x, e.xkey.x); - g_mutex_lock (vdp_sink->x_lock); - keysym = - XkbKeycodeToKeysym (vdp_sink->device->display, e.xkey.keycode, 0, - 0); - g_mutex_unlock (vdp_sink->x_lock); - if (keysym != NoSymbol) { - char *key_str = NULL; - - g_mutex_lock (vdp_sink->x_lock); - key_str = XKeysymToString (keysym); - g_mutex_unlock (vdp_sink->x_lock); - gst_navigation_send_key_event (GST_NAVIGATION (vdp_sink), - e.type == KeyPress ? "key-press" : "key-release", key_str); - - } else { - gst_navigation_send_key_event (GST_NAVIGATION (vdp_sink), - e.type == KeyPress ? "key-press" : "key-release", "unknown"); - } - break; - default: - GST_DEBUG_OBJECT (vdp_sink, "vdp_sink unhandled X event (%d)", e.type); - } - g_mutex_lock (vdp_sink->flow_lock); - g_mutex_lock (vdp_sink->x_lock); - } - - while (XCheckWindowEvent (vdp_sink->device->display, - vdp_sink->window->win, ExposureMask | StructureNotifyMask, &e)) { - switch (e.type) { - case Expose: - exposed = TRUE; - break; - case ConfigureNotify: - configured = TRUE; - break; - default: - break; - } - } - - if (vdp_sink->handle_expose && (exposed || configured)) { - g_mutex_unlock (vdp_sink->x_lock); - g_mutex_unlock (vdp_sink->flow_lock); - - gst_vdp_sink_expose (GST_X_OVERLAY (vdp_sink)); - - g_mutex_lock (vdp_sink->flow_lock); - g_mutex_lock (vdp_sink->x_lock); - } - - /* Handle Display events */ - while (XPending (vdp_sink->device->display)) { - XNextEvent (vdp_sink->device->display, &e); - - switch (e.type) { - case ClientMessage:{ - Atom wm_delete; - - wm_delete = XInternAtom (vdp_sink->device->display, - "WM_DELETE_WINDOW", False); - if (wm_delete == (Atom) e.xclient.data.l[0]) { - /* Handle window deletion by posting an error on the bus */ - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, NOT_FOUND, - ("Output window was closed"), (NULL)); - - g_mutex_unlock (vdp_sink->x_lock); - gst_vdp_sink_window_destroy (vdp_sink, vdp_sink->window); - vdp_sink->window = NULL; - g_mutex_lock (vdp_sink->x_lock); - } - break; - } - default: - break; - } - } - - g_mutex_unlock (vdp_sink->x_lock); - g_mutex_unlock (vdp_sink->flow_lock); -} - -static gpointer -gst_vdp_sink_event_thread (VdpSink * vdp_sink) -{ - g_return_val_if_fail (GST_IS_VDP_SINK (vdp_sink), NULL); - - GST_OBJECT_LOCK (vdp_sink); - while (vdp_sink->running) { - GST_OBJECT_UNLOCK (vdp_sink); - - if (vdp_sink->window) { - gst_vdp_sink_handle_xevents (vdp_sink); - } - g_usleep (100000); - - GST_OBJECT_LOCK (vdp_sink); - } - GST_OBJECT_UNLOCK (vdp_sink); - - return NULL; -} - -/* This function calculates the pixel aspect ratio */ -static GValue * -gst_vdp_sink_calculate_par (Display * display) -{ - static const gint par[][2] = { - {1, 1}, /* regular screen */ - {16, 15}, /* PAL TV */ - {11, 10}, /* 525 line Rec.601 video */ - {54, 59}, /* 625 line Rec.601 video */ - {64, 45}, /* 1280x1024 on 16:9 display */ - {5, 3}, /* 1280x1024 on 4:3 display */ - {4, 3} /* 800x600 on 16:9 display */ - }; - gint screen_num; - gint width, height; - gint widthmm, heightmm; - gint i; - gint index; - gdouble ratio; - gdouble delta; - GValue *par_value; - -#define DELTA(idx) (ABS (ratio - ((gdouble) par[idx][0] / par[idx][1]))) - - screen_num = DefaultScreen (display); - width = DisplayWidth (display, screen_num); - height = DisplayHeight (display, screen_num); - widthmm = DisplayWidthMM (display, screen_num); - heightmm = DisplayHeightMM (display, screen_num); - - /* first calculate the "real" ratio based on the X values; - * which is the "physical" w/h divided by the w/h in pixels of the display */ - ratio = (gdouble) (widthmm * height) - / (heightmm * width); - - /* DirectFB's X in 720x576 reports the physical dimensions wrong, so - * override here */ - if (width == 720 && height == 576) { - ratio = 4.0 * 576 / (3.0 * 720); - } - GST_DEBUG ("calculated pixel aspect ratio: %f", ratio); - - /* now find the one from par[][2] with the lowest delta to the real one */ - delta = DELTA (0); - index = 0; - - for (i = 1; i < sizeof (par) / (sizeof (gint) * 2); ++i) { - gdouble this_delta = DELTA (i); - - if (this_delta < delta) { - index = i; - delta = this_delta; - } - } - - GST_DEBUG ("Decided on index %d (%d/%d)", index, - par[index][0], par[index][1]); - - par_value = g_new0 (GValue, 1); - g_value_init (par_value, GST_TYPE_FRACTION); - gst_value_set_fraction (par_value, par[index][0], par[index][1]); - GST_DEBUG ("set X11 PAR to %d/%d", - gst_value_get_fraction_numerator (par_value), - gst_value_get_fraction_denominator (par_value)); - - return par_value; -} - -static GstCaps * -gst_vdp_sink_get_allowed_caps (GstVdpDevice * device, GValue * par) -{ - GstCaps *templ_caps, *allowed_caps, *caps; - gint i; - - allowed_caps = gst_vdp_output_buffer_get_allowed_caps (device); - templ_caps = gst_static_pad_template_get_caps (&sink_template); - caps = gst_caps_intersect (allowed_caps, templ_caps); - - gst_caps_unref (allowed_caps); - gst_caps_unref (templ_caps); - - if (!par) - par = gst_vdp_sink_calculate_par (device->display); - - for (i = 0; i < gst_caps_get_size (caps); i++) { - GstStructure *structure; - - structure = gst_caps_get_structure (caps, i); - gst_structure_set_value (structure, "pixel-aspect-ratio", par); - } - - return caps; -} - -static void -gst_vdp_sink_post_error (VdpSink * vdp_sink, GError * error) -{ - GstMessage *message; - - message = gst_message_new_error (GST_OBJECT (vdp_sink), error, NULL); - gst_element_post_message (GST_ELEMENT (vdp_sink), message); - g_error_free (error); -} - -static gboolean -gst_vdp_sink_open_device (VdpSink * vdp_sink) -{ - gboolean res; - GstVdpDevice *device; - GError *err; - - g_mutex_lock (vdp_sink->device_lock); - if (vdp_sink->device) { - res = TRUE; - goto done; - } - - err = NULL; - vdp_sink->device = device = gst_vdp_get_device (vdp_sink->display_name, &err); - if (!device) - goto device_error; - - vdp_sink->bpool = gst_vdp_output_buffer_pool_new (device); - - vdp_sink->caps = gst_vdp_sink_get_allowed_caps (device, vdp_sink->par); - GST_DEBUG ("runtime calculated caps: %" GST_PTR_FORMAT, vdp_sink->caps); - - /* call XSynchronize with the current value of synchronous */ - GST_DEBUG_OBJECT (vdp_sink, "XSynchronize called with %s", - vdp_sink->synchronous ? "TRUE" : "FALSE"); - XSynchronize (device->display, vdp_sink->synchronous); - - /* Setup our event listening thread */ - vdp_sink->running = TRUE; - vdp_sink->event_thread = g_thread_create ( - (GThreadFunc) gst_vdp_sink_event_thread, vdp_sink, TRUE, NULL); - - res = TRUE; - -done: - g_mutex_unlock (vdp_sink->device_lock); - return res; - -device_error: - gst_vdp_sink_post_error (vdp_sink, err); - res = FALSE; - goto done; -} - -static gboolean -gst_vdp_sink_start (GstBaseSink * bsink) -{ - VdpSink *vdp_sink = GST_VDP_SINK (bsink); - gboolean res = TRUE; - - vdp_sink->window = NULL; - vdp_sink->cur_image = NULL; - - vdp_sink->event_thread = NULL; - - vdp_sink->fps_n = 0; - vdp_sink->fps_d = 1; - - res = gst_vdp_sink_open_device (vdp_sink); - - return res; -} - -static void -gst_vdp_device_clear (VdpSink * vdp_sink) -{ - g_return_if_fail (GST_IS_VDP_SINK (vdp_sink)); - - GST_OBJECT_LOCK (vdp_sink); - if (vdp_sink->device == NULL) { - GST_OBJECT_UNLOCK (vdp_sink); - return; - } - GST_OBJECT_UNLOCK (vdp_sink); - - g_mutex_lock (vdp_sink->x_lock); - - g_object_unref (vdp_sink->bpool); - g_object_unref (vdp_sink->device); - vdp_sink->device = NULL; - - g_mutex_unlock (vdp_sink->x_lock); -} - -static gboolean -gst_vdp_sink_stop (GstBaseSink * bsink) -{ - VdpSink *vdp_sink = GST_VDP_SINK (bsink); - - vdp_sink->running = FALSE; - /* Wait for our event thread to finish before we clean up our stuff. */ - if (vdp_sink->event_thread) - g_thread_join (vdp_sink->event_thread); - - if (vdp_sink->cur_image) { - gst_buffer_unref (GST_BUFFER_CAST (vdp_sink->cur_image)); - vdp_sink->cur_image = NULL; - } - - g_mutex_lock (vdp_sink->flow_lock); - if (vdp_sink->window) { - gst_vdp_sink_window_destroy (vdp_sink, vdp_sink->window); - vdp_sink->window = NULL; - } - g_mutex_unlock (vdp_sink->flow_lock); - - gst_vdp_device_clear (vdp_sink); - - return TRUE; -} - -/* Element stuff */ - -static GstCaps * -gst_vdp_sink_getcaps (GstBaseSink * bsink) -{ - VdpSink *vdp_sink; - GstCaps *caps; - - vdp_sink = GST_VDP_SINK (bsink); - - if (vdp_sink->caps) - caps = gst_caps_copy (vdp_sink->caps); - else - caps = gst_static_pad_template_get_caps (&sink_template); - - return caps; -} - -static gboolean -gst_vdp_sink_setcaps (GstBaseSink * bsink, GstCaps * caps) -{ - VdpSink *vdp_sink; - GstCaps *allowed_caps; - gboolean ret = TRUE; - GstStructure *structure; - GstCaps *intersection; - gint new_width, new_height; - const GValue *fps; - - vdp_sink = GST_VDP_SINK (bsink); - - GST_OBJECT_LOCK (vdp_sink); - if (!vdp_sink->device) - return FALSE; - GST_OBJECT_UNLOCK (vdp_sink); - - allowed_caps = gst_pad_get_caps (GST_BASE_SINK_PAD (bsink)); - GST_DEBUG_OBJECT (vdp_sink, - "sinkconnect possible caps %" GST_PTR_FORMAT " with given caps %" - GST_PTR_FORMAT, allowed_caps, caps); - - /* We intersect those caps with our template to make sure they are correct */ - intersection = gst_caps_intersect (allowed_caps, caps); - gst_caps_unref (allowed_caps); - - GST_DEBUG_OBJECT (vdp_sink, "intersection returned %" GST_PTR_FORMAT, - intersection); - if (gst_caps_is_empty (intersection)) { - gst_caps_unref (intersection); - return FALSE; - } - - gst_caps_unref (intersection); - - structure = gst_caps_get_structure (caps, 0); - - ret &= gst_structure_get_int (structure, "width", &new_width); - ret &= gst_structure_get_int (structure, "height", &new_height); - fps = gst_structure_get_value (structure, "framerate"); - ret &= (fps != NULL); - if (!ret) - return FALSE; - - GST_VIDEO_SINK_WIDTH (vdp_sink) = new_width; - GST_VIDEO_SINK_HEIGHT (vdp_sink) = new_height; - vdp_sink->fps_n = gst_value_get_fraction_numerator (fps); - vdp_sink->fps_d = gst_value_get_fraction_denominator (fps); - - gst_vdp_buffer_pool_set_caps (vdp_sink->bpool, caps); - - /* Notify application to set xwindow id now */ - g_mutex_lock (vdp_sink->flow_lock); - if (!vdp_sink->window) { - g_mutex_unlock (vdp_sink->flow_lock); - gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (vdp_sink)); - } else { - g_mutex_unlock (vdp_sink->flow_lock); - } - - /* Creating our window and our image */ - if (GST_VIDEO_SINK_WIDTH (vdp_sink) <= 0 - || GST_VIDEO_SINK_HEIGHT (vdp_sink) <= 0) { - GST_ELEMENT_ERROR (vdp_sink, CORE, NEGOTIATION, (NULL), - ("Invalid image size.")); - return FALSE; - } - - g_mutex_lock (vdp_sink->flow_lock); - if (!vdp_sink->window) { - vdp_sink->window = gst_vdp_sink_window_new (vdp_sink, - GST_VIDEO_SINK_WIDTH (vdp_sink), GST_VIDEO_SINK_HEIGHT (vdp_sink)); - } - g_mutex_unlock (vdp_sink->flow_lock); - - return TRUE; -} - -static void -gst_vdp_sink_get_times (GstBaseSink * bsink, GstBuffer * buf, - GstClockTime * start, GstClockTime * end) -{ - VdpSink *vdp_sink; - - vdp_sink = GST_VDP_SINK (bsink); - - if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { - *start = GST_BUFFER_TIMESTAMP (buf); - if (GST_BUFFER_DURATION_IS_VALID (buf)) { - *end = *start + GST_BUFFER_DURATION (buf); - } else { - if (vdp_sink->fps_n > 0) { - *end = *start + - gst_util_uint64_scale_int (GST_SECOND, vdp_sink->fps_d, - vdp_sink->fps_n); - } - } - } -} - -static GstFlowReturn -gst_vdp_sink_show_frame (GstBaseSink * bsink, GstBuffer * outbuf) -{ - VdpSink *vdp_sink = GST_VDP_SINK (bsink); - VdpStatus status; - GstVdpDevice *device; - - g_return_val_if_fail (GST_IS_VDP_SINK (vdp_sink), FALSE); - - /* We take the flow_lock. If expose is in there we don't want to run - concurrently from the data flow thread */ - g_mutex_lock (vdp_sink->flow_lock); - - if (G_UNLIKELY (vdp_sink->window == NULL)) { - g_mutex_unlock (vdp_sink->flow_lock); - return GST_FLOW_ERROR; - } - - device = vdp_sink->device; - - if (vdp_sink->cur_image) { - VdpOutputSurface surface = - GST_VDP_OUTPUT_BUFFER (vdp_sink->cur_image)->surface; - VdpPresentationQueueStatus queue_status; - VdpTime pres_time; - - g_mutex_lock (vdp_sink->x_lock); - status = - device->vdp_presentation_queue_query_surface_status (vdp_sink-> - window->queue, surface, &queue_status, &pres_time); - g_mutex_unlock (vdp_sink->x_lock); - - if (queue_status == VDP_PRESENTATION_QUEUE_STATUS_QUEUED) { - g_mutex_unlock (vdp_sink->flow_lock); - return GST_FLOW_OK; - } - } - - /* Expose sends a NULL image, we take the latest frame */ - if (!outbuf) { - if (vdp_sink->cur_image) { - outbuf = vdp_sink->cur_image; - } else { - g_mutex_unlock (vdp_sink->flow_lock); - return GST_FLOW_OK; - } - } - - gst_vdp_sink_window_update_geometry (vdp_sink, vdp_sink->window); - - g_mutex_lock (vdp_sink->x_lock); - - status = device->vdp_presentation_queue_display (vdp_sink->window->queue, - GST_VDP_OUTPUT_BUFFER (outbuf)->surface, 0, 0, 0); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vdp_sink, RESOURCE, READ, - ("Could not display frame"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - - g_mutex_unlock (vdp_sink->x_lock); - g_mutex_unlock (vdp_sink->flow_lock); - return GST_FLOW_ERROR; - } - - - if (!vdp_sink->cur_image) - vdp_sink->cur_image = gst_buffer_ref (outbuf); - - else if (vdp_sink->cur_image != outbuf) { - gst_buffer_unref (vdp_sink->cur_image); - vdp_sink->cur_image = gst_buffer_ref (outbuf); - } - - XSync (vdp_sink->device->display, FALSE); - - g_mutex_unlock (vdp_sink->x_lock); - g_mutex_unlock (vdp_sink->flow_lock); - - return GST_FLOW_OK; -} - - -static gboolean -gst_vdp_sink_event (GstBaseSink * sink, GstEvent * event) -{ - VdpSink *vdp_sink = GST_VDP_SINK (sink); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_TAG:{ - GstTagList *l; - gchar *title = NULL; - - gst_event_parse_tag (event, &l); - gst_tag_list_get_string (l, GST_TAG_TITLE, &title); - - if (title) { - GST_DEBUG_OBJECT (vdp_sink, "got tags, title='%s'", title); - gst_vdp_sink_window_set_title (vdp_sink, vdp_sink->window, title); - - g_free (title); - } - break; - } - default: - break; - } - if (GST_BASE_SINK_CLASS (parent_class)->event) - return GST_BASE_SINK_CLASS (parent_class)->event (sink, event); - else - return TRUE; -} - -/* Buffer management - * - * The buffer_alloc function must either return a buffer with given size and - * caps or create a buffer with different caps attached to the buffer. This - * last option is called reverse negotiation, ie, where the sink suggests a - * different format from the upstream peer. - * - * We try to do reverse negotiation when our geometry changes and we like a - * resized buffer. - */ -static GstFlowReturn -gst_vdp_sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, - GstCaps * caps, GstBuffer ** buf) -{ - VdpSink *vdp_sink; - GstStructure *structure = NULL; - GstFlowReturn ret = GST_FLOW_OK; - gint width, height; - GstCaps *alloc_caps; - gint w_width, w_height; - GError *err; - - vdp_sink = GST_VDP_SINK (bsink); - - GST_LOG_OBJECT (vdp_sink, - "a buffer of %d bytes was requested with caps %" GST_PTR_FORMAT - " and offset %" G_GUINT64_FORMAT, size, caps, offset); - - /* get struct to see what is requested */ - structure = gst_caps_get_structure (caps, 0); - if (!gst_structure_get_int (structure, "width", &width) || - !gst_structure_get_int (structure, "height", &height)) { - GST_WARNING_OBJECT (vdp_sink, "invalid caps for buffer allocation %" - GST_PTR_FORMAT, caps); - ret = GST_FLOW_NOT_NEGOTIATED; - goto beach; - } - - alloc_caps = gst_caps_ref (caps); - - /* We take the flow_lock because the window might go away */ - g_mutex_lock (vdp_sink->flow_lock); - if (!vdp_sink->window) { - g_mutex_unlock (vdp_sink->flow_lock); - goto alloc; - } - - /* What is our geometry */ - gst_vdp_sink_window_update_geometry (vdp_sink, vdp_sink->window); - w_width = vdp_sink->window->width; - w_height = vdp_sink->window->height; - - g_mutex_unlock (vdp_sink->flow_lock); - - /* We would like another geometry */ - if (width != w_width || height != w_height) { - GstCaps *new_caps, *allowed_caps, *desired_caps; - GstStructure *desired_struct; - - /* make a copy of the incomming caps to create the new - * suggestion. We can't use make_writable because we might - * then destroy the original caps which we still need when the - * peer does not accept the suggestion. */ - new_caps = gst_caps_copy (caps); - desired_struct = gst_caps_get_structure (new_caps, 0); - - GST_DEBUG ("we would love to receive a %dx%d video", w_width, w_height); - gst_structure_set (desired_struct, "width", G_TYPE_INT, w_width, NULL); - gst_structure_set (desired_struct, "height", G_TYPE_INT, w_height, NULL); - - allowed_caps = gst_pad_get_caps (GST_BASE_SINK_PAD (vdp_sink)); - desired_caps = gst_caps_intersect (new_caps, allowed_caps); - - gst_caps_unref (new_caps); - gst_caps_unref (allowed_caps); - - /* see if peer accepts our new suggestion, if there is no peer, this - * function returns true. */ - if (gst_pad_peer_accept_caps (GST_VIDEO_SINK_PAD (vdp_sink), desired_caps)) { - /* we will not alloc a buffer of the new suggested caps. Make sure - * we also unref this new caps after we set it on the buffer. */ - GST_DEBUG ("peer pad accepts our desired caps %" GST_PTR_FORMAT, - desired_caps); - gst_caps_unref (alloc_caps); - alloc_caps = desired_caps; - } else { - GST_DEBUG ("peer pad does not accept our desired caps %" GST_PTR_FORMAT, - desired_caps); - /* we alloc a buffer with the original incomming caps already in the - * width and height variables */ - gst_caps_unref (desired_caps); - } - } - -alloc: - gst_vdp_buffer_pool_set_caps (vdp_sink->bpool, alloc_caps); - gst_caps_unref (alloc_caps); - - err = NULL; - *buf = - GST_BUFFER_CAST (gst_vdp_buffer_pool_get_buffer (vdp_sink->bpool, &err)); - if (!*buf) { - gst_vdp_sink_post_error (vdp_sink, err); - return GST_FLOW_ERROR; - } - -beach: - return ret; -} - -/* Interfaces stuff */ - -static gboolean -gst_vdp_sink_interface_supported (GstImplementsInterface * iface, GType type) -{ - g_assert (type == GST_TYPE_NAVIGATION || type == GST_TYPE_X_OVERLAY); - return TRUE; -} - -static void -gst_vdp_sink_interface_init (GstImplementsInterfaceClass * klass) -{ - klass->supported = gst_vdp_sink_interface_supported; -} - -static void -gst_vdp_sink_navigation_send_event (GstNavigation * navigation, - GstStructure * structure) -{ - VdpSink *vdp_sink = GST_VDP_SINK (navigation); - GstEvent *event; - gint x_offset, y_offset; - gdouble x, y; - GstPad *pad = NULL; - - event = gst_event_new_navigation (structure); - - /* We are not converting the pointer coordinates as there's no hardware - scaling done here. The only possible scaling is done by videoscale and - videoscale will have to catch those events and tranform the coordinates - to match the applied scaling. So here we just add the offset if the image - is centered in the window. */ - - /* We take the flow_lock while we look at the window */ - g_mutex_lock (vdp_sink->flow_lock); - - if (!vdp_sink->window) { - g_mutex_unlock (vdp_sink->flow_lock); - return; - } - - x_offset = vdp_sink->window->width - GST_VIDEO_SINK_WIDTH (vdp_sink); - y_offset = vdp_sink->window->height - GST_VIDEO_SINK_HEIGHT (vdp_sink); - - g_mutex_unlock (vdp_sink->flow_lock); - - if (x_offset > 0 && gst_structure_get_double (structure, "pointer_x", &x)) { - x -= x_offset / 2; - gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL); - } - if (y_offset > 0 && gst_structure_get_double (structure, "pointer_y", &y)) { - y -= y_offset / 2; - gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL); - } - - pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (vdp_sink)); - - if (GST_IS_PAD (pad) && GST_IS_EVENT (event)) { - gst_pad_send_event (pad, event); - - gst_object_unref (pad); - } -} - -static void -gst_vdp_sink_navigation_init (GstNavigationInterface * iface) -{ - iface->send_event = gst_vdp_sink_navigation_send_event; -} - -static void -gst_vdp_sink_set_window_handle (GstXOverlay * overlay, guintptr window_handle) -{ - VdpSink *vdp_sink = GST_VDP_SINK (overlay); - GstVdpWindow *window = NULL; - XWindowAttributes attr; - Window xwindow_id = (XID) window_handle; - - /* We acquire the stream lock while setting this window in the element. - We are basically cleaning tons of stuff replacing the old window, putting - images while we do that would surely crash */ - g_mutex_lock (vdp_sink->flow_lock); - - /* If we already use that window return */ - if (vdp_sink->window && (xwindow_id == vdp_sink->window->win)) { - g_mutex_unlock (vdp_sink->flow_lock); - return; - } - - /* If the element has not initialized the X11 context try to do so */ - if (!gst_vdp_sink_open_device (vdp_sink)) { - g_mutex_unlock (vdp_sink->flow_lock); - /* we have thrown a GST_ELEMENT_ERROR now */ - return; - } - - /* If a window is there already we destroy it */ - if (vdp_sink->window) { - gst_vdp_sink_window_destroy (vdp_sink, vdp_sink->window); - vdp_sink->window = NULL; - } - - /* If the xid is 0 we go back to an internal window */ - if (xwindow_id == 0) { - /* If no width/height caps nego did not happen window will be created - during caps nego then */ - if (GST_VIDEO_SINK_WIDTH (vdp_sink) && GST_VIDEO_SINK_HEIGHT (vdp_sink)) { - window = gst_vdp_sink_window_new (vdp_sink, - GST_VIDEO_SINK_WIDTH (vdp_sink), GST_VIDEO_SINK_HEIGHT (vdp_sink)); - } - } else { - window = g_new0 (GstVdpWindow, 1); - - window->win = xwindow_id; - - /* We get window geometry, set the event we want to receive, - and create a GC */ - g_mutex_lock (vdp_sink->x_lock); - XGetWindowAttributes (vdp_sink->device->display, window->win, &attr); - window->width = attr.width; - window->height = attr.height; - window->internal = FALSE; - if (vdp_sink->handle_events) { - XSelectInput (vdp_sink->device->display, window->win, ExposureMask | - StructureNotifyMask | PointerMotionMask | KeyPressMask | - KeyReleaseMask); - } - g_mutex_unlock (vdp_sink->x_lock); - - gst_vdp_sink_window_setup_vdpau (vdp_sink, window); - } - - if (window) - vdp_sink->window = window; - - g_mutex_unlock (vdp_sink->flow_lock); -} - -static void -gst_vdp_sink_expose (GstXOverlay * overlay) -{ - gst_vdp_sink_show_frame (GST_BASE_SINK (overlay), NULL); -} - -static void -gst_vdp_sink_set_event_handling (GstXOverlay * overlay, gboolean handle_events) -{ - VdpSink *vdp_sink = GST_VDP_SINK (overlay); - - vdp_sink->handle_events = handle_events; - - g_mutex_lock (vdp_sink->flow_lock); - - if (G_UNLIKELY (!vdp_sink->window)) { - g_mutex_unlock (vdp_sink->flow_lock); - return; - } - - g_mutex_lock (vdp_sink->x_lock); - - if (handle_events) { - if (vdp_sink->window->internal) { - XSelectInput (vdp_sink->device->display, vdp_sink->window->win, - ExposureMask | StructureNotifyMask | PointerMotionMask | - KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask); - } else { - XSelectInput (vdp_sink->device->display, vdp_sink->window->win, - ExposureMask | StructureNotifyMask | PointerMotionMask | - KeyPressMask | KeyReleaseMask); - } - } else { - XSelectInput (vdp_sink->device->display, vdp_sink->window->win, 0); - } - - g_mutex_unlock (vdp_sink->x_lock); - - g_mutex_unlock (vdp_sink->flow_lock); -} - -static void -gst_vdp_sink_xoverlay_init (GstXOverlayClass * iface) -{ - iface->set_window_handle = gst_vdp_sink_set_window_handle; - iface->expose = gst_vdp_sink_expose; - iface->handle_events = gst_vdp_sink_set_event_handling; -} - -/* =========================================== */ -/* */ -/* Init & Class init */ -/* */ -/* =========================================== */ - -static void -gst_vdp_sink_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - VdpSink *vdp_sink; - - g_return_if_fail (GST_IS_VDP_SINK (object)); - - vdp_sink = GST_VDP_SINK (object); - - switch (prop_id) { - case PROP_DISPLAY: - vdp_sink->display_name = g_strdup (g_value_get_string (value)); - break; - case PROP_SYNCHRONOUS: - vdp_sink->synchronous = g_value_get_boolean (value); - if (vdp_sink->device) { - GST_DEBUG_OBJECT (vdp_sink, "XSynchronize called with %s", - vdp_sink->synchronous ? "TRUE" : "FALSE"); - g_mutex_lock (vdp_sink->x_lock); - XSynchronize (vdp_sink->device->display, vdp_sink->synchronous); - g_mutex_unlock (vdp_sink->x_lock); - } - break; - case PROP_PIXEL_ASPECT_RATIO: - { - GValue *tmp; - - tmp = g_new0 (GValue, 1); - g_value_init (tmp, GST_TYPE_FRACTION); - - if (!g_value_transform (value, tmp)) { - GST_WARNING_OBJECT (vdp_sink, - "Could not transform string to aspect ratio"); - g_free (tmp); - } else { - GST_DEBUG_OBJECT (vdp_sink, "set PAR to %d/%d", - gst_value_get_fraction_numerator (tmp), - gst_value_get_fraction_denominator (tmp)); - g_free (vdp_sink->par); - vdp_sink->par = tmp; - } - } - break; - case PROP_HANDLE_EVENTS: - gst_vdp_sink_set_event_handling (GST_X_OVERLAY (vdp_sink), - g_value_get_boolean (value)); - break; - case PROP_HANDLE_EXPOSE: - vdp_sink->handle_expose = g_value_get_boolean (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_vdp_sink_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - VdpSink *vdp_sink; - - g_return_if_fail (GST_IS_VDP_SINK (object)); - - vdp_sink = GST_VDP_SINK (object); - - switch (prop_id) { - case PROP_DISPLAY: - g_value_set_string (value, vdp_sink->display_name); - break; - case PROP_SYNCHRONOUS: - g_value_set_boolean (value, vdp_sink->synchronous); - break; - case PROP_PIXEL_ASPECT_RATIO: - if (vdp_sink->par) - g_value_transform (vdp_sink->par, value); - break; - case PROP_HANDLE_EVENTS: - g_value_set_boolean (value, vdp_sink->handle_events); - break; - case PROP_HANDLE_EXPOSE: - g_value_set_boolean (value, vdp_sink->handle_expose); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_vdp_sink_finalize (GObject * object) -{ - VdpSink *vdp_sink; - - vdp_sink = GST_VDP_SINK (object); - - if (vdp_sink->display_name) { - g_free (vdp_sink->display_name); - vdp_sink->display_name = NULL; - } - if (vdp_sink->par) { - g_free (vdp_sink->par); - vdp_sink->par = NULL; - } - if (vdp_sink->device_lock) { - g_mutex_free (vdp_sink->device_lock); - vdp_sink->device_lock = NULL; - } - if (vdp_sink->x_lock) { - g_mutex_free (vdp_sink->x_lock); - vdp_sink->x_lock = NULL; - } - if (vdp_sink->flow_lock) { - g_mutex_free (vdp_sink->flow_lock); - vdp_sink->flow_lock = NULL; - } - - g_free (vdp_sink->media_title); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gst_vdp_sink_init (VdpSink * vdp_sink) -{ - vdp_sink->device = NULL; - - vdp_sink->display_name = NULL; - vdp_sink->par = NULL; - - vdp_sink->device_lock = g_mutex_new (); - vdp_sink->x_lock = g_mutex_new (); - vdp_sink->flow_lock = g_mutex_new (); - - vdp_sink->synchronous = FALSE; - vdp_sink->handle_events = TRUE; - vdp_sink->handle_expose = TRUE; -} - -static void -gst_vdp_sink_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - - gst_element_class_set_static_metadata (element_class, - "VDPAU Sink", - "Sink/Video", - "VDPAU Sink", "Carl-Anton Ingmarsson "); - - gst_element_class_add_static_pad_template (element_class, &sink_template); -} - -static void -gst_vdp_sink_class_init (VdpSinkClass * klass) -{ - GObjectClass *gobject_class; - GstBaseSinkClass *gstbasesink_class; - - gobject_class = (GObjectClass *) klass; - gstbasesink_class = (GstBaseSinkClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->finalize = gst_vdp_sink_finalize; - gobject_class->set_property = gst_vdp_sink_set_property; - gobject_class->get_property = gst_vdp_sink_get_property; - - g_object_class_install_property (gobject_class, PROP_DISPLAY, - g_param_spec_string ("display", "Display", "X Display name", - NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_SYNCHRONOUS, - g_param_spec_boolean ("synchronous", "Synchronous", "When enabled, runs " - "the X display in synchronous mode. (used only for debugging)", FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_PIXEL_ASPECT_RATIO, - g_param_spec_string ("pixel-aspect-ratio", "Pixel Aspect Ratio", - "The pixel aspect ratio of the device", "1/1", - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_HANDLE_EVENTS, - g_param_spec_boolean ("handle-events", "Handle XEvents", - "When enabled, XEvents will be selected and handled", TRUE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_HANDLE_EXPOSE, - g_param_spec_boolean ("handle-expose", "Handle expose", - "When enabled, " - "the current frame will always be drawn in response to X Expose " - "events", TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_vdp_sink_start); - gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_vdp_sink_stop); - gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_vdp_sink_getcaps); - gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_vdp_sink_setcaps); - gstbasesink_class->buffer_alloc = - GST_DEBUG_FUNCPTR (gst_vdp_sink_buffer_alloc); - gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_vdp_sink_get_times); - gstbasesink_class->preroll = GST_DEBUG_FUNCPTR (gst_vdp_sink_show_frame); - gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_vdp_sink_show_frame); - gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_vdp_sink_event); -} - -/* ============================================================= */ -/* */ -/* Public Methods */ -/* */ -/* ============================================================= */ - -/* =========================================== */ -/* */ -/* Object typing & Creation */ -/* */ -/* =========================================== */ - -GType -gst_vdp_sink_get_type (void) -{ - static GType vdp_sink_type = 0; - - if (!vdp_sink_type) { - static const GTypeInfo vdp_sink_info = { - sizeof (VdpSinkClass), - gst_vdp_sink_base_init, - NULL, - (GClassInitFunc) gst_vdp_sink_class_init, - NULL, - NULL, - sizeof (VdpSink), - 0, - (GInstanceInitFunc) gst_vdp_sink_init, - }; - static const GInterfaceInfo iface_info = { - (GInterfaceInitFunc) gst_vdp_sink_interface_init, - NULL, - NULL, - }; - static const GInterfaceInfo navigation_info = { - (GInterfaceInitFunc) gst_vdp_sink_navigation_init, - NULL, - NULL, - }; - static const GInterfaceInfo overlay_info = { - (GInterfaceInitFunc) gst_vdp_sink_xoverlay_init, - NULL, - NULL, - }; - - vdp_sink_type = g_type_register_static (GST_TYPE_VIDEO_SINK, - "VdpSink", &vdp_sink_info, 0); - - g_type_add_interface_static (vdp_sink_type, GST_TYPE_IMPLEMENTS_INTERFACE, - &iface_info); - g_type_add_interface_static (vdp_sink_type, GST_TYPE_NAVIGATION, - &navigation_info); - g_type_add_interface_static (vdp_sink_type, GST_TYPE_X_OVERLAY, - &overlay_info); - } - - DEBUG_INIT (); - - return vdp_sink_type; -} diff --git a/sys/vdpau/gstvdpsink.h b/sys/vdpau/gstvdpsink.h deleted file mode 100644 index 04e3bd5882..0000000000 --- a/sys/vdpau/gstvdpsink.h +++ /dev/null @@ -1,138 +0,0 @@ -/* GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * Copyright (C) 2005 Julien Moutte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_VDP_SINK_H__ -#define __GST_VDP_SINK_H__ - -#include - -#include -#include - -#include -#include - -#include "gstvdpdevice.h" - -G_BEGIN_DECLS - -#define GST_TYPE_VDP_SINK \ - (gst_vdp_sink_get_type()) -#define GST_VDP_SINK(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VDP_SINK, VdpSink)) -#define GST_VDP_SINK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VDP_SINK, VdpSinkClass)) -#define GST_IS_VDP_SINK(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VDP_SINK)) -#define GST_IS_VDP_SINK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VDP_SINK)) - -typedef struct _GstXContext GstXContext; -typedef struct _GstVdpWindow GstVdpWindow; - -typedef struct _VdpSink VdpSink; -typedef struct _VdpSinkClass VdpSinkClass; - -/* - * GstVdpWindow: - * @win: the Window ID of this X11 window - * @target the VdpPresentationQueueTarget of this window - * @queue the VdpPresentationQueue of this window - * @width: the width in pixels of Window @win - * @height: the height in pixels of Window @win - * @internal: used to remember if Window @win was created internally or passed - * through the #GstXOverlay interface - * - * Structure used to store informations about a Window. - */ -struct _GstVdpWindow { - Window win; - VdpPresentationQueueTarget target; - VdpPresentationQueue queue; - gint width, height; - gboolean internal; -}; - -/** - * VdpSink: - * @display_name: the name of the Display we want to render to - * @device: the GstVdpDevice associated with the display_name - * @window: the #GstVdpWindow we are rendering to - * @cur_image: a reference to the last #GstBuffer that was put to @window. It - * is used when Expose events are received to redraw the latest video frame - * @event_thread: a thread listening for events on @window and handling them - * @running: used to inform @event_thread if it should run/shutdown - * @fps_n: the framerate fraction numerator - * @fps_d: the framerate fraction denominator - * @x_lock: used to protect X calls as we are not using the XLib in threaded - * mode - * @flow_lock: used to protect data flow routines from external calls such as - * events from @event_thread or methods from the #GstXOverlay interface - * @par: used to override calculated pixel aspect ratio from @xcontext - * @synchronous: used to store if XSynchronous should be used or not (for - * debugging purpose only) - * @handle_events: used to know if we should handle select XEvents or not - * - * The #VdpSink data structure. - */ -struct _VdpSink { - /* Our element stuff */ - GstVideoSink videosink; - - char *display_name; - - GstVdpDevice *device; - GstBufferPool *bpool; - GstCaps *caps; - - GstVdpWindow *window; - GstBuffer *cur_image; - - GThread *event_thread; - gboolean running; - - /* Framerate numerator and denominator */ - gint fps_n; - gint fps_d; - - GMutex *device_lock; - GMutex *x_lock; - GMutex *flow_lock; - - /* object-set pixel aspect ratio */ - GValue *par; - - gboolean synchronous; - gboolean handle_events; - gboolean handle_expose; - - /* stream metadata */ - gchar *media_title; -}; - -struct _VdpSinkClass { - GstVideoSinkClass parent_class; -}; - -GType gst_vdp_sink_get_type(void); - -G_END_DECLS - -#endif /* __GST_VDP_SINK_H__ */ diff --git a/sys/vdpau/gstvdputils.c b/sys/vdpau/gstvdputils.c deleted file mode 100644 index 0092358887..0000000000 --- a/sys/vdpau/gstvdputils.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * gst-plugins-bad - * Copyright (C) 2012 Edward Hervey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstvdputils.h" - -typedef struct -{ - VdpChromaType chroma_type; - VdpYCbCrFormat format; - GstVideoFormat vformat; -} GstVdpVideoBufferFormats; - -static const GstVdpVideoBufferFormats yuv_formats[] = { - {VDP_CHROMA_TYPE_420, VDP_YCBCR_FORMAT_YV12, GST_VIDEO_FORMAT_YV12}, - {VDP_CHROMA_TYPE_420, VDP_YCBCR_FORMAT_NV12, GST_VIDEO_FORMAT_NV12}, - {VDP_CHROMA_TYPE_422, VDP_YCBCR_FORMAT_UYVY, GST_VIDEO_FORMAT_UYVY}, - {VDP_CHROMA_TYPE_444, VDP_YCBCR_FORMAT_V8U8Y8A8, GST_VIDEO_FORMAT_AYUV}, - /* { */ - /* VDP_CHROMA_TYPE_444, */ - /* VDP_YCBCR_FORMAT_Y8U8V8A8, */ - /* GST_MAKE_FOURCC ('A', 'V', 'U', 'Y') */ - /* }, */ - {VDP_CHROMA_TYPE_422, VDP_YCBCR_FORMAT_YUYV, GST_VIDEO_FORMAT_YUY2} -}; - -VdpYCbCrFormat -gst_video_format_to_vdp_ycbcr (GstVideoFormat format) -{ - int i; - - for (i = 0; i < G_N_ELEMENTS (yuv_formats); i++) { - if (yuv_formats[i].vformat == format) - return yuv_formats[i].format; - } - - return -1; -} - -VdpChromaType -gst_video_info_to_vdp_chroma_type (GstVideoInfo * info) -{ - const GstVideoFormatInfo *finfo = info->finfo; - VdpChromaType ret = -1; - - /* Check subsampling of second plane (first is always non-subsampled) */ - switch (GST_VIDEO_FORMAT_INFO_W_SUB (finfo, 1)) { - case 0: - /* Not subsampled in width for second plane */ - if (GST_VIDEO_FORMAT_INFO_W_SUB (finfo, 2)) - /* Not subsampled at all (4:4:4) */ - ret = VDP_CHROMA_TYPE_444; - break; - case 1: - /* Subsampled horizontally once */ - if (GST_VIDEO_FORMAT_INFO_H_SUB (finfo, 2) == 0) - /* Not subsampled vertically (4:2:2) */ - ret = VDP_CHROMA_TYPE_422; - else if (GST_VIDEO_FORMAT_INFO_H_SUB (finfo, 2) == 1) - /* Subsampled vertically once (4:2:0) */ - ret = VDP_CHROMA_TYPE_420; - break; - default: - break; - } - - return ret; -} diff --git a/sys/vdpau/gstvdputils.h b/sys/vdpau/gstvdputils.h deleted file mode 100644 index c7c83af3f8..0000000000 --- a/sys/vdpau/gstvdputils.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * gst-plugins-bad - * Copyright (C) 2012 Edward Hervey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GST_VDP_UTILS_H_ -#define _GST_VDP_UTILS_H_ - -#include -#include -#include -#include -#include "gstvdpdevice.h" - -G_BEGIN_DECLS - -VdpChromaType gst_video_info_to_vdp_chroma_type (GstVideoInfo *info); - -VdpYCbCrFormat gst_video_format_to_vdp_ycbcr (GstVideoFormat format); - -G_END_DECLS - -#endif /* _GST_VDP_UTILS_H_ */ diff --git a/sys/vdpau/gstvdpvideobufferpool.c b/sys/vdpau/gstvdpvideobufferpool.c deleted file mode 100644 index 33f346e481..0000000000 --- a/sys/vdpau/gstvdpvideobufferpool.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * gst-plugins-bad - * Copyright (C) 2012 Edward Hervey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstvdpvideobufferpool.h" -#include "gstvdpvideomemory.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_vidbufpool_debug); -#define GST_CAT_DEFAULT gst_vdp_vidbufpool_debug - -static void gst_vdp_video_buffer_pool_finalize (GObject * object); - -#define DEBUG_INIT \ - GST_DEBUG_CATEGORY_INIT (gst_vdp_vidbufpool_debug, "vdpvideopool", 0, \ - "VDPAU Video bufferpool"); - -#define gst_vdp_video_buffer_pool_parent_class parent_class -G_DEFINE_TYPE_WITH_CODE (GstVdpVideoBufferPool, gst_vdp_video_buffer_pool, - GST_TYPE_BUFFER_POOL, DEBUG_INIT); - -static const gchar ** -gst_vdp_video_buffer_pool_get_options (GstBufferPool * pool) -{ - static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META, - GST_BUFFER_POOL_OPTION_VDP_VIDEO_META, NULL - }; - - return options; -} - -static gboolean -gst_vdp_video_buffer_pool_set_config (GstBufferPool * pool, - GstStructure * config) -{ - GstVdpVideoBufferPool *vdppool = GST_VDP_VIDEO_BUFFER_POOL_CAST (pool); - GstVideoInfo info; - GstCaps *caps; - - if (!gst_buffer_pool_config_get_params (config, &caps, NULL, NULL, NULL)) - goto wrong_config; - - if (caps == NULL) - goto no_caps; - - /* now parse the caps from the config */ - if (!gst_video_info_from_caps (&info, caps)) - goto wrong_caps; - - GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, info.width, info.height, - caps); - - if (GST_VIDEO_INFO_FORMAT (&info) == GST_VIDEO_FORMAT_UNKNOWN) - goto unknown_format; - - vdppool->info = info; - - /* enable metadata based on config of the pool */ - vdppool->add_videometa = - gst_buffer_pool_config_has_option (config, - GST_BUFFER_POOL_OPTION_VIDEO_META); - - /* parse extra alignment info */ - vdppool->add_vdpmeta = gst_buffer_pool_config_has_option (config, - GST_BUFFER_POOL_OPTION_VDP_VIDEO_META); - - return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config); - - /* ERRORS */ -wrong_config: - { - GST_WARNING_OBJECT (pool, "invalid config"); - return FALSE; - } -no_caps: - { - GST_WARNING_OBJECT (pool, "no caps in config"); - return FALSE; - } -wrong_caps: - { - GST_WARNING_OBJECT (pool, - "failed getting geometry from caps %" GST_PTR_FORMAT, caps); - return FALSE; - } -unknown_format: - { - GST_WARNING_OBJECT (vdppool, "failed to get format from caps %" - GST_PTR_FORMAT, caps); - GST_ELEMENT_ERROR (vdppool, RESOURCE, WRITE, - ("Failed to create output image buffer of %dx%d pixels", - info.width, info.height), - ("Invalid input caps %" GST_PTR_FORMAT, caps)); - return FALSE; - } -} - -/* This function handles GstBuffer creation */ -static GstFlowReturn -gst_vdp_video_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, - GstBufferPoolAcquireParams * params) -{ - GstVdpVideoBufferPool *vdppool = GST_VDP_VIDEO_BUFFER_POOL_CAST (pool); - GstVideoInfo *info; - GstBuffer *buf; - GstMemory *vdp_mem; - - info = &vdppool->info; - - if (!(buf = gst_buffer_new ())) - goto no_buffer; - - if (!(vdp_mem = gst_vdp_video_memory_alloc (vdppool->device, info))) - goto mem_create_failed; - - gst_buffer_append_memory (buf, vdp_mem); - - if (vdppool->add_videometa) { - GstVideoMeta *vmeta; - - GST_DEBUG_OBJECT (pool, "adding GstVideoMeta"); - /* these are just the defaults for now */ - vmeta = gst_buffer_add_video_meta (buf, 0, GST_VIDEO_INFO_FORMAT (info), - GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info)); - vmeta->map = gst_vdp_video_memory_map; - vmeta->unmap = gst_vdp_video_memory_unmap; - } - - *buffer = buf; - - return GST_FLOW_OK; - - /* ERROR */ -no_buffer: - { - GST_WARNING_OBJECT (pool, "can't create image"); - return GST_FLOW_ERROR; - } - -mem_create_failed: - { - GST_WARNING_OBJECT (pool, "Could create GstVdpVideo Memory"); - return GST_FLOW_ERROR; - } -} - - -GstBufferPool * -gst_vdp_video_buffer_pool_new (GstVdpDevice * device) -{ - GstVdpVideoBufferPool *pool; - - pool = g_object_new (GST_TYPE_VDP_VIDEO_BUFFER_POOL, NULL); - g_object_ref_sink (pool); - pool->device = gst_object_ref (device); - - GST_LOG_OBJECT (pool, "new VdpVideo buffer pool %p", pool); - - return GST_BUFFER_POOL_CAST (pool); -} - -static void -gst_vdp_video_buffer_pool_class_init (GstVdpVideoBufferPoolClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass; - - gobject_class->finalize = gst_vdp_video_buffer_pool_finalize; - - gstbufferpool_class->get_options = gst_vdp_video_buffer_pool_get_options; - gstbufferpool_class->set_config = gst_vdp_video_buffer_pool_set_config; - gstbufferpool_class->alloc_buffer = gst_vdp_video_buffer_pool_alloc; -} - -static void -gst_vdp_video_buffer_pool_init (GstVdpVideoBufferPool * pool) -{ - -} - -static void -gst_vdp_video_buffer_pool_finalize (GObject * object) -{ - GstVdpVideoBufferPool *pool = GST_VDP_VIDEO_BUFFER_POOL_CAST (object); - - GST_LOG_OBJECT (pool, "finalize VdpVideo buffer pool %p", pool); - - gst_object_unref (pool->device); - - G_OBJECT_CLASS (gst_vdp_video_buffer_pool_parent_class)->finalize (object); -} diff --git a/sys/vdpau/gstvdpvideobufferpool.h b/sys/vdpau/gstvdpvideobufferpool.h deleted file mode 100644 index c2a180bb77..0000000000 --- a/sys/vdpau/gstvdpvideobufferpool.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * gst-plugins-bad - * Copyright (C) Carl-Anton Ingmarsson 2010 - * 2012 Edward Hervey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _GST_VDP_VIDEO_BUFFERPOOL_H_ -#define _GST_VDP_VIDEO_BUFFERPOOL_H_ - -#include -#include -#include -#include -#include "gstvdpdevice.h" - -G_BEGIN_DECLS - -#define GST_VDPAU_SURFACE_META_GET(buf) ((GstVdpauMeta *)gst_buffer_get_meta(buf,gst_vdpau_surface_meta_api_get_type())) -#define GST_VDPAU_SURFACE_META_ADD(buf) ((GstVdpauMeta *)gst_buffer_add_meta(buf,gst_vdpau_surface_meta_get_info(),NULL)) - -struct _GstVdpauSurfaceMeta { - GstMeta meta; - - GstVdpDevice *device; - VdpVideoSurface surface; -}; - -GType gst_vdpau_surface_meta_api_get_type (void); - -const GstMetaInfo * gst_vdpau_surface_meta_get_info (void); -/** - * GST_BUFFER_POOL_OPTION_VDP_VIDEO_META: - * - * An option that can be activated on bufferpool to request VdpVideo metadata - * on buffers from the pool. - */ -#define GST_BUFFER_POOL_OPTION_VDP_VIDEO_META "GstBufferPoolOptionVdpVideoMeta" - -typedef struct _GstVdpVideoBufferPool GstVdpVideoBufferPool; -typedef struct _GstVdpVideoBufferPoolClass GstVdpVideoBufferPoolClass; - -/* buffer pool functions */ -#define GST_TYPE_VDP_VIDEO_BUFFER_POOL (gst_vdp_video_buffer_pool_get_type()) -#define GST_IS_VDP_VIDEO_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_VIDEO_BUFFER_POOL)) -#define GST_VDP_VIDEO_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_VIDEO_BUFFER_POOL, GstVdpVideoBufferPool)) -#define GST_VDP_VIDEO_BUFFER_POOL_CAST(obj) ((GstVdpVideoBufferPool*)(obj)) - -struct _GstVdpVideoBufferPool -{ - GstBufferPool bufferpool; - - GstVdpDevice *device; - - GstVideoInfo info; - VdpChromaType chroma_type; - - gboolean add_videometa; - gboolean add_vdpmeta; -}; - -struct _GstVdpVideoBufferPoolClass -{ - GstBufferPoolClass parent_class; -}; - -GType gst_vdp_video_buffer_pool_get_type (void); -GstBufferPool *gst_vdp_video_buffer_pool_new (GstVdpDevice *device); - -GstCaps *gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_type); -#if 0 -GstCaps *gst_vdp_video_buffer_get_allowed_caps (GstVdpDevice * device); - -gboolean gst_vdp_video_buffer_calculate_size (guint32 fourcc, gint width, gint height, guint *size); -/* FIXME : Replace with map/unmap */ -gboolean gst_vdp_video_buffer_download (GstVdpVideoBuffer *inbuf, GstBuffer *outbuf, guint32 fourcc, gint width, gint height); -gboolean gst_vdp_video_buffer_upload (GstVdpVideoBuffer *video_buf, GstBuffer *src_buf, guint fourcc, gint width, gint height); -#endif - - -G_END_DECLS - -#endif /* _GST_VDP_VIDEO_BUFFER_POOL_H_ */ diff --git a/sys/vdpau/gstvdpvideomemory.c b/sys/vdpau/gstvdpvideomemory.c deleted file mode 100644 index 17778a0bb9..0000000000 --- a/sys/vdpau/gstvdpvideomemory.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2012 Edward Hervey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "gstvdpvideomemory.h" -#include "gstvdputils.h" - -GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE); -GST_DEBUG_CATEGORY_STATIC (gst_vdp_video_mem_debug); -#define GST_CAT_DEFAULT gst_vdp_video_mem_debug - -static GstAllocator *_vdp_video_allocator; - - -static void -_vdp_video_mem_init (GstVdpVideoMemory * mem, GstAllocator * allocator, - GstMemory * parent, GstVdpDevice * device, GstVideoInfo * info) -{ - gst_memory_init (GST_MEMORY_CAST (mem), GST_MEMORY_FLAG_NO_SHARE, - allocator, parent, GST_VIDEO_INFO_SIZE (info), 0, 0, - GST_VIDEO_INFO_SIZE (info)); - - mem->device = gst_object_ref (device); - mem->info = info; - mem->chroma_type = gst_video_info_to_vdp_chroma_type (info); - mem->ycbcr_format = - gst_video_format_to_vdp_ycbcr (GST_VIDEO_INFO_FORMAT (info)); - mem->refcount = 0; - - GST_DEBUG ("new VdpVideo memory"); -} - - -static GstVdpVideoMemory * -_vdp_video_mem_new (GstAllocator * allocator, GstMemory * parent, - GstVdpDevice * device, GstVideoInfo * info) -{ - VdpStatus status; - GstVdpVideoMemory *mem; - VdpVideoSurface surface; - - mem = g_slice_new0 (GstVdpVideoMemory); - _vdp_video_mem_init (mem, allocator, parent, device, info); - - GST_TRACE - ("Calling VdpVideoSurfaceCreate(chroma_type:%d, width:%d, height:%d)", - mem->chroma_type, mem->info->width, mem->info->height); - - status = - device->vdp_video_surface_create (device->device, mem->chroma_type, - mem->info->width, mem->info->height, &surface); - - if (status != VDP_STATUS_OK) - goto create_error; - - /* device->vdp_video_surface_get_parameters (device->device, &chroma_type, */ - /* &width, &height); */ - - GST_TRACE ("created surface %u", surface); - - mem->surface = surface; - - return mem; - - /* ERRORS */ -create_error: - { - GST_ERROR ("Failed to create video surface: %s", - device->vdp_get_error_string (status)); - g_slice_free (GstVdpVideoMemory, mem); - return NULL; - } -} - -static gboolean -ensure_data (GstVdpVideoMemory * vmem) -{ - VdpStatus vdp_stat; - GstVideoInfo *info = vmem->info; -#ifndef GST_DISABLE_GST_DEBUG - GstClockTime before, after; -#endif - - if (g_atomic_int_add (&vmem->refcount, 1) > 1) - return TRUE; - - /* Allocate enough room to store data */ - vmem->cache = g_malloc (GST_VIDEO_INFO_SIZE (info)); - vmem->cached_data[0] = vmem->cache; - vmem->cached_data[1] = vmem->cache + GST_VIDEO_INFO_PLANE_OFFSET (info, 1); - vmem->cached_data[2] = vmem->cache + GST_VIDEO_INFO_PLANE_OFFSET (info, 2); - vmem->destination_pitches[0] = GST_VIDEO_INFO_PLANE_STRIDE (info, 0); - vmem->destination_pitches[1] = GST_VIDEO_INFO_PLANE_STRIDE (info, 1); - vmem->destination_pitches[2] = GST_VIDEO_INFO_PLANE_STRIDE (info, 2); - - GST_DEBUG ("cached_data %p %p %p", - vmem->cached_data[0], vmem->cached_data[1], vmem->cached_data[2]); - GST_DEBUG ("pitches %d %d %d", - vmem->destination_pitches[0], - vmem->destination_pitches[1], vmem->destination_pitches[2]); - -#ifndef GST_DISABLE_GST_DEBUG - before = gst_util_get_timestamp (); -#endif - vdp_stat = - vmem->device->vdp_video_surface_get_bits_ycbcr (vmem->surface, - vmem->ycbcr_format, vmem->cached_data, vmem->destination_pitches); -#ifndef GST_DISABLE_GST_DEBUG - after = gst_util_get_timestamp (); -#endif - - GST_CAT_WARNING (GST_CAT_PERFORMANCE, "Downloading took %" GST_TIME_FORMAT, - GST_TIME_ARGS (after - before)); - - if (vdp_stat != VDP_STATUS_OK) { - GST_ERROR ("Failed to get bits : %s", - vmem->device->vdp_get_error_string (vdp_stat)); - g_free (vmem->cache); - vmem->cache = NULL; - return FALSE; - } - - return TRUE; -} - -static void -release_data (GstVdpVideoMemory * vmem) -{ - g_return_if_fail (vmem->refcount > 0); - - if (g_atomic_int_dec_and_test (&vmem->refcount)) { - g_free (vmem->cache); - } -} - -static gpointer -_vdp_video_mem_map (GstVdpVideoMemory * vmem, gsize maxsize, GstMapFlags flags) -{ - GST_DEBUG ("surface:%d, maxsize:%" G_GSIZE_FORMAT ", flags:%d", - vmem->surface, maxsize, flags); - - if (!ensure_data (vmem)) - return NULL; - - return vmem->cache; -} - -static void -_vdp_video_mem_unmap (GstVdpVideoMemory * vmem) -{ - GST_DEBUG ("surface:%d", vmem->surface); - - release_data (vmem); -} - - -static GstMemory * -_vdp_video_mem_copy (GstVdpVideoMemory * src, gssize offset, gssize size) -{ - GST_FIXME ("Implement !"); - return NULL; -} - -static GstMemory * -_vdp_video_mem_share (GstVdpVideoMemory * mem, gssize offset, gssize size) -{ - GST_FIXME ("Implement !"); - return NULL; -} - -static gboolean -_vdp_video_mem_is_span (GstVdpVideoMemory * mem1, GstVdpVideoMemory * mem2, - gsize * offset) -{ - return FALSE; -} - -static GstMemory * -_vdp_video_mem_alloc (GstAllocator * allocator, gsize size, - GstAllocationParams * params) -{ - g_warning ("use gst_vdp_video_memory_alloc () to allocate from this " - "GstVdpVideoMemory allocator"); - - return NULL; -} - -static void -_vdp_video_mem_free (GstAllocator * allocator, GstMemory * mem) -{ - GstVdpVideoMemory *vmem = (GstVdpVideoMemory *) mem; - VdpStatus status; - - GST_DEBUG ("Destroying surface %d", vmem->surface); - - status = vmem->device->vdp_video_surface_destroy (vmem->surface); - if (status != VDP_STATUS_OK) - GST_ERROR ("Couldn't destroy the VdpVideoSurface: %s", - vmem->device->vdp_get_error_string (status)); - - gst_object_unref (vmem->device); - - g_free (vmem->cache); - - g_slice_free (GstVdpVideoMemory, vmem); -} - -/** - * gst_vdp_video_memory_alloc: - * @device: a #GstVdpDevice - * @info: the #GstVideoInfo describing the format to use - * - * Returns: a GstMemory object with a VdpVideoSurface specified by @info - * from @device - */ -GstMemory * -gst_vdp_video_memory_alloc (GstVdpDevice * device, GstVideoInfo * info) -{ - return (GstMemory *) _vdp_video_mem_new (_vdp_video_allocator, NULL, device, - info); -} - -G_DEFINE_TYPE (GstVdpVideoAllocator, gst_vdp_video_allocator, - GST_TYPE_ALLOCATOR); - -static void -gst_vdp_video_allocator_class_init (GstVdpVideoAllocatorClass * klass) -{ - GstAllocatorClass *allocator_class; - - allocator_class = (GstAllocatorClass *) klass; - - allocator_class->alloc = _vdp_video_mem_alloc; - allocator_class->free = _vdp_video_mem_free; -} - -static void -gst_vdp_video_allocator_init (GstVdpVideoAllocator * allocator) -{ - GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator); - - alloc->mem_type = GST_VDP_VIDEO_MEMORY_ALLOCATOR; - alloc->mem_map = (GstMemoryMapFunction) _vdp_video_mem_map; - alloc->mem_unmap = (GstMemoryUnmapFunction) _vdp_video_mem_unmap; - alloc->mem_copy = (GstMemoryCopyFunction) _vdp_video_mem_copy; - alloc->mem_share = (GstMemoryShareFunction) _vdp_video_mem_share; - alloc->mem_is_span = (GstMemoryIsSpanFunction) _vdp_video_mem_is_span; -} - -/** - * gst_vdp_video_memory_init: - * - * Initializes the GL Memory allocator. It is safe to call this function - * multiple times. This must be called before any other GstVdpVideoMemory operation. - */ -void -gst_vdp_video_memory_init (void) -{ - static volatile gsize _init = 0; - - if (g_once_init_enter (&_init)) { - _vdp_video_allocator = - g_object_new (gst_vdp_video_allocator_get_type (), NULL); - gst_object_ref_sink (_vdp_video_allocator); - - gst_allocator_register (GST_VDP_VIDEO_MEMORY_ALLOCATOR, - gst_object_ref (_vdp_video_allocator)); - GST_DEBUG_CATEGORY_INIT (gst_vdp_video_mem_debug, "vdpvideomem", 0, - "VDPAU VideoSurface Memory/Allocator"); - GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE"); - g_once_init_leave (&_init, 1); - } -} - -gboolean -gst_vdp_video_memory_map (GstVideoMeta * meta, guint plane, GstMapInfo * info, - gpointer * data, gint * stride, GstMapFlags flags) -{ - GstBuffer *buffer = meta->buffer; - GstVdpVideoMemory *vmem = - (GstVdpVideoMemory *) gst_buffer_get_memory (buffer, 0); - - /* Only handle GstVdpVideoMemory */ - g_return_val_if_fail (((GstMemory *) vmem)->allocator == _vdp_video_allocator, - FALSE); - - GST_DEBUG ("plane:%d", plane); - - /* download if not already done */ - if (!ensure_data (vmem)) - return FALSE; - - *data = vmem->cached_data[plane]; - *stride = vmem->destination_pitches[plane]; - - return TRUE; -} - -gboolean -gst_vdp_video_memory_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info) -{ - GstVdpVideoMemory *vmem = - (GstVdpVideoMemory *) gst_buffer_get_memory (meta->buffer, 0); - - GST_DEBUG ("plane:%d", plane); - - GST_FIXME ("implement unmap (and potential upload on last unmap)"); - - release_data (vmem); - - return TRUE; -} diff --git a/sys/vdpau/gstvdpvideomemory.h b/sys/vdpau/gstvdpvideomemory.h deleted file mode 100644 index afe7491a06..0000000000 --- a/sys/vdpau/gstvdpvideomemory.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2012 Edward Hervey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _GST_VDP_VIDEO_MEMORY_H_ -#define _GST_VDP_VIDEO_MEMORY_H_ - -#include -#include -#include -#include -#include - -#include "gstvdpdevice.h" - -G_BEGIN_DECLS - -#define GST_TYPE_VDP_VIDEO_ALLOCATOR (gst_vdp_video_allocator_get_type()) -GType gst_vdp_video_allocator_get_type(void); - -#define GST_IS_VDP_VIDEO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_VIDEO_ALLOCATOR)) -#define GST_IS_VDP_VIDEO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_VIDEO_ALLOCATOR)) -#define GST_VDP_VIDEO_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_VIDEO_ALLOCATOR, GstVdpVideoAllocatorClass)) -#define GST_VDP_VIDEO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_VIDEO_ALLOCATOR, GstVdpVideoAllocator)) -#define GST_VDP_VIDEO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_VIDEO_ALLOCATOR, GstVdpVideoAllocatorClass)) -#define GST_VDP_VIDEO_ALLOCATOR_CAST(obj) ((GstVdpVideoAllocator *)(obj)) - -typedef struct _GstVdpVideoMemory GstVdpVideoMemory; -typedef struct _GstVdpVideoAllocator GstVdpVideoAllocator; -typedef struct _GstVdpVideoAllocatorClass GstVdpVideoAllocatorClass; - -/** - * GstVdpVideoMemory: - * @mem: the parent object - * @device: the #GstVdpDevice to use - * @surface: the #VdpVideoSurface - * - * Represents information about a #VdpVideoSurface - */ -struct _GstVdpVideoMemory -{ - GstMemory mem; - - GstVdpDevice *device; - VdpVideoSurface surface; - - GstVideoInfo *info; - VdpChromaType chroma_type; - VdpYCbCrFormat ycbcr_format; - - /* Cached data for mapping */ - volatile gint refcount; - GstMapFlags map_flags; - guint n_planes; - guint8 *cache; - void * cached_data[4]; - uint32_t destination_pitches[4]; -}; - -#define GST_VDP_VIDEO_MEMORY_ALLOCATOR "VdpVideoMemory" - -#define GST_CAPS_FEATURE_MEMORY_VDPAU "memory:VdpVideoSurface" - -void gst_vdp_video_memory_init (void); - -GstMemory * -gst_vdp_video_memory_alloc (GstVdpDevice * device, GstVideoInfo *info); - -gboolean gst_vdp_video_memory_map(GstVideoMeta * meta, guint plane, - GstMapInfo * info, gpointer * data, - gint * stride, GstMapFlags flags); -gboolean gst_vdp_video_memory_unmap(GstVideoMeta * meta, guint plane, - GstMapInfo * info); - -struct _GstVdpVideoAllocator -{ - GstAllocator parent; -}; - -struct _GstVdpVideoAllocatorClass -{ - GstAllocatorClass parent_class; -}; - -G_END_DECLS - -#endif /* _GST_VDP_VIDEO_MEMORY_H_ */ diff --git a/sys/vdpau/gstvdpvideopostprocess.c b/sys/vdpau/gstvdpvideopostprocess.c deleted file mode 100644 index e2032f4f6a..0000000000 --- a/sys/vdpau/gstvdpvideopostprocess.c +++ /dev/null @@ -1,1290 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/** - * SECTION:element-vdpauvideopostprocess - * @title: vdpauvideopostprocess - * - * FIXME:Describe vdpaumpegdec here. - * - * ## Example launch line - * |[ - * gst-launch-1.0 -v -m fakesrc ! vdpauvideopostprocess ! fakesink silent=TRUE - * ]| - * - */ - -/* - * TODO: - * + add support for more postprocessing options - * + mixing videos. (This should perhaps be done in a separate element based on - * VdpOutputSurface) - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "gstvdpoutputbuffer.h" - -#include "gstvdpvideopostprocess.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_vpp_debug); -#define GST_CAT_DEFAULT gst_vdp_vpp_debug - -/* Filter signals and args */ -enum -{ - /* FILL ME */ - LAST_SIGNAL -}; - -enum -{ - PROP_0, - PROP_DISPLAY, - PROP_FORCE_ASPECT_RATIO, - PROP_DEINTERLACE_MODE, - PROP_DEINTERLACE_METHOD, - PROP_NOISE_REDUCTION, - PROP_SHARPENING, - PROP_INVERSE_TELECINE -}; - -G_DEFINE_TYPE (GstVdpVideoPostProcess, gst_vdp_vpp, GST_TYPE_ELEMENT); - -static void gst_vdp_vpp_finalize (GObject * object); - -#define GST_TYPE_VDP_DEINTERLACE_METHODS (gst_vdp_deinterlace_methods_get_type ()) -static GType -gst_vdp_deinterlace_methods_get_type (void) -{ - static GType deinterlace_methods_type = 0; - - static const GEnumValue methods_types[] = { - {GST_VDP_DEINTERLACE_METHOD_BOB, - "Vertically scale a single field to the size of a single frame.", - "bob"}, - {GST_VDP_DEINTERLACE_METHOD_TEMPORAL, "Motion Adaptive: Simple Detection", - "temporal"}, - {GST_VDP_DEINTERLACE_METHOD_TEMPORAL_SPATIAL, - "Motion Adaptive: Advanced Detection", "temporal-spatial"}, - {0, NULL, NULL}, - }; - - if (!deinterlace_methods_type) { - deinterlace_methods_type = - g_enum_register_static ("GstVdpDeinterlaceMethods", methods_types); - } - return deinterlace_methods_type; -} - -#define GST_TYPE_VDP_DEINTERLACE_MODES (gst_vdp_deinterlace_modes_get_type ()) -static GType -gst_vdp_deinterlace_modes_get_type (void) -{ - static GType deinterlace_modes_type = 0; - - static const GEnumValue modes_types[] = { - {GST_VDP_DEINTERLACE_MODE_AUTO, "Auto detection", "auto"}, - {GST_VDP_DEINTERLACE_MODE_INTERLACED, "Enfore deinterlacing", "interlaced"}, - {GST_VDP_DEINTERLACE_MODE_DISABLED, "Run in passthrough mode", "disabled"}, - {0, NULL, NULL}, - }; - - if (!deinterlace_modes_type) { - deinterlace_modes_type = - g_enum_register_static ("GstVdpDeinterlaceModes", modes_types); - } - return deinterlace_modes_type; -} - -static void -gst_vdp_vpp_set_attribute_float (GstVdpVideoPostProcess * vpp, - VdpVideoMixerAttribute attribute, gfloat value) -{ - VdpVideoMixerAttribute attributes[1]; - const void *attribute_values[1]; - VdpStatus status; - - attributes[0] = attribute; - attribute_values[0] = &value; - - status = - vpp->device->vdp_video_mixer_set_attribute_values (vpp->mixer, 1, - attributes, attribute_values); - if (status != VDP_STATUS_OK) { - GST_WARNING_OBJECT (vpp, - "Couldn't set noise reduction level on mixer, " - "error returned from vdpau was: %s", - vpp->device->vdp_get_error_string (status)); - } -} - -static void -gst_vdp_vpp_activate_feature (GstVdpVideoPostProcess * vpp, - VdpVideoMixerFeature feature, gboolean activate) -{ - VdpVideoMixerFeature features[1]; - VdpBool enable[1]; - VdpStatus status; - - features[0] = feature; - if (activate) - enable[0] = VDP_TRUE; - else - enable[0] = VDP_FALSE; - - status = - vpp->device->vdp_video_mixer_set_feature_enables (vpp->mixer, 1, - features, enable); - if (status != VDP_STATUS_OK) { - GST_WARNING_OBJECT (vpp, "Couldn't set deinterlace method on mixer, " - "error returned from vdpau was: %s", - vpp->device->vdp_get_error_string (status)); - } -} - -static VdpVideoMixerFeature -gst_vdp_feature_from_deinterlace_method (GstVdpDeinterlaceMethods method) -{ - gint i; - VdpVideoMixerFeature feature = 0; - - typedef struct - { - GstVdpDeinterlaceMethods method; - VdpVideoMixerFeature feature; - } VdpDeinterlaceMethod; - - static const VdpDeinterlaceMethod deinterlace_methods[] = { - {GST_VDP_DEINTERLACE_METHOD_TEMPORAL, - VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL}, - {GST_VDP_DEINTERLACE_METHOD_TEMPORAL_SPATIAL, - VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL} - }; - - for (i = 0; i < G_N_ELEMENTS (deinterlace_methods); i++) { - if (deinterlace_methods[i].method == method) { - feature = deinterlace_methods[i].feature; - break; - } - } - - return feature; -} - -static void -gst_vdp_vpp_activate_deinterlace_method (GstVdpVideoPostProcess * vpp, - GstVdpDeinterlaceMethods method, gboolean activate) -{ - gst_vdp_vpp_activate_feature (vpp, - gst_vdp_feature_from_deinterlace_method (method), activate); -} - -static void -gst_vdp_picture_clear (GstVdpPicture pic) -{ - if (pic.buf) { - gst_buffer_unref (GST_BUFFER (pic.buf)); - pic.buf = NULL; - } -} - -static gboolean -gst_vdp_vpp_is_interlaced (GstVdpVideoPostProcess * vpp) -{ - if (vpp->mode == GST_VDP_DEINTERLACE_MODE_INTERLACED) - return TRUE; - - if (vpp->mode == GST_VDP_DEINTERLACE_MODE_AUTO && vpp->interlaced) - return TRUE; - - return FALSE; -} - -static guint -gst_vdp_vpp_get_required_pictures (GstVdpVideoPostProcess * vpp) -{ - guint ret; - - if (vpp->noise_reduction != 0.0) - return 2; - - if (!gst_vdp_vpp_is_interlaced (vpp)) - return 1; - - switch (vpp->method) { - case GST_VDP_DEINTERLACE_METHOD_BOB: - ret = 1; - break; - case GST_VDP_DEINTERLACE_METHOD_TEMPORAL: - case GST_VDP_DEINTERLACE_METHOD_TEMPORAL_SPATIAL: - ret = 2; - break; - default: - g_assert_not_reached (); - break; - } - - return ret; -} - -static gboolean -gst_vdp_vpp_get_next_picture (GstVdpVideoPostProcess * vpp, - GstVdpPicture * current_pic, - guint32 * video_surfaces_past_count, VdpVideoSurface * video_surfaces_past, - guint32 * video_surfaces_future_count, - VdpVideoSurface * video_surfaces_future) -{ - gint i; - gint required_pictures; - - required_pictures = gst_vdp_vpp_get_required_pictures (vpp); - - if (vpp->n_future_pictures < required_pictures) - return FALSE; - - *current_pic = vpp->future_pictures[0]; - for (i = 0; i < vpp->n_future_pictures - 1; i++) { - vpp->future_pictures[i] = vpp->future_pictures[i + 1]; - } - - vpp->future_pictures[vpp->n_future_pictures - 1].buf = NULL; - vpp->n_future_pictures--; - - *video_surfaces_future_count = vpp->n_future_pictures; - for (i = 0; i < vpp->n_future_pictures; i++) - video_surfaces_future[i] = vpp->future_pictures[i].buf->surface; - - *video_surfaces_past_count = vpp->n_past_pictures; - for (i = 0; i < vpp->n_past_pictures; i++) - video_surfaces_past[i] = vpp->past_pictures[i].buf->surface; - - if (vpp->n_past_pictures == MAX_PICTURES) { - gst_vdp_picture_clear (vpp->past_pictures[MAX_PICTURES - 1]); - vpp->n_past_pictures--; - } - - /* move every picture upwards one step in the array */ - for (i = vpp->n_past_pictures; i > 0; i--) { - vpp->past_pictures[i] = vpp->past_pictures[i - 1]; - } - - /* add the picture to the past surfaces */ - vpp->past_pictures[0] = *current_pic; - vpp->n_past_pictures++; - - return TRUE; -} - -static void -gst_vdp_vpp_add_buffer (GstVdpVideoPostProcess * vpp, GstVdpVideoBuffer * buf) -{ - gboolean repeated; - gboolean tff; - gboolean onefield; - GstVdpPicture pic1, pic2; - - if (!gst_vdp_vpp_is_interlaced (vpp)) { - pic1.buf = buf; - pic1.structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME; - pic1.timestamp = GST_BUFFER_TIMESTAMP (buf); - vpp->future_pictures[vpp->n_future_pictures++] = pic1; - return; - } - - repeated = GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_RFF); - tff = GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_TFF); - onefield = GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_ONEFIELD); - - pic1.buf = buf; - pic2.buf = (GstVdpVideoBuffer *) gst_buffer_ref (GST_BUFFER (buf)); - if (tff) { - pic1.structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD; - pic2.structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD; - } else { - pic1.structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD; - pic2.structure = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD; - } - - pic1.timestamp = GST_BUFFER_TIMESTAMP (buf); - pic2.timestamp = pic1.timestamp + vpp->field_duration; - - if (repeated) { - vpp->future_pictures[vpp->n_future_pictures++] = pic1; - - pic1.timestamp = pic2.timestamp; - vpp->future_pictures[vpp->n_future_pictures++] = pic1; - gst_buffer_ref (GST_BUFFER (pic1.buf)); - - pic2.timestamp += vpp->field_duration; - vpp->future_pictures[vpp->n_future_pictures++] = pic2; - } else if (!onefield) { - vpp->future_pictures[vpp->n_future_pictures++] = pic1; - vpp->future_pictures[vpp->n_future_pictures++] = pic2; - } else { - vpp->future_pictures[vpp->n_future_pictures++] = pic1; - gst_buffer_unref (GST_BUFFER (pic2.buf)); - } -} - -static void -gst_vdp_vpp_post_error (GstVdpVideoPostProcess * vpp, GError * error) -{ - GstMessage *message; - - message = gst_message_new_error (GST_OBJECT (vpp), error, NULL); - gst_element_post_message (GST_ELEMENT (vpp), message); - g_error_free (error); -} - -static GstFlowReturn -gst_vdp_vpp_create_mixer (GstVdpVideoPostProcess * vpp) -{ -#define VDP_NUM_MIXER_PARAMETER 3 -#define MAX_NUM_FEATURES 5 - - VdpStatus status; - GstVdpDevice *device; - - VdpVideoMixerFeature features[5]; - guint n_features = 0; - VdpVideoMixerParameter parameters[VDP_NUM_MIXER_PARAMETER] = { - VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH, - VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT, - VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE - }; - const void *parameter_values[VDP_NUM_MIXER_PARAMETER]; - - parameter_values[0] = &vpp->width; - parameter_values[1] = &vpp->height; - parameter_values[2] = &vpp->chroma_type; - - if (gst_vdp_vpp_is_interlaced (vpp) - && vpp->method != GST_VDP_DEINTERLACE_METHOD_BOB) { - features[n_features++] = - gst_vdp_feature_from_deinterlace_method (vpp->method); - } - if (vpp->noise_reduction > 0.0) - features[n_features++] = VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION; - if (vpp->sharpening != 0.0) - features[n_features++] = VDP_VIDEO_MIXER_FEATURE_SHARPNESS; - if (vpp->inverse_telecine) - features[n_features++] = VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE; - - device = vpp->device; - - status = - device->vdp_video_mixer_create (device->device, n_features, features, - VDP_NUM_MIXER_PARAMETER, parameters, parameter_values, &vpp->mixer); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vpp, RESOURCE, READ, - ("Could not create vdpau video mixer"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - return GST_FLOW_ERROR; - } - - if (vpp->noise_reduction > 0.0) { - gst_vdp_vpp_set_attribute_float (vpp, - VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL, vpp->noise_reduction); - } - if (vpp->sharpening != 0.0) { - gst_vdp_vpp_set_attribute_float (vpp, - VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL, vpp->sharpening); - } - - return GST_FLOW_OK; -} - -static gint -gst_greatest_common_divisor (gint a, gint b) -{ - while (b != 0) { - int temp = a; - - a = b; - b = temp % b; - } - - return ABS (a); -} - -static gboolean -gst_fraction_double (gint * n_out, gint * d_out) -{ - gint n, d, gcd; - - n = *n_out; - d = *d_out; - - if (d == 0) - return FALSE; - - if (n == 0 || (n == G_MAXINT && d == 1)) - return TRUE; - - gcd = gst_greatest_common_divisor (n, d); - n /= gcd; - d /= gcd; - - if (G_MAXINT / 2 >= ABS (n)) { - n *= 2; - } else if (d >= 2) { - d /= 2; - } else - return FALSE; - - *n_out = n; - *d_out = d; - - return TRUE; -} - -static gboolean -gst_vdp_vpp_sink_setcaps (GstPad * pad, GstCaps * caps) -{ - GstVdpVideoPostProcess *vpp = - GST_VDP_VIDEO_POST_PROCESS (gst_pad_get_parent (pad)); - GstStructure *structure; - GstCaps *video_caps = NULL; - gboolean res = FALSE; - - GstCaps *allowed_caps, *output_caps, *src_caps; - - /* check if the input is non native */ - structure = gst_caps_get_structure (caps, 0); - if (gst_structure_has_name (structure, "video/x-raw-yuv")) { - if (!gst_structure_get_fourcc (structure, "format", &vpp->fourcc)) - goto done; - vpp->native_input = FALSE; - video_caps = gst_vdp_yuv_to_video_caps (caps); - if (!video_caps) - goto done; - - if (!vpp->vpool) - vpp->vpool = gst_vdp_video_buffer_pool_new (vpp->device); - - gst_vdp_buffer_pool_set_caps (vpp->vpool, video_caps); - - } else { - vpp->native_input = TRUE; - video_caps = gst_caps_ref (caps); - - if (vpp->vpool) { - g_object_unref (vpp->vpool); - vpp->vpool = NULL; - } - } - - structure = gst_caps_get_structure (video_caps, 0); - if (!gst_structure_get_int (structure, "width", &vpp->width) || - !gst_structure_get_int (structure, "height", &vpp->height) || - !gst_structure_get_int (structure, "chroma-type", - (gint *) & vpp->chroma_type)) - goto done; - - - /* get interlaced flag */ - gst_structure_get_boolean (structure, "interlaced", &vpp->interlaced); - - /* extract par */ - if (gst_structure_has_field_typed (structure, "pixel-aspect-ratio", - GST_TYPE_FRACTION)) { - gst_structure_get_fraction (structure, "pixel-aspect-ratio", &vpp->par_n, - &vpp->par_d); - vpp->got_par = TRUE; - } else - vpp->got_par = FALSE; - - allowed_caps = gst_pad_get_allowed_caps (vpp->srcpad); - if (G_UNLIKELY (!allowed_caps)) - goto null_allowed_caps; - if (G_UNLIKELY (gst_caps_is_empty (allowed_caps))) - goto empty_allowed_caps; - GST_DEBUG ("allowed_caps: %" GST_PTR_FORMAT, allowed_caps); - - output_caps = gst_vdp_video_to_output_caps (video_caps); - src_caps = gst_caps_intersect (output_caps, allowed_caps); - gst_caps_unref (allowed_caps); - gst_caps_unref (output_caps); - - if (gst_caps_is_empty (src_caps)) - goto not_negotiated; - - gst_pad_fixate_caps (vpp->srcpad, src_caps); - - - if (gst_vdp_vpp_is_interlaced (vpp)) { - gint fps_n, fps_d; - - if (gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) { - gst_fraction_double (&fps_n, &fps_d); - gst_caps_set_simple (src_caps, "framerate", GST_TYPE_FRACTION, fps_n, - fps_d, NULL); - vpp->field_duration = gst_util_uint64_scale (GST_SECOND, fps_d, fps_n); - } - - gst_caps_set_simple (src_caps, "interlaced", G_TYPE_BOOLEAN, FALSE, NULL); - } - - GST_DEBUG ("src_caps: %" GST_PTR_FORMAT, src_caps); - - res = gst_pad_set_caps (vpp->srcpad, src_caps); - gst_caps_unref (src_caps); - -done: - gst_object_unref (vpp); - if (video_caps) - gst_caps_unref (video_caps); - - return res; - -null_allowed_caps: - GST_ERROR_OBJECT (vpp, "Got null from gst_pad_get_allowed_caps"); - goto done; - -empty_allowed_caps: - GST_ERROR_OBJECT (vpp, "Got EMPTY caps from gst_pad_get_allowed_caps"); - - gst_caps_unref (allowed_caps); - goto done; - -not_negotiated: - gst_caps_unref (src_caps); - GST_ERROR_OBJECT (vpp, "Couldn't find suitable output format"); - goto done; -} - -static void -gst_vdp_vpp_flush (GstVdpVideoPostProcess * vpp) -{ - gint i; - - for (i = 0; i < vpp->n_future_pictures; i++) { - gst_vdp_picture_clear (vpp->future_pictures[i]); - } - vpp->n_future_pictures = 0; - - for (i = 0; i < vpp->n_past_pictures; i++) { - gst_vdp_picture_clear (vpp->past_pictures[i]); - } - vpp->n_past_pictures = 0; -} - -static gboolean -gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) -{ - gint i; - GError *err; - - vpp->interlaced = FALSE; - vpp->field_duration = GST_CLOCK_TIME_NONE; - - vpp->earliest_time = GST_CLOCK_TIME_NONE; - vpp->discont = FALSE; - - vpp->mixer = VDP_INVALID_HANDLE; - vpp->vpool = NULL; - - for (i = 0; i < MAX_PICTURES; i++) { - vpp->future_pictures[i].buf = NULL; - vpp->past_pictures[i].buf = NULL; - } - vpp->n_future_pictures = 0; - vpp->n_past_pictures = 0; - - err = NULL; - vpp->device = gst_vdp_get_device (vpp->display, &err); - if (G_UNLIKELY (!vpp->device)) - goto device_error; - - g_object_set (G_OBJECT (vpp->srcpad), "device", vpp->device, NULL); - - return TRUE; - -device_error: - gst_vdp_vpp_post_error (vpp, err); - return FALSE; -} - -static gboolean -gst_vdp_vpp_stop (GstVdpVideoPostProcess * vpp) -{ - gst_vdp_vpp_flush (vpp); - - if (vpp->vpool) - g_object_unref (vpp->vpool); - - if (vpp->mixer != VDP_INVALID_HANDLE) { - GstVdpDevice *device = vpp->device; - VdpStatus status; - - status = device->vdp_video_mixer_destroy (vpp->mixer); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (vpp, RESOURCE, READ, - ("Could not destroy vdpau decoder"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - return FALSE; - } - } - - return TRUE; -} - -static GstFlowReturn -gst_vdp_vpp_drain (GstVdpVideoPostProcess * vpp) -{ - GstVdpPicture current_pic; - - guint32 video_surfaces_past_count; - VdpVideoSurface video_surfaces_past[MAX_PICTURES]; - - guint32 video_surfaces_future_count; - VdpVideoSurface video_surfaces_future[MAX_PICTURES]; - - GstFlowReturn ret; - - while (gst_vdp_vpp_get_next_picture (vpp, - ¤t_pic, - &video_surfaces_past_count, video_surfaces_past, - &video_surfaces_future_count, video_surfaces_future)) { - GError *err; - GstVdpOutputBuffer *outbuf; - - GstStructure *structure; - GstVideoRectangle src_r = { 0, }; - GstVideoRectangle dest_r = { 0, }; - VdpRect rect; - - GstVdpDevice *device; - VdpStatus status; - - err = NULL; - ret = - gst_vdp_output_src_pad_alloc_buffer ((GstVdpOutputSrcPad *) vpp->srcpad, - &outbuf, &err); - if (ret != GST_FLOW_OK) - goto output_pad_error; - - src_r.w = vpp->width; - src_r.h = vpp->height; - if (vpp->got_par) { - gint new_width; - - new_width = gst_util_uint64_scale_int (src_r.w, vpp->par_n, vpp->par_d); - src_r.x += (src_r.w - new_width) / 2; - src_r.w = new_width; - } - - structure = gst_caps_get_structure (GST_BUFFER_CAPS (outbuf), 0); - if (!gst_structure_get_int (structure, "width", &dest_r.w) || - !gst_structure_get_int (structure, "height", &dest_r.h)) - goto invalid_caps; - - if (vpp->force_aspect_ratio) { - GstVideoRectangle res_r = { 0, }; - - gst_video_sink_center_rect (src_r, dest_r, &res_r, TRUE); - rect.x0 = res_r.x; - rect.x1 = res_r.w + res_r.x; - rect.y0 = res_r.y; - rect.y1 = res_r.h + res_r.y; - } else { - rect.x0 = 0; - rect.x1 = dest_r.w; - rect.y0 = 0; - rect.y1 = dest_r.h; - } - - device = vpp->device; - status = - device->vdp_video_mixer_render (vpp->mixer, VDP_INVALID_HANDLE, NULL, - current_pic.structure, video_surfaces_past_count, video_surfaces_past, - current_pic.buf->surface, video_surfaces_future_count, - video_surfaces_future, NULL, outbuf->surface, NULL, &rect, 0, NULL); - if (status != VDP_STATUS_OK) - goto render_error; - - GST_BUFFER_TIMESTAMP (outbuf) = current_pic.timestamp; - if (gst_vdp_vpp_is_interlaced (vpp)) - GST_BUFFER_DURATION (outbuf) = vpp->field_duration; - else - GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (current_pic.buf); - - if (GST_BUFFER_FLAG_IS_SET (current_pic.buf, GST_BUFFER_FLAG_DISCONT)) - GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT); - - if (GST_BUFFER_FLAG_IS_SET (current_pic.buf, GST_BUFFER_FLAG_PREROLL)) - GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_PREROLL); - - if (GST_BUFFER_FLAG_IS_SET (current_pic.buf, GST_BUFFER_FLAG_GAP)) - GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP); - - err = NULL; - ret = - gst_vdp_output_src_pad_push ((GstVdpOutputSrcPad *) vpp->srcpad, - outbuf, &err); - if (ret != GST_FLOW_OK) - goto output_pad_error; - - continue; - - invalid_caps: - gst_buffer_unref (GST_BUFFER (outbuf)); - GST_ELEMENT_ERROR (vpp, STREAM, FAILED, ("Invalid output caps"), (NULL)); - ret = GST_FLOW_ERROR; - break; - - render_error: - gst_buffer_unref (GST_BUFFER (outbuf)); - GST_ELEMENT_ERROR (vpp, RESOURCE, READ, - ("Could not postprocess frame"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - ret = GST_FLOW_ERROR; - break; - - output_pad_error: - if (ret == GST_FLOW_ERROR && err != NULL) - gst_vdp_vpp_post_error (vpp, err); - break; - } - - return ret; -} - -static GstFlowReturn -gst_vdp_vpp_chain (GstPad * pad, GstBuffer * buffer) -{ - GstVdpVideoPostProcess *vpp = - GST_VDP_VIDEO_POST_PROCESS (gst_pad_get_parent (pad)); - - GstClockTime qostime; - GstFlowReturn ret = GST_FLOW_OK; - GError *err; - - GST_DEBUG ("chain"); - - /* can only do QoS if the segment is in TIME */ - if (vpp->segment.format != GST_FORMAT_TIME) - goto no_qos; - - /* QOS is done on the running time of the buffer, get it now */ - qostime = gst_segment_to_running_time (&vpp->segment, GST_FORMAT_TIME, - GST_BUFFER_TIMESTAMP (buffer)); - - if (qostime != -1) { - gboolean need_skip; - GstClockTime earliest_time; - - /* lock for getting the QoS parameters that are set (in a different thread) - * with the QOS events */ - GST_OBJECT_LOCK (vpp); - earliest_time = vpp->earliest_time; - /* check for QoS, don't perform conversion for buffers - * that are known to be late. */ - need_skip = GST_CLOCK_TIME_IS_VALID (earliest_time) && qostime != -1 && - qostime <= earliest_time; - - GST_OBJECT_UNLOCK (vpp); - - if (need_skip) { - GST_DEBUG_OBJECT (vpp, "skipping transform: qostime %" - GST_TIME_FORMAT " <= %" GST_TIME_FORMAT, - GST_TIME_ARGS (qostime), GST_TIME_ARGS (earliest_time)); - /* mark discont for next buffer */ - vpp->discont = TRUE; - gst_buffer_unref (buffer); - return GST_FLOW_OK; - } - } - -no_qos: - - if (vpp->discont) { - GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT); - vpp->discont = FALSE; - } - - if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))) { - GST_DEBUG_OBJECT (vpp, "Received discont buffer"); - gst_vdp_vpp_flush (vpp); - } - - if (!vpp->native_input) { - GstVdpVideoBuffer *video_buf; - - err = NULL; - video_buf = - (GstVdpVideoBuffer *) gst_vdp_buffer_pool_get_buffer (vpp->vpool, &err); - if (G_UNLIKELY (!video_buf)) - goto video_buf_error; - - if (!gst_vdp_video_buffer_upload (video_buf, buffer, vpp->fourcc, - vpp->width, vpp->height)) { - gst_buffer_unref (GST_BUFFER (video_buf)); - GST_ELEMENT_ERROR (vpp, RESOURCE, READ, - ("Couldn't upload YUV data to vdpau"), (NULL)); - ret = GST_FLOW_ERROR; - goto error; - } - - gst_buffer_copy_metadata (GST_BUFFER (video_buf), buffer, - GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS); - - gst_buffer_unref (buffer); - buffer = GST_BUFFER (video_buf); - } - - if (G_UNLIKELY (vpp->mixer == VDP_INVALID_HANDLE)) { - ret = gst_vdp_vpp_create_mixer (vpp); - if (ret != GST_FLOW_OK) - goto error; - } - - gst_vdp_vpp_add_buffer (vpp, GST_VDP_VIDEO_BUFFER (buffer)); - - ret = gst_vdp_vpp_drain (vpp); - -done: - gst_object_unref (vpp); - - return ret; - -error: - gst_buffer_unref (buffer); - goto done; - -video_buf_error: - gst_buffer_unref (GST_BUFFER (buffer)); - gst_vdp_vpp_post_error (vpp, err); - ret = GST_FLOW_ERROR; - goto done; -} - -static GstCaps * -gst_vdp_vpp_sink_getcaps (GstPad * pad) -{ - GstVdpVideoPostProcess *vpp = - GST_VDP_VIDEO_POST_PROCESS (gst_pad_get_parent (pad)); - GstCaps *caps; - - if (vpp->device) { - caps = gst_vdp_video_buffer_get_allowed_caps (vpp->device); - } else { - GstElementClass *element_class = GST_ELEMENT_GET_CLASS (vpp); - GstPadTemplate *sink_template; - - sink_template = gst_element_class_get_pad_template (element_class, "sink"); - caps = gst_caps_copy (gst_pad_template_get_caps (sink_template)); - } - GST_DEBUG ("returning caps: %" GST_PTR_FORMAT, caps); - - gst_object_unref (vpp); - - return caps; -} - -static gboolean -gst_vdp_vpp_src_event (GstPad * pad, GstEvent * event) -{ - GstVdpVideoPostProcess *vpp = - GST_VDP_VIDEO_POST_PROCESS (gst_pad_get_parent (pad)); - gboolean res; - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_QOS: - { - gdouble proportion; - GstClockTimeDiff diff; - GstClockTime timestamp; - - gst_event_parse_qos (event, &proportion, &diff, ×tamp); - - GST_OBJECT_LOCK (vpp); - vpp->earliest_time = timestamp + diff; - GST_OBJECT_UNLOCK (vpp); - - res = gst_pad_event_default (pad, event); - break; - } - default: - res = gst_pad_event_default (pad, event); - } - - gst_object_unref (vpp); - - return res; -} - -static gboolean -gst_vdp_vpp_sink_event (GstPad * pad, GstEvent * event) -{ - GstVdpVideoPostProcess *vpp = - GST_VDP_VIDEO_POST_PROCESS (gst_pad_get_parent (pad)); - gboolean res; - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_FLUSH_STOP: - { - GST_DEBUG_OBJECT (vpp, "flush stop"); - - gst_vdp_vpp_flush (vpp); - - res = gst_pad_event_default (pad, event); - break; - } - case GST_EVENT_NEWSEGMENT: - { - gboolean update; - gdouble rate, applied_rate; - GstFormat format; - gint64 start, stop, time; - - gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate, - &format, &start, &stop, &time); - - GST_OBJECT_LOCK (vpp); - gst_segment_set_newsegment_full (&vpp->segment, update, rate, - applied_rate, format, start, stop, time); - GST_OBJECT_UNLOCK (vpp); - - res = gst_pad_event_default (pad, event); - break; - } - default: - res = gst_pad_event_default (pad, event); - } - - gst_object_unref (vpp); - - return res; -} - -static GstStateChangeReturn -gst_vdp_vpp_change_state (GstElement * element, GstStateChange transition) -{ - GstVdpVideoPostProcess *vpp; - GstStateChangeReturn ret; - - vpp = GST_VDP_VIDEO_POST_PROCESS (element); - - switch (transition) { - case GST_STATE_CHANGE_READY_TO_PAUSED: - if (!gst_vdp_vpp_start (vpp)) - return GST_STATE_CHANGE_FAILURE; - break; - default: - break; - } - - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); - - switch (transition) { - case GST_STATE_CHANGE_PAUSED_TO_READY: - if (!gst_vdp_vpp_stop (vpp)) - ret = GST_STATE_CHANGE_FAILURE; - break; - default: - break; - } - - return ret; -} - -/* GObject vmethod implementations */ -static void -gst_vdp_vpp_get_property (GObject * object, guint property_id, GValue * value, - GParamSpec * pspec) -{ - GstVdpVideoPostProcess *vpp = GST_VDP_VIDEO_POST_PROCESS (object); - - switch (property_id) { - case PROP_DISPLAY: - g_value_set_string (value, vpp->display); - break; - - case PROP_FORCE_ASPECT_RATIO: - g_value_set_boolean (value, vpp->force_aspect_ratio); - break; - - case PROP_DEINTERLACE_MODE: - g_value_set_enum (value, vpp->mode); - break; - - case PROP_DEINTERLACE_METHOD: - g_value_set_enum (value, vpp->method); - break; - - case PROP_NOISE_REDUCTION: - g_value_set_float (value, vpp->noise_reduction); - break; - - case PROP_SHARPENING: - g_value_set_float (value, vpp->sharpening); - break; - - case PROP_INVERSE_TELECINE: - g_value_set_boolean (value, vpp->inverse_telecine); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -/* GObject vmethod implementations */ -static void -gst_vdp_vpp_set_property (GObject * object, guint property_id, - const GValue * value, GParamSpec * pspec) -{ - GstVdpVideoPostProcess *vpp = GST_VDP_VIDEO_POST_PROCESS (object); - - switch (property_id) { - case PROP_DISPLAY: - g_free (vpp->display); - vpp->display = g_value_dup_string (value); - break; - - case PROP_FORCE_ASPECT_RATIO: - vpp->force_aspect_ratio = g_value_get_boolean (value); - break; - - case PROP_DEINTERLACE_MODE: - vpp->mode = g_value_get_enum (value); - break; - - case PROP_DEINTERLACE_METHOD: - { - GstVdpDeinterlaceMethods oldvalue; - - oldvalue = vpp->method; - vpp->method = g_value_get_enum (value); - if (oldvalue == vpp->method) - break; - - if (vpp->mixer != VDP_INVALID_HANDLE) { - if (oldvalue != GST_VDP_DEINTERLACE_METHOD_BOB) - gst_vdp_vpp_activate_deinterlace_method (vpp, oldvalue, FALSE); - - if (vpp->method != GST_VDP_DEINTERLACE_METHOD_BOB) - gst_vdp_vpp_activate_deinterlace_method (vpp, oldvalue, TRUE); - } - break; - } - - case PROP_NOISE_REDUCTION: - { - gfloat old_value; - - old_value = vpp->noise_reduction; - vpp->noise_reduction = g_value_get_float (value); - if (vpp->noise_reduction == old_value) - break; - - if (vpp->mixer != VDP_INVALID_HANDLE) { - if (vpp->noise_reduction == 0.0) - gst_vdp_vpp_activate_feature (vpp, - VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION, FALSE); - - if (old_value == 0.0) - gst_vdp_vpp_activate_feature (vpp, - VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION, TRUE); - - gst_vdp_vpp_set_attribute_float (vpp, - VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL, - vpp->noise_reduction); - } - break; - } - - case PROP_SHARPENING: - { - gfloat old_value; - - old_value = vpp->sharpening; - vpp->sharpening = g_value_get_float (value); - if (vpp->sharpening == old_value) - break; - - if (vpp->mixer != VDP_INVALID_HANDLE) { - if (vpp->sharpening == 0.0) - gst_vdp_vpp_activate_feature (vpp, - VDP_VIDEO_MIXER_FEATURE_SHARPNESS, FALSE); - - if (old_value == 0.0) - gst_vdp_vpp_activate_feature (vpp, - VDP_VIDEO_MIXER_FEATURE_SHARPNESS, TRUE); - - gst_vdp_vpp_set_attribute_float (vpp, - VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL, vpp->sharpening); - } - break; - } - - case PROP_INVERSE_TELECINE: - { - vpp->inverse_telecine = g_value_get_boolean (value); - - if (vpp->mixer != VDP_INVALID_HANDLE) { - gst_vdp_vpp_activate_feature (vpp, - VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE, vpp->inverse_telecine); - } - break; - } - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -/* GType vmethod implementations */ - -/* initialize the vdpaumpegdecoder's class */ -static void -gst_vdp_vpp_class_init (GstVdpVideoPostProcessClass * klass) -{ - GObjectClass *gobject_class; - GstElementClass *gstelement_class; - GstCaps *src_caps, *sink_caps; - GstPadTemplate *src_template, *sink_template; - - GST_DEBUG_CATEGORY_INIT (gst_vdp_vpp_debug, "vdpauvideopostprocess", 0, - "VDPAU video surface to output surface"); - - gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass *) klass; - - gobject_class->get_property = gst_vdp_vpp_get_property; - gobject_class->set_property = gst_vdp_vpp_set_property; - gobject_class->finalize = gst_vdp_vpp_finalize; - - g_object_class_install_property (gobject_class, PROP_DISPLAY, - g_param_spec_string ("display", "Display", "X Display name", - NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, PROP_FORCE_ASPECT_RATIO, - g_param_spec_boolean ("force-aspect-ratio", "Force aspect ratio", - "When enabled, the plugin will only scale up the input surface to the" - "maximum size where the aspect ratio can be preserved", TRUE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (gobject_class, PROP_DEINTERLACE_MODE, - g_param_spec_enum ("mode", "Deinterlace mode", - "Specifies if the element should deinterlace or not", - GST_TYPE_VDP_DEINTERLACE_MODES, GST_VDP_DEINTERLACE_MODE_AUTO, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (gobject_class, PROP_DEINTERLACE_METHOD, - g_param_spec_enum ("method", "Deinterlace method", - "Specifies which deinterlace method to use", - GST_TYPE_VDP_DEINTERLACE_METHODS, GST_VDP_DEINTERLACE_METHOD_BOB, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (gobject_class, PROP_NOISE_REDUCTION, - g_param_spec_float ("noise-reduction", "Noise reduction", - "The amount of noise reduction that should be done", 0.0, 1.0, 0.0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (gobject_class, PROP_SHARPENING, - g_param_spec_float ("sharpening", "Sharpening", - "The amount of sharpening or blurring to be applied", -1.0, 1.0, 0.0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (gobject_class, PROP_INVERSE_TELECINE, - g_param_spec_boolean ("inverse-telecine", "Inverse telecine", - "Whether inverse telecine should be used", FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - gst_element_class_set_metadata (gstelement_class, - "VdpauVideoPostProcess", - "Filter/Converter/Decoder/Video", - "Post process GstVdpVideoBuffers and output GstVdpOutputBuffers", - "Carl-Anton Ingmarsson "); - - gstelement_class->change_state = gst_vdp_vpp_change_state; - - /* SRC PAD */ - src_caps = gst_vdp_output_buffer_get_template_caps (); - src_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - src_caps); - gst_element_class_add_pad_template (gstelement_class, src_template); - gst_caps_unref (src_caps); - - /* SINK PAD */ - sink_caps = gst_vdp_video_buffer_get_caps (FALSE, 0); - sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - sink_caps); - gst_element_class_add_pad_template (gstelement_class, sink_template); - gst_caps_unref (sink_caps); -} - -static void -gst_vdp_vpp_init (GstVdpVideoPostProcess * vpp) -{ - GstPadTemplate *src_template, *sink_template; - - vpp->device = NULL; - vpp->mixer = VDP_INVALID_HANDLE; - - vpp->display = NULL; - - vpp->force_aspect_ratio = FALSE; - vpp->mode = GST_VDP_DEINTERLACE_MODE_AUTO; - vpp->method = GST_VDP_DEINTERLACE_METHOD_BOB; - - vpp->noise_reduction = 0.0; - vpp->sharpening = 0.0; - - /* SRC PAD */ - src_template = - gst_element_class_get_pad_template (GST_ELEMENT_CLASS (gclass), "src"); - - vpp->srcpad = GST_PAD (gst_vdp_output_src_pad_new (src_template, "src")); - gst_element_add_pad (GST_ELEMENT (vpp), vpp->srcpad); - - gst_pad_set_event_function (vpp->srcpad, - GST_DEBUG_FUNCPTR (gst_vdp_vpp_src_event)); - - /* SINK PAD */ - sink_template = - gst_element_class_get_pad_template (GST_ELEMENT_CLASS (gclass), "sink"); - vpp->sinkpad = gst_pad_new_from_template (sink_template, "sink"); - gst_element_add_pad (GST_ELEMENT (vpp), vpp->sinkpad); - - gst_pad_set_getcaps_function (vpp->sinkpad, gst_vdp_vpp_sink_getcaps); - gst_pad_set_setcaps_function (vpp->sinkpad, gst_vdp_vpp_sink_setcaps); - gst_pad_set_chain_function (vpp->sinkpad, - GST_DEBUG_FUNCPTR (gst_vdp_vpp_chain)); - gst_pad_set_event_function (vpp->sinkpad, - GST_DEBUG_FUNCPTR (gst_vdp_vpp_sink_event)); -} - -static void -gst_vdp_vpp_finalize (GObject * object) -{ -} diff --git a/sys/vdpau/gstvdpvideopostprocess.h b/sys/vdpau/gstvdpvideopostprocess.h deleted file mode 100644 index 40f7c3661f..0000000000 --- a/sys/vdpau/gstvdpvideopostprocess.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_VDP_VIDEO_POST_PROCESS_H__ -#define __GST_VDP_VIDEO_POST_PROCESS_H__ - -#include - -#include "gstvdpdevice.h" -#include "gstvdpvideobufferpool.h" - -G_BEGIN_DECLS - -#define MAX_PICTURES 6 - -typedef struct _GstVdpPicture GstVdpPicture; - -struct _GstVdpPicture -{ - GstBuffer *buf; - VdpVideoMixerPictureStructure structure; - GstClockTime timestamp; -}; - -typedef enum -{ - GST_VDP_DEINTERLACE_MODE_AUTO, - GST_VDP_DEINTERLACE_MODE_INTERLACED, - GST_VDP_DEINTERLACE_MODE_DISABLED -} GstVdpDeinterlaceModes; - -typedef enum -{ - GST_VDP_DEINTERLACE_METHOD_BOB, - GST_VDP_DEINTERLACE_METHOD_TEMPORAL, - GST_VDP_DEINTERLACE_METHOD_TEMPORAL_SPATIAL -} GstVdpDeinterlaceMethods; - -#define GST_TYPE_VDP_VIDEO_POST_PROCESS (gst_vdp_vpp_get_type()) -#define GST_VDP_VIDEO_POST_PROCESS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VDP_VIDEO_POST_PROCESS,GstVdpVideoPostProcess)) -#define GST_VDP_VIDEO_POST_PROCESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VDP_VIDEO_POST_PROCESS,GstVdpVideoPostProcessClass)) -#define GST_IS_VDP_VIDEO_POST_PROCESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VDP_VIDEO_POST_PROCESS)) -#define GST_IS_VDP_VIDEO_POST_PROCESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VDP_VIDEO_POST_PROCESS)) - -typedef struct _GstVdpVideoPostProcess GstVdpVideoPostProcess; -typedef struct _GstVdpVideoPostProcessClass GstVdpVideoPostProcessClass; - -struct _GstVdpVideoPostProcess -{ - GstElement element; - - GstPad *sinkpad, *srcpad; - - gboolean native_input; - VdpChromaType chroma_type; - gint width, height; - guint32 fourcc; - GstBufferPool *vpool; - - gboolean got_par; - gint par_n, par_d; - - gboolean interlaced; - GstClockTime field_duration; - - GstSegment segment; - GstClockTime earliest_time; - gboolean discont; - - GstVdpDevice *device; - VdpVideoMixer mixer; - - GstVdpPicture future_pictures[MAX_PICTURES]; - guint n_future_pictures; - - GstVdpPicture past_pictures[MAX_PICTURES]; - guint n_past_pictures; - - gboolean force_aspect_ratio; - GstVdpDeinterlaceModes mode; - GstVdpDeinterlaceMethods method; - - /* properties */ - gchar *display; - gfloat noise_reduction; - gfloat sharpening; - gboolean inverse_telecine; -}; - -struct _GstVdpVideoPostProcessClass -{ - GstElementClass element_class; -}; - -GType gst_vdp_vpp_get_type (void); - -G_END_DECLS - -#endif /* __GST_VDP_VIDEO_POST_PROCESS_H__ */ diff --git a/sys/vdpau/h264/gsth264dpb.c b/sys/vdpau/h264/gsth264dpb.c deleted file mode 100644 index 9676315fe3..0000000000 --- a/sys/vdpau/h264/gsth264dpb.c +++ /dev/null @@ -1,427 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2009 Carl-Anton Ingmarsson . - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "gsth264dpb.h" -#include "gstvdpvideomemory.h" - -/* Properties */ -enum -{ - PROP_0, - PROP_NUM_REF_FRAMES, - PROP_MAX_LONGTERM_IDX -}; - -GST_DEBUG_CATEGORY_STATIC (h264dpb_debug); -#define GST_CAT_DEFAULT h264dpb_debug - -#define DEBUG_INIT \ - GST_DEBUG_CATEGORY_INIT (h264dpb_debug, "vdph264dpb", 0, \ - "VDPAU H264 DPB"); - -G_DEFINE_TYPE_WITH_CODE (GstH264DPB, gst_h264_dpb, G_TYPE_OBJECT, DEBUG_INIT); - -void -gst_h264_dpb_fill_reference_frames (GstH264DPB * dpb, - VdpReferenceFrameH264 reference_frames[16]) -{ - GstH264Frame **frames; - guint i; - - frames = dpb->frames; - for (i = 0; i < dpb->n_frames; i++) { - GstH264Frame *frame = frames[i]; - GstVdpVideoMemory *vmem = - (GstVdpVideoMemory *) gst_buffer_get_memory (frame->frame-> - output_buffer, 0); - - reference_frames[i].surface = vmem->surface; - - reference_frames[i].is_long_term = frame->is_long_term; - reference_frames[i].top_is_reference = frame->is_reference; - reference_frames[i].bottom_is_reference = frame->is_reference; - reference_frames[i].field_order_cnt[0] = frame->poc; - reference_frames[i].field_order_cnt[1] = frame->poc; - reference_frames[i].frame_idx = frame->frame_idx; - } - - for (i = dpb->n_frames; i < 16; i++) { - reference_frames[i].surface = VDP_INVALID_HANDLE; - reference_frames[i].is_long_term = FALSE; - reference_frames[i].top_is_reference = VDP_FALSE; - reference_frames[i].bottom_is_reference = VDP_FALSE; - reference_frames[i].field_order_cnt[0] = 0; - reference_frames[i].field_order_cnt[1] = 0; - reference_frames[i].frame_idx = 0; - } -} - -static void -gst_h264_dpb_remove (GstH264DPB * dpb, guint idx) -{ - GstH264Frame **frames; - guint i; - - frames = dpb->frames; - gst_video_codec_frame_unref (frames[idx]->frame); - dpb->n_frames--; - - for (i = idx; i < dpb->n_frames; i++) - frames[i] = frames[i + 1]; -} - -static GstFlowReturn -gst_h264_dpb_output (GstH264DPB * dpb, guint idx) -{ - GstFlowReturn ret; - GstH264Frame *frame = dpb->frames[idx]; - - gst_video_codec_frame_ref (frame->frame); - ret = dpb->output (dpb, frame, dpb->user_data); - frame->output_needed = FALSE; - - if (!frame->is_reference) - gst_h264_dpb_remove (dpb, idx); - - return ret; -} - -static gboolean -gst_h264_dpb_bump (GstH264DPB * dpb, guint poc, GstFlowReturn * ret) -{ - GstH264Frame **frames; - guint i; - gint bump_idx; - - frames = dpb->frames; - bump_idx = -1; - for (i = 0; i < dpb->n_frames; i++) { - if (frames[i]->output_needed) { - bump_idx = i; - break; - } - } - - if (bump_idx != -1) { - for (i = bump_idx + 1; i < dpb->n_frames; i++) { - if (frames[i]->output_needed && (frames[i]->poc < frames[bump_idx]->poc)) { - bump_idx = i; - } - } - - if (frames[bump_idx]->poc < poc) { - *ret = gst_h264_dpb_output (dpb, bump_idx); - return TRUE; - } - } - - return FALSE; -} - -GstFlowReturn -gst_h264_dpb_add (GstH264DPB * dpb, GstH264Frame * h264_frame) -{ - GstFlowReturn ret = GST_FLOW_OK; - - GST_DEBUG ("add frame with poc: %d", h264_frame->poc); - - if (h264_frame->is_reference && h264_frame->is_long_term && - (h264_frame->frame_idx > dpb->max_longterm_frame_idx)) - h264_frame->is_reference = FALSE; - - if (h264_frame->is_reference) { - while (dpb->n_frames == dpb->max_frames) { - if (!gst_h264_dpb_bump (dpb, G_MAXUINT, &ret)) - goto no_room; - } - GST_DEBUG ("Storing frame in slot %d", dpb->n_frames); - dpb->frames[dpb->n_frames++] = h264_frame; - } else { - while (gst_h264_dpb_bump (dpb, h264_frame->poc, &ret)) { - if (ret != GST_FLOW_OK) - return ret; - } - - ret = dpb->output (dpb, h264_frame, dpb->user_data); - } - - return ret; - - /* ERRORS */ -no_room: - { - GST_ERROR_OBJECT (dpb, "Couldn't make room in DPB"); - return GST_FLOW_OK; - } -} - -void -gst_h264_dpb_flush (GstH264DPB * dpb, gboolean output) -{ - GstFlowReturn ret; - guint i; - - GST_DEBUG ("flush"); - - if (output) - while (gst_h264_dpb_bump (dpb, G_MAXUINT, &ret)); - - for (i = 0; i < dpb->n_frames; i++) - gst_video_codec_frame_unref (dpb->frames[i]->frame); - - dpb->n_frames = 0; - -} - -void -gst_h264_dpb_mark_sliding (GstH264DPB * dpb) -{ - GstH264Frame **frames; - guint i; - gint mark_idx = -1; - - if (dpb->n_frames != dpb->max_frames) - return; - - frames = dpb->frames; - for (i = 0; i < dpb->n_frames; i++) { - if (frames[i]->is_reference && !frames[i]->is_long_term) { - mark_idx = i; - break; - } - } - - if (mark_idx != -1) { - for (i = mark_idx; i < dpb->n_frames; i++) { - if (frames[i]->is_reference && !frames[i]->is_long_term && - frames[i]->frame_idx < frames[mark_idx]->frame_idx) - mark_idx = i; - } - - frames[mark_idx]->is_reference = FALSE; - if (!frames[mark_idx]->output_needed) - gst_h264_dpb_remove (dpb, mark_idx); - } -} - -void -gst_h264_dpb_mark_long_term (GstH264DPB * dpb, guint16 pic_num, - guint16 long_term_frame_idx) -{ - GstH264Frame **frames; - guint i; - gint mark_idx = -1; - - frames = dpb->frames; - for (i = 0; i < dpb->n_frames; i++) { - if (frames[i]->is_reference && !frames[i]->is_long_term && - frames[i]->frame_idx == pic_num) { - mark_idx = i; - break; - } - } - - if (mark_idx != -1) { - frames[mark_idx]->is_long_term = TRUE; - frames[mark_idx]->frame_idx = long_term_frame_idx; - } -} - -void -gst_h264_dpb_mark_short_term_unused (GstH264DPB * dpb, guint16 pic_num) -{ - GstH264Frame **frames; - guint i; - gint mark_idx = -1; - - frames = dpb->frames; - for (i = 0; i < dpb->n_frames; i++) { - if (frames[i]->is_reference && !frames[i]->is_long_term && - frames[i]->frame_idx == pic_num) { - mark_idx = i; - break; - } - } - - if (mark_idx != -1) { - - frames[mark_idx]->is_reference = FALSE; - if (!frames[mark_idx]->output_needed) - gst_h264_dpb_remove (dpb, mark_idx); - } -} - -void -gst_h264_dpb_mark_long_term_unused (GstH264DPB * dpb, guint16 long_term_pic_num) -{ - GstH264Frame **frames; - guint i; - gint mark_idx = -1; - - frames = dpb->frames; - for (i = 0; i < dpb->n_frames; i++) { - if (frames[i]->is_reference && frames[i]->is_long_term && - frames[i]->frame_idx == long_term_pic_num) { - mark_idx = i; - break; - } - } - - if (mark_idx != -1) { - - frames[mark_idx]->is_reference = FALSE; - if (!frames[mark_idx]->output_needed) - gst_h264_dpb_remove (dpb, mark_idx); - } -} - -void -gst_h264_dpb_mark_all_unused (GstH264DPB * dpb) -{ - GstH264Frame **frames; - guint i; - - frames = dpb->frames; - for (i = 0; i < dpb->n_frames; i++) { - frames[i]->is_reference = FALSE; - if (!frames[i]->output_needed) { - gst_h264_dpb_remove (dpb, i); - i--; - } - } - -} - -void -gst_h264_dpb_set_output_func (GstH264DPB * dpb, GstH264DPBOutputFunc func, - gpointer user_data) -{ - g_return_if_fail (GST_IS_H264_DPB (dpb)); - - dpb->output = func; - dpb->user_data = user_data; -} - -/* GObject vmethod implementations */ -static void -gst_h264_dpb_get_property (GObject * object, guint property_id, - GValue * value, GParamSpec * pspec) -{ - GstH264DPB *dpb = GST_H264_DPB (object); - - switch (property_id) { - case PROP_NUM_REF_FRAMES: - g_value_set_uint (value, dpb->max_frames); - break; - case PROP_MAX_LONGTERM_IDX: - g_value_set_int (value, dpb->max_longterm_frame_idx); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gst_h264_dpb_set_property (GObject * object, guint property_id, - const GValue * value, GParamSpec * pspec) -{ - GstH264DPB *dpb = GST_H264_DPB (object); - - switch (property_id) { - case PROP_NUM_REF_FRAMES: - { - GstFlowReturn ret; - guint i; - - dpb->max_frames = g_value_get_uint (value); - for (i = dpb->n_frames; i > dpb->max_frames; i--) - gst_h264_dpb_bump (dpb, G_MAXUINT, &ret); - - break; - } - - case PROP_MAX_LONGTERM_IDX: - { - GstH264Frame **frames; - guint i; - - dpb->max_longterm_frame_idx = g_value_get_int (value); - - frames = dpb->frames; - for (i = dpb->n_frames; i < dpb->n_frames; i++) { - if (frames[i]->is_reference && frames[i]->is_long_term && - frames[i]->frame_idx > dpb->max_longterm_frame_idx) { - frames[i]->is_reference = FALSE; - if (!frames[i]->output_needed) { - gst_h264_dpb_remove (dpb, i); - i--; - } - } - } - break; - } - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gst_h264_dpb_finalize (GObject * object) -{ - GstH264DPB *dpb = GST_H264_DPB (object); - guint i; - - for (i = 0; i < dpb->n_frames; i++) - gst_video_codec_frame_unref (dpb->frames[i]->frame); - - G_OBJECT_CLASS (gst_h264_dpb_parent_class)->finalize (object); -} - -static void -gst_h264_dpb_init (GstH264DPB * dpb) -{ - dpb->n_frames = 0; - dpb->max_longterm_frame_idx = -1; - dpb->max_frames = MAX_DPB_SIZE; -} - -static void -gst_h264_dpb_class_init (GstH264DPBClass * klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = gst_h264_dpb_finalize; - object_class->set_property = gst_h264_dpb_set_property; - object_class->get_property = gst_h264_dpb_get_property; - - g_object_class_install_property (object_class, PROP_NUM_REF_FRAMES, - g_param_spec_uint ("num-ref-frames", "Num Ref Frames", - "How many reference frames the DPB should hold ", - 0, 16, 16, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (object_class, PROP_MAX_LONGTERM_IDX, - g_param_spec_int ("max-longterm-frame-idx", "MaxLongTermFrameIDX", - "Maximum long-term frame index", - -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - -} diff --git a/sys/vdpau/h264/gsth264dpb.h b/sys/vdpau/h264/gsth264dpb.h deleted file mode 100644 index 81956390d8..0000000000 --- a/sys/vdpau/h264/gsth264dpb.h +++ /dev/null @@ -1,98 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2009 Carl-Anton Ingmarsson . - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GST_H264_DPB_H_ -#define _GST_H264_DPB_H_ - -#include -#include - -#include -#include - -G_BEGIN_DECLS - -#define MAX_DPB_SIZE 16 - -#define GST_TYPE_H264_DPB (gst_h264_dpb_get_type ()) -#define GST_H264_DPB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_H264_DPB, GstH264DPB)) -#define GST_H264_DPB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_H264_DPB, GstH264DPBClass)) -#define GST_IS_H264_DPB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_H264_DPB)) -#define GST_IS_H264_DPB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_H264_DPB)) -#define GST_H264_DPB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_H264_DPB, GstH264DPBClass)) - -typedef struct _GstH264DPB GstH264DPB; -typedef struct _GstH264DPBClass GstH264DPBClass; - -typedef struct _GstH264Frame -{ - GstVideoCodecFrame *frame; - - guint poc; - guint16 frame_idx; - gboolean is_reference; - gboolean is_long_term; - gboolean output_needed; -} GstH264Frame; - - -typedef GstFlowReturn (*GstH264DPBOutputFunc) (GstH264DPB *dpb, GstH264Frame *h264_frame, gpointer user_data); - -struct _GstH264DPB -{ - GObject parent_instance; - - /* private */ - GstH264Frame *frames[MAX_DPB_SIZE]; - guint n_frames; - - guint max_frames; - gint max_longterm_frame_idx; - - GstH264DPBOutputFunc output; - gpointer user_data; -}; - -struct _GstH264DPBClass -{ - GObjectClass parent_class; -}; - -void -gst_h264_dpb_fill_reference_frames (GstH264DPB *dpb, VdpReferenceFrameH264 reference_frames[16]); - -gboolean gst_h264_dpb_add (GstH264DPB *dpb, GstH264Frame *h264_frame); -void gst_h264_dpb_flush (GstH264DPB *dpb, gboolean output); - -void gst_h264_dpb_mark_sliding (GstH264DPB *dpb); - -void gst_h264_dpb_mark_long_term_unused (GstH264DPB *dpb, guint16 long_term_pic_num); -void gst_h264_dpb_mark_short_term_unused (GstH264DPB *dpb, guint16 pic_num); -void gst_h264_dpb_mark_all_unused (GstH264DPB *dpb); -void gst_h264_dpb_mark_long_term (GstH264DPB *dpb, guint16 pic_num, guint16 long_term_frame_idx); - -void gst_h264_dpb_set_output_func (GstH264DPB *dpb, GstH264DPBOutputFunc func, - gpointer user_data); - -GType gst_h264_dpb_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* _GST_H264_DPB_H_ */ diff --git a/sys/vdpau/h264/gstvdph264dec.c b/sys/vdpau/h264/gstvdph264dec.c deleted file mode 100644 index ac56428ce8..0000000000 --- a/sys/vdpau/h264/gstvdph264dec.c +++ /dev/null @@ -1,581 +0,0 @@ -/* GStreamer -* -* Copyright (C) 2009 Carl-Anton Ingmarsson . -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 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 -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public -* License along with this library; if not, write to the -* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -* Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include "gstvdph264dec.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_h264_dec_debug); -#define GST_CAT_DEFAULT gst_vdp_h264_dec_debug - -static GstStaticPadTemplate sink_template = -GST_STATIC_PAD_TEMPLATE (GST_VIDEO_DECODER_SINK_NAME, - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-h264,stream-format=byte-stream,alignment=au") - ); - -#define DEBUG_INIT \ - GST_DEBUG_CATEGORY_INIT (gst_vdp_h264_dec_debug, "vdpauh264dec", 0, \ - "VDPAU h264 decoder"); - -#define gst_vdp_h264_dec_parent_class parent_class -G_DEFINE_TYPE_WITH_CODE (GstVdpH264Dec, gst_vdp_h264_dec, GST_TYPE_VDP_DECODER, - DEBUG_INIT); - -static GstFlowReturn -gst_vdp_h264_dec_output (GstH264DPB * dpb, GstH264Frame * h264_frame, - gpointer user_data) -{ - GstVideoDecoder *video_decoder = (GstVideoDecoder *) user_data; - - GST_DEBUG ("poc: %d", h264_frame->poc); - - return gst_video_decoder_finish_frame (video_decoder, h264_frame->frame); -} - -static guint -gst_vdp_h264_dec_calculate_poc (GstVdpH264Dec * h264_dec, - GstH264SliceHdr * slice) -{ - GstH264SPS *seq; - guint poc = 0; - - seq = slice->pps->sequence; - - if (seq->pic_order_cnt_type == 0) { - guint32 max_poc_cnt_lsb = 1 << (seq->log2_max_pic_order_cnt_lsb_minus4 + 4); - - if ((slice->pic_order_cnt_lsb < h264_dec->prev_poc_lsb) && - ((h264_dec->prev_poc_lsb - slice->pic_order_cnt_lsb) >= - (max_poc_cnt_lsb / 2))) - h264_dec->poc_msb = h264_dec->poc_msb + max_poc_cnt_lsb; - - else if ((slice->pic_order_cnt_lsb > h264_dec->prev_poc_lsb) && - ((slice->pic_order_cnt_lsb - h264_dec->prev_poc_lsb) > - (max_poc_cnt_lsb / 2))) - h264_dec->poc_msb = h264_dec->poc_msb - max_poc_cnt_lsb; - - poc = h264_dec->poc_msb + slice->pic_order_cnt_lsb; - - h264_dec->prev_poc_lsb = slice->pic_order_cnt_lsb; - } - - return poc; -} - -static void -gst_vdp_h264_dec_init_frame_info (GstVdpH264Dec * h264_dec, - GstH264Frame * h264_frame, GstH264SliceHdr * slice) -{ - h264_frame->poc = gst_vdp_h264_dec_calculate_poc (h264_dec, slice); - - h264_frame->output_needed = TRUE; - h264_frame->is_long_term = FALSE; - h264_frame->frame_idx = slice->frame_num; - - /* is reference */ - if (slice->nalu_ref_idc == 0) - h264_frame->is_reference = FALSE; - else if (slice->slice_type == GST_H264_NAL_SLICE_IDR) { - h264_frame->is_reference = TRUE; - if (slice->dec_ref_pic_marking.long_term_reference_flag) { - h264_frame->is_long_term = TRUE; - h264_frame->frame_idx = 0; - } - } else { - h264_frame->is_reference = TRUE; - - if (slice->dec_ref_pic_marking.adaptive_ref_pic_marking_mode_flag) { - GstH264RefPicMarking *marking; - guint i; - - marking = slice->dec_ref_pic_marking.ref_pic_marking; - for (i = 0; i < slice->dec_ref_pic_marking.n_ref_pic_marking; i++) { - if (marking[i].memory_management_control_operation == 6) { - h264_frame->is_long_term = TRUE; - h264_frame->frame_idx = marking[i].long_term_frame_idx; - break; - } - } - } - } - -} - -static GstFlowReturn -gst_vdp_h264_dec_idr (GstVdpH264Dec * h264_dec, GstVideoCodecFrame * frame, - GstH264SliceHdr * slice) -{ - GstH264SPS *seq; - - GST_DEBUG_OBJECT (h264_dec, "Handling IDR slice"); - - h264_dec->poc_msb = 0; - h264_dec->prev_poc_lsb = 0; - - if (slice->dec_ref_pic_marking.no_output_of_prior_pics_flag) - gst_h264_dpb_flush (h264_dec->dpb, FALSE); - else - gst_h264_dpb_flush (h264_dec->dpb, TRUE); - - if (slice->dec_ref_pic_marking.long_term_reference_flag) - g_object_set (h264_dec->dpb, "max-longterm-frame-idx", 0, NULL); - else - g_object_set (h264_dec->dpb, "max-longterm-frame-idx", -1, NULL); - - seq = slice->pps->sequence; - - if (seq->id != h264_dec->current_sps) { - GstVideoCodecState *state; - VdpDecoderProfile profile; - GstFlowReturn ret; - - GST_DEBUG_OBJECT (h264_dec, "Sequence changed !"); - - state = - gst_video_decoder_set_output_state (GST_VIDEO_DECODER (h264_dec), - GST_VIDEO_FORMAT_YV12, seq->width, seq->height, h264_dec->input_state); - - /* calculate framerate if we haven't got one */ - if (state->info.fps_n == 0) { - state->info.fps_n = seq->fps_num; - state->info.fps_d = seq->fps_den; - } - if (state->info.par_n == 0 && seq->vui_parameters_present_flag) { - state->info.par_n = seq->vui_parameters.par_n; - state->info.par_d = seq->vui_parameters.par_d; - } - - if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (h264_dec))) - goto nego_fail; - - switch (seq->profile_idc) { - case 66: - profile = VDP_DECODER_PROFILE_H264_BASELINE; - break; - - case 77: - profile = VDP_DECODER_PROFILE_H264_MAIN; - break; - - case 100: - profile = VDP_DECODER_PROFILE_H264_HIGH; - break; - - default: - goto profile_not_suported; - } - - ret = gst_vdp_decoder_init_decoder (GST_VDP_DECODER (h264_dec), profile, - seq->num_ref_frames, h264_dec->input_state); - if (ret != GST_FLOW_OK) - return ret; - - g_object_set (h264_dec->dpb, "num-ref-frames", seq->num_ref_frames, NULL); - - h264_dec->current_sps = seq->id; - } - - return GST_FLOW_OK; - -profile_not_suported: - { - GST_ELEMENT_ERROR (h264_dec, STREAM, WRONG_TYPE, - ("vdpauh264dec doesn't support this streams profile"), - ("profile_idc: %d", seq->profile_idc)); - return GST_FLOW_ERROR; - } - -nego_fail: - { - GST_ERROR_OBJECT (h264_dec, "Negotiation failed"); - return GST_FLOW_NOT_NEGOTIATED; - } -} - -static void -gst_vdp_h264_dec_fill_info (VdpPictureInfoH264 * info, GstVdpH264Dec * h264_dec, - GstH264Frame * h264_frame, GstH264SliceHdr * slice) -{ - GstH264PPS *pic; - GstH264SPS *seq; - - pic = slice->pps; - seq = pic->sequence; - - GST_DEBUG_OBJECT (h264_dec, "Filling info"); - - /* FIXME: we only handle frames for now */ - info->field_order_cnt[0] = h264_frame->poc; - info->field_order_cnt[1] = h264_frame->poc; - - info->is_reference = h264_frame->is_reference; - info->frame_num = slice->frame_num; - - info->field_pic_flag = slice->field_pic_flag; - info->bottom_field_flag = slice->bottom_field_flag; - info->num_ref_idx_l0_active_minus1 = slice->num_ref_idx_l0_active_minus1; - info->num_ref_idx_l1_active_minus1 = slice->num_ref_idx_l1_active_minus1; - - info->num_ref_frames = seq->num_ref_frames; - info->mb_adaptive_frame_field_flag = seq->mb_adaptive_frame_field_flag; - info->frame_mbs_only_flag = seq->frame_mbs_only_flag; - info->log2_max_frame_num_minus4 = seq->log2_max_frame_num_minus4; - info->pic_order_cnt_type = seq->pic_order_cnt_type; - info->log2_max_pic_order_cnt_lsb_minus4 = - seq->log2_max_pic_order_cnt_lsb_minus4; - info->delta_pic_order_always_zero_flag = - seq->delta_pic_order_always_zero_flag; - info->direct_8x8_inference_flag = seq->direct_8x8_inference_flag; - - info->constrained_intra_pred_flag = pic->constrained_intra_pred_flag; - info->weighted_pred_flag = pic->weighted_pred_flag; - info->weighted_bipred_idc = pic->weighted_bipred_idc; - info->transform_8x8_mode_flag = pic->transform_8x8_mode_flag; - info->chroma_qp_index_offset = pic->chroma_qp_index_offset; - info->second_chroma_qp_index_offset = pic->second_chroma_qp_index_offset; - info->pic_init_qp_minus26 = pic->pic_init_qp_minus26; - info->entropy_coding_mode_flag = pic->entropy_coding_mode_flag; - info->pic_order_present_flag = pic->pic_order_present_flag; - info->deblocking_filter_control_present_flag = - pic->deblocking_filter_control_present_flag; - info->redundant_pic_cnt_present_flag = pic->redundant_pic_cnt_present_flag; - - memcpy (&info->scaling_lists_4x4, &pic->scaling_lists_4x4, 96); - memcpy (&info->scaling_lists_8x8, &pic->scaling_lists_8x8, 128); - - gst_h264_dpb_fill_reference_frames (h264_dec->dpb, info->referenceFrames); -} - -static VdpBitstreamBuffer * -gst_vdp_h264_dec_create_bitstream_buffers (GstVdpH264Dec * h264_dec, - GstH264Meta * meta, GstMapInfo * info) -{ - VdpBitstreamBuffer *bufs; - guint i; - gsize offset = 0; - - bufs = g_new (VdpBitstreamBuffer, meta->num_slices); - - for (i = 0; i < meta->num_slices; i++) { - bufs[i].bitstream = info->data + offset; - if (i == meta->num_slices) - offset = info->size; - else - offset = meta->slice_offsets[i + 1]; - bufs[i].bitstream_bytes = offset - meta->slice_offsets[i]; - bufs[i].struct_version = VDP_BITSTREAM_BUFFER_VERSION; - } - - return bufs; -} - -static GstFlowReturn -gst_vdp_h264_dec_handle_dpb (GstVdpH264Dec * h264_dec, - GstH264Frame * h264_frame, GstH264SliceHdr * slice) -{ - if (slice->nalu_ref_idc != 0 && slice->slice_type != GST_H264_NAL_SLICE_IDR) { - if (slice->dec_ref_pic_marking.adaptive_ref_pic_marking_mode_flag) { - GstH264RefPicMarking *marking; - guint i; - - marking = slice->dec_ref_pic_marking.ref_pic_marking; - for (i = 0; i < slice->dec_ref_pic_marking.n_ref_pic_marking; i++) { - - switch (marking[i].memory_management_control_operation) { - case 1: - { - guint16 pic_num; - - pic_num = slice->frame_num - - (marking[i].difference_of_pic_nums_minus1 + 1); - gst_h264_dpb_mark_short_term_unused (h264_dec->dpb, pic_num); - break; - } - - case 2: - { - gst_h264_dpb_mark_long_term_unused (h264_dec->dpb, - marking[i].long_term_pic_num); - break; - } - - case 3: - { - guint16 pic_num; - - pic_num = slice->frame_num - - (marking[i].difference_of_pic_nums_minus1 + 1); - gst_h264_dpb_mark_long_term (h264_dec->dpb, pic_num, - marking[i].long_term_frame_idx); - break; - } - - case 4: - { - g_object_set (h264_dec->dpb, "max-longterm-frame-idx", - marking[i].max_long_term_frame_idx_plus1 - 1, NULL); - break; - } - - case 5: - { - gst_h264_dpb_mark_all_unused (h264_dec->dpb); - g_object_set (h264_dec->dpb, "max-longterm-frame-idx", -1, NULL); - break; - } - - default: - break; - } - } - } else - gst_h264_dpb_mark_sliding (h264_dec->dpb); - } - - return gst_h264_dpb_add (h264_dec->dpb, h264_frame); - -} - -static void -gst_h264_frame_free (GstH264Frame * frame) -{ - g_slice_free (GstH264Frame, frame); -} - -static GstFlowReturn -gst_vdp_h264_dec_handle_frame (GstVideoDecoder * video_decoder, - GstVideoCodecFrame * frame) -{ - GstVdpH264Dec *h264_dec = GST_VDP_H264_DEC (video_decoder); - GstH264Meta *h264_meta; - GstH264Frame *h264_frame; - GList *tmp; - GstFlowReturn ret; - VdpPictureInfoH264 info; - VdpBitstreamBuffer *bufs; - GstH264SliceHdr *first_slice; - guint i; - GstMapInfo map; - - GST_DEBUG ("handle_frame"); - - h264_meta = gst_buffer_get_h264_meta (frame->input_buffer); - if (G_UNLIKELY (h264_meta == NULL)) - goto no_h264_meta; - - if (G_UNLIKELY (h264_meta->num_slices == 0)) - goto no_slices; - - /* Handle PPS/SPS/SEI if present */ - if (h264_meta->sps) { - for (tmp = h264_meta->sps; tmp; tmp = tmp->next) { - GstH264SPS *sps = (GstH264SPS *) tmp->data; - GST_LOG_OBJECT (h264_dec, "Storing SPS %d", sps->id); - h264_dec->sps[sps->id] = g_slice_dup (GstH264SPS, sps); - } - } - if (h264_meta->pps) { - for (tmp = h264_meta->pps; tmp; tmp = tmp->next) { - GstH264PPS *pps = (GstH264PPS *) tmp->data; - GST_LOG_OBJECT (h264_dec, "Storing PPS %d", pps->id); - h264_dec->pps[pps->id] = g_slice_dup (GstH264PPS, pps); - /* Adjust pps pointer */ - h264_dec->pps[pps->id]->sequence = h264_dec->sps[pps->sps_id]; - } - } - - first_slice = &h264_meta->slices[0]; - - if (!h264_dec->got_idr && first_slice->slice_type != GST_H264_NAL_SLICE_IDR) - goto no_idr; - - /* Handle slices */ - for (i = 0; i < h264_meta->num_slices; i++) { - GstH264SliceHdr *slice = &h264_meta->slices[i]; - - GST_LOG_OBJECT (h264_dec, "Handling slice #%d", i); - slice->pps = h264_dec->pps[slice->pps_id]; - } - - if (first_slice->slice_type == GST_H264_NAL_SLICE_IDR) { - ret = gst_vdp_h264_dec_idr (h264_dec, frame, first_slice); - if (ret == GST_FLOW_OK) - h264_dec->got_idr = TRUE; - else - goto skip_frame; - } - - h264_frame = g_slice_new0 (GstH264Frame); - gst_video_codec_frame_set_user_data (frame, h264_frame, - (GDestroyNotify) gst_h264_frame_free); - - gst_vdp_h264_dec_init_frame_info (h264_dec, h264_frame, first_slice); - h264_frame->frame = frame; - gst_vdp_h264_dec_fill_info (&info, h264_dec, h264_frame, first_slice); - info.slice_count = h264_meta->num_slices; - - if (!gst_buffer_map (frame->input_buffer, &map, GST_MAP_READ)) - goto map_fail; - bufs = gst_vdp_h264_dec_create_bitstream_buffers (h264_dec, h264_meta, &map); - - ret = gst_vdp_decoder_render (GST_VDP_DECODER (h264_dec), - (VdpPictureInfo *) & info, h264_meta->num_slices, bufs, frame); - g_free (bufs); - gst_buffer_unmap (frame->input_buffer, &map); - - if (ret != GST_FLOW_OK) - goto render_fail; - - /* DPB handling */ - return gst_vdp_h264_dec_handle_dpb (h264_dec, h264_frame, first_slice); - - /* EARLY exit */ -no_idr: - { - GST_DEBUG_OBJECT (video_decoder, "Didn't see a IDR yet, skipping frame"); - return gst_video_decoder_finish_frame (video_decoder, frame); - } - -skip_frame: - { - GST_DEBUG_OBJECT (video_decoder, "Skipping frame"); - return gst_video_decoder_finish_frame (video_decoder, frame); - } - - /* ERRORS */ -no_h264_meta: - { - GST_ERROR_OBJECT (video_decoder, "Input buffer doesn't have GstH264Meta"); - return GST_FLOW_ERROR; - } - -no_slices: - { - GST_ERROR_OBJECT (video_decoder, "Input buffer doesn't have any slices"); - return GST_FLOW_ERROR; - } - -map_fail: - { - GST_ERROR_OBJECT (video_decoder, "Failed to map input buffer for READ"); - return GST_FLOW_ERROR; - } - -render_fail: - { - GST_ERROR_OBJECT (video_decoder, "Failed to render : %s", - gst_flow_get_name (ret)); - gst_video_decoder_drop_frame (video_decoder, frame); - return ret; - } -} - - -static gboolean -gst_vdp_h264_dec_flush (GstVideoDecoder * video_decoder) -{ - GstVdpH264Dec *h264_dec = GST_VDP_H264_DEC (video_decoder); - - h264_dec->got_idr = FALSE; - gst_h264_dpb_flush (h264_dec->dpb, FALSE); - - return TRUE; -} - -static gboolean -gst_vdp_h264_dec_start (GstVideoDecoder * video_decoder) -{ - GstVdpH264Dec *h264_dec = GST_VDP_H264_DEC (video_decoder); - - h264_dec->got_idr = FALSE; - h264_dec->current_sps = -1; - h264_dec->got_idr = FALSE; - - h264_dec->dpb = g_object_new (GST_TYPE_H264_DPB, NULL); - gst_h264_dpb_set_output_func (h264_dec->dpb, gst_vdp_h264_dec_output, - h264_dec); - - return GST_VIDEO_DECODER_CLASS (parent_class)->start (video_decoder); -} - -static gboolean -gst_vdp_h264_dec_stop (GstVideoDecoder * video_decoder) -{ - GstVdpH264Dec *h264_dec = GST_VDP_H264_DEC (video_decoder); - - g_object_unref (h264_dec->dpb); - - return GST_VIDEO_DECODER_CLASS (parent_class)->stop (video_decoder); -} - -static gboolean -gst_vdp_h264_dec_set_format (GstVideoDecoder * video_decoder, - GstVideoCodecState * state) -{ - GstVdpH264Dec *h264_dec = GST_VDP_H264_DEC (video_decoder); - - if (h264_dec->input_state) - gst_video_codec_state_unref (h264_dec->input_state); - - h264_dec->input_state = gst_video_codec_state_ref (state); - - GST_FIXME_OBJECT (video_decoder, "Do something when receiving input state ?"); - - return TRUE; -} - -static void -gst_vdp_h264_dec_init (GstVdpH264Dec * h264_dec) -{ -} - -static void -gst_vdp_h264_dec_class_init (GstVdpH264DecClass * klass) -{ - GstElementClass *element_class; - GstVideoDecoderClass *video_decoder_class; - - element_class = GST_ELEMENT_CLASS (klass); - video_decoder_class = GST_VIDEO_DECODER_CLASS (klass); - - gst_element_class_set_static_metadata (element_class, - "VDPAU H264 Decoder", - "Decoder", - "Decode h264 stream with vdpau", - "Carl-Anton Ingmarsson "); - - gst_element_class_add_static_pad_template (element_class, &sink_template); - - video_decoder_class->start = gst_vdp_h264_dec_start; - video_decoder_class->stop = gst_vdp_h264_dec_stop; - video_decoder_class->flush = gst_vdp_h264_dec_flush; - - video_decoder_class->set_format = gst_vdp_h264_dec_set_format; - - video_decoder_class->handle_frame = gst_vdp_h264_dec_handle_frame; -} diff --git a/sys/vdpau/h264/gstvdph264dec.h b/sys/vdpau/h264/gstvdph264dec.h deleted file mode 100644 index 07074338c5..0000000000 --- a/sys/vdpau/h264/gstvdph264dec.h +++ /dev/null @@ -1,70 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2009 Carl-Anton Ingmarsson . - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_VDP_H264_DEC_H__ -#define __GST_VDP_H264_DEC_H__ - -#include -#include - -#include "../gstvdpdecoder.h" -#include "gsth264dpb.h" - -G_BEGIN_DECLS - -#define GST_TYPE_VDP_H264_DEC (gst_vdp_h264_dec_get_type()) -#define GST_VDP_H264_DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VDP_H264_DEC,GstVdpH264Dec)) -#define GST_VDP_H264_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VDP_H264_DEC,GstVdpH264DecClass)) -#define GST_VDP_H264_DEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VDP_H264_DEC,GstVdpH264DecClass)) -#define GST_IS_VDP_H264_DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VDP_H264_DEC)) -#define GST_IS_VDP_H264_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VDP_H264_DEC)) -#define GST_VDP_H264_DEC_CAST(obj) ((GstVdpH264Dec *)(obj)) - -typedef struct _GstVdpH264Dec GstVdpH264Dec; -typedef struct _GstVdpH264DecClass GstVdpH264DecClass; - - -struct _GstVdpH264Dec { - GstVdpDecoder vdp_decoder; - - GstH264DPB *dpb; - GstH264SPS *sps[GST_H264_MAX_SPS_COUNT]; - GstH264PPS *pps[GST_H264_MAX_PPS_COUNT]; - - /* Current SPS being used. Default:-1 */ - gint current_sps; - - gboolean got_idr; - - GstVideoCodecState *input_state; - - guint poc_msb; - guint prev_poc_lsb; -}; - -struct _GstVdpH264DecClass { - GstVdpDecoderClass vdp_decoder_class; -}; - -GType gst_vdp_h264_dec_get_type (void); - -G_END_DECLS - -#endif /* __GST_VDP_H264_DEC_H__ */ diff --git a/sys/vdpau/meson.build b/sys/vdpau/meson.build deleted file mode 100644 index 605efcb0ac..0000000000 --- a/sys/vdpau/meson.build +++ /dev/null @@ -1,30 +0,0 @@ -vdpau_sources = [ - 'gstvdpau.c', - 'gstvdputils.c', - 'gstvdpvideomemory.c', - 'gstvdpvideobufferpool.c', - 'gstvdpdevice.c', - 'gstvdpdecoder.c', - 'mpeg/gstvdpmpegdec.c', - # 'h264/gsth264dpb.c', - # 'h264/gstvdph264dec.c', -] - -vdpau_dep = dependency('vdpau', required: get_option('vdpau')) - -if vdpau_dep.found() - if x11_dep.found() - gstvdpau = library('gstvdpau', - vdpau_sources, - c_args: gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API'], - include_directories: [configinc], - dependencies: [gstbase_dep, gstvideo_dep, gstcodecparsers_dep, vdpau_dep, x11_dep, libm], - install: true, - install_dir: plugins_install_dir, - ) - pkgconfig.generate(gstvdpau, install_dir: plugins_pkgconfig_install_dir) - plugins += [gstvdpau] - elif get_option('vdpau').enabled() - error('vdpau plugin was enabled but required X11 dependency was not found.') - endif -endif diff --git a/sys/vdpau/mpeg/gstvdpmpegdec.c b/sys/vdpau/mpeg/gstvdpmpegdec.c deleted file mode 100644 index b7f95695cf..0000000000 --- a/sys/vdpau/mpeg/gstvdpmpegdec.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/** - * SECTION:element-vdpaumpegdec - * - * FIXME:Describe vdpaumpegdec here. - * - * ## Example launch line - * - * |[ - * gst-launch-1.0 -v -m fakesrc ! vdpaumpegdec ! fakesink silent=TRUE - * ]| - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include "gstvdpmpegdec.h" -#include "gstvdpvideomemory.h" - -GST_DEBUG_CATEGORY_STATIC (gst_vdp_mpeg_dec_debug); -#define GST_CAT_DEFAULT gst_vdp_mpeg_dec_debug - -/* the capabilities of the inputs and outputs. - * - * describe the real formats here. - */ -static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/mpeg, mpegversion = (int) [ 1, 2 ], " - "systemstream = (boolean) false") - ); - -#define DEBUG_INIT \ - GST_DEBUG_CATEGORY_INIT (gst_vdp_mpeg_dec_debug, "vdpaumpegdec", 0, \ - "VDPAU mpeg decoder"); -#define gst_vdp_mpeg_dec_parent_class parent_class -G_DEFINE_TYPE_WITH_CODE (GstVdpMpegDec, gst_vdp_mpeg_dec, GST_TYPE_VDP_DECODER, - DEBUG_INIT); - -static void gst_vdp_mpeg_dec_init_info (VdpPictureInfoMPEG1Or2 * vdp_info); - -#define SYNC_CODE_SIZE 3 - -static VdpDecoderProfile -gst_vdp_mpeg_dec_get_profile (GstMpegVideoSequenceExt * hdr) -{ - VdpDecoderProfile profile; - - switch (hdr->profile) { - case GST_MPEG_VIDEO_PROFILE_SIMPLE: - profile = VDP_DECODER_PROFILE_MPEG2_SIMPLE; - break; - default: - profile = VDP_DECODER_PROFILE_MPEG2_MAIN; - break; - } - - return profile; -} - -static gboolean -gst_vdp_mpeg_dec_handle_picture_coding (GstVdpMpegDec * mpeg_dec, - GstMpegVideoPictureExt * pic_ext, GstVideoCodecFrame * frame) -{ - VdpPictureInfoMPEG1Or2 *info; -#if 0 - gint fields; -#endif - - GST_DEBUG_OBJECT (mpeg_dec, "Handling GstMpegVideoPictureExt"); - - info = &mpeg_dec->vdp_info; - - /* FIXME : Set defaults when pic_ext isn't present */ - - memcpy (&mpeg_dec->vdp_info.f_code, &pic_ext->f_code, 4); - - info->intra_dc_precision = pic_ext->intra_dc_precision; - info->picture_structure = pic_ext->picture_structure; - info->top_field_first = pic_ext->top_field_first; - info->frame_pred_frame_dct = pic_ext->frame_pred_frame_dct; - info->concealment_motion_vectors = pic_ext->concealment_motion_vectors; - info->q_scale_type = pic_ext->q_scale_type; - info->intra_vlc_format = pic_ext->intra_vlc_format; - info->alternate_scan = pic_ext->alternate_scan; - -#if 0 - fields = 2; - if (pic_ext->picture_structure == 3) { - if (mpeg_dec->stream_info.interlaced) { - if (pic_ext->progressive_frame == 0) - fields = 2; - if (pic_ext->progressive_frame == 0 && pic_ext->repeat_first_field == 0) - fields = 2; - if (pic_ext->progressive_frame == 1 && pic_ext->repeat_first_field == 1) - fields = 3; - } else { - if (pic_ext->repeat_first_field == 0) - fields = 2; - if (pic_ext->repeat_first_field == 1 && pic_ext->top_field_first == 0) - fields = 4; - if (pic_ext->repeat_first_field == 1 && pic_ext->top_field_first == 1) - fields = 6; - } - } else - fields = 1; -#endif - - if (pic_ext->top_field_first) - GST_FIXME ("Set TFF on outgoing buffer"); -#if 0 - GST_VIDEO_FRAME_FLAG_SET (frame, GST_VIDEO_FRAME_FLAG_TFF); -#endif - - return TRUE; -} - -static gboolean -gst_vdp_mpeg_dec_handle_picture (GstVdpMpegDec * mpeg_dec, - GstMpegVideoPictureHdr * pic_hdr) -{ - GST_DEBUG_OBJECT (mpeg_dec, "Handling GstMpegVideoPictureHdr"); - - mpeg_dec->vdp_info.picture_coding_type = pic_hdr->pic_type; - - if (mpeg_dec->stream_info.version == 1) { - mpeg_dec->vdp_info.full_pel_forward_vector = - pic_hdr->full_pel_forward_vector; - mpeg_dec->vdp_info.full_pel_backward_vector = - pic_hdr->full_pel_backward_vector; - memcpy (&mpeg_dec->vdp_info.f_code, &pic_hdr->f_code, 4); - } - - mpeg_dec->frame_nr = mpeg_dec->gop_frame + pic_hdr->tsn; - - return TRUE; -} - -static gboolean -gst_vdp_mpeg_dec_set_format (GstVideoDecoder * decoder, - GstVideoCodecState * state) -{ - GstVdpMpegDec *mpeg_dec = (GstVdpMpegDec *) decoder; - - /* FIXME : Check the hardware can handle the level/profile */ - if (mpeg_dec->input_state) - gst_video_codec_state_unref (mpeg_dec->input_state); - mpeg_dec->input_state = gst_video_codec_state_ref (state); - - return TRUE; -} - -#if 0 -static gboolean -gst_vdp_mpeg_dec_handle_gop (GstVdpMpegDec * mpeg_dec, const guint8 * data, - gsize size, guint offset) -{ - GstMpegVideoGop gop; - GstClockTime time; - - if (!gst_mpeg_video_parse_gop (&gop, data, size, offset)) - return FALSE; - - time = GST_SECOND * (gop.hour * 3600 + gop.minute * 60 + gop.second); - - GST_DEBUG ("gop timestamp: %" GST_TIME_FORMAT, GST_TIME_ARGS (time)); - - mpeg_dec->gop_frame = - gst_util_uint64_scale (time, mpeg_dec->stream_info.fps_n, - mpeg_dec->stream_info.fps_d * GST_SECOND) + gop.frame; - - if (mpeg_dec->state == GST_VDP_MPEG_DEC_STATE_NEED_GOP) - mpeg_dec->state = GST_VDP_MPEG_DEC_STATE_NEED_DATA; - - return TRUE; -} -#endif - -static gboolean -gst_vdp_mpeg_dec_handle_quant_matrix (GstVdpMpegDec * mpeg_dec, - GstMpegVideoQuantMatrixExt * qm) -{ - GST_DEBUG_OBJECT (mpeg_dec, "Handling GstMpegVideoQuantMatrixExt"); - - memcpy (&mpeg_dec->vdp_info.intra_quantizer_matrix, - &qm->intra_quantiser_matrix, 64); - memcpy (&mpeg_dec->vdp_info.non_intra_quantizer_matrix, - &qm->non_intra_quantiser_matrix, 64); - - return TRUE; -} - -static GstFlowReturn -gst_vdp_mpeg_dec_handle_sequence (GstVdpMpegDec * mpeg_dec, - GstMpegVideoSequenceHdr * hdr, GstMpegVideoSequenceExt * ext) -{ - GstFlowReturn ret; - GstVideoDecoder *video_decoder = GST_VIDEO_DECODER (mpeg_dec); - GstVdpMpegStreamInfo stream_info; - - GST_DEBUG_OBJECT (mpeg_dec, "Handling GstMpegVideoSequenceHdr"); - - memcpy (&mpeg_dec->vdp_info.intra_quantizer_matrix, - &hdr->intra_quantizer_matrix, 64); - memcpy (&mpeg_dec->vdp_info.non_intra_quantizer_matrix, - &hdr->non_intra_quantizer_matrix, 64); - - stream_info.width = hdr->width; - stream_info.height = hdr->height; - - stream_info.fps_n = hdr->fps_n; - stream_info.fps_d = hdr->fps_d; - - stream_info.par_n = hdr->par_w; - stream_info.par_d = hdr->par_h; - - stream_info.interlaced = FALSE; - stream_info.version = 1; - stream_info.profile = VDP_DECODER_PROFILE_MPEG1; - - if (ext) { - GST_DEBUG_OBJECT (mpeg_dec, "Handling GstMpegVideoSequenceExt"); - - /* FIXME : isn't this already processed by mpegvideoparse ? */ - stream_info.fps_n *= (ext->fps_n_ext + 1); - stream_info.fps_d *= (ext->fps_d_ext + 1); - - stream_info.width += (ext->horiz_size_ext << 12); - stream_info.height += (ext->vert_size_ext << 12); - - stream_info.interlaced = !ext->progressive; - stream_info.version = 2; - stream_info.profile = gst_vdp_mpeg_dec_get_profile (ext); - } - - GST_DEBUG_OBJECT (mpeg_dec, "Setting output state to %dx%d", - stream_info.width, stream_info.height); - mpeg_dec->output_state = - gst_video_decoder_set_output_state (video_decoder, GST_VIDEO_FORMAT_YV12, - stream_info.width, stream_info.height, mpeg_dec->input_state); - if (stream_info.interlaced) - mpeg_dec->output_state->info.interlace_mode = - GST_VIDEO_INTERLACE_MODE_INTERLEAVED; - gst_video_decoder_negotiate (video_decoder); - - ret = gst_vdp_decoder_init_decoder (GST_VDP_DECODER (mpeg_dec), - stream_info.profile, 2, mpeg_dec->output_state); - mpeg_dec->state = GST_VDP_MPEG_DEC_STATE_NEED_DATA; - - return ret; -} - -static GstFlowReturn -gst_vdp_mpeg_dec_handle_frame (GstVideoDecoder * video_decoder, - GstVideoCodecFrame * frame) -{ - GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (video_decoder); - - VdpPictureInfoMPEG1Or2 *info; - GstMpegVideoMeta *mpeg_meta; - GstVdpVideoMemory *vmem; - - GstFlowReturn ret = GST_FLOW_OK; - VdpBitstreamBuffer vbit[1]; - GstMapInfo mapinfo; - - /* FIXME : Specify in sink query that we need the mpeg video meta */ - - /* Parse all incoming data from the frame */ - mpeg_meta = gst_buffer_get_mpeg_video_meta (frame->input_buffer); - if (!mpeg_meta) - goto no_meta; - - /* GST_MPEG_VIDEO_PACKET_SEQUENCE */ - if (mpeg_meta->sequencehdr) { - ret = - gst_vdp_mpeg_dec_handle_sequence (mpeg_dec, mpeg_meta->sequencehdr, - mpeg_meta->sequenceext); - if (ret != GST_FLOW_OK) - goto sequence_parse_fail; - } - - if (mpeg_dec->state == GST_VDP_MPEG_DEC_STATE_NEED_SEQUENCE) - goto need_sequence; - - /* GST_MPEG_VIDEO_PACKET_PICTURE */ - if (mpeg_meta->pichdr) - gst_vdp_mpeg_dec_handle_picture (mpeg_dec, mpeg_meta->pichdr); - - /* GST_MPEG_VIDEO_PACKET_EXT_PICTURE_CODING */ - if (mpeg_meta->picext) - gst_vdp_mpeg_dec_handle_picture_coding (mpeg_dec, mpeg_meta->picext, frame); - - /* GST_MPEG_VIDEO_PACKET_GOP */ - /* if (mpeg_meta->gop) */ - /* GST_FIXME_OBJECT (mpeg_dec, "Handle GOP !"); */ - /* gst_vdp_mpeg_dec_handle_gop (mpeg_dec, mpeg_frame.gop); */ - - /* GST_MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX */ - if (mpeg_meta->quantext) - gst_vdp_mpeg_dec_handle_quant_matrix (mpeg_dec, mpeg_meta->quantext); - - info = &mpeg_dec->vdp_info; - - info->slice_count = mpeg_meta->num_slices; - - GST_DEBUG_OBJECT (mpeg_dec, "picture coding type %d", - info->picture_coding_type); - - /* check if we can decode the frame */ - if (info->picture_coding_type != GST_MPEG_VIDEO_PICTURE_TYPE_I - && info->backward_reference == VDP_INVALID_HANDLE) - goto need_i_frame; - - if (info->picture_coding_type == GST_MPEG_VIDEO_PICTURE_TYPE_B - && info->forward_reference == VDP_INVALID_HANDLE) - goto need_non_b_frame; - - if (info->picture_coding_type != GST_MPEG_VIDEO_PICTURE_TYPE_B) { - if (info->backward_reference != VDP_INVALID_HANDLE) { - GST_DEBUG_OBJECT (mpeg_dec, "Pushing B frame"); - ret = gst_video_decoder_finish_frame (video_decoder, mpeg_dec->b_frame); - } - - if (info->forward_reference != VDP_INVALID_HANDLE) { - GST_DEBUG_OBJECT (mpeg_dec, "Releasing no-longer needed forward frame"); - gst_video_codec_frame_unref (mpeg_dec->f_frame); - info->forward_reference = VDP_INVALID_HANDLE; - } - - info->forward_reference = info->backward_reference; - mpeg_dec->f_frame = mpeg_dec->b_frame; - - info->backward_reference = VDP_INVALID_HANDLE; - } - - if (ret != GST_FLOW_OK) - goto exit_after_b_frame; - - /* decode */ - if (!gst_buffer_map (frame->input_buffer, &mapinfo, GST_MAP_READ)) - goto map_fail; - - vbit[0].struct_version = VDP_BITSTREAM_BUFFER_VERSION; - vbit[0].bitstream = mapinfo.data + mpeg_meta->slice_offset; - vbit[0].bitstream_bytes = mapinfo.size - mpeg_meta->slice_offset; - - ret = gst_vdp_decoder_render (GST_VDP_DECODER (mpeg_dec), - (VdpPictureInfo *) info, 1, vbit, frame); - - gst_buffer_unmap (frame->input_buffer, &mapinfo); - - if (ret != GST_FLOW_OK) - goto render_fail; - - vmem = (GstVdpVideoMemory *) gst_buffer_get_memory (frame->output_buffer, 0); - - if (info->picture_coding_type == GST_MPEG_VIDEO_PICTURE_TYPE_B) { - ret = gst_video_decoder_finish_frame (video_decoder, frame); - } else { - info->backward_reference = vmem->surface; - mpeg_dec->b_frame = gst_video_codec_frame_ref (frame); - } - - return ret; - - /* EARLY EXIT */ -need_sequence: - { - GST_DEBUG_OBJECT (mpeg_dec, "Drop frame since we haven't found a " - "GST_MPEG_VIDEO_PACKET_SEQUENCE yet"); - - gst_video_decoder_finish_frame (video_decoder, frame); - return GST_FLOW_OK; - } - -need_i_frame: - { - GST_DEBUG_OBJECT (mpeg_dec, - "Drop frame since we haven't got an I_FRAME yet"); - - gst_video_decoder_finish_frame (video_decoder, frame); - return GST_FLOW_OK; - } - -need_non_b_frame: - { - GST_DEBUG_OBJECT (mpeg_dec, - "Drop frame since we haven't got two non B_FRAME yet"); - - gst_video_decoder_finish_frame (video_decoder, frame); - return GST_FLOW_OK; - } - - - /* ERRORS */ -no_meta: - { - GST_ERROR_OBJECT (video_decoder, - "Input buffer does not have MpegVideo GstMeta"); - gst_video_decoder_drop_frame (video_decoder, frame); - return GST_FLOW_ERROR; - } - -sequence_parse_fail: - { - GST_ERROR_OBJECT (video_decoder, "Failed to handle sequence header"); - gst_video_decoder_finish_frame (video_decoder, frame); - return ret; - } - -exit_after_b_frame: - { - GST_WARNING_OBJECT (video_decoder, "Leaving after pushing B frame"); - gst_video_decoder_finish_frame (video_decoder, frame); - return ret; - } - -map_fail: - { - GST_ERROR_OBJECT (video_decoder, "Failed to map input buffer"); - gst_video_decoder_drop_frame (video_decoder, frame); - return GST_FLOW_ERROR; - } - -render_fail: - { - GST_ERROR_OBJECT (video_decoder, "Error when rendering the frame"); - gst_video_decoder_drop_frame (video_decoder, frame); - return ret; - } -} - -static gboolean -gst_vdp_mpeg_dec_flush (GstVideoDecoder * video_decoder) -{ - GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (video_decoder); - - if (mpeg_dec->vdp_info.forward_reference != VDP_INVALID_HANDLE) - gst_video_codec_frame_unref (mpeg_dec->f_frame); - if (mpeg_dec->vdp_info.backward_reference != VDP_INVALID_HANDLE) - gst_video_codec_frame_unref (mpeg_dec->b_frame); - - gst_vdp_mpeg_dec_init_info (&mpeg_dec->vdp_info); - - mpeg_dec->prev_packet = -1; - - return TRUE; -} - -static gboolean -gst_vdp_mpeg_dec_start (GstVideoDecoder * video_decoder) -{ - GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (video_decoder); - - GST_DEBUG_OBJECT (video_decoder, "Starting"); - - gst_vdp_mpeg_dec_init_info (&mpeg_dec->vdp_info); - - mpeg_dec->decoder = VDP_INVALID_HANDLE; - mpeg_dec->state = GST_VDP_MPEG_DEC_STATE_NEED_SEQUENCE; - - memset (&mpeg_dec->stream_info, 0, sizeof (GstVdpMpegStreamInfo)); - - return GST_VIDEO_DECODER_CLASS (parent_class)->start (video_decoder); -} - -static gboolean -gst_vdp_mpeg_dec_stop (GstVideoDecoder * video_decoder) -{ - GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (video_decoder); - - if (mpeg_dec->vdp_info.forward_reference != VDP_INVALID_HANDLE) - mpeg_dec->vdp_info.forward_reference = VDP_INVALID_HANDLE; - if (mpeg_dec->vdp_info.backward_reference != VDP_INVALID_HANDLE) - mpeg_dec->vdp_info.backward_reference = VDP_INVALID_HANDLE; - - mpeg_dec->state = GST_VDP_MPEG_DEC_STATE_NEED_SEQUENCE; - - return GST_VIDEO_DECODER_CLASS (parent_class)->stop (video_decoder); -} - -/* initialize the vdpaumpegdecoder's class */ -static void -gst_vdp_mpeg_dec_class_init (GstVdpMpegDecClass * klass) -{ - GstElementClass *element_class; - GstVideoDecoderClass *video_decoder_class; - - element_class = GST_ELEMENT_CLASS (klass); - video_decoder_class = GST_VIDEO_DECODER_CLASS (klass); - - gst_element_class_set_static_metadata (element_class, - "VDPAU Mpeg Decoder", - "Decoder", - "Decode mpeg stream with vdpau", - "Carl-Anton Ingmarsson "); - - gst_element_class_add_static_pad_template (element_class, &sink_template); - - video_decoder_class->start = gst_vdp_mpeg_dec_start; - video_decoder_class->stop = gst_vdp_mpeg_dec_stop; - video_decoder_class->flush = gst_vdp_mpeg_dec_flush; - - video_decoder_class->handle_frame = gst_vdp_mpeg_dec_handle_frame; - video_decoder_class->set_format = gst_vdp_mpeg_dec_set_format; -} - -static void -gst_vdp_mpeg_dec_init_info (VdpPictureInfoMPEG1Or2 * vdp_info) -{ - vdp_info->forward_reference = VDP_INVALID_HANDLE; - vdp_info->backward_reference = VDP_INVALID_HANDLE; - vdp_info->slice_count = 0; - vdp_info->picture_structure = 3; - vdp_info->picture_coding_type = 0; - vdp_info->intra_dc_precision = 0; - vdp_info->frame_pred_frame_dct = 1; - vdp_info->concealment_motion_vectors = 0; - vdp_info->intra_vlc_format = 0; - vdp_info->alternate_scan = 0; - vdp_info->q_scale_type = 0; - vdp_info->top_field_first = 1; -} - -static void -gst_vdp_mpeg_dec_init (GstVdpMpegDec * mpeg_dec) -{ -} diff --git a/sys/vdpau/mpeg/gstvdpmpegdec.h b/sys/vdpau/mpeg/gstvdpmpegdec.h deleted file mode 100644 index 96f085efbf..0000000000 --- a/sys/vdpau/mpeg/gstvdpmpegdec.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_VDP_MPEG_DEC_H__ -#define __GST_VDP_MPEG_DEC_H__ - -#include -#include - -#include "../gstvdpdecoder.h" - -G_BEGIN_DECLS -typedef struct _GstVdpMpegStreamInfo GstVdpMpegStreamInfo; - -struct _GstVdpMpegStreamInfo -{ - gint width, height; - gint fps_n, fps_d; - gint par_n, par_d; - gboolean interlaced; - gint version; - VdpDecoderProfile profile; -}; - -#define GST_TYPE_VDP_MPEG_DEC (gst_vdp_mpeg_dec_get_type()) -#define GST_VDP_MPEG_DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VDP_MPEG_DEC,GstVdpMpegDec)) -#define GST_VDP_MPEG_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VDP_MPEG_DEC,GstVdpMpegDecClass)) -#define GST_IS_VDP_MPEG_DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VDP_MPEG_DEC)) -#define GST_IS_VDP_MPEG_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VDP_MPEG_DEC)) - -typedef enum { - GST_VDP_MPEG_DEC_STATE_NEED_SEQUENCE, - GST_VDP_MPEG_DEC_STATE_NEED_GOP, - GST_VDP_MPEG_DEC_STATE_NEED_DATA -} GstVdpMpegDecState; - -typedef struct _GstVdpMpegDec GstVdpMpegDec; -typedef struct _GstVdpMpegDecClass GstVdpMpegDecClass; - -struct _GstVdpMpegDec -{ - GstVdpDecoder vdp_decoder; - - VdpDecoder decoder; - - GstVdpMpegStreamInfo stream_info; - - /* decoder state */ - GstVideoCodecState *input_state; - GstVideoCodecState *output_state; - GstVdpMpegDecState state; - gint prev_packet; - - /* currently decoded frame info */ - VdpPictureInfoMPEG1Or2 vdp_info; - guint64 frame_nr; - - /* frame_nr from GOP */ - guint64 gop_frame; - - /* forward and backward reference */ - GstVideoCodecFrame *f_frame, *b_frame; -}; - -struct _GstVdpMpegDecClass -{ - GstVdpDecoderClass vdp_decoder_class; -}; - -GType gst_vdp_mpeg_dec_get_type (void); - -G_END_DECLS - -#endif /* __GST_VDP_MPEG_DEC_H__ */ diff --git a/sys/vdpau/mpeg4/gstmpeg4frame.c b/sys/vdpau/mpeg4/gstmpeg4frame.c deleted file mode 100644 index 7da6488123..0000000000 --- a/sys/vdpau/mpeg4/gstmpeg4frame.c +++ /dev/null @@ -1,109 +0,0 @@ -/* -* GStreamer -* Copyright (C) 2009 Carl-Anton Ingmarsson -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 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 -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public -* License along with this library; if not, write to the -* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -* Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstmpeg4frame.h" - -GST_DEBUG_CATEGORY_STATIC (gst_mpeg4_frame_debug); -#define GST_CAT_DEFAULT gst_mpeg4_frame_debug - -#define DEBUG_INIT(bla) \ -GST_DEBUG_CATEGORY_INIT (gst_mpeg4_frame_debug, "gstmpeg4frame", 0, "Mpeg4 Frame"); - -GstMpeg4Frame * -gst_mpeg4_frame_new (void) -{ - GstMpeg4Frame *frame; - - frame = (GstMpeg4Frame *) gst_mini_object_new (GST_TYPE_MPEG4_FRAME); - - return frame; -} - -static GObjectClass *gst_mpeg4_frame_parent_class; - -static void -gst_mpeg4_frame_finalize (GstMpeg4Frame * mpeg4_frame) -{ - if (mpeg4_frame->vos_buf) - gst_buffer_unref (mpeg4_frame->vos_buf); - - if (mpeg4_frame->vo_buf) - gst_buffer_unref (mpeg4_frame->vo_buf); - - if (mpeg4_frame->vol_buf) - gst_buffer_unref (mpeg4_frame->vol_buf); - - if (mpeg4_frame->gov_buf) - gst_buffer_unref (mpeg4_frame->gov_buf); - - if (mpeg4_frame->vop_buf) - gst_buffer_unref (mpeg4_frame->vop_buf); - - - GST_MINI_OBJECT_CLASS (gst_mpeg4_frame_parent_class)->finalize - (GST_MINI_OBJECT (mpeg4_frame)); -} - -static void -gst_mpeg4_frame_init (GstMpeg4Frame * mpeg4_frame, gpointer g_class) -{ -} - -static void -gst_mpeg4_frame_class_init (gpointer g_class, gpointer class_data) -{ - GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class); - - gst_mpeg4_frame_parent_class = g_type_class_peek_parent (g_class); - - mini_object_class->finalize = (GstMiniObjectFinalizeFunction) - gst_mpeg4_frame_finalize; -} - - -GType -gst_mpeg4_frame_get_type (void) -{ - static GType _gst_mpeg4_frame_type = 0; - - if (G_UNLIKELY (_gst_mpeg4_frame_type == 0)) { - static const GTypeInfo info = { - sizeof (GstMpeg4FrameClass), - NULL, - NULL, - gst_mpeg4_frame_class_init, - NULL, - NULL, - sizeof (GstMpeg4Frame), - 0, - (GInstanceInitFunc) gst_mpeg4_frame_init, - NULL - }; - _gst_mpeg4_frame_type = g_type_register_static (GST_TYPE_VIDEO_FRAME, - "GstMpeg4Frame", &info, 0); - - DEBUG_INIT (); - } - return _gst_mpeg4_frame_type; -} diff --git a/sys/vdpau/mpeg4/gstmpeg4frame.h b/sys/vdpau/mpeg4/gstmpeg4frame.h deleted file mode 100644 index bf7b5bdbdd..0000000000 --- a/sys/vdpau/mpeg4/gstmpeg4frame.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* GStreamer -* Copyright (C) 2009 Carl-Anton Ingmarsson -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 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 -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public -* License along with this library; if not, write to the -* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -* Boston, MA 02110-1301, USA. -*/ - -#ifndef _GST_MPEG4_FRAME_H_ -#define _GST_MPEG4_FRAME_H_ - -#include - -#include "mpeg4util.h" - -#define GST_MPEG4_FRAME_GOT_PRIMARY GST_VIDEO_FRAME_FLAG_LAST - -typedef struct _GstMpeg4Frame GstMpeg4Frame; - -struct _GstMpeg4Frame -{ - GstBuffer *vos_buf; - GstBuffer *vo_buf; - GstBuffer *vol_buf; - GstBuffer *gov_buf; - GstBuffer *vop_buf; - - guint32 vop_time; -}; - -GstMpeg4Frame *gst_mpeg4_frame_new (void); - -#endif diff --git a/sys/vdpau/mpeg4/gstvdpmpeg4dec.c b/sys/vdpau/mpeg4/gstvdpmpeg4dec.c deleted file mode 100644 index a871f5a13d..0000000000 --- a/sys/vdpau/mpeg4/gstvdpmpeg4dec.c +++ /dev/null @@ -1,476 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/** - * SECTION:element-vdpaumpeg4dec - * - * FIXME:Describe vdpaumpeg4dec here. - * - * ## Example launch line - * - * |[ - * gst-launch-1.0 -v -m fakesrc ! vdpaumpeg4dec ! fakesink silent=TRUE - * ]| - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include - -#include "gstvdpmpeg4dec.h" - -GST_DEBUG_CATEGORY (gst_vdp_mpeg4_dec_debug); -#define GST_CAT_DEFAULT gst_vdp_mpeg4_dec_debug - -/* the capabilities of the inputs and outputs. - * - * describe the real formats here. - */ -static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/mpeg, mpegversion = (int) 4, " - "systemstream = (boolean) false; " - "video/x-divx, divxversion = (int) [4, 5]; " "video/x-xvid")); - -#define DEBUG_INIT(bla) \ - GST_DEBUG_CATEGORY_INIT (gst_vdp_mpeg4_dec_debug, "vdpaumpeg4dec", 0, \ - "VDPAU mpeg4 decoder"); - -G_DEFINE_TYPE_FULL (GstVdpMpeg4Dec, gst_vdp_mpeg4_dec, GST_TYPE_VDP_DECODER, - DEBUG_INIT); - -#define SYNC_CODE_SIZE 3 - -static VdpPictureInfoMPEG4Part2 -gst_vdp_mpeg4_dec_fill_info (GstVdpMpeg4Dec * mpeg4_dec, - GstMpeg4Frame * mpeg4_frame, Mpeg4VideoObjectPlane * vop) -{ - Mpeg4VideoObjectLayer *vol; - VdpPictureInfoMPEG4Part2 info; - - vol = &mpeg4_dec->vol; - - info.forward_reference = VDP_INVALID_HANDLE; - info.backward_reference = VDP_INVALID_HANDLE; - - /* forward reference */ - if (vop->coding_type != I_VOP && mpeg4_dec->f_frame) { - info.forward_reference = - GST_VDP_VIDEO_BUFFER (GST_VIDEO_FRAME (mpeg4_dec->f_frame)-> - src_buffer)->surface; - } - - if (vop->coding_type == B_VOP) { - guint32 trd_time, trb_time; - - trd_time = mpeg4_dec->b_frame->vop_time - mpeg4_dec->f_frame->vop_time; - trb_time = mpeg4_frame->vop_time - mpeg4_dec->f_frame->vop_time; - - info.trd[0] = trd_time; - info.trb[0] = trb_time; - - info.trd[1] = round ((double) trd_time / (double) mpeg4_dec->tframe); - info.trb[1] = round ((double) trb_time / (double) mpeg4_dec->tframe); - - /* backward reference */ - if (mpeg4_dec->b_frame) { - info.backward_reference = - GST_VDP_VIDEO_BUFFER (GST_VIDEO_FRAME (mpeg4_dec->b_frame)-> - src_buffer)->surface; - } - } - - memcpy (info.intra_quantizer_matrix, vol->intra_quant_mat, 64); - memcpy (info.non_intra_quantizer_matrix, vol->non_intra_quant_mat, 64); - - info.vop_time_increment_resolution = vol->vop_time_increment_resolution; - info.resync_marker_disable = vol->resync_marker_disable; - info.interlaced = vol->interlaced; - info.quant_type = vol->quant_type; - info.quarter_sample = vol->quarter_sample; - /* FIXME: support short video header */ - info.short_video_header = FALSE; - - info.vop_coding_type = vop->coding_type; - info.vop_fcode_forward = vop->fcode_forward; - info.vop_fcode_backward = vop->fcode_backward; - info.rounding_control = vop->rounding_type; - info.alternate_vertical_scan_flag = vop->alternate_vertical_scan_flag; - info.top_field_first = vop->top_field_first; - - return info; -} - -static gboolean -gst_vdp_mpeg4_dec_handle_configuration (GstVdpMpeg4Dec * mpeg4_dec, - GstMpeg4Frame * mpeg4_frame) -{ - Mpeg4VisualObjectSequence vos; - Mpeg4VisualObject vo; - Mpeg4VideoObjectLayer vol; - - GstVideoState state; - guint8 profile_indication; - VdpDecoderProfile profile; - - GstFlowReturn ret; - - if (mpeg4_dec->is_configured) - return GST_FLOW_OK; - - if (!mpeg4_frame->vos_buf || !mpeg4_frame->vo_buf || !mpeg4_frame->vol_buf) - goto skip_frame; - - if (!mpeg4_util_parse_VOS (mpeg4_frame->vos_buf, &vos)) - goto skip_frame; - - if (!mpeg4_util_parse_VO (mpeg4_frame->vo_buf, &vo)) - goto skip_frame; - - if (!mpeg4_util_parse_VOL (mpeg4_frame->vol_buf, &vo, &vol)) - goto skip_frame; - - state = gst_base_video_decoder_get_state (GST_BASE_VIDEO_DECODER (mpeg4_dec)); - - state.width = vol.width; - state.height = vol.height; - - if (vol.fixed_vop_rate) { - state.fps_n = vol.vop_time_increment_resolution; - state.fps_d = vol.fixed_vop_time_increment; - } - - state.par_n = vol.par_n; - state.par_d = vol.par_d; - - gst_base_video_decoder_set_state (GST_BASE_VIDEO_DECODER (mpeg4_dec), state); - - profile_indication = vos.profile_and_level_indication >> 4; - switch (profile_indication) { - case 0x0: - profile = VDP_DECODER_PROFILE_MPEG4_PART2_SP; - break; - - case 0xf: - profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP; - break; - - default: - goto unsupported_profile; - } - ret = gst_vdp_decoder_init_decoder (GST_VDP_DECODER (mpeg4_dec), profile, 2); - if (ret != GST_FLOW_OK) - return ret; - - mpeg4_dec->vol = vol; - mpeg4_dec->is_configured = TRUE; - - return GST_FLOW_OK; - -skip_frame: - GST_WARNING ("Skipping frame since we're not configured yet"); - gst_base_video_decoder_skip_frame (GST_BASE_VIDEO_DECODER (mpeg4_dec), - GST_VIDEO_FRAME (mpeg4_frame)); - return GST_FLOW_CUSTOM_ERROR; - -unsupported_profile: - GST_ELEMENT_ERROR (mpeg4_dec, STREAM, WRONG_TYPE, - ("vdpaumpeg4dec doesn't support this streams profile"), - ("profile_and_level_indication: %d", vos.profile_and_level_indication)); - return GST_FLOW_ERROR; -} - -static GstFlowReturn -gst_vdp_mpeg4_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder, - GstVideoFrame * frame, GstClockTimeDiff deadline) -{ - GstVdpMpeg4Dec *mpeg4_dec = GST_VDP_MPEG4_DEC (base_video_decoder); - - GstMpeg4Frame *mpeg4_frame; - GstFlowReturn ret; - - Mpeg4VideoObjectLayer *vol; - Mpeg4VideoObjectPlane vop; - - VdpPictureInfoMPEG4Part2 info; - VdpBitstreamBuffer bufs[1]; - GstVdpVideoBuffer *video_buf; - - mpeg4_frame = GST_MPEG4_FRAME (frame); - - ret = gst_vdp_mpeg4_dec_handle_configuration (mpeg4_dec, mpeg4_frame); - if (ret != GST_FLOW_OK) - return ret; - - vol = &mpeg4_dec->vol; - if (!mpeg4_util_parse_VOP (mpeg4_frame->vop_buf, vol, &vop)) { - gst_base_video_decoder_skip_frame (base_video_decoder, frame); - return GST_FLOW_CUSTOM_ERROR; - } - - /* calculate vop time */ - mpeg4_frame->vop_time = - vop.modulo_time_base * vol->vop_time_increment_resolution + - vop.time_increment; - - if (mpeg4_dec->tframe == -1 && vop.coding_type == B_VOP) - mpeg4_dec->tframe = mpeg4_frame->vop_time - mpeg4_dec->f_frame->vop_time; - - if (vop.coding_type != B_VOP) { - if (mpeg4_dec->b_frame) { - - ret = gst_base_video_decoder_finish_frame (base_video_decoder, - GST_VIDEO_FRAME_CAST (mpeg4_dec->b_frame)); - - if (mpeg4_dec->f_frame) - gst_video_frame_unref (GST_VIDEO_FRAME_CAST (mpeg4_dec->f_frame)); - - mpeg4_dec->f_frame = mpeg4_dec->b_frame; - mpeg4_dec->b_frame = NULL; - } - } - - info = gst_vdp_mpeg4_dec_fill_info (mpeg4_dec, mpeg4_frame, &vop); - bufs[0].struct_version = VDP_BITSTREAM_BUFFER_VERSION; - bufs[0].bitstream = GST_BUFFER_DATA (mpeg4_frame->vop_buf); - bufs[0].bitstream_bytes = GST_BUFFER_SIZE (mpeg4_frame->vop_buf); - - ret = gst_vdp_decoder_render (GST_VDP_DECODER (base_video_decoder), - (VdpPictureInfo *) & info, 1, bufs, &video_buf); - if (ret != GST_FLOW_OK) { - gst_base_video_decoder_skip_frame (base_video_decoder, frame); - return ret; - } - - frame->src_buffer = GST_BUFFER_CAST (video_buf); - - if (vop.coding_type == B_VOP) - ret = gst_base_video_decoder_finish_frame (base_video_decoder, frame); - else { - gst_video_frame_ref (GST_VIDEO_FRAME_CAST (mpeg4_frame)); - mpeg4_dec->b_frame = mpeg4_frame; - ret = GST_FLOW_OK; - } - - return ret; -} - -static GstFlowReturn -gst_vdp_mpeg4_dec_parse_data (GstBaseVideoDecoder * base_video_decoder, - GstBuffer * buf, gboolean at_eos, GstVideoFrame * frame) -{ - GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf); - guint8 start_code; - GstMpeg4Frame *mpeg4_frame; - - GstFlowReturn ret = GST_FLOW_OK; - - /* start code prefix */ - SKIP (&reader, 24); - - /* start_code */ - READ_UINT8 (&reader, start_code, 8); - - mpeg4_frame = GST_MPEG4_FRAME_CAST (frame); - - /* collect packages */ - if (start_code == MPEG4_PACKET_VOS) { - if (mpeg4_frame->vop_buf) - ret = gst_base_video_decoder_have_frame (base_video_decoder, FALSE, - (GstVideoFrame **) & mpeg4_frame); - - gst_buffer_replace (&mpeg4_frame->vos_buf, buf); - } - - else if (start_code == MPEG4_PACKET_EVOS) { - if (mpeg4_frame->vop_buf) - ret = gst_base_video_decoder_have_frame (base_video_decoder, FALSE, - (GstVideoFrame **) & mpeg4_frame); - } - - else if (start_code == MPEG4_PACKET_VO) - gst_buffer_replace (&mpeg4_frame->vo_buf, buf); - - else if (start_code >= MPEG4_PACKET_VOL_MIN && - start_code <= MPEG4_PACKET_VOL_MAX) - gst_buffer_replace (&mpeg4_frame->vol_buf, buf); - - else if (start_code == MPEG4_PACKET_GOV) { - if (mpeg4_frame->vop_buf) - ret = gst_base_video_decoder_have_frame (base_video_decoder, FALSE, - (GstVideoFrame **) & mpeg4_frame); - - gst_buffer_replace (&mpeg4_frame->gov_buf, buf); - } - - else if (start_code == MPEG4_PACKET_VOP) { - if (mpeg4_frame->vop_buf) - ret = gst_base_video_decoder_have_frame (base_video_decoder, FALSE, - (GstVideoFrame **) & mpeg4_frame); - - mpeg4_frame->vop_buf = buf; - } - - else - gst_buffer_unref (buf); - - - if (at_eos && mpeg4_frame->vop_buf) - ret = gst_base_video_decoder_have_frame (base_video_decoder, TRUE, - (GstVideoFrame **) & mpeg4_frame); - - return ret; - -error: - gst_buffer_unref (buf); - GST_WARNING ("error parsing packet"); - return GST_FLOW_OK; -} - -static gint -gst_vdp_mpeg4_dec_scan_for_sync (GstBaseVideoDecoder * base_video_decoder, - GstAdapter * adapter) -{ - gint m; - - m = gst_adapter_masked_scan_uint32 (adapter, 0xffffff00, 0x00000100, 0, - gst_adapter_available (adapter)); - if (m == -1) - return gst_adapter_available (adapter) - SYNC_CODE_SIZE; - - return m; -} - -static GstBaseVideoDecoderScanResult -gst_vdp_mpeg4_dec_scan_for_packet_end (GstBaseVideoDecoder * base_video_decoder, - GstAdapter * adapter, guint * size, gboolean at_eos) -{ - guint8 *data; - guint32 sync_code; - - data = g_slice_alloc (SYNC_CODE_SIZE); - gst_adapter_copy (adapter, data, 0, SYNC_CODE_SIZE); - sync_code = ((data[0] << 16) | (data[1] << 8) | data[2]); - - if (sync_code != 0x000001) - return GST_BASE_VIDEO_DECODER_SCAN_RESULT_LOST_SYNC; - - *size = gst_adapter_masked_scan_uint32 (adapter, 0xffffff00, 0x00000100, - SYNC_CODE_SIZE, gst_adapter_available (adapter) - SYNC_CODE_SIZE); - - if (*size == -1) - return GST_BASE_VIDEO_DECODER_SCAN_RESULT_NEED_DATA; - - return GST_BASE_VIDEO_DECODER_SCAN_RESULT_OK; -} - -static GstVideoFrame * -gst_vdp_mpeg4_dec_create_frame (GstBaseVideoDecoder * base_video_decoder) -{ - return GST_VIDEO_FRAME_CAST (gst_mpeg4_frame_new ()); -} - -static gboolean -gst_vdp_mpeg4_dec_flush (GstBaseVideoDecoder * base_video_decoder) -{ - GstVdpMpeg4Dec *mpeg4_dec = GST_VDP_MPEG4_DEC (base_video_decoder); - - if (mpeg4_dec->b_frame) { - gst_video_frame_unref (GST_VIDEO_FRAME_CAST (mpeg4_dec->b_frame)); - mpeg4_dec->b_frame = NULL; - } - - if (mpeg4_dec->f_frame) { - gst_video_frame_unref (GST_VIDEO_FRAME_CAST (mpeg4_dec->f_frame)); - mpeg4_dec->f_frame = NULL; - } - - return TRUE; -} - -static gboolean -gst_vdp_mpeg4_dec_start (GstBaseVideoDecoder * base_video_decoder) -{ - GstVdpMpeg4Dec *mpeg4_dec = GST_VDP_MPEG4_DEC (base_video_decoder); - - mpeg4_dec->is_configured = FALSE; - mpeg4_dec->tframe = -1; - - mpeg4_dec->b_frame = NULL; - mpeg4_dec->f_frame = NULL; - - return GST_BASE_VIDEO_DECODER_CLASS - (parent_class)->start (base_video_decoder); -} - -static gboolean -gst_vdp_mpeg4_dec_stop (GstBaseVideoDecoder * base_video_decoder) -{ - return GST_BASE_VIDEO_DECODER_CLASS (parent_class)->stop (base_video_decoder); -} - -static void -gst_vdp_mpeg4_dec_base_init (gpointer gclass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); - - gst_element_class_set_static_metadata (element_class, - "VDPAU Mpeg4 Decoder", - "Decoder", - "Decode mpeg4 stream with vdpau", - "Carl-Anton Ingmarsson "); - - gst_element_class_add_static_pad_template (element_class, &sink_template); -} - -/* initialize the vdpaumpeg4decoder's class */ -static void -gst_vdp_mpeg4_dec_class_init (GstVdpMpeg4DecClass * klass) -{ - GstBaseVideoDecoderClass *base_video_decoder_class; - - base_video_decoder_class = GST_BASE_VIDEO_DECODER_CLASS (klass); - - base_video_decoder_class->start = gst_vdp_mpeg4_dec_start; - base_video_decoder_class->stop = gst_vdp_mpeg4_dec_stop; - base_video_decoder_class->flush = gst_vdp_mpeg4_dec_flush; - - base_video_decoder_class->create_frame = gst_vdp_mpeg4_dec_create_frame; - - base_video_decoder_class->scan_for_sync = gst_vdp_mpeg4_dec_scan_for_sync; - base_video_decoder_class->scan_for_packet_end = - gst_vdp_mpeg4_dec_scan_for_packet_end; - base_video_decoder_class->parse_data = gst_vdp_mpeg4_dec_parse_data; - - base_video_decoder_class->handle_frame = gst_vdp_mpeg4_dec_handle_frame; -} - -static void -gst_vdp_mpeg4_dec_init (GstVdpMpeg4Dec * mpeg4_dec, - GstVdpMpeg4DecClass * gclass) -{ -} diff --git a/sys/vdpau/mpeg4/gstvdpmpeg4dec.h b/sys/vdpau/mpeg4/gstvdpmpeg4dec.h deleted file mode 100644 index 788d832a7a..0000000000 --- a/sys/vdpau/mpeg4/gstvdpmpeg4dec.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_VDP_MPEG4_DEC_H__ -#define __GST_VDP_MPEG4_DEC_H__ - -#include - -#include "../gstvdpdecoder.h" - -#include "mpeg4util.h" -#include "gstmpeg4frame.h" - -G_BEGIN_DECLS - -#define GST_TYPE_VDP_MPEG4_DEC (gst_vdp_mpeg4_dec_get_type()) -#define GST_VDP_MPEG4_DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VDP_MPEG4_DEC,GstVdpMpeg4Dec)) -#define GST_VDP_MPEG4_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VDP_MPEG4_DEC,GstVdpMpeg4DecClass)) -#define GST_IS_VDP_MPEG4_DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VDP_MPEG4_DEC)) -#define GST_IS_VDP_MPEG4_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VDP_MPEG4_DEC)) - -typedef struct _GstVdpMpeg4Dec GstVdpMpeg4Dec; -typedef struct _GstVdpMpeg4DecClass GstVdpMpeg4DecClass; - -struct _GstVdpMpeg4Dec -{ - GstVdpDecoder vdp_decoder; - - gboolean is_configured; - Mpeg4VideoObjectLayer vol; - guint32 tframe; - - GstMpeg4Frame *f_frame, *b_frame; -}; - -struct _GstVdpMpeg4DecClass -{ - GstVdpDecoderClass vdp_decoder_class; -}; - -GType gst_vdp_mpeg4_dec_get_type (void); - -G_END_DECLS - -#endif /* __GST_VDP_MPEG4_DEC_H__ */ diff --git a/sys/vdpau/mpeg4/mpeg4util.c b/sys/vdpau/mpeg4/mpeg4util.c deleted file mode 100644 index b87cefb355..0000000000 --- a/sys/vdpau/mpeg4/mpeg4util.c +++ /dev/null @@ -1,473 +0,0 @@ -/* -* GStreamer -* Copyright (C) 2009 Carl-Anton Ingmarsson -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 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 -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public -* License along with this library; if not, write to the -* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -* Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "mpeg4util.h" - -GST_DEBUG_CATEGORY_EXTERN (gst_vdp_mpeg4_dec_debug); -#define GST_CAT_DEFAULT gst_vdp_mpeg4_dec_debug - -const guint8 default_intra_quant_mat[64] = { - 8, 17, 18, 19, 21, 23, 25, 27, - 17, 18, 19, 21, 23, 25, 27, 28, - 20, 21, 22, 23, 24, 26, 28, 30, - 21, 22, 23, 24, 26, 28, 30, 32, - 22, 23, 24, 26, 28, 30, 32, 35, - 23, 24, 26, 28, 30, 32, 35, 38, - 25, 26, 28, 30, 32, 35, 38, 41, - 27, 28, 30, 32, 35, 38, 41, 45 -}; - -const guint8 default_non_intra_quant_mat[64] = { - 16, 17, 18, 19, 20, 21, 22, 23, - 17, 18, 19, 20, 21, 22, 23, 24, - 18, 19, 20, 21, 22, 23, 24, 25, - 19, 20, 21, 22, 23, 24, 26, 27, - 20, 21, 22, 23, 25, 26, 27, 28, - 21, 22, 23, 24, 26, 27, 28, 30, - 22, 23, 24, 26, 27, 28, 30, 31, - 23, 24, 25, 27, 28, 30, 31, 33, -}; - -const guint8 mpeg4_zigzag_8x8[64] = { - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63 -}; - -gboolean -mpeg4_util_parse_VOP (GstBuffer * buf, Mpeg4VideoObjectLayer * vol, - Mpeg4VideoObjectPlane * vop) -{ - GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf); - - guint8 vop_start_code; - guint8 modulo_time_base; - - /* set default values */ - vop->modulo_time_base = 0; - vop->rounding_type = 0; - vop->top_field_first = 1; - vop->alternate_vertical_scan_flag = 0; - vop->fcode_forward = 1; - vop->fcode_backward = 1; - - /* start code prefix */ - SKIP (&reader, 24); - - READ_UINT8 (&reader, vop_start_code, 8); - if (vop_start_code != MPEG4_PACKET_VOP) - goto wrong_start_code; - - READ_UINT8 (&reader, vop->coding_type, 2); - - READ_UINT8 (&reader, modulo_time_base, 1); - while (modulo_time_base) { - vop->modulo_time_base++; - - READ_UINT8 (&reader, modulo_time_base, 1); - } - - /* marker bit */ - SKIP (&reader, 1); - READ_UINT16 (&reader, vop->time_increment, vol->vop_time_increment_bits); - /* marker bit */ - SKIP (&reader, 1); - - READ_UINT8 (&reader, vop->coded, 1); - if (!vop->coded) - return TRUE; - - if (vop->coding_type == P_VOP) - READ_UINT8 (&reader, vop->rounding_type, 1); - - READ_UINT8 (&reader, vop->intra_dc_vlc_thr, 3); - - if (vol->interlaced) { - READ_UINT8 (&reader, vop->top_field_first, 1); - READ_UINT8 (&reader, vop->alternate_vertical_scan_flag, 1); - } - - READ_UINT16 (&reader, vop->quant, vol->quant_precision); - - if (vop->coding_type != I_VOP) { - READ_UINT8 (&reader, vop->fcode_forward, 3); - CHECK_ALLOWED (vop->fcode_forward, 1, 7); - } - - if (vop->coding_type == B_VOP) { - READ_UINT8 (&reader, vop->fcode_backward, 3); - CHECK_ALLOWED (vop->fcode_backward, 1, 7); - } - - return TRUE; - -error: - GST_WARNING ("error parsing \"Video Object Plane\""); - return FALSE; - -wrong_start_code: - GST_WARNING ("got buffer with wrong start code"); - goto error; -} - -gboolean -mpeg4_util_parse_GOV (GstBuffer * buf, Mpeg4GroupofVideoObjectPlane * gov) -{ - GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf); - - guint8 gov_start_code; - - /* start code prefix */ - SKIP (&reader, 24); - - READ_UINT8 (&reader, gov_start_code, 8); - if (gov_start_code != MPEG4_PACKET_GOV) - goto wrong_start_code; - - READ_UINT8 (&reader, gov->hours, 5); - READ_UINT8 (&reader, gov->minutes, 6); - /* marker bit */ - SKIP (&reader, 1); - READ_UINT8 (&reader, gov->seconds, 6); - - READ_UINT8 (&reader, gov->closed, 1); - READ_UINT8 (&reader, gov->broken_link, 1); - - return TRUE; - -error: - GST_WARNING ("error parsing \"Group of Video Object Plane\""); - return FALSE; - -wrong_start_code: - GST_WARNING ("got buffer with wrong start code"); - goto error; -} - -static void -mpeg4_util_par_from_info (guint8 aspect_ratio_info, guint8 * par_n, - guint8 * par_d) -{ - switch (aspect_ratio_info) { - case 0x02: - *par_n = 12; - *par_d = 11; - break; - case 0x03: - *par_n = 10; - *par_d = 11; - break; - case 0x04: - *par_n = 16; - *par_d = 11; - break; - case 0x05: - *par_n = 40; - *par_d = 33; - break; - - case 0x01: - default: - *par_n = 1; - *par_d = 1; - } -} - -static gboolean -mpeg4_util_parse_quant (GstBitReader * reader, guint8 quant_mat[64], - const guint8 default_quant_mat[64]) -{ - guint8 load_quant_mat; - - READ_UINT8 (reader, load_quant_mat, 1); - if (load_quant_mat) { - guint i; - guint8 val; - - val = 1; - for (i = 0; i < 64; i++) { - - if (val != 0) - READ_UINT8 (reader, val, 8); - - if (val == 0) { - if (i == 0) - goto invalid_quant_mat; - quant_mat[mpeg4_zigzag_8x8[i]] = quant_mat[mpeg4_zigzag_8x8[i - 1]]; - } else - quant_mat[mpeg4_zigzag_8x8[i]] = val; - } - } else - memcpy (quant_mat, default_quant_mat, 64); - - return TRUE; - -error: - GST_WARNING ("error parsing quant matrix"); - return FALSE; - -invalid_quant_mat: - GST_WARNING ("the first value should be non zero"); - goto error; -} - -gboolean -mpeg4_util_parse_VOL (GstBuffer * buf, Mpeg4VisualObject * vo, - Mpeg4VideoObjectLayer * vol) -{ - GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf); - - guint8 video_object_layer_start_code; - guint8 aspect_ratio_info; - guint8 control_parameters; - guint8 not_8_bit; - - /* set default values */ - vol->verid = vo->verid; - vol->priority = vo->priority; - - vol->low_delay = FALSE; - vol->chroma_format = 1; - vol->vbv_parameters = FALSE; - vol->quant_precision = 5; - vol->bits_per_pixel = 8; - vol->quarter_sample = FALSE; - - /* start code prefix */ - SKIP (&reader, 24); - - READ_UINT8 (&reader, video_object_layer_start_code, 8); - if (!(video_object_layer_start_code >= MPEG4_PACKET_VOL_MIN && - video_object_layer_start_code <= MPEG4_PACKET_VOL_MAX)) - goto wrong_start_code; - - READ_UINT8 (&reader, vol->random_accesible_vol, 1); - READ_UINT8 (&reader, vol->video_object_type_indication, 8); - - READ_UINT8 (&reader, vol->is_object_layer_identifier, 1); - if (vol->is_object_layer_identifier) { - READ_UINT8 (&reader, vol->verid, 4); - READ_UINT8 (&reader, vol->priority, 3); - } - - READ_UINT8 (&reader, aspect_ratio_info, 4); - if (aspect_ratio_info != 0xff) - mpeg4_util_par_from_info (aspect_ratio_info, &vol->par_n, &vol->par_d); - - else { - READ_UINT8 (&reader, vol->par_n, 8); - CHECK_ALLOWED (vol->par_n, 1, 255); - READ_UINT8 (&reader, vol->par_d, 8); - CHECK_ALLOWED (vol->par_d, 1, 255); - } - - READ_UINT8 (&reader, control_parameters, 1); - if (control_parameters) { - READ_UINT8 (&reader, vol->chroma_format, 2); - READ_UINT8 (&reader, vol->low_delay, 1); - - READ_UINT8 (&reader, vol->vbv_parameters, 1); - if (vol->vbv_parameters) { - guint16 first_half, latter_half; - guint8 latter_part; - - READ_UINT16 (&reader, first_half, 15); - SKIP (&reader, 1); - READ_UINT16 (&reader, latter_half, 15); - SKIP (&reader, 1); - vol->bit_rate = (first_half << 15) | latter_half; - - READ_UINT16 (&reader, first_half, 15); - SKIP (&reader, 1); - READ_UINT8 (&reader, latter_part, 3); - SKIP (&reader, 1); - vol->vbv_buffer_size = (first_half << 15) | latter_part; - } - } - - READ_UINT8 (&reader, vol->shape, 2); - if (vol->shape != 0x0) - goto invalid_shape; - - /* marker_bit */ - SKIP (&reader, 1); - READ_UINT16 (&reader, vol->vop_time_increment_resolution, 16); - CHECK_ALLOWED (vol->vop_time_increment_resolution, 1, G_MAXUINT16); - vol->vop_time_increment_bits = - g_bit_storage (vol->vop_time_increment_resolution); - /* marker_bit */ - SKIP (&reader, 1); - - READ_UINT8 (&reader, vol->fixed_vop_rate, 1); - if (vol->fixed_vop_rate) - READ_UINT16 (&reader, vol->fixed_vop_time_increment, - vol->vop_time_increment_bits); - - /* marker bit */ - SKIP (&reader, 1); - READ_UINT16 (&reader, vol->width, 13); - /* marker bit */ - SKIP (&reader, 1); - READ_UINT16 (&reader, vol->height, 13); - /* marker bit */ - SKIP (&reader, 1); - - READ_UINT8 (&reader, vol->interlaced, 1); - READ_UINT8 (&reader, vol->obmc_disable, 1); - - if (vol->verid == 0x1) { - READ_UINT8 (&reader, vol->sprite_enable, 1); - } else - READ_UINT8 (&reader, vol->sprite_enable, 2); - - if (vol->sprite_enable != 0x0) - goto invalid_sprite_enable; - - READ_UINT8 (&reader, not_8_bit, 1); - if (not_8_bit) { - READ_UINT8 (&reader, vol->quant_precision, 4); - CHECK_ALLOWED (vol->quant_precision, 3, 9); - - READ_UINT8 (&reader, vol->bits_per_pixel, 4); - CHECK_ALLOWED (vol->bits_per_pixel, 4, 12); - } - - - READ_UINT8 (&reader, vol->quant_type, 1); - if (vol->quant_type) { - if (!mpeg4_util_parse_quant (&reader, vol->intra_quant_mat, - default_intra_quant_mat)) - goto error; - - if (!mpeg4_util_parse_quant (&reader, vol->non_intra_quant_mat, - default_non_intra_quant_mat)) - goto error; - } else { - memset (&vol->intra_quant_mat, 0, 64); - memset (&vol->non_intra_quant_mat, 0, 64); - } - - if (vol->verid != 0x1) - READ_UINT8 (&reader, vol->quarter_sample, 1); - - READ_UINT8 (&reader, vol->complexity_estimation_disable, 1); - if (!vol->complexity_estimation_disable) - goto complexity_estimation_error; - - READ_UINT8 (&reader, vol->resync_marker_disable, 1); - - return TRUE; - -error: - GST_WARNING ("error parsing \"Video Object Layer\""); - return FALSE; - -wrong_start_code: - GST_WARNING ("got buffer with wrong start code"); - goto error; - -invalid_shape: - GST_WARNING ("we only support rectangular shape"); - goto error; - -invalid_sprite_enable: - GST_WARNING ("we only support sprite_enable == 0"); - goto error; - -complexity_estimation_error: - GST_WARNING ("don't support complexity estimation"); - goto error; -} - -gboolean -mpeg4_util_parse_VO (GstBuffer * buf, Mpeg4VisualObject * vo) -{ - GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf); - - guint8 visual_object_start_code; - guint8 is_visual_object_identifier; - - /* set defualt values */ - vo->verid = 0x1; - vo->priority = 1; - - /* start code prefix */ - SKIP (&reader, 24); - - READ_UINT8 (&reader, visual_object_start_code, 8); - if (visual_object_start_code != MPEG4_PACKET_VO) - goto wrong_start_code; - - READ_UINT8 (&reader, is_visual_object_identifier, 1); - if (is_visual_object_identifier) { - READ_UINT8 (&reader, vo->verid, 4); - READ_UINT8 (&reader, vo->priority, 3); - } - - READ_UINT8 (&reader, vo->type, 4); - - return TRUE; - -wrong_start_code: - GST_WARNING ("got buffer with wrong start code"); - return FALSE; - -error: - GST_WARNING ("error parsing \"Visual Object\""); - return FALSE; -} - -gboolean -mpeg4_util_parse_VOS (GstBuffer * buf, Mpeg4VisualObjectSequence * vos) -{ - GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf); - - guint8 visual_object_sequence_start_code; - - /* start code prefix */ - SKIP (&reader, 24); - - READ_UINT8 (&reader, visual_object_sequence_start_code, 8); - if (visual_object_sequence_start_code != MPEG4_PACKET_VOS) - goto wrong_start_code; - - READ_UINT8 (&reader, vos->profile_and_level_indication, 8); - - return TRUE; - -wrong_start_code: - GST_WARNING ("got buffer with wrong start code"); - return FALSE; - -error: - GST_WARNING ("error parsing \"Visual Object\""); - return FALSE; -} diff --git a/sys/vdpau/mpeg4/mpeg4util.h b/sys/vdpau/mpeg4/mpeg4util.h deleted file mode 100644 index 57769c1a88..0000000000 --- a/sys/vdpau/mpeg4/mpeg4util.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Carl-Anton Ingmarsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_MPEG4UTIL_H__ -#define __GST_MPEG4UTIL_H__ - -#include -#include - -#define CHECK_ALLOWED(val, min, max) { \ - if (val < min || val > max) { \ - GST_WARNING ("value not in allowed range. value: %d, range %d-%d", \ - val, min, max); \ - goto error; \ - } \ -} - -#define READ_UINT8(reader, val, nbits) { \ - if (!gst_bit_reader_get_bits_uint8 (reader, &val, nbits)) { \ - GST_WARNING ("failed to read uint8, nbits: %d", nbits); \ - goto error; \ - } \ -} - -#define READ_UINT16(reader, val, nbits) { \ - if (!gst_bit_reader_get_bits_uint16 (reader, &val, nbits)) { \ - GST_WARNING ("failed to read uint16, nbits: %d", nbits); \ - goto error; \ - } \ -} - -#define READ_UINT32(reader, val, nbits) { \ - if (!gst_bit_reader_get_bits_uint32 (reader, &val, nbits)) { \ - GST_WARNING ("failed to read uint32, nbits: %d", nbits); \ - goto error; \ - } \ -} - -#define READ_UINT64(reader, val, nbits) { \ - if (!gst_bit_reader_get_bits_uint64 (reader, &val, nbits)) { \ - GST_WARNING ("failed to read uint64, nbits: %d", nbits); \ - goto error; \ - } \ -} - -#define SKIP(reader, nbits) { \ - if (!gst_bit_reader_skip (reader, nbits)) { \ - GST_WARNING ("failed to skip nbits: %d", nbits); \ - goto error; \ - } \ -} - -typedef struct _Mpeg4VisualObjectSequence Mpeg4VisualObjectSequence; -typedef struct _Mpeg4VisualObject Mpeg4VisualObject; -typedef struct _Mpeg4VideoObjectLayer Mpeg4VideoObjectLayer; -typedef struct _Mpeg4GroupofVideoObjectPlane Mpeg4GroupofVideoObjectPlane; -typedef struct _Mpeg4VideoObjectPlane Mpeg4VideoObjectPlane; - -#define MPEG4_PACKET_VOL_MIN 0x20 -#define MPEG4_PACKET_VOL_MAX 0x2f - -#define MPEG4_PACKET_VOS 0xb0 -#define MPEG4_PACKET_EVOS 0xb1 -#define MPEG4_PACKET_GOV 0xb3 -#define MPEG4_PACKET_VO 0xb5 -#define MPEG4_PACKET_VOP 0xb6 - -#define I_VOP 0x0 -#define P_VOP 0x1 -#define B_VOP 0x2 -#define S_VOP 0x3 - -struct _Mpeg4VisualObjectSequence { - guint8 profile_and_level_indication; -}; - -struct _Mpeg4VisualObject { - guint8 verid; - guint8 priority; - guint8 type; -}; - -struct _Mpeg4VideoObjectLayer { - guint8 random_accesible_vol; - guint8 video_object_type_indication; - - guint8 is_object_layer_identifier; - /* if is_object_layer_identifier */ - guint8 verid; - guint8 priority; - - guint8 par_n; - guint8 par_d; - - guint8 chroma_format; - guint8 low_delay; - guint8 vbv_parameters; - /* if vbv_parameters */ - guint32 bit_rate; - guint32 vbv_buffer_size; - - guint8 shape; - - guint16 vop_time_increment_resolution; - guint8 vop_time_increment_bits; - guint8 fixed_vop_rate; - /* if fixed_vop_rate */ - guint16 fixed_vop_time_increment; - - guint16 width; - guint16 height; - guint8 interlaced; - guint8 obmc_disable; - - guint8 sprite_enable; - - guint8 quant_precision; - guint8 bits_per_pixel; - - guint8 quant_type; - guint8 intra_quant_mat[64]; - guint8 non_intra_quant_mat[64]; - - guint8 quarter_sample; - guint8 complexity_estimation_disable; - guint8 resync_marker_disable; -}; - -struct _Mpeg4GroupofVideoObjectPlane { - guint8 hours; - guint8 minutes; - guint8 seconds; - - guint8 closed; - guint8 broken_link; -}; - -struct _Mpeg4VideoObjectPlane { - guint8 coding_type; - guint8 modulo_time_base; - guint16 time_increment; - - guint8 coded; - guint8 rounding_type; - guint8 intra_dc_vlc_thr; - - guint8 top_field_first; - guint8 alternate_vertical_scan_flag; - - guint16 quant; - - guint8 fcode_forward; - guint8 fcode_backward; -}; - -gboolean mpeg4_util_parse_VOP (GstBuffer *buf, Mpeg4VideoObjectLayer *vol, Mpeg4VideoObjectPlane *vop); -gboolean mpeg4_util_parse_GOV (GstBuffer *buf, Mpeg4GroupofVideoObjectPlane *gov); -gboolean mpeg4_util_parse_VOL (GstBuffer *buf, Mpeg4VisualObject *vo, Mpeg4VideoObjectLayer *vol); -gboolean mpeg4_util_parse_VO (GstBuffer *buf, Mpeg4VisualObject *vo); -gboolean mpeg4_util_parse_VOS (GstBuffer *buf, Mpeg4VisualObjectSequence *vos); - -#endif /* __GST_MPEG4UTIL_H__ */ \ No newline at end of file diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index dbc746fd76..b303d6c674 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -18,8 +18,7 @@ AM_TESTS_ENVIRONMENT += \ decklinksrc \ decklinksink dtlssrtpdec dtlssrtpenc dvbsrc dvbbasebin dfbvideosink festival fluidsynth \ kmssink \ - rsndvdbin rfbsrc vdpauyuvvideo vdpauvideoyuv \ - vdpaumpegdec vdpaumpeg4dec vdpauh264dec vdpauvideopostprocess vdpausink neonhttpsrc waylandsink" + rsndvdbin rfbsrc neonhttpsrc waylandsink" plugindir = $(libdir)/gstreamer-@GST_API_VERSION@