mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
basevideo: Add function to allocate src buffer
This commit is contained in:
parent
12f539c6bb
commit
83d6a5099b
3 changed files with 35 additions and 19 deletions
|
@ -571,28 +571,18 @@ gst_schro_dec_process (GstSchroDec * schro_dec, gboolean eos)
|
|||
GstBuffer *outbuf;
|
||||
GstVideoState *state;
|
||||
SchroFrame *schro_frame;
|
||||
GstFlowReturn flow_ret;
|
||||
int size;
|
||||
|
||||
GST_DEBUG ("need frame");
|
||||
|
||||
state =
|
||||
gst_base_video_decoder_get_state (GST_BASE_VIDEO_DECODER
|
||||
(schro_dec));
|
||||
size =
|
||||
gst_video_format_get_size (state->format, state->width,
|
||||
outbuf =
|
||||
gst_base_video_decoder_alloc_src_buffer (GST_BASE_VIDEO_DECODER
|
||||
(schro_dec));
|
||||
schro_frame =
|
||||
gst_schro_buffer_wrap (outbuf, state->format, state->width,
|
||||
state->height);
|
||||
flow_ret =
|
||||
gst_pad_alloc_buffer_and_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
|
||||
(schro_dec), GST_BUFFER_OFFSET_NONE, size,
|
||||
GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (schro_dec)), &outbuf);
|
||||
if (flow_ret != GST_FLOW_OK) {
|
||||
go = FALSE;
|
||||
ret = flow_ret;
|
||||
break;
|
||||
}
|
||||
schro_frame = gst_schro_buffer_wrap (outbuf,
|
||||
state->format, state->width, state->height);
|
||||
schro_decoder_add_output_picture (schro_dec->decoder, schro_frame);
|
||||
break;
|
||||
}
|
||||
|
@ -642,6 +632,8 @@ gst_schro_dec_process (GstSchroDec * schro_dec, gboolean eos)
|
|||
GST_DEBUG ("codec error");
|
||||
ret = GST_FLOW_ERROR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -659,8 +651,6 @@ gst_schro_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder,
|
|||
|
||||
GST_DEBUG ("handle frame");
|
||||
|
||||
gst_base_video_decoder_set_src_caps (base_video_decoder);
|
||||
|
||||
input_buffer = gst_schro_wrap_gst_buffer (frame->sink_buffer);
|
||||
frame->sink_buffer = NULL;
|
||||
|
||||
|
@ -680,8 +670,6 @@ gst_schro_dec_finish (GstBaseVideoDecoder * base_video_decoder)
|
|||
|
||||
GST_DEBUG ("finish");
|
||||
|
||||
gst_base_video_decoder_set_src_caps (base_video_decoder);
|
||||
|
||||
schro_decoder_autoparse_push_end_of_sequence (schro_dec->decoder);
|
||||
|
||||
return gst_schro_dec_process (schro_dec, TRUE);
|
||||
|
|
|
@ -1468,6 +1468,32 @@ gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder)
|
|||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
GstBuffer *
|
||||
gst_base_video_decoder_alloc_src_buffer (GstBaseVideoDecoder *
|
||||
base_video_decoder)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
GstFlowReturn flow_ret;
|
||||
int num_bytes;
|
||||
GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
|
||||
|
||||
num_bytes = gst_video_format_get_size (state->format, state->width,
|
||||
state->height);
|
||||
flow_ret =
|
||||
gst_pad_alloc_buffer_and_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
|
||||
(base_video_decoder), GST_BUFFER_OFFSET_NONE, num_bytes,
|
||||
GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)),
|
||||
&buffer);
|
||||
|
||||
if (flow_ret != GST_FLOW_OK) {
|
||||
buffer = gst_buffer_new_and_alloc (num_bytes);
|
||||
gst_buffer_set_caps (buffer,
|
||||
GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)));
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
GstFlowReturn
|
||||
gst_base_video_decoder_alloc_src_frame (GstBaseVideoDecoder *
|
||||
base_video_decoder, GstVideoFrame * frame)
|
||||
|
|
|
@ -168,6 +168,8 @@ void gst_base_video_decoder_set_sync_point (GstBaseVideoDecoder *base_video_deco
|
|||
|
||||
void gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder *base_video_decoder);
|
||||
|
||||
GstBuffer * gst_base_video_decoder_alloc_src_buffer (GstBaseVideoDecoder *
|
||||
base_video_decoder);
|
||||
GstFlowReturn gst_base_video_decoder_alloc_src_frame (GstBaseVideoDecoder *base_video_decoder,
|
||||
GstVideoFrame *frame);
|
||||
|
||||
|
|
Loading…
Reference in a new issue