diff --git a/package/ffmpeg/0032-Omxdec-Use-strde-and-slice-form-decoder-to-calculate.patch b/package/ffmpeg/0032-Omxdec-Use-strde-and-slice-form-decoder-to-calculate.patch new file mode 100644 index 00000000..d62cbcee --- /dev/null +++ b/package/ffmpeg/0032-Omxdec-Use-strde-and-slice-form-decoder-to-calculate.patch @@ -0,0 +1,36 @@ +From d077e89380593feafd82e96a293b26fb2d02aba2 Mon Sep 17 00:00:00 2001 +From: Som Qin +Date: Thu, 21 Sep 2023 16:06:09 +0800 +Subject: [PATCH] Omxdec: Use strde and slice form decoder to calculate avframe + buffer linesize + +Signed-off-by: Som Qin +--- + libavcodec/omxdec.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libavcodec/omxdec.c b/libavcodec/omxdec.c +index 6cb0d98..0edca36 100755 +--- a/libavcodec/omxdec.c ++++ b/libavcodec/omxdec.c +@@ -509,6 +509,8 @@ static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, O + s->dec_out_width = out_port_params.format.video.nFrameWidth; + s->dec_out_height = out_port_params.format.video.nFrameHeight; + s->dec_pix_fmt = out_port_params.format.video.eColorFormat; ++ s->stride = out_port_params.format.video.nStride; ++ s->plane_size = out_port_params.format.video.nSliceHeight; + + av_log(s->avctx, AV_LOG_VERBOSE, "w:%d, h:%d, fmt:%d\n", s->dec_out_width, s->dec_out_height, s->dec_pix_fmt); + if (!s->num_out_buffers) { +@@ -1339,8 +1341,6 @@ static int omx_decode_frame(AVCodecContext *avctx, void *data, + avctx->width = s->dec_out_width; + avctx->height = s->dec_out_height; + avctx->pix_fmt = omx_map_color_format(avctx, s->dec_pix_fmt); +- s->stride = avctx->width; +- s->plane_size = avctx->height; + + if (buffer->nFlags & OMX_BUFFERFLAG_EOS) + s->got_eos = 1; +-- +2.25.1 + diff --git a/package/gstreamer1/gst1-plugins-bad/0006-Support-direct-display-using-of-wave511-omx-decoder.patch b/package/gstreamer1/gst1-plugins-bad/0006-Support-direct-display-using-of-wave511-omx-decoder.patch new file mode 100644 index 00000000..5f2ede74 --- /dev/null +++ b/package/gstreamer1/gst1-plugins-bad/0006-Support-direct-display-using-of-wave511-omx-decoder.patch @@ -0,0 +1,60 @@ +From 23c80a346def541e7a750efa22be1da64777067e Mon Sep 17 00:00:00 2001 +From: Som Qin +Date: Wed, 18 Oct 2023 09:55:16 +0800 +Subject: [PATCH] Support direct display using of wave511 omx decoder + +Gets environment variables "SF_OMX_SLICE" to support special cases + +Signed-off-by: Som Qin +--- + sys/kms/gstkmsallocator.c | 27 ++++++++++++++++++++++++++- + 1 file changed, 26 insertions(+), 1 deletion(-) + +diff --git a/sys/kms/gstkmsallocator.c b/sys/kms/gstkmsallocator.c +index cb2f6bd..493cd92 100644 +--- a/sys/kms/gstkmsallocator.c ++++ b/sys/kms/gstkmsallocator.c +@@ -189,7 +189,18 @@ gst_kms_allocator_memory_create (GstKMSAllocator * allocator, + fmt = gst_drm_format_from_video (GST_VIDEO_INFO_FORMAT (vinfo)); + arg.bpp = gst_drm_bpp_from_drm (fmt); + arg.width = GST_VIDEO_INFO_WIDTH (vinfo); +- h = GST_VIDEO_INFO_HEIGHT (vinfo); ++ char* env = NULL; ++ env = getenv("SF_OMX_SLICE"); ++ if (env) { ++ gint slice, i; ++ slice = atoi(env); ++ if (slice > 0 && slice > vinfo->height) { ++ h = slice; ++ } else { ++ h = GST_VIDEO_INFO_HEIGHT (vinfo); ++ } ++ } else ++ h = GST_VIDEO_INFO_HEIGHT (vinfo); + arg.height = gst_drm_height_from_drm (fmt, h); + + ret = drmIoctl (allocator->priv->fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); +@@ -498,6 +509,20 @@ gst_kms_allocator_bo_alloc (GstAllocator * allocator, GstVideoInfo * vinfo) + + mem = GST_MEMORY_CAST (kmsmem); + ++ char* env = NULL; ++ env = getenv("SF_OMX_SLICE"); ++ if (env) { ++ gint slice, i; ++ slice = atoi(env); ++ if (slice > 0 && slice > vinfo->height) { ++ GST_DEBUG_OBJECT (alloc, "slice %d is large than height %d, recalculate size/offset", ++ slice, vinfo->height ); ++ vinfo->size = vinfo->size / vinfo->height * slice; ++ for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) ++ vinfo->offset[i] = vinfo->offset[i] / vinfo->height * slice; ++ } ++ } ++ + if (!gst_kms_allocator_memory_create (alloc, kmsmem, vinfo)) { + g_slice_free (GstKMSMemory, kmsmem); + return NULL; +-- +2.25.1 + diff --git a/package/starfive/sf-gst-omx/0023-Set-a-env-SF_OMX_SLICE-when-nSliceHeight-nFrameHeigh.patch b/package/starfive/sf-gst-omx/0023-Set-a-env-SF_OMX_SLICE-when-nSliceHeight-nFrameHeigh.patch new file mode 100644 index 00000000..1a200974 --- /dev/null +++ b/package/starfive/sf-gst-omx/0023-Set-a-env-SF_OMX_SLICE-when-nSliceHeight-nFrameHeigh.patch @@ -0,0 +1,71 @@ +From 6b7d167c0ef5d376064a18c76e1a408158c85971 Mon Sep 17 00:00:00 2001 +From: Som Qin +Date: Wed, 18 Oct 2023 09:25:41 +0800 +Subject: [PATCH] Set a env "SF_OMX_SLICE" when nSliceHeight > nFrameHeight in + dec output port. + +Env variables are set to bypass the negotiation mechanism to direct display +with drm(kmssink). + +Signed-off-by: Som Qin +--- + omx/gstomxvideodec.c | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) + +diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c +index 6224e09..57e5b5c 100644 +--- a/omx/gstomxvideodec.c ++++ b/omx/gstomxvideodec.c +@@ -1054,6 +1054,8 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) + GList *images = NULL; + GList *frames = NULL; + GstVideoInfo v_info; ++ OMX_PARAM_PORTDEFINITIONTYPE port_def; ++ guint frame_height, frame_slice; + gint i; + + if (!gst_video_info_from_caps (&v_info, caps)) { +@@ -1063,6 +1065,15 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) + self->use_buffers = FALSE; + } + ++ gst_omx_port_get_port_definition (self->dec_out_port, &port_def); ++ frame_slice = port_def.format.video.nSliceHeight; ++ frame_height = port_def.format.video.nFrameHeight; ++ if (frame_slice && (frame_slice > frame_height)) { ++ v_info.size = v_info.size / frame_height * frame_slice; ++ for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) ++ v_info.offset[i] = v_info.offset[i] / frame_height * frame_slice; ++ } ++ + GST_DEBUG_OBJECT (self, "Trying to use %d buffers", min); + + for (i = 0; i < min && self->use_buffers; i++) { +@@ -1345,7 +1356,7 @@ gst_omx_video_dec_reconfigure_output_port (GstOMXVideoDec * self) + OMX_PARAM_PORTDEFINITIONTYPE port_def; + GstVideoFormat format; + GstVideoInterlaceMode interlace_mode; +- guint frame_height; ++ guint frame_height, frame_slice; + + /* At this point the decoder output port is disabled */ + interlace_mode = gst_omx_video_dec_get_output_interlace_info (self); +@@ -1589,6 +1600,15 @@ gst_omx_video_dec_reconfigure_output_port (GstOMXVideoDec * self) + interlace_mode = GST_VIDEO_INTERLACE_MODE_ALTERNATE; + } + ++ frame_slice = port_def.format.video.nSliceHeight; ++ if (frame_slice && (frame_slice > frame_height)) { ++ char string[32]; ++ sprintf(string, "%d", frame_slice); ++ setenv ("SF_OMX_SLICE", string, 1); ++ } else { ++ unsetenv ("SF_OMX_SLICE"); ++ } ++ + GST_DEBUG_OBJECT (self, + "Setting output state: format %s (%d), width %u, height %u", + gst_video_format_to_string (format), +-- +2.25.1 +