0023-Set-a-env-SF_OMX_SLICE-when-nSliceHeight-nFrameHeigh.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 6b7d167c0ef5d376064a18c76e1a408158c85971 Mon Sep 17 00:00:00 2001
  2. From: Som Qin <som.qin@starfivetech.com>
  3. Date: Wed, 18 Oct 2023 09:25:41 +0800
  4. Subject: [PATCH] Set a env "SF_OMX_SLICE" when nSliceHeight > nFrameHeight in
  5. dec output port.
  6. Env variables are set to bypass the negotiation mechanism to direct display
  7. with drm(kmssink).
  8. Signed-off-by: Som Qin <som.qin@starfivetech.com>
  9. ---
  10. omx/gstomxvideodec.c | 22 +++++++++++++++++++++-
  11. 1 file changed, 21 insertions(+), 1 deletion(-)
  12. diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c
  13. index 6224e09..57e5b5c 100644
  14. --- a/omx/gstomxvideodec.c
  15. +++ b/omx/gstomxvideodec.c
  16. @@ -1054,6 +1054,8 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
  17. GList *images = NULL;
  18. GList *frames = NULL;
  19. GstVideoInfo v_info;
  20. + OMX_PARAM_PORTDEFINITIONTYPE port_def;
  21. + guint frame_height, frame_slice;
  22. gint i;
  23. if (!gst_video_info_from_caps (&v_info, caps)) {
  24. @@ -1063,6 +1065,15 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
  25. self->use_buffers = FALSE;
  26. }
  27. + gst_omx_port_get_port_definition (self->dec_out_port, &port_def);
  28. + frame_slice = port_def.format.video.nSliceHeight;
  29. + frame_height = port_def.format.video.nFrameHeight;
  30. + if (frame_slice && (frame_slice > frame_height)) {
  31. + v_info.size = v_info.size / frame_height * frame_slice;
  32. + for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
  33. + v_info.offset[i] = v_info.offset[i] / frame_height * frame_slice;
  34. + }
  35. +
  36. GST_DEBUG_OBJECT (self, "Trying to use %d buffers", min);
  37. for (i = 0; i < min && self->use_buffers; i++) {
  38. @@ -1345,7 +1356,7 @@ gst_omx_video_dec_reconfigure_output_port (GstOMXVideoDec * self)
  39. OMX_PARAM_PORTDEFINITIONTYPE port_def;
  40. GstVideoFormat format;
  41. GstVideoInterlaceMode interlace_mode;
  42. - guint frame_height;
  43. + guint frame_height, frame_slice;
  44. /* At this point the decoder output port is disabled */
  45. interlace_mode = gst_omx_video_dec_get_output_interlace_info (self);
  46. @@ -1589,6 +1600,15 @@ gst_omx_video_dec_reconfigure_output_port (GstOMXVideoDec * self)
  47. interlace_mode = GST_VIDEO_INTERLACE_MODE_ALTERNATE;
  48. }
  49. + frame_slice = port_def.format.video.nSliceHeight;
  50. + if (frame_slice && (frame_slice > frame_height)) {
  51. + char string[32];
  52. + sprintf(string, "%d", frame_slice);
  53. + setenv ("SF_OMX_SLICE", string, 1);
  54. + } else {
  55. + unsetenv ("SF_OMX_SLICE");
  56. + }
  57. +
  58. GST_DEBUG_OBJECT (self,
  59. "Setting output state: format %s (%d), width %u, height %u",
  60. gst_video_format_to_string (format),
  61. --
  62. 2.25.1