diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-23 00:28:49 +0200 |
---|---|---|
committer | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-23 00:29:34 +0200 |
commit | 0b3c6e4b9ed84557659171481a05168a662289a3 (patch) | |
tree | 8a50b3c8b05f4ac822242657157663849e5862d5 /sys/vdpau/h264 | |
parent | 6089bfd36a798763960b284acfdda22ccd32dc50 (diff) |
vdpau: add gst_vdp_decoder_render and gst_vdp_decoder_init_decoder
Diffstat (limited to 'sys/vdpau/h264')
-rw-r--r-- | sys/vdpau/h264/gstvdph264dec.c | 124 |
1 files changed, 34 insertions, 90 deletions
diff --git a/sys/vdpau/h264/gstvdph264dec.c b/sys/vdpau/h264/gstvdph264dec.c index 8a7efd882b..d95a25bdd3 100644 --- a/sys/vdpau/h264/gstvdph264dec.c +++ b/sys/vdpau/h264/gstvdph264dec.c @@ -261,8 +261,9 @@ gst_vdp_h264_dec_idr (GstVdpH264Dec * h264_dec, GstH264Frame * h264_frame) seq = slice->picture->sequence; if (seq != h264_dec->sequence) { GstVideoState state; + + VdpDecoderProfile profile; GstFlowReturn ret; - GstVdpDevice *device; state = gst_base_video_decoder_get_state (GST_BASE_VIDEO_DECODER (h264_dec)); @@ -293,55 +294,37 @@ gst_vdp_h264_dec_idr (GstVdpH264Dec * h264_dec, GstH264Frame * h264_frame) gst_base_video_decoder_set_state (GST_BASE_VIDEO_DECODER (h264_dec), state); - ret = gst_vdp_decoder_get_device (GST_VDP_DECODER (h264_dec), &device, - NULL); - - if (ret == GST_FLOW_OK) { - VdpDecoderProfile profile; - VdpStatus status; - - if (h264_dec->decoder != VDP_INVALID_HANDLE) { - device->vdp_decoder_destroy (h264_dec->decoder); - h264_dec->decoder = VDP_INVALID_HANDLE; - } - + switch (seq->profile_idc) { + case 66: + profile = VDP_DECODER_PROFILE_H264_BASELINE; + break; - 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; + case 77: + profile = VDP_DECODER_PROFILE_H264_MAIN; + break; - default: - return FALSE; - } + case 100: + profile = VDP_DECODER_PROFILE_H264_HIGH; + break; - status = device->vdp_decoder_create (device->device, profile, - state.width, state.height, seq->num_ref_frames, &h264_dec->decoder); - if (status != VDP_STATUS_OK) { - GST_ELEMENT_ERROR (h264_dec, RESOURCE, READ, - ("Could not create vdpau decoder"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); + default: + 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; + } - return FALSE; - } - } else - return FALSE; + ret = gst_vdp_decoder_init_decoder (GST_VDP_DECODER (h264_dec), profile, + seq->num_ref_frames); + if (ret != GST_FLOW_OK) + return ret; g_object_set (h264_dec->dpb, "num-ref-frames", seq->num_ref_frames, NULL); h264_dec->sequence = seq; } - return TRUE; + return GST_FLOW_OK; } static VdpPictureInfoH264 @@ -464,14 +447,10 @@ gst_vdp_h264_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder, GstH264Sequence *seq; GstFlowReturn ret; - GError *err = NULL; GstVdpVideoBuffer *outbuf; VdpPictureInfoH264 info; - GstVdpDevice *device; - VdpVideoSurface surface; VdpBitstreamBuffer *bufs; guint n_bufs; - VdpStatus status; GST_DEBUG ("handle_frame"); @@ -483,11 +462,13 @@ gst_vdp_h264_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder, if (slice->nal_unit.IdrPicFlag) { - if (gst_vdp_h264_dec_idr (h264_dec, h264_frame)) + ret = gst_vdp_h264_dec_idr (h264_dec, h264_frame); + + if (ret == GST_FLOW_OK) h264_dec->got_idr = TRUE; else { gst_base_video_decoder_skip_frame (base_video_decoder, frame); - return GST_FLOW_OK; + return ret; } } @@ -498,29 +479,20 @@ gst_vdp_h264_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder, } - gst_vdp_h264_dec_init_frame_info (h264_dec, h264_frame); - - - /* decoding */ - if ((ret = gst_vdp_decoder_alloc_buffer (GST_VDP_DECODER (h264_dec), &outbuf, - &err) != GST_FLOW_OK)) - goto alloc_error; - - device = GST_VDP_VIDEO_BUFFER (outbuf)->device; - surface = GST_VDP_VIDEO_BUFFER (outbuf)->surface; - info = gst_vdp_h264_dec_fill_info (h264_dec, h264_frame); bufs = gst_vdp_h264_dec_create_bitstream_buffers (h264_dec, h264_frame, &n_bufs); - status = device->vdp_decoder_render (h264_dec->decoder, surface, - (VdpPictureInfo *) & info, n_bufs, bufs); - + ret = gst_vdp_decoder_render (GST_VDP_DECODER (h264_dec), + (VdpPictureInfo *) & info, n_bufs, bufs, &outbuf); g_free (bufs); - if (status != VDP_STATUS_OK) - goto decode_error; + + if (ret != GST_FLOW_OK) { + gst_base_video_decoder_skip_frame (base_video_decoder, frame); + return ret; + } frame->src_buffer = GST_BUFFER_CAST (outbuf); @@ -588,24 +560,6 @@ gst_vdp_h264_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder, gst_h264_dpb_add (h264_dec->dpb, h264_frame); return GST_FLOW_OK; - -alloc_error: - gst_base_video_decoder_skip_frame (base_video_decoder, frame); - - if (ret == GST_FLOW_ERROR) - gst_vdp_decoder_post_error (GST_VDP_DECODER (h264_dec), err); - return ret; - -decode_error: - GST_ELEMENT_ERROR (h264_dec, RESOURCE, READ, - ("Could not decode"), - ("Error returned from vdpau was: %s", - device->vdp_get_error_string (status))); - - gst_buffer_unref (GST_BUFFER_CAST (outbuf)); - gst_base_video_decoder_skip_frame (base_video_decoder, frame); - - return GST_FLOW_ERROR; } static gint @@ -875,19 +829,9 @@ gst_vdp_h264_dec_stop (GstBaseVideoDecoder * base_video_decoder) { GstVdpH264Dec *h264_dec = GST_VDP_H264_DEC (base_video_decoder); - GstFlowReturn ret; - GstVdpDevice *device; - g_object_unref (h264_dec->parser); g_object_unref (h264_dec->dpb); - ret = gst_vdp_decoder_get_device (GST_VDP_DECODER (h264_dec), &device, NULL); - if (ret == GST_FLOW_OK) { - - if (h264_dec->decoder != VDP_INVALID_HANDLE) - device->vdp_decoder_destroy (h264_dec->decoder); - } - return TRUE; } |