From db64b868ffec518168a609852325d3d942c1b5d9 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 22 Feb 2012 11:44:23 +0100 Subject: [PATCH] schro: Port to 0.11 Works with some sample files. There seems to be some timestamping issue though, but the 0.10 version also complains about that too. --- configure.ac | 2 +- ext/schroedinger/gstschrodec.c | 65 +++++++-------- ext/schroedinger/gstschroenc.c | 131 ++++++++++++++++--------------- ext/schroedinger/gstschroutils.c | 79 +++++++++---------- ext/schroedinger/gstschroutils.h | 4 +- 5 files changed, 139 insertions(+), 142 deletions(-) diff --git a/configure.ac b/configure.ac index 1c51f7e069..3d935dec6a 100644 --- a/configure.ac +++ b/configure.ac @@ -312,7 +312,7 @@ GST_PLUGINS_NONPORTED=" aiff asfmux \ decklink fbdev linsys shm vcd \ apexsink bz2 cdaudio celt cog curl dc1394 dirac directfb resindvd \ gsettings jp2k ladspa mimic \ - musepack musicbrainz nas neon ofa openal opencv rsvg schro sdl smooth sndfile soundtouch spandsp timidity \ + musepack musicbrainz nas neon ofa openal opencv rsvg sdl smooth sndfile soundtouch spandsp timidity \ wildmidi xvid apple_media lv2 teletextdec opus dvb" AC_SUBST(GST_PLUGINS_NONPORTED) diff --git a/ext/schroedinger/gstschrodec.c b/ext/schroedinger/gstschrodec.c index 68e143fa70..494a64c1b4 100644 --- a/ext/schroedinger/gstschrodec.c +++ b/ext/schroedinger/gstschrodec.c @@ -79,7 +79,8 @@ enum static void gst_schro_dec_finalize (GObject * object); -static gboolean gst_schro_dec_sink_query (GstPad * pad, GstQuery * query); +static gboolean gst_schro_dec_sink_query (GstPad * pad, GstSchroDec * dec, + GstQuery * query); static gboolean gst_schro_dec_start (GstBaseVideoDecoder * dec); static gboolean gst_schro_dec_stop (GstBaseVideoDecoder * dec); @@ -87,7 +88,7 @@ static gboolean gst_schro_dec_reset (GstBaseVideoDecoder * dec); static GstFlowReturn gst_schro_dec_parse_data (GstBaseVideoDecoder * base_video_decoder, gboolean at_eos); static GstFlowReturn gst_schro_dec_handle_frame (GstBaseVideoDecoder * decoder, - GstVideoFrame * frame); + GstVideoFrameState * frame); static gboolean gst_schro_dec_finish (GstBaseVideoDecoder * base_video_decoder); static void gst_schrodec_send_tags (GstSchroDec * schro_dec); @@ -99,21 +100,27 @@ GST_STATIC_PAD_TEMPLATE ("sink", ); static GstStaticPadTemplate gst_schro_dec_src_template = - GST_STATIC_PAD_TEMPLATE ("src", +GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV (GST_SCHRO_YUV_LIST) ";" - GST_VIDEO_CAPS_ARGB) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_SCHRO_YUV_LIST)) ); -GST_BOILERPLATE (GstSchroDec, gst_schro_dec, GstBaseVideoDecoder, - GST_TYPE_BASE_VIDEO_DECODER); +#define gst_schro_dec_parent_class parent_class +G_DEFINE_TYPE (GstSchroDec, gst_schro_dec, GST_TYPE_BASE_VIDEO_DECODER); static void -gst_schro_dec_base_init (gpointer g_class) +gst_schro_dec_class_init (GstSchroDecClass * klass) { + GObjectClass *gobject_class; + GstElementClass *element_class; + GstBaseVideoDecoderClass *base_video_decoder_class; - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + gobject_class = G_OBJECT_CLASS (klass); + element_class = GST_ELEMENT_CLASS (klass); + base_video_decoder_class = GST_BASE_VIDEO_DECODER_CLASS (klass); + + gobject_class->finalize = gst_schro_dec_finalize; gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_schro_dec_src_template)); @@ -123,18 +130,6 @@ gst_schro_dec_base_init (gpointer g_class) gst_element_class_set_details_simple (element_class, "Dirac Decoder", "Codec/Decoder/Video", "Decode Dirac streams", "David Schleef "); -} - -static void -gst_schro_dec_class_init (GstSchroDecClass * klass) -{ - GObjectClass *gobject_class; - GstBaseVideoDecoderClass *base_video_decoder_class; - - gobject_class = G_OBJECT_CLASS (klass); - base_video_decoder_class = GST_BASE_VIDEO_DECODER_CLASS (klass); - - gobject_class->finalize = gst_schro_dec_finalize; base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_schro_dec_start); base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_schro_dec_stop); @@ -150,12 +145,12 @@ gst_schro_dec_class_init (GstSchroDecClass * klass) } static void -gst_schro_dec_init (GstSchroDec * schro_dec, GstSchroDecClass * klass) +gst_schro_dec_init (GstSchroDec * schro_dec) { GST_DEBUG ("gst_schro_dec_init"); gst_pad_set_query_function (GST_BASE_VIDEO_CODEC_SINK_PAD (schro_dec), - gst_schro_dec_sink_query); + (GstPadQueryFunction) gst_schro_dec_sink_query); schro_dec->decoder = schro_decoder_new (); } @@ -218,13 +213,10 @@ gst_schro_dec_sink_convert (GstPad * pad, } static gboolean -gst_schro_dec_sink_query (GstPad * pad, GstQuery * query) +gst_schro_dec_sink_query (GstPad * pad, GstSchroDec * dec, GstQuery * query) { - GstSchroDec *dec; gboolean res = FALSE; - dec = GST_SCHRO_DEC (gst_pad_get_parent (pad)); - switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CONVERT: { @@ -240,13 +232,12 @@ gst_schro_dec_sink_query (GstPad * pad, GstQuery * query) break; } default: - res = gst_pad_query_default (pad, query); + res = gst_pad_query_default (pad, GST_OBJECT (dec), query); break; } done: - gst_object_unref (dec); - return res; + error: GST_DEBUG_OBJECT (dec, "query failed"); goto done; @@ -410,7 +401,7 @@ gst_schro_dec_parse_data (GstBaseVideoDecoder * base_video_decoder, } if (SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE (parse_code)) { - GstVideoFrame *frame; + GstVideoFrameState *frame; if (next != 0 && next != SCHRO_PARSE_HEADER_SIZE) { GST_WARNING ("next is not 0 or 13 in EOS packet (%d)", next); @@ -491,7 +482,7 @@ gst_schro_dec_parse_data (GstBaseVideoDecoder * base_video_decoder, } if (SCHRO_PARSE_CODE_IS_PICTURE (parse_code)) { - GstVideoFrame *frame; + GstVideoFrameState *frame; guint8 tmp[4]; frame = base_video_decoder->current_frame; @@ -516,12 +507,12 @@ gst_schrodec_send_tags (GstSchroDec * schro_dec) { GstTagList *list; - list = gst_tag_list_new (); + list = gst_tag_list_new_empty (); gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_VIDEO_CODEC, "Dirac", NULL); - gst_element_found_tags_for_pad (GST_ELEMENT_CAST (schro_dec), - GST_BASE_VIDEO_CODEC_SRC_PAD (schro_dec), list); + gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (schro_dec), + gst_event_new_tag (gst_tag_list_copy (list))); } static GstFlowReturn @@ -568,7 +559,7 @@ gst_schro_dec_process (GstSchroDec * schro_dec, gboolean eos) { SchroFrame *schro_frame; SchroTag *tag; - GstVideoFrame *frame; + GstVideoFrameState *frame; GST_DEBUG ("got frame"); @@ -621,7 +612,7 @@ gst_schro_dec_process (GstSchroDec * schro_dec, gboolean eos) GstFlowReturn gst_schro_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder, - GstVideoFrame * frame) + GstVideoFrameState * frame) { GstSchroDec *schro_dec; SchroBuffer *input_buffer; diff --git a/ext/schroedinger/gstschroenc.c b/ext/schroedinger/gstschroenc.c index f5c86bb08b..437947f8d8 100644 --- a/ext/schroedinger/gstschroenc.c +++ b/ext/schroedinger/gstschroenc.c @@ -92,27 +92,22 @@ static void gst_schro_enc_get_property (GObject * object, guint prop_id, static GstFlowReturn gst_schro_enc_process (GstSchroEnc * schro_enc); static gboolean gst_schro_enc_set_format (GstBaseVideoEncoder * - base_video_encoder, GstVideoState * state); + base_video_encoder, GstVideoInfo * info); static gboolean gst_schro_enc_start (GstBaseVideoEncoder * base_video_encoder); static gboolean gst_schro_enc_stop (GstBaseVideoEncoder * base_video_encoder); static GstFlowReturn gst_schro_enc_finish (GstBaseVideoEncoder * base_video_encoder); static GstFlowReturn gst_schro_enc_handle_frame (GstBaseVideoEncoder * - base_video_encoder, GstVideoFrame * frame); + base_video_encoder, GstVideoFrameState * frame); static GstFlowReturn gst_schro_enc_shape_output (GstBaseVideoEncoder * - base_video_encoder, GstVideoFrame * frame); + base_video_encoder, GstVideoFrameState * frame); static void gst_schro_enc_finalize (GObject * object); -#if SCHRO_CHECK_VERSION(1,0,12) -#define ARGB_CAPS ";" GST_VIDEO_CAPS_ARGB -#else -#define ARGB_CAPS -#endif static GstStaticPadTemplate gst_schro_enc_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV (GST_SCHRO_YUV_LIST) ARGB_CAPS) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_SCHRO_YUV_LIST)) ); static GstStaticPadTemplate gst_schro_enc_src_template = @@ -122,24 +117,8 @@ static GstStaticPadTemplate gst_schro_enc_src_template = GST_STATIC_CAPS ("video/x-dirac;video/x-qt-part;video/x-mp4-part") ); -GST_BOILERPLATE (GstSchroEnc, gst_schro_enc, GstBaseVideoEncoder, - GST_TYPE_BASE_VIDEO_ENCODER); - -static void -gst_schro_enc_base_init (gpointer g_class) -{ - - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_schro_enc_src_template)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_schro_enc_sink_template)); - - gst_element_class_set_details_simple (element_class, "Dirac Encoder", - "Codec/Encoder/Video", - "Encode raw video into Dirac stream", "David Schleef "); -} +#define gst_schro_enc_parent_class parent_class +G_DEFINE_TYPE (GstSchroEnc, gst_schro_enc, GST_TYPE_BASE_VIDEO_ENCODER); static GType register_enum_list (const SchroEncoderSetting * setting) @@ -170,10 +149,12 @@ static void gst_schro_enc_class_init (GstSchroEncClass * klass) { GObjectClass *gobject_class; + GstElementClass *element_class; GstBaseVideoEncoderClass *basevideocoder_class; int i; gobject_class = G_OBJECT_CLASS (klass); + element_class = GST_ELEMENT_CLASS (klass); basevideocoder_class = GST_BASE_VIDEO_ENCODER_CLASS (klass); gobject_class->set_property = gst_schro_enc_set_property; @@ -214,6 +195,15 @@ gst_schro_enc_class_init (GstSchroEncClass * klass) } } + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_schro_enc_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_schro_enc_sink_template)); + + gst_element_class_set_details_simple (element_class, "Dirac Encoder", + "Codec/Encoder/Video", + "Encode raw video into Dirac stream", "David Schleef "); + basevideocoder_class->set_format = GST_DEBUG_FUNCPTR (gst_schro_enc_set_format); basevideocoder_class->start = GST_DEBUG_FUNCPTR (gst_schro_enc_start); @@ -226,7 +216,7 @@ gst_schro_enc_class_init (GstSchroEncClass * klass) } static void -gst_schro_enc_init (GstSchroEnc * schro_enc, GstSchroEncClass * klass) +gst_schro_enc_init (GstSchroEnc * schro_enc) { GST_DEBUG ("gst_schro_enc_init"); @@ -257,7 +247,7 @@ gst_schro_enc_finalize (GObject * object) static gboolean gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder, - GstVideoState * state) + GstVideoInfo * info) { GstSchroEnc *schro_enc = GST_SCHRO_ENC (base_video_encoder); GstCaps *caps; @@ -273,7 +263,7 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder, schro_video_format_set_std_video_format (schro_enc->video_format, SCHRO_VIDEO_FORMAT_CUSTOM); - switch (state->format) { + switch (GST_VIDEO_INFO_FORMAT (info)) { case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_YV12: #if SCHRO_CHECK_VERSION(1,0,11) @@ -303,20 +293,27 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder, g_assert_not_reached (); } - schro_enc->video_format->frame_rate_numerator = state->fps_n; - schro_enc->video_format->frame_rate_denominator = state->fps_d; + schro_enc->video_format->frame_rate_numerator = info->fps_n; + schro_enc->video_format->frame_rate_denominator = info->fps_d; - schro_enc->video_format->width = state->width; - schro_enc->video_format->height = state->height; + schro_enc->video_format->width = info->width; + schro_enc->video_format->height = info->height; +#if 0 schro_enc->video_format->clean_width = state->clean_width; schro_enc->video_format->clean_height = state->clean_height; schro_enc->video_format->left_offset = state->clean_offset_left; schro_enc->video_format->top_offset = state->clean_offset_top; +#else + schro_enc->video_format->clean_width = info->width; + schro_enc->video_format->clean_height = info->height; + schro_enc->video_format->left_offset = 0; + schro_enc->video_format->top_offset = 0; +#endif - schro_enc->video_format->aspect_ratio_numerator = state->par_n; - schro_enc->video_format->aspect_ratio_denominator = state->par_d; + schro_enc->video_format->aspect_ratio_numerator = info->par_n; + schro_enc->video_format->aspect_ratio_denominator = info->par_d; - switch (state->format) { + switch (GST_VIDEO_INFO_FORMAT (info)) { default: schro_video_format_set_std_signal_range (schro_enc->video_format, SCHRO_SIGNAL_RANGE_8BIT_VIDEO); @@ -357,37 +354,48 @@ gst_schro_enc_set_format (GstBaseVideoEncoder * base_video_encoder, schro_enc->granule_offset = ~0; caps = gst_caps_new_simple ("video/x-dirac", - "width", G_TYPE_INT, state->width, - "height", G_TYPE_INT, state->height, - "framerate", GST_TYPE_FRACTION, state->fps_n, - state->fps_d, - "pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n, - state->par_d, NULL); + "width", G_TYPE_INT, info->width, + "height", G_TYPE_INT, info->height, + "framerate", GST_TYPE_FRACTION, info->fps_n, + info->fps_d, + "pixel-aspect-ratio", GST_TYPE_FRACTION, info->par_n, info->par_d, NULL); + + GST_BUFFER_FLAG_SET (seq_header_buffer, GST_BUFFER_FLAG_HEADER); - GST_BUFFER_FLAG_SET (seq_header_buffer, GST_BUFFER_FLAG_IN_CAPS); { GValue array = { 0 }; GValue value = { 0 }; + guint8 *outdata; GstBuffer *buf; - int size; + GstMemory *seq_header_memory, *extra_header; + gsize size; g_value_init (&array, GST_TYPE_ARRAY); g_value_init (&value, GST_TYPE_BUFFER); - size = GST_BUFFER_SIZE (seq_header_buffer); - buf = gst_buffer_new_and_alloc (size + SCHRO_PARSE_HEADER_SIZE); + + buf = gst_buffer_new (); + /* Add the sequence header */ + seq_header_memory = gst_buffer_get_memory (seq_header_buffer, 0); + gst_buffer_append_memory (buf, seq_header_memory); + + size = gst_buffer_get_size (buf) + SCHRO_PARSE_HEADER_SIZE; + outdata = g_malloc0 (SCHRO_PARSE_HEADER_SIZE); + + GST_WRITE_UINT32_BE (outdata, 0x42424344); + GST_WRITE_UINT8 (outdata + 4, SCHRO_PARSE_CODE_END_OF_SEQUENCE); + GST_WRITE_UINT32_BE (outdata + 5, 0); + GST_WRITE_UINT32_BE (outdata + 9, size); + + extra_header = gst_memory_new_wrapped (0, outdata, SCHRO_PARSE_HEADER_SIZE, + 0, SCHRO_PARSE_HEADER_SIZE, outdata, g_free); + gst_buffer_append_memory (buf, extra_header); /* ogg(mux) expects the header buffers to have 0 timestamps - set OFFSET and OFFSET_END accordingly */ GST_BUFFER_OFFSET (buf) = 0; GST_BUFFER_OFFSET_END (buf) = 0; - GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS); + GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_HEADER); - memcpy (GST_BUFFER_DATA (buf), GST_BUFFER_DATA (seq_header_buffer), size); - GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + size + 0, 0x42424344); - GST_WRITE_UINT8 (GST_BUFFER_DATA (buf) + size + 4, - SCHRO_PARSE_CODE_END_OF_SEQUENCE); - GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + size + 5, 0); - GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + size + 9, size); gst_value_set_buffer (&value, buf); gst_buffer_unref (buf); gst_value_array_append_value (&array, &value); @@ -500,7 +508,7 @@ gst_schro_enc_finish (GstBaseVideoEncoder * base_video_encoder) static GstFlowReturn gst_schro_enc_handle_frame (GstBaseVideoEncoder * base_video_encoder, - GstVideoFrame * frame) + GstVideoFrameState * frame) { GstSchroEnc *schro_enc = GST_SCHRO_ENC (base_video_encoder); SchroFrame *schro_frame; @@ -529,7 +537,7 @@ gst_schro_enc_handle_frame (GstBaseVideoEncoder * base_video_encoder, static GstFlowReturn gst_schro_enc_shape_output (GstBaseVideoEncoder * base_video_encoder, - GstVideoFrame * frame) + GstVideoFrameState * frame) { GstSchroEnc *schro_enc; int delay; @@ -563,9 +571,6 @@ gst_schro_enc_shape_output (GstBaseVideoEncoder * base_video_encoder, GST_BUFFER_OFFSET_END (buf) = schro_enc->last_granulepos; } - gst_buffer_set_caps (buf, - GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder))); - return gst_pad_push (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder), buf); } @@ -573,7 +578,7 @@ static GstFlowReturn gst_schro_enc_process (GstSchroEnc * schro_enc) { SchroBuffer *encoded_buffer; - GstVideoFrame *frame; + GstVideoFrameState *frame; GstFlowReturn ret; int presentation_frame; void *voidptr; @@ -603,10 +608,12 @@ gst_schro_enc_process (GstSchroEnc * schro_enc) GstMessage *message; GstStructure *structure; GstBuffer *buf; + gpointer data; - buf = gst_buffer_new_and_alloc (sizeof (double) * 21); + data = g_malloc (sizeof (double) * 21); schro_encoder_get_frame_stats (schro_enc->encoder, - (double *) GST_BUFFER_DATA (buf), 21); + (double *) data, 21); + buf = gst_buffer_new_wrapped (data, sizeof (double) * 21); structure = gst_structure_new ("GstSchroEnc", "frame-stats", GST_TYPE_BUFFER, buf, NULL); gst_buffer_unref (buf); diff --git a/ext/schroedinger/gstschroutils.c b/ext/schroedinger/gstschroutils.c index f23abf7e54..6af3692f88 100644 --- a/ext/schroedinger/gstschroutils.c +++ b/ext/schroedinger/gstschroutils.c @@ -50,54 +50,47 @@ gst_schro_buffer_wrap (GstBuffer * buf, GstVideoFormat format, int width, int height) { SchroFrame *frame; + GstMapInfo info; + + if (!gst_buffer_map (buf, &info, GST_MAP_READ)) + return NULL; switch (format) { case GST_VIDEO_FORMAT_I420: - frame = - schro_frame_new_from_data_I420 (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_I420 (info.data, width, height); break; case GST_VIDEO_FORMAT_YV12: - frame = - schro_frame_new_from_data_YV12 (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_YV12 (info.data, width, height); break; case GST_VIDEO_FORMAT_YUY2: - frame = - schro_frame_new_from_data_YUY2 (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_YUY2 (info.data, width, height); break; case GST_VIDEO_FORMAT_UYVY: - frame = - schro_frame_new_from_data_UYVY (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_UYVY (info.data, width, height); break; case GST_VIDEO_FORMAT_AYUV: - frame = - schro_frame_new_from_data_AYUV (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_AYUV (info.data, width, height); break; #if SCHRO_CHECK_VERSION(1,0,12) case GST_VIDEO_FORMAT_ARGB: - frame = - schro_frame_new_from_data_ARGB (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_ARGB (info.data, width, height); break; #endif #if SCHRO_CHECK_VERSION(1,0,11) case GST_VIDEO_FORMAT_Y42B: - frame = - schro_frame_new_from_data_Y42B (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_Y42B (info.data, width, height); break; case GST_VIDEO_FORMAT_Y444: - frame = - schro_frame_new_from_data_Y444 (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_Y444 (info.data, width, height); break; case GST_VIDEO_FORMAT_v210: - frame = - schro_frame_new_from_data_v210 (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_v210 (info.data, width, height); break; case GST_VIDEO_FORMAT_v216: - frame = - schro_frame_new_from_data_v216 (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_v216 (info.data, width, height); break; case GST_VIDEO_FORMAT_AYUV64: - frame = - schro_frame_new_from_data_AY64 (GST_BUFFER_DATA (buf), width, height); + frame = schro_frame_new_from_data_AY64 (info.data, width, height); break; #endif default: @@ -106,10 +99,11 @@ gst_schro_buffer_wrap (GstBuffer * buf, GstVideoFormat format, int width, } schro_frame_set_free_callback (frame, gst_schro_frame_free, buf); + gst_buffer_unmap (buf, &info); + return frame; } -#ifdef GST_BUFFER_FREE_FUNC static void schro_buf_free_func (gpointer priv) { @@ -117,43 +111,48 @@ schro_buf_free_func (gpointer priv) schro_buffer_unref (buffer); } -#endif /* takes the reference */ GstBuffer * gst_schro_wrap_schro_buffer (SchroBuffer * buffer) { - GstBuffer *gstbuf; + GstMemory *mem; + GstBuffer *buf; -#ifdef GST_BUFFER_FREE_FUNC - gstbuf = gst_buffer_new (); - GST_BUFFER_DATA (gstbuf) = buffer->data; - GST_BUFFER_SIZE (gstbuf) = buffer->length; - GST_BUFFER_MALLOCDATA (gstbuf) = (void *) buffer; - GST_BUFFER_FREE_FUNC (gstbuf) = schro_buf_free_func; -#else - gstbuf = gst_buffer_new_and_alloc (buffer->length); - memcpy (GST_BUFFER_DATA (gstbuf), buffer->data, buffer->length); -#endif + mem = + gst_memory_new_wrapped (0, buffer->data, buffer->length, 0, + buffer->length, buffer, schro_buf_free_func); + buf = gst_buffer_new (); + gst_buffer_append_memory (buf, mem); - return gstbuf; + return buf; } static void gst_schro_buffer_free (SchroBuffer * buffer, void *priv) { - gst_buffer_unref (GST_BUFFER (priv)); + gst_memory_unref (GST_MEMORY_CAST (priv)); } SchroBuffer * gst_schro_wrap_gst_buffer (GstBuffer * buffer) { SchroBuffer *schrobuf; + GstMemory *mem; + GstMapInfo info; - schrobuf = schro_buffer_new_with_data (GST_BUFFER_DATA (buffer), - GST_BUFFER_SIZE (buffer)); + mem = gst_buffer_get_merged_memory (buffer); + if (!gst_memory_map (mem, &info, GST_MAP_READ)) { + GST_ERROR ("Couldn't get readable memory from gstbuffer"); + return NULL; + } + + /* FIXME : We can't control if data won't be read/write outside + * of schro ... */ + schrobuf = schro_buffer_new_with_data (info.data, info.size); + gst_memory_unmap (mem, &info); schrobuf->free = gst_schro_buffer_free; - schrobuf->priv = buffer; + schrobuf->priv = mem; return schrobuf; } diff --git a/ext/schroedinger/gstschroutils.h b/ext/schroedinger/gstschroutils.h index c1d06c5038..ad8a5c4899 100644 --- a/ext/schroedinger/gstschroutils.h +++ b/ext/schroedinger/gstschroutils.h @@ -25,9 +25,9 @@ #include #if SCHRO_CHECK_VERSION(1,0,11) -#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, Y42B, Y444, v216, v210, AY64 }" +#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, Y42B, Y444, v216, v210, AY64, ARGB }" #else -#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV }" +#define GST_SCHRO_YUV_LIST "{ I420, YV12, YUY2, UYVY, AYUV, ARGB }" #endif SchroFrame *