• Home
  • Raw
  • Download

Lines Matching refs:thiz

84 static gboolean gst_msdkdec_negotiate (GstMsdkDec * thiz, gboolean hard_reset);
87 gst_msdkdec_add_bs_extra_param (GstMsdkDec * thiz, mfxExtBuffer * param) in gst_msdkdec_add_bs_extra_param() argument
89 if (thiz->num_bs_extra_params < MAX_BS_EXTRA_PARAMS) { in gst_msdkdec_add_bs_extra_param()
90 thiz->bs_extra_params[thiz->num_bs_extra_params] = param; in gst_msdkdec_add_bs_extra_param()
91 thiz->num_bs_extra_params++; in gst_msdkdec_add_bs_extra_param()
147 unmap_frame (GstMsdkDec * thiz, MsdkSurface * s) in unmap_frame() argument
163 gst_msdkdec_free_unlocked_msdk_surfaces (GstMsdkDec * thiz) in gst_msdkdec_free_unlocked_msdk_surfaces() argument
168 for (l = thiz->locked_msdk_surfaces; l;) { in gst_msdkdec_free_unlocked_msdk_surfaces()
172 unmap_frame (thiz, surface); in gst_msdkdec_free_unlocked_msdk_surfaces()
174 thiz->locked_msdk_surfaces = in gst_msdkdec_free_unlocked_msdk_surfaces()
175 g_list_delete_link (thiz->locked_msdk_surfaces, l); in gst_msdkdec_free_unlocked_msdk_surfaces()
182 allocate_output_buffer (GstMsdkDec * thiz, GstBuffer ** buffer) in allocate_output_buffer() argument
186 GstVideoDecoder *decoder = GST_VIDEO_DECODER (thiz); in allocate_output_buffer()
199 gst_msdkdec_free_unlocked_msdk_surfaces (thiz); in allocate_output_buffer()
216 get_surface (GstMsdkDec * thiz, GstBuffer * buffer) in get_surface() argument
229 if (!gst_buffer_pool_is_active (thiz->pool) && in get_surface()
230 !gst_buffer_pool_set_active (thiz->pool, TRUE)) { in get_surface()
235 if (!gst_video_frame_map (&i->copy, &thiz->non_msdk_pool_info, buffer, in get_surface()
239 if (gst_buffer_pool_acquire_buffer (thiz->pool, &buffer, in get_surface()
247 gst_video_decoder_get_output_state (GST_VIDEO_DECODER (thiz)); in get_surface()
257 &thiz->param); in get_surface()
259 thiz->locked_msdk_surfaces = g_list_append (thiz->locked_msdk_surfaces, i); in get_surface()
271 GST_ERROR_OBJECT (thiz, "failed to handle buffer"); in get_surface()
276 gst_msdkdec_close_decoder (GstMsdkDec * thiz, gboolean reset_param) in gst_msdkdec_close_decoder() argument
280 if (!thiz->context || !thiz->initialized) in gst_msdkdec_close_decoder()
283 GST_DEBUG_OBJECT (thiz, "Closing decoder with context %" GST_PTR_FORMAT, in gst_msdkdec_close_decoder()
284 thiz->context); in gst_msdkdec_close_decoder()
286 if (thiz->use_video_memory) in gst_msdkdec_close_decoder()
287 gst_msdk_frame_free (thiz->context, &thiz->alloc_resp); in gst_msdkdec_close_decoder()
289 status = MFXVideoDECODE_Close (gst_msdk_context_get_session (thiz->context)); in gst_msdkdec_close_decoder()
291 GST_WARNING_OBJECT (thiz, "Decoder close failed (%s)", in gst_msdkdec_close_decoder()
295 g_array_set_size (thiz->tasks, 0); in gst_msdkdec_close_decoder()
298 memset (&thiz->param, 0, sizeof (thiz->param)); in gst_msdkdec_close_decoder()
300 thiz->num_bs_extra_params = 0; in gst_msdkdec_close_decoder()
301 thiz->initialized = FALSE; in gst_msdkdec_close_decoder()
302 gst_adapter_clear (thiz->adapter); in gst_msdkdec_close_decoder()
309 GstMsdkDec *thiz = GST_MSDKDEC (element); in gst_msdkdec_set_context() local
312 gst_object_replace ((GstObject **) & thiz->context, in gst_msdkdec_set_context()
321 gst_msdkdec_init_decoder (GstMsdkDec * thiz) in gst_msdkdec_init_decoder() argument
323 GstMsdkDecClass *klass = GST_MSDKDEC_GET_CLASS (thiz); in gst_msdkdec_init_decoder()
329 if (thiz->initialized) in gst_msdkdec_init_decoder()
332 if (!thiz->context) { in gst_msdkdec_init_decoder()
333 GST_WARNING_OBJECT (thiz, "No MSDK Context"); in gst_msdkdec_init_decoder()
337 if (!thiz->input_state) { in gst_msdkdec_init_decoder()
338 GST_DEBUG_OBJECT (thiz, "Have no input state yet"); in gst_msdkdec_init_decoder()
341 info = &thiz->input_state->info; in gst_msdkdec_init_decoder()
343 GST_OBJECT_LOCK (thiz); in gst_msdkdec_init_decoder()
345 if (thiz->use_video_memory) { in gst_msdkdec_init_decoder()
346 gst_msdk_set_frame_allocator (thiz->context); in gst_msdkdec_init_decoder()
347 thiz->param.IOPattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY; in gst_msdkdec_init_decoder()
349 thiz->param.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY; in gst_msdkdec_init_decoder()
352 GST_INFO_OBJECT (thiz, "This MSDK decoder uses %s memory", in gst_msdkdec_init_decoder()
353 thiz->use_video_memory ? "video" : "system"); in gst_msdkdec_init_decoder()
355 thiz->param.AsyncDepth = thiz->async_depth; in gst_msdkdec_init_decoder()
358 g_return_val_if_fail (thiz->param.mfx.FrameInfo.Width in gst_msdkdec_init_decoder()
359 && thiz->param.mfx.FrameInfo.Height, FALSE); in gst_msdkdec_init_decoder()
361 klass->preinit_decoder (thiz); in gst_msdkdec_init_decoder()
367 && info->fps_n != thiz->param.mfx.FrameInfo.FrameRateExtN in gst_msdkdec_init_decoder()
368 && info->fps_d != thiz->param.mfx.FrameInfo.FrameRateExtD) { in gst_msdkdec_init_decoder()
369 thiz->param.mfx.FrameInfo.FrameRateExtN = info->fps_n; in gst_msdkdec_init_decoder()
370 thiz->param.mfx.FrameInfo.FrameRateExtD = info->fps_d; in gst_msdkdec_init_decoder()
373 if (info->par_n && info->par_d && !thiz->param.mfx.FrameInfo.AspectRatioW in gst_msdkdec_init_decoder()
374 && !thiz->param.mfx.FrameInfo.AspectRatioH) { in gst_msdkdec_init_decoder()
375 thiz->param.mfx.FrameInfo.AspectRatioW = info->par_n; in gst_msdkdec_init_decoder()
376 thiz->param.mfx.FrameInfo.AspectRatioH = info->par_d; in gst_msdkdec_init_decoder()
379 thiz->param.mfx.FrameInfo.FourCC = in gst_msdkdec_init_decoder()
380 thiz->param.mfx.FrameInfo.FourCC ? thiz->param.mfx. in gst_msdkdec_init_decoder()
382 thiz->param.mfx.FrameInfo.ChromaFormat = in gst_msdkdec_init_decoder()
383 thiz->param.mfx.FrameInfo.ChromaFormat ? thiz->param.mfx. in gst_msdkdec_init_decoder()
386 session = gst_msdk_context_get_session (thiz->context); in gst_msdkdec_init_decoder()
388 status = MFXVideoDECODE_Query (session, &thiz->param, &thiz->param); in gst_msdkdec_init_decoder()
390 GST_ERROR_OBJECT (thiz, "Video Decode Query failed (%s)", in gst_msdkdec_init_decoder()
394 GST_WARNING_OBJECT (thiz, "Video Decode Query returned: %s", in gst_msdkdec_init_decoder()
398 klass->postinit_decoder (thiz); in gst_msdkdec_init_decoder()
400 status = MFXVideoDECODE_QueryIOSurf (session, &thiz->param, &request); in gst_msdkdec_init_decoder()
402 GST_ERROR_OBJECT (thiz, "Query IO surfaces failed (%s)", in gst_msdkdec_init_decoder()
406 GST_WARNING_OBJECT (thiz, "Query IO surfaces returned: %s", in gst_msdkdec_init_decoder()
410 if (request.NumFrameSuggested < thiz->param.AsyncDepth) { in gst_msdkdec_init_decoder()
411 GST_ERROR_OBJECT (thiz, "Required %d surfaces (%d suggested), async %d", in gst_msdkdec_init_decoder()
412 request.NumFrameMin, request.NumFrameSuggested, thiz->param.AsyncDepth); in gst_msdkdec_init_decoder()
417 if (G_LIKELY (thiz->min_prealloc_buffers)) in gst_msdkdec_init_decoder()
418 request.NumFrameSuggested += thiz->min_prealloc_buffers; in gst_msdkdec_init_decoder()
420 GST_WARNING_OBJECT (thiz, in gst_msdkdec_init_decoder()
424 if (thiz->use_video_memory) { in gst_msdkdec_init_decoder()
428 gst_msdk_context_get_shared_async_depth (thiz->context); in gst_msdkdec_init_decoder()
432 if (thiz->use_dmabuf) in gst_msdkdec_init_decoder()
434 gst_msdk_frame_alloc (thiz->context, &request, &thiz->alloc_resp); in gst_msdkdec_init_decoder()
439 thiz->min_prealloc_buffers = request.NumFrameSuggested; in gst_msdkdec_init_decoder()
441 GST_DEBUG_OBJECT (thiz, "Required %d surfaces (%d suggested)", in gst_msdkdec_init_decoder()
444 status = MFXVideoDECODE_Init (session, &thiz->param); in gst_msdkdec_init_decoder()
446 GST_ERROR_OBJECT (thiz, "Init failed (%s)", msdk_status_to_string (status)); in gst_msdkdec_init_decoder()
449 GST_WARNING_OBJECT (thiz, "Init returned: %s", in gst_msdkdec_init_decoder()
453 status = MFXVideoDECODE_GetVideoParam (session, &thiz->param); in gst_msdkdec_init_decoder()
455 GST_ERROR_OBJECT (thiz, "Get Video Parameters failed (%s)", in gst_msdkdec_init_decoder()
459 GST_WARNING_OBJECT (thiz, "Get Video Parameters returned: %s", in gst_msdkdec_init_decoder()
463 g_array_set_size (thiz->tasks, 0); /* resets array content */ in gst_msdkdec_init_decoder()
464 g_array_set_size (thiz->tasks, thiz->param.AsyncDepth); in gst_msdkdec_init_decoder()
465 thiz->next_task = 0; in gst_msdkdec_init_decoder()
467 GST_OBJECT_UNLOCK (thiz); in gst_msdkdec_init_decoder()
469 thiz->initialized = TRUE; in gst_msdkdec_init_decoder()
473 GST_OBJECT_UNLOCK (thiz); in gst_msdkdec_init_decoder()
496 srcpad_can_dmabuf (GstMsdkDec * thiz) in srcpad_can_dmabuf() argument
502 srcpad = GST_VIDEO_DECODER_SRC_PAD (thiz); in srcpad_can_dmabuf()
525 gst_msdkdec_set_src_caps (GstMsdkDec * thiz, gboolean need_allocation) in gst_msdkdec_set_src_caps() argument
539 thiz->param.mfx.FrameInfo.CropW ? thiz->param.mfx. in gst_msdkdec_set_src_caps()
540 FrameInfo.CropW : GST_VIDEO_INFO_WIDTH (&thiz->input_state->info); in gst_msdkdec_set_src_caps()
542 thiz->param.mfx.FrameInfo.CropH ? thiz->param.mfx. in gst_msdkdec_set_src_caps()
543 FrameInfo.CropH : GST_VIDEO_INFO_HEIGHT (&thiz->input_state->info); in gst_msdkdec_set_src_caps()
546 gst_msdk_get_video_format_from_mfx_fourcc (thiz->param.mfx. in gst_msdkdec_set_src_caps()
550 GST_WARNING_OBJECT (thiz, "Failed to find a valid video format"); in gst_msdkdec_set_src_caps()
555 gst_video_decoder_set_output_state (GST_VIDEO_DECODER (thiz), in gst_msdkdec_set_src_caps()
556 format, width, height, thiz->input_state); in gst_msdkdec_set_src_caps()
562 GST_ROUND_UP_16 (thiz->param.mfx.FrameInfo.Width ? thiz->param.mfx. in gst_msdkdec_set_src_caps()
565 GST_ROUND_UP_32 (thiz->param.mfx.FrameInfo.Height ? thiz->param.mfx. in gst_msdkdec_set_src_caps()
574 if (srcpad_can_dmabuf (thiz)) in gst_msdkdec_set_src_caps()
581 GST_ROUND_UP_16 (thiz->param.mfx.FrameInfo.Width ? thiz->param.mfx. in gst_msdkdec_set_src_caps()
584 GST_ROUND_UP_32 (thiz->param.mfx.FrameInfo.Height ? thiz->param.mfx. in gst_msdkdec_set_src_caps()
595 GST_INFO_OBJECT (thiz, "new alloc caps = %" GST_PTR_FORMAT, in gst_msdkdec_set_src_caps()
611 gst_msdkdec_set_latency (GstMsdkDec * thiz) in gst_msdkdec_set_latency() argument
613 GstVideoInfo *info = &thiz->input_state->info; in gst_msdkdec_set_latency()
617 min_delayed_frames = thiz->async_depth; in gst_msdkdec_set_latency()
630 GST_INFO_OBJECT (thiz, in gst_msdkdec_set_latency()
634 gst_video_decoder_set_latency (GST_VIDEO_DECODER (thiz), latency, latency); in gst_msdkdec_set_latency()
647 finish_task (GstMsdkDec * thiz, MsdkDecTask * task) in finish_task() argument
652 unmap_frame (thiz, surface); in finish_task()
654 thiz->locked_msdk_surfaces = in finish_task()
655 g_list_append (thiz->locked_msdk_surfaces, surface); in finish_task()
663 gst_msdkdec_frame_corruption_report (GstMsdkDec * thiz, mfxU16 corruption) in gst_msdkdec_frame_corruption_report() argument
665 if (!thiz->report_error || !corruption) in gst_msdkdec_frame_corruption_report()
669 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_frame_corruption_report()
673 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_frame_corruption_report()
677 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_frame_corruption_report()
681 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_frame_corruption_report()
685 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_frame_corruption_report()
689 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_frame_corruption_report()
694 gst_msdkdec_finish_task (GstMsdkDec * thiz, MsdkDecTask * task) in gst_msdkdec_finish_task() argument
696 GstVideoDecoder *decoder = GST_VIDEO_DECODER (thiz); in gst_msdkdec_finish_task()
706 (thiz->context), task->sync_point, 300000); in gst_msdkdec_finish_task()
708 GST_ERROR_OBJECT (thiz, "failed to do sync operation"); in gst_msdkdec_finish_task()
715 gst_msdkdec_frame_corruption_report (thiz, in gst_msdkdec_finish_task()
717 GST_DEBUG_OBJECT (thiz, "Decoded MFX TimeStamp: %" G_GUINT64_FORMAT, in gst_msdkdec_finish_task()
730 GST_INFO_OBJECT (thiz, "Discarding frame: %p PTS: %" GST_TIME_FORMAT in gst_msdkdec_finish_task()
746 unmap_frame (thiz, surface); in gst_msdkdec_finish_task()
748 GST_DEBUG_OBJECT (thiz, "surface %p TimeStamp: %" G_GUINT64_FORMAT in gst_msdkdec_finish_task()
754 finish_task (thiz, task); in gst_msdkdec_finish_task()
763 GST_ERROR_OBJECT (thiz, "Failed to finish frame"); in gst_msdkdec_finish_task()
766 finish_task (thiz, task); in gst_msdkdec_finish_task()
771 gst_msdkdec_context_prepare (GstMsdkDec * thiz) in gst_msdkdec_context_prepare() argument
775 if (!gst_msdk_context_find (GST_ELEMENT_CAST (thiz), &thiz->context)) in gst_msdkdec_context_prepare()
778 if (thiz->context == thiz->old_context) { in gst_msdkdec_context_prepare()
779 GST_INFO_OBJECT (thiz, "Found old context %" GST_PTR_FORMAT in gst_msdkdec_context_prepare()
780 ", reusing as-is", thiz->context); in gst_msdkdec_context_prepare()
788 thiz->use_video_memory = TRUE; in gst_msdkdec_context_prepare()
790 thiz->use_video_memory = FALSE; in gst_msdkdec_context_prepare()
793 GST_INFO_OBJECT (thiz, "Found context %" GST_PTR_FORMAT " from neighbour", in gst_msdkdec_context_prepare()
794 thiz->context); in gst_msdkdec_context_prepare()
796 if (!(gst_msdk_context_get_job_type (thiz->context) & GST_MSDK_JOB_DECODER)) { in gst_msdkdec_context_prepare()
797 gst_msdk_context_add_job_type (thiz->context, GST_MSDK_JOB_DECODER); in gst_msdkdec_context_prepare()
806 GST_INFO_OBJECT (thiz, "Creating new context %" GST_PTR_FORMAT " with " in gst_msdkdec_context_prepare()
807 "joined session", thiz->context); in gst_msdkdec_context_prepare()
808 parent_context = thiz->context; in gst_msdkdec_context_prepare()
812 GST_ERROR_OBJECT (thiz, "Failed to create a context with parent context " in gst_msdkdec_context_prepare()
817 thiz->context = msdk_context; in gst_msdkdec_context_prepare()
818 gst_msdk_context_add_shared_async_depth (thiz->context, in gst_msdkdec_context_prepare()
829 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_start() local
831 if (!gst_msdkdec_context_prepare (thiz)) { in gst_msdkdec_start()
832 if (!gst_msdk_context_ensure_context (GST_ELEMENT_CAST (thiz), in gst_msdkdec_start()
833 thiz->hardware, GST_MSDK_JOB_DECODER)) in gst_msdkdec_start()
835 GST_INFO_OBJECT (thiz, "Creating new context %" GST_PTR_FORMAT, in gst_msdkdec_start()
836 thiz->context); in gst_msdkdec_start()
841 gst_object_replace ((GstObject **) & thiz->old_context, in gst_msdkdec_start()
842 (GstObject *) thiz->context); in gst_msdkdec_start()
844 gst_msdk_context_add_shared_async_depth (thiz->context, thiz->async_depth); in gst_msdkdec_start()
852 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_close() local
854 gst_clear_object (&thiz->context); in gst_msdkdec_close()
862 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_stop() local
866 if (thiz->input_state) { in gst_msdkdec_stop()
867 gst_video_codec_state_unref (thiz->input_state); in gst_msdkdec_stop()
868 thiz->input_state = NULL; in gst_msdkdec_stop()
870 if (thiz->pool) { in gst_msdkdec_stop()
871 gst_object_unref (thiz->pool); in gst_msdkdec_stop()
872 thiz->pool = NULL; in gst_msdkdec_stop()
874 gst_video_info_init (&thiz->non_msdk_pool_info); in gst_msdkdec_stop()
876 gst_msdkdec_close_decoder (thiz, TRUE); in gst_msdkdec_stop()
883 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_set_format() local
885 if (thiz->input_state) { in gst_msdkdec_set_format()
888 if (!gst_video_info_is_equal (&thiz->input_state->info, &state->info)) { in gst_msdkdec_set_format()
889 GST_INFO_OBJECT (thiz, "Schedule renegotiation as video info changed"); in gst_msdkdec_set_format()
890 thiz->do_renego = TRUE; in gst_msdkdec_set_format()
892 gst_video_codec_state_unref (thiz->input_state); in gst_msdkdec_set_format()
894 thiz->input_state = gst_video_codec_state_ref (state); in gst_msdkdec_set_format()
901 gst_msdkdec_set_latency (thiz); in gst_msdkdec_set_format()
906 release_msdk_surfaces (GstMsdkDec * thiz) in release_msdk_surfaces() argument
911 gst_msdkdec_free_unlocked_msdk_surfaces (thiz); in release_msdk_surfaces()
913 for (l = thiz->locked_msdk_surfaces; l; l = l->next) { in release_msdk_surfaces()
915 unmap_frame (thiz, surface); in release_msdk_surfaces()
920 GST_ERROR_OBJECT (thiz, "msdk still locked %d surfaces", locked); in release_msdk_surfaces()
921 g_list_free (thiz->locked_msdk_surfaces); in release_msdk_surfaces()
922 thiz->locked_msdk_surfaces = NULL; in release_msdk_surfaces()
938 gst_msdkdec_negotiate (GstMsdkDec * thiz, gboolean hard_reset) in gst_msdkdec_negotiate() argument
940 GstVideoDecoder *decoder = GST_VIDEO_DECODER (thiz); in gst_msdkdec_negotiate()
941 GST_DEBUG_OBJECT (thiz, in gst_msdkdec_negotiate()
946 if (gst_msdkdec_drain (GST_VIDEO_DECODER (thiz)) != GST_FLOW_OK) in gst_msdkdec_negotiate()
952 if (thiz->initialized) { in gst_msdkdec_negotiate()
966 gst_msdkdec_close_decoder (thiz, FALSE); in gst_msdkdec_negotiate()
969 thiz->do_realloc = TRUE; in gst_msdkdec_negotiate()
974 if (!gst_msdkdec_set_src_caps (thiz, hard_reset)) in gst_msdkdec_negotiate()
983 if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (thiz))) in gst_msdkdec_negotiate()
986 thiz->do_renego = FALSE; in gst_msdkdec_negotiate()
987 thiz->do_realloc = FALSE; in gst_msdkdec_negotiate()
992 GST_ERROR_OBJECT (thiz, "Failed to Drain the queued decoded frames"); in gst_msdkdec_negotiate()
996 GST_ERROR_OBJECT (thiz, "Failed to re-negotiate"); in gst_msdkdec_negotiate()
1001 find_msdk_surface (GstMsdkDec * thiz, MsdkDecTask * task, in find_msdk_surface() argument
1008 l = g_list_find_custom (thiz->locked_msdk_surfaces, out_surface, in find_msdk_surface()
1011 GST_ERROR_OBJECT (thiz, "msdk return an invalid surface %p", out_surface); in find_msdk_surface()
1015 thiz->locked_msdk_surfaces = in find_msdk_surface()
1016 g_list_delete_link (thiz->locked_msdk_surfaces, l); in find_msdk_surface()
1021 gst_msdkdec_error_report (GstMsdkDec * thiz) in gst_msdkdec_error_report() argument
1023 if (!thiz->report_error) in gst_msdkdec_error_report()
1028 if (thiz->error_report.ErrorTypes & MFX_ERROR_SPS) in gst_msdkdec_error_report()
1029 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_error_report()
1032 if (thiz->error_report.ErrorTypes & MFX_ERROR_PPS) in gst_msdkdec_error_report()
1033 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_error_report()
1036 if (thiz->error_report.ErrorTypes & MFX_ERROR_SLICEHEADER) in gst_msdkdec_error_report()
1037 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_error_report()
1040 if (thiz->error_report.ErrorTypes & MFX_ERROR_FRAME_GAP) in gst_msdkdec_error_report()
1041 GST_ELEMENT_WARNING (thiz, STREAM, DECODE, in gst_msdkdec_error_report()
1050 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_handle_frame() local
1051 GstMsdkDecClass *klass = GST_MSDKDEC_GET_CLASS (thiz); in gst_msdkdec_handle_frame()
1080 if (!thiz->initialized || thiz->do_renego) { in gst_msdkdec_handle_frame()
1084 gst_adapter_clear (thiz->adapter); in gst_msdkdec_handle_frame()
1086 if (!klass->configure || !klass->configure (thiz)) { in gst_msdkdec_handle_frame()
1108 if (thiz->num_bs_extra_params) { in gst_msdkdec_handle_frame()
1109 bitstream.NumExtParam = thiz->num_bs_extra_params; in gst_msdkdec_handle_frame()
1110 bitstream.ExtParam = thiz->bs_extra_params; in gst_msdkdec_handle_frame()
1128 if (thiz->param.mfx.DecodedOrder == GST_MSDKDEC_OUTPUT_ORDER_DECODE) in gst_msdkdec_handle_frame()
1132 gst_adapter_push (thiz->adapter, gst_buffer_ref (input_buffer)); in gst_msdkdec_handle_frame()
1133 data_size = gst_adapter_available (thiz->adapter); in gst_msdkdec_handle_frame()
1135 bitstream.Data = (mfxU8 *) gst_adapter_map (thiz->adapter, data_size); in gst_msdkdec_handle_frame()
1140 GST_DEBUG_OBJECT (thiz, in gst_msdkdec_handle_frame()
1146 session = gst_msdk_context_get_session (thiz->context); in gst_msdkdec_handle_frame()
1148 if (!thiz->initialized || thiz->do_renego) { in gst_msdkdec_handle_frame()
1157 if (thiz->report_error) in gst_msdkdec_handle_frame()
1158 thiz->error_report.ErrorTypes = 0; in gst_msdkdec_handle_frame()
1161 status = MFXVideoDECODE_DecodeHeader (session, &bitstream, &thiz->param); in gst_msdkdec_handle_frame()
1163 gst_msdkdec_error_report (thiz); in gst_msdkdec_handle_frame()
1170 if (!klass->post_configure (thiz)) { in gst_msdkdec_handle_frame()
1175 if (!thiz->initialized) in gst_msdkdec_handle_frame()
1179 gst_video_decoder_get_output_state (GST_VIDEO_DECODER (thiz)); in gst_msdkdec_handle_frame()
1185 if (thiz->param.mfx.FrameInfo.Width > in gst_msdkdec_handle_frame()
1187 || thiz->param.mfx.FrameInfo.Height > in gst_msdkdec_handle_frame()
1197 if (thiz->force_reset_on_res_change) in gst_msdkdec_handle_frame()
1200 if (!gst_msdkdec_negotiate (thiz, hard_reset)) { in gst_msdkdec_handle_frame()
1201 GST_ELEMENT_ERROR (thiz, CORE, NEGOTIATION, in gst_msdkdec_handle_frame()
1214 task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task); in gst_msdkdec_handle_frame()
1215 flow = gst_msdkdec_finish_task (thiz, task); in gst_msdkdec_handle_frame()
1218 GST_ERROR_OBJECT (thiz, "Failed to finish a task"); in gst_msdkdec_handle_frame()
1222 flow = allocate_output_buffer (thiz, &buffer); in gst_msdkdec_handle_frame()
1228 surface = get_surface (thiz, buffer); in gst_msdkdec_handle_frame()
1232 for (i = 0; i < thiz->tasks->len - 1; i++) { in gst_msdkdec_handle_frame()
1233 thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len; in gst_msdkdec_handle_frame()
1234 task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task); in gst_msdkdec_handle_frame()
1235 flow = gst_msdkdec_finish_task (thiz, task); in gst_msdkdec_handle_frame()
1238 surface = get_surface (thiz, buffer); in gst_msdkdec_handle_frame()
1243 GST_ERROR_OBJECT (thiz, "Couldn't get a surface"); in gst_msdkdec_handle_frame()
1250 if (thiz->report_error) in gst_msdkdec_handle_frame()
1251 thiz->error_report.ErrorTypes = 0; in gst_msdkdec_handle_frame()
1258 if (!find_msdk_surface (thiz, task, out_surface)) { in gst_msdkdec_handle_frame()
1264 gst_msdkdec_error_report (thiz); in gst_msdkdec_handle_frame()
1275 if (thiz->report_error) in gst_msdkdec_handle_frame()
1276 thiz->error_report.ErrorTypes = 0; in gst_msdkdec_handle_frame()
1278 status = MFXVideoDECODE_DecodeHeader (session, &bitstream, &thiz->param); in gst_msdkdec_handle_frame()
1280 gst_msdkdec_error_report (thiz); in gst_msdkdec_handle_frame()
1288 if (!gst_msdkdec_negotiate (thiz, TRUE)) in gst_msdkdec_handle_frame()
1301 thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len; in gst_msdkdec_handle_frame()
1318 thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len; in gst_msdkdec_handle_frame()
1338 thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len; in gst_msdkdec_handle_frame()
1340 GST_ERROR_OBJECT (thiz, "DecodeFrameAsync failed (%s)", in gst_msdkdec_handle_frame()
1349 gst_adapter_flush (thiz->adapter, bitstream.DataOffset); in gst_msdkdec_handle_frame()
1357 if (thiz->param.mfx.DecodedOrder == GST_MSDKDEC_OUTPUT_ORDER_DECODE) in gst_msdkdec_handle_frame()
1358 gst_msdkdec_finish_task (thiz, task); in gst_msdkdec_handle_frame()
1383 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_parse() local
1390 size = gst_adapter_available (thiz->adapter); in gst_msdkdec_parse()
1395 buffer = gst_adapter_get_buffer (thiz->adapter, size); in gst_msdkdec_parse()
1396 gst_adapter_flush (thiz->adapter, size); in gst_msdkdec_parse()
1404 gst_msdkdec_create_buffer_pool (GstMsdkDec * thiz, GstVideoInfo * info, in gst_msdkdec_create_buffer_pool() argument
1419 alloc_resp = &thiz->alloc_resp; in gst_msdkdec_create_buffer_pool()
1421 pool = gst_msdk_buffer_pool_new (thiz->context, alloc_resp); in gst_msdkdec_create_buffer_pool()
1429 if (thiz->use_dmabuf) in gst_msdkdec_create_buffer_pool()
1430 allocator = gst_msdk_dmabuf_allocator_new (thiz->context, info, alloc_resp); in gst_msdkdec_create_buffer_pool()
1431 else if (thiz->use_video_memory) in gst_msdkdec_create_buffer_pool()
1432 allocator = gst_msdk_video_allocator_new (thiz->context, info, alloc_resp); in gst_msdkdec_create_buffer_pool()
1450 if (thiz->use_video_memory) { in gst_msdkdec_create_buffer_pool()
1453 if (thiz->use_dmabuf) in gst_msdkdec_create_buffer_pool()
1470 GST_INFO_OBJECT (thiz, "failed to create bufferpool"); in gst_msdkdec_create_buffer_pool()
1475 GST_INFO_OBJECT (thiz, "failed to create allocator"); in gst_msdkdec_create_buffer_pool()
1481 GST_INFO_OBJECT (thiz, "failed to set config"); in gst_msdkdec_create_buffer_pool()
1491 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_decide_allocation() local
1511 min_buffers += thiz->async_depth; in gst_msdkdec_decide_allocation()
1513 max_buffers += thiz->async_depth; in gst_msdkdec_decide_allocation()
1519 thiz->min_prealloc_buffers = min_buffers; in gst_msdkdec_decide_allocation()
1523 thiz->use_video_memory = thiz->use_dmabuf = TRUE; in gst_msdkdec_decide_allocation()
1530 if (!gst_msdkdec_init_decoder (thiz)) in gst_msdkdec_decide_allocation()
1534 min_buffers = thiz->min_prealloc_buffers; in gst_msdkdec_decide_allocation()
1538 if (thiz->do_realloc || !thiz->pool) { in gst_msdkdec_decide_allocation()
1540 gst_video_decoder_get_output_state (GST_VIDEO_DECODER (thiz)); in gst_msdkdec_decide_allocation()
1541 gst_clear_object (&thiz->pool); in gst_msdkdec_decide_allocation()
1543 thiz->pool = in gst_msdkdec_decide_allocation()
1544 gst_msdkdec_create_buffer_pool (thiz, &output_state->info, min_buffers); in gst_msdkdec_decide_allocation()
1546 if (!thiz->pool) { in gst_msdkdec_decide_allocation()
1565 pool = gst_object_ref (thiz->pool); in gst_msdkdec_decide_allocation()
1587 gst_video_info_from_caps (&thiz->non_msdk_pool_info, pool_caps); in gst_msdkdec_decide_allocation()
1591 gst_video_decoder_get_output_state (GST_VIDEO_DECODER (thiz)); in gst_msdkdec_decide_allocation()
1592 GST_VIDEO_INFO_WIDTH (&thiz->non_msdk_pool_info) = in gst_msdkdec_decide_allocation()
1594 GST_VIDEO_INFO_HEIGHT (&thiz->non_msdk_pool_info) = in gst_msdkdec_decide_allocation()
1624 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_drain() local
1634 if (!thiz->initialized) in gst_msdkdec_drain()
1636 session = gst_msdk_context_get_session (thiz->context); in gst_msdkdec_drain()
1639 task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task); in gst_msdkdec_drain()
1640 if ((flow = gst_msdkdec_finish_task (thiz, task)) != GST_FLOW_OK) { in gst_msdkdec_drain()
1648 flow = allocate_output_buffer (thiz, &buffer); in gst_msdkdec_drain()
1651 surface = get_surface (thiz, buffer); in gst_msdkdec_drain()
1656 if (thiz->report_error) in gst_msdkdec_drain()
1657 thiz->error_report.ErrorTypes = 0; in gst_msdkdec_drain()
1664 if (!find_msdk_surface (thiz, task, out_surface)) { in gst_msdkdec_drain()
1669 gst_msdkdec_error_report (thiz); in gst_msdkdec_drain()
1672 thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len; in gst_msdkdec_drain()
1683 thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len; in gst_msdkdec_drain()
1693 for (i = 0; i < thiz->tasks->len; i++) { in gst_msdkdec_drain()
1694 task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task); in gst_msdkdec_drain()
1695 gst_msdkdec_finish_task (thiz, task); in gst_msdkdec_drain()
1696 thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len; in gst_msdkdec_drain()
1705 GstMsdkDec *thiz = GST_MSDKDEC (decoder); in gst_msdkdec_flush() local
1708 ret = gst_msdkdec_drain (GST_VIDEO_DECODER_CAST (thiz)); in gst_msdkdec_flush()
1723 GstMsdkDec *thiz = GST_MSDKDEC (object); in gst_msdkdec_set_property() local
1726 GST_OBJECT_LOCK (thiz); in gst_msdkdec_set_property()
1728 state = GST_STATE (thiz); in gst_msdkdec_set_property()
1735 thiz->hardware = g_value_get_boolean (value); in gst_msdkdec_set_property()
1738 thiz->async_depth = g_value_get_uint (value); in gst_msdkdec_set_property()
1744 GST_OBJECT_UNLOCK (thiz); in gst_msdkdec_set_property()
1750 GST_WARNING_OBJECT (thiz, "setting property in wrong state"); in gst_msdkdec_set_property()
1751 GST_OBJECT_UNLOCK (thiz); in gst_msdkdec_set_property()
1759 GstMsdkDec *thiz = GST_MSDKDEC (object); in gst_msdkdec_get_property() local
1761 GST_OBJECT_LOCK (thiz); in gst_msdkdec_get_property()
1764 g_value_set_boolean (value, thiz->hardware); in gst_msdkdec_get_property()
1767 g_value_set_uint (value, thiz->async_depth); in gst_msdkdec_get_property()
1773 GST_OBJECT_UNLOCK (thiz); in gst_msdkdec_get_property()
1779 GstMsdkDec *thiz = GST_MSDKDEC (object); in gst_msdkdec_dispose() local
1781 g_clear_object (&thiz->adapter); in gst_msdkdec_dispose()
1782 gst_clear_object (&thiz->context); in gst_msdkdec_dispose()
1783 gst_clear_object (&thiz->old_context); in gst_msdkdec_dispose()
1791 GstMsdkDec *thiz = GST_MSDKDEC (object); in gst_msdkdec_finalize() local
1793 g_array_unref (thiz->tasks); in gst_msdkdec_finalize()
1794 thiz->tasks = NULL; in gst_msdkdec_finalize()
1796 release_msdk_surfaces (thiz); in gst_msdkdec_finalize()
1896 gst_msdkdec_init (GstMsdkDec * thiz) in gst_msdkdec_init() argument
1898 gst_video_info_init (&thiz->non_msdk_pool_info); in gst_msdkdec_init()
1899 thiz->tasks = g_array_new (FALSE, TRUE, sizeof (MsdkDecTask)); in gst_msdkdec_init()
1900 thiz->hardware = PROP_HARDWARE_DEFAULT; in gst_msdkdec_init()
1901 thiz->async_depth = PROP_ASYNC_DEPTH_DEFAULT; in gst_msdkdec_init()
1902 thiz->do_renego = TRUE; in gst_msdkdec_init()
1903 thiz->do_realloc = TRUE; in gst_msdkdec_init()
1904 thiz->force_reset_on_res_change = TRUE; in gst_msdkdec_init()
1905 thiz->report_error = FALSE; in gst_msdkdec_init()
1906 thiz->adapter = gst_adapter_new (); in gst_msdkdec_init()
1907 thiz->input_state = NULL; in gst_msdkdec_init()
1908 thiz->pool = NULL; in gst_msdkdec_init()
1909 thiz->context = NULL; in gst_msdkdec_init()