Q on gst_buffer_relace()
Makoto Harada
makotouu at gmail.com
Mon Nov 10 02:46:18 PST 2014
Dear experts,
I'm now working on our custom h264 decoder, and have a couple of questions
regarding the usage of gst_buffer_replace().
First of all, please take a look at the pseudo code below.
What I would like to do is to replace the contents of frame->input_buffer with
my_buffer in special case, otherwise just handling the incoming frame from up
stream.
I thought this can be possible via gst_buffer_replace().
my_hundle_frame(GstVideoDecoder * dec, GstVideoCodecFrame * frame)
{
if(special_case)
{
/* replace input_buffer with buffer_new */
GstBuffer *my_buffer;
my_buffer = gst_buffer_new_allocate (NULL, my_size, NULL);
do_something(my_buffer);
gst_buffer_replace(&frame->input_buffer, my_buffer);
gst_buffer_unref(my_buffer); //(*1): Do we need to unref my_buffer ?
}
do_h264_decode(frame);
gst_video_decoder_finish_frame (my_decoder, frame);
}
When checking the usage of gst_buffer_replace() below, reference count of old
buffer(frame->input_buffer)
will be decremented, and new buffer (my_buffer) will be incremented by calling
gst_buffer_replace().
https://developer.gnome.org/gstreamer/stable/gstreamer-GstBuffer.html#gst-buffer-replace
Questions:
Q1. Do we need to call gst_buffer_unref() at (*1) or not ?
I thought that it's required since gst_buffer_replace() will increment
it by one.
But, when checking the code of official plugins (good, bad, etc..),
they are not
consistent. so, I'm a little bit confused. Any comment please ?
# Case1: do gst_buffer_unref
http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst/videoparsers/gsth264parse.c?id=c203fd52e8cbbf7d1c71b4497750f59525c74c22#n721
# Case2: not do gst_buffer_unref
http://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/gst/avi/gstavidemux.c?h=1.4#n1913
Q2. When checking ref count just before and after gst_buffer_replace() by
using some printing function,
ref count of new buffer was incremented and the one of old buffer did
not change at all.
I can not understand why ref count of old buffer is not changed. Is
there any special case ?
Q3. How do I take care of the old buffer in terms of ref count after
calling gst_buffer_replace()?
Does gstreamer take care of them automatically, or do I have to do
something ?
Really appreciated any feedback.
Kind Regards,
Makoto Harada
More information about the gstreamer-devel
mailing list