return TRUE;
}
-static gboolean
+static GstFlowReturn
gst_vp9_decoder_check_codec_change (GstVp9Decoder * self,
const GstVp9FrameHeader * frame_hdr)
{
GstVp9DecoderPrivate *priv = self->priv;
- gboolean ret = TRUE;
+ GstFlowReturn ret = GST_FLOW_OK;
gboolean changed = FALSE;
if (priv->width != frame_hdr->width || priv->height != frame_hdr->height) {
priv->had_sequence = TRUE;
if (klass->new_sequence)
- priv->had_sequence = klass->new_sequence (self, frame_hdr);
+ ret = klass->new_sequence (self, frame_hdr);
- ret = priv->had_sequence;
+ if (ret != GST_FLOW_OK)
+ priv->had_sequence = FALSE;
}
return ret;
return GST_FLOW_OK;
}
- if (check_codec_change &&
- !gst_vp9_decoder_check_codec_change (self, &frame_hdr)) {
- GST_ERROR_OBJECT (self, "codec change error");
- goto unmap_and_error;
+ if (check_codec_change) {
+ ret = gst_vp9_decoder_check_codec_change (self, &frame_hdr);
+ if (ret != GST_FLOW_OK) {
+ GST_WARNING_OBJECT (self, "Subclass cannot handle codec change");
+ goto unmap_and_error;
+ }
}
if (!priv->had_sequence) {
picture->size = map.size;
if (klass->new_picture) {
- if (!klass->new_picture (self, frame, picture)) {
- GST_ERROR_OBJECT (self, "new picture error");
+ ret = klass->new_picture (self, frame, picture);
+ if (ret != GST_FLOW_OK) {
+ GST_WARNING_OBJECT (self, "subclass failed to handle new picture");
goto unmap_and_error;
}
}
if (klass->start_picture) {
- if (!klass->start_picture (self, picture)) {
- GST_ERROR_OBJECT (self, "start picture error");
+ ret = klass->start_picture (self, picture);
+ if (ret != GST_FLOW_OK) {
+ GST_WARNING_OBJECT (self, "subclass failed to handle start picture");
goto unmap_and_error;
}
}
if (klass->decode_picture) {
- if (!klass->decode_picture (self, picture, priv->dpb)) {
- GST_ERROR_OBJECT (self, "decode picture error");
+ ret = klass->decode_picture (self, picture, priv->dpb);
+ if (ret != GST_FLOW_OK) {
+ GST_WARNING_OBJECT (self, "subclass failed to decode current picture");
goto unmap_and_error;
}
}
if (klass->end_picture) {
- if (!klass->end_picture (self, picture)) {
- GST_ERROR_OBJECT (self, "end picture error");
+ ret = klass->end_picture (self, picture);
+ if (ret != GST_FLOW_OK) {
+ GST_WARNING_OBJECT (self, "subclass failed to handle end picture");
goto unmap_and_error;
}
}
ret = klass->output_picture (self, frame, picture);
}
+ if (ret == GST_FLOW_ERROR) {
+ GST_VIDEO_DECODER_ERROR (self, 1, STREAM, DECODE,
+ ("Failed to decode data"), (NULL), ret);
+ return ret;
+ }
+
return ret;
unmap_and_error:
if (picture)
gst_vp9_picture_unref (picture);
+ if (ret == GST_FLOW_OK)
+ ret = GST_FLOW_ERROR;
+
gst_video_decoder_drop_frame (decoder, frame);
GST_VIDEO_DECODER_ERROR (self, 1, STREAM, DECODE,
("Failed to decode data"), (NULL), ret);
*
* Since: 1.18
*/
- gboolean (*new_sequence) (GstVp9Decoder * decoder,
+ GstFlowReturn (*new_sequence) (GstVp9Decoder * decoder,
const GstVp9FrameHeader *frame_hdr);
/**
*
* Since: 1.18
*/
- gboolean (*new_picture) (GstVp9Decoder * decoder,
+ GstFlowReturn (*new_picture) (GstVp9Decoder * decoder,
GstVideoCodecFrame * frame,
GstVp9Picture * picture);
*
* Since: 1.18
*/
- gboolean (*start_picture) (GstVp9Decoder * decoder,
+ GstFlowReturn (*start_picture) (GstVp9Decoder * decoder,
GstVp9Picture * picture);
/**
*
* Since: 1.18
*/
- gboolean (*decode_picture) (GstVp9Decoder * decoder,
+ GstFlowReturn (*decode_picture) (GstVp9Decoder * decoder,
GstVp9Picture * picture,
GstVp9Dpb * dpb);
*
* Since: 1.18
*/
- gboolean (*end_picture) (GstVp9Decoder * decoder,
+ GstFlowReturn (*end_picture) (GstVp9Decoder * decoder,
GstVp9Picture * picture);
/**
GstEvent * event);
/* GstVp9Decoder */
-static gboolean gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder,
+static GstFlowReturn gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder,
const GstVp9FrameHeader * frame_hdr);
-static gboolean gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder,
+static GstFlowReturn gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder,
GstVideoCodecFrame * frame, GstVp9Picture * picture);
static GstVp9Picture *gst_d3d11_vp9_dec_duplicate_picture (GstVp9Decoder *
decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
-static gboolean gst_d3d11_vp9_dec_start_picture (GstVp9Decoder * decoder,
+static GstFlowReturn gst_d3d11_vp9_dec_start_picture (GstVp9Decoder * decoder,
GstVp9Picture * picture);
-static gboolean gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder,
+static GstFlowReturn gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder,
GstVp9Picture * picture, GstVp9Dpb * dpb);
-static gboolean gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder,
+static GstFlowReturn gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder,
GstVp9Picture * picture);
static GstFlowReturn gst_d3d11_vp9_dec_output_picture (GstVp9Decoder *
decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
return GST_VIDEO_DECODER_CLASS (parent_class)->sink_event (decoder, event);
}
-static gboolean
+static GstFlowReturn
gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder,
const GstVp9FrameHeader * frame_hdr)
{
if (out_format == GST_VIDEO_FORMAT_UNKNOWN) {
GST_ERROR_OBJECT (self, "Could not support profile %d", frame_hdr->profile);
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
gst_video_info_set_format (&info,
decoder->input_state, &info, (gint) frame_hdr->width,
(gint) frame_hdr->height, NUM_OUTPUT_VIEW)) {
GST_ERROR_OBJECT (self, "Failed to create decoder");
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
/* Will be updated per decode_picture */
inner->last_frame_width = inner->last_frame_height = 0;
inner->last_show_frame = FALSE;
- return TRUE;
+ return GST_FLOW_OK;
}
-static gboolean
+static GstFlowReturn
gst_d3d11_vp9_dec_new_picture (GstVp9Decoder * decoder,
GstVideoCodecFrame * frame, GstVp9Picture * picture)
{
GST_VIDEO_DECODER (decoder));
if (!view_buffer) {
GST_DEBUG_OBJECT (self, "No available output view buffer");
- return FALSE;
+ return GST_FLOW_FLUSHING;
}
GST_LOG_OBJECT (self, "New output view buffer %" GST_PTR_FORMAT, view_buffer);
GST_LOG_OBJECT (self, "New VP9 picture %p", picture);
- return TRUE;
+ return GST_FLOW_OK;
}
static GstVp9Picture *
return new_picture;
}
-static gboolean
+static GstFlowReturn
gst_d3d11_vp9_dec_start_picture (GstVp9Decoder * decoder,
GstVp9Picture * picture)
{
inner->bitstream_buffer.resize (0);
- return TRUE;
+ return GST_FLOW_OK;
}
static ID3D11VideoDecoderOutputView *
}
}
-static gboolean
+static GstFlowReturn
gst_d3d11_vp9_dec_decode_picture (GstVp9Decoder * decoder,
GstVp9Picture * picture, GstVp9Dpb * dpb)
{
&view_id);
if (!view) {
GST_ERROR_OBJECT (self, "current picture does not have output view handle");
- return FALSE;
+ return GST_FLOW_ERROR;
}
memset (pic_params, 0, sizeof (DXVA_PicParams_VP9));
inner->last_frame_height = pic_params->height;
inner->last_show_frame = TRUE;
- return TRUE;
+ return GST_FLOW_OK;
}
-static gboolean
+static GstFlowReturn
gst_d3d11_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture)
{
GstD3D11Vp9Dec *self = GST_D3D11_VP9_DEC (decoder);
if (inner->bitstream_buffer.empty ()) {
GST_ERROR_OBJECT (self, "No bitstream buffer to submit");
- return FALSE;
+ return GST_FLOW_ERROR;
}
view = gst_d3d11_vp9_dec_get_output_view_from_picture (self,
picture, &view_id);
if (!view) {
GST_ERROR_OBJECT (self, "current picture does not have output view handle");
- return FALSE;
+ return GST_FLOW_ERROR;
}
memset (&input_args, 0, sizeof (GstD3D11DecodeInputStreamArgs));
input_args.bitstream = &inner->bitstream_buffer[0];
input_args.bitstream_size = inner->bitstream_buffer.size ();
- return gst_d3d11_decoder_decode_frame (inner->d3d11_decoder,
- view, &input_args);
+ if (!gst_d3d11_decoder_decode_frame (inner->d3d11_decoder, view, &input_args))
+ return GST_FLOW_ERROR;
+
+ return GST_FLOW_OK;
}
static GstFlowReturn
GstQuery * query);
/* GstVp9Decoder */
-static gboolean gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
+static GstFlowReturn gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
const GstVp9FrameHeader * frame_hdr);
-static gboolean gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder,
+static GstFlowReturn gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder,
GstVideoCodecFrame * frame, GstVp9Picture * picture);
static GstVp9Picture *gst_nv_vp9_dec_duplicate_picture (GstVp9Decoder *
decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
-static gboolean gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
+static GstFlowReturn gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
GstVp9Picture * picture, GstVp9Dpb * dpb);
static GstFlowReturn gst_nv_vp9_dec_output_picture (GstVp9Decoder *
decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
return GST_VIDEO_DECODER_CLASS (parent_class)->src_query (decoder, query);
}
-static gboolean
+static GstFlowReturn
gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
const GstVp9FrameHeader * frame_hdr)
{
if (out_format == GST_VIDEO_FORMAT_UNKNOWN) {
GST_ERROR_OBJECT (self, "Could not support profile %d", self->profile);
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
gst_video_info_set_format (&info, out_format, self->width, self->height);
cudaVideoCodec_VP9, &info, self->width, self->height,
NUM_OUTPUT_VIEW)) {
GST_ERROR_OBJECT (self, "Failed to configure decoder");
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
memset (&self->params, 0, sizeof (CUVIDPICPARAMS));
self->params.CodecSpecific.vp9.colorSpace = frame_hdr->color_space;
- return TRUE;
+ return GST_FLOW_OK;
}
-static gboolean
+static GstFlowReturn
gst_nv_vp9_dec_new_picture (GstVp9Decoder * decoder,
GstVideoCodecFrame * frame, GstVp9Picture * picture)
{
nv_frame = gst_nv_decoder_new_frame (self->decoder);
if (!nv_frame) {
GST_ERROR_OBJECT (self, "No available decoder frame");
- return FALSE;
+ return GST_FLOW_ERROR;
}
GST_LOG_OBJECT (self,
gst_vp9_picture_set_user_data (picture,
nv_frame, (GDestroyNotify) gst_nv_decoder_frame_unref);
- return TRUE;
+ return GST_FLOW_OK;
}
static GstNvDecoderFrame *
return new_picture;
}
-static gboolean
+static GstFlowReturn
gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
GstVp9Picture * picture, GstVp9Dpb * dpb)
{
frame = gst_nv_vp9_dec_get_decoder_frame_from_picture (self, picture);
if (!frame) {
GST_ERROR_OBJECT (self, "Decoder frame is unavailable");
- return FALSE;
+ return GST_FLOW_ERROR;
}
params->nBitstreamDataLen = picture->size;
memcpy (vp9_params->segmentFeatureData, sp->feature_data,
sizeof (sp->feature_data));
- return gst_nv_decoder_decode_picture (self->decoder, &self->params);
+ if (!gst_nv_decoder_decode_picture (self->decoder, &self->params))
+ return GST_FLOW_ERROR;
+
+ return GST_FLOW_OK;
}
static GstFlowReturn
return VAProfileNone;
}
-static gboolean
+static GstFlowReturn
gst_va_vp9_new_sequence (GstVp9Decoder * decoder,
const GstVp9FrameHeader * frame_hdr)
{
profile = _get_profile (self, frame_hdr->profile);
if (profile == VAProfileNone)
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
if (!gst_va_decoder_has_profile (base->decoder, profile)) {
GST_ERROR_OBJECT (self, "Profile %s is not supported",
gst_va_profile_name (profile));
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
rt_format = _get_rtformat (self, frame_hdr->profile, frame_hdr->bit_depth,
frame_hdr->subsampling_x, frame_hdr->subsampling_y);
if (rt_format == 0)
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
if (!gst_va_decoder_config_is_equal (base->decoder, profile,
rt_format, frame_hdr->width, frame_hdr->height)) {
self->need_negotiation = TRUE;
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
}
}
- return TRUE;
+ return GST_FLOW_OK;
}
-static gboolean
+static GstFlowReturn
_check_resolution_change (GstVaVp9Dec * self, GstVp9Picture * picture)
{
GstVaBaseDec *base = GST_VA_BASE_DEC (self);
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Resolution changed, but failed to"
" negotiate with downstream");
- return FALSE;
+ return GST_FLOW_NOT_NEGOTIATED;
/* @TODO: if negotiation fails, decoder should resize output
* frame. For that we would need an auxiliar allocator, and
}
}
- return TRUE;
+ return GST_FLOW_OK;
}
-static gboolean
+static GstFlowReturn
gst_va_vp9_dec_new_picture (GstVp9Decoder * decoder,
GstVideoCodecFrame * frame, GstVp9Picture * picture)
{
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
- if (!_check_resolution_change (self, picture))
- return FALSE;
+ ret = _check_resolution_change (self, picture);
+ if (ret != GST_FLOW_OK)
+ return ret;
ret = gst_video_decoder_allocate_output_frame (vdec, frame);
if (ret != GST_FLOW_OK)
GST_LOG_OBJECT (self, "New va decode picture %p - %#x", pic,
gst_va_decode_picture_get_surface (pic));
- return TRUE;
+ return GST_FLOW_OK;
error:
{
GST_WARNING_OBJECT (self, "Failed to allocated output buffer, return %s",
gst_flow_get_name (ret));
- return FALSE;
+ return ret;
}
}
sizeof (slice_param), (gpointer) picture->data, picture->size);
}
-static gboolean
+static GstFlowReturn
gst_va_vp9_decode_picture (GstVp9Decoder * decoder, GstVp9Picture * picture,
GstVp9Dpb * dpb)
{
- return _fill_param (decoder, picture, dpb) && _fill_slice (decoder, picture);
+ if (_fill_param (decoder, picture, dpb) && _fill_slice (decoder, picture))
+ return GST_FLOW_OK;
+
+ return GST_FLOW_ERROR;
}
-static gboolean
+static GstFlowReturn
gst_va_vp9_dec_end_picture (GstVp9Decoder * decoder, GstVp9Picture * picture)
{
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
va_pic = gst_vp9_picture_get_user_data (picture);
- return gst_va_decoder_decode (base->decoder, va_pic);
+ if (!gst_va_decoder_decode (base->decoder, va_pic))
+ return GST_FLOW_ERROR;
+
+ return GST_FLOW_OK;
}
static GstFlowReturn
GstVaDecodePicture *va_pic, *va_dup;
GstVp9Picture *new_picture;
- if (!_check_resolution_change (GST_VA_VP9_DEC (decoder), picture))
+ if (_check_resolution_change (GST_VA_VP9_DEC (decoder), picture) !=
+ GST_FLOW_OK) {
return NULL;
+ }
va_pic = gst_vp9_picture_get_user_data (picture);
va_dup = gst_va_decode_picture_dup (va_pic);