From 161ebd130771bf102853f8a5ad66ab2e50b6008a Mon Sep 17 00:00:00 2001 From: StevenTheGeek Date: Mon, 2 Nov 2026 23:12:52 +0000 Subject: [PATCH] gst: Always set the smart resize and crop when configuring gst_pisp_convert_configure() resets rgb_enables to the input and output enables, and the backend only re-enables the downscale and resample blocks in updateSmartResize() when the smart resize is dirty. SetSmartResize() was skipped when the output size had not changed, so after any reconfigure at the same output size the resampler was left disabled and the output was an unscaled, wrongly tiled crop of the input. This shows when the input caps change but the output size does not, for example a tiled NV12 (SAND128) stream from v4l2slh265dec followed by an I420 stream of the same size from avdec_h264, in either order, or a change of frame rate only. The config sent to the backend has rgb_enables 0x48203 on the first configure and 0x40203 (no RESAMPLE0) after the reconfigure. Always call SetSmartResize() so the resampler is re-enabled on every configure. Call SetCrop() every time as well for consistency, and drop the now unused applied_smart_resize and applied_crop caches. Signed-off-by: StevenTheGeek --- src/gst/gstpispconvert.cpp | 19 +++++++------------ src/gst/gstpispconvert.h | 4 ---- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/gst/gstpispconvert.cpp b/src/gst/gstpispconvert.cpp index ceab319..6028dc2 100644 --- a/src/gst/gstpispconvert.cpp +++ b/src/gst/gstpispconvert.cpp @@ -1027,21 +1027,16 @@ static gboolean gst_pisp_convert_configure(GstPispConvert *self) GST_INFO_OBJECT(self, "Crop%u: offset=(%u,%u) size=%ux%u", i, crop.offset_x, crop.offset_y, crop.width, crop.height); - /* Only call SetCrop if parameters changed */ - if (memcmp(&crop, &self->priv->applied_crop[i], sizeof(crop)) != 0) - { - self->priv->backend->SetCrop(i, crop); - self->priv->applied_crop[i] = crop; - } + self->priv->backend->SetCrop(i, crop); - /* Only call SetSmartResize if parameters changed */ + /* Always set the smart resize: the global config above resets rgb_enables to the + * input and outputs only, and libpisp re-enables the downscale/resample blocks only + * when the smart resize is dirty. Skipping it when the output size is unchanged left + * the resampler off after a reconfigure, so a new input format (or frame rate) at + * the same output size was shown unscaled, cropped and tiled wrongly. */ libpisp::BackEnd::SmartResize smart_resize = { (uint16_t)output_cfg[i].image.width, (uint16_t)output_cfg[i].image.height }; - if (memcmp(&smart_resize, &self->priv->applied_smart_resize[i], sizeof(smart_resize)) != 0) - { - self->priv->backend->SetSmartResize(i, smart_resize); - self->priv->applied_smart_resize[i] = smart_resize; - } + self->priv->backend->SetSmartResize(i, smart_resize); } /* Prepare the hardware configuration */ diff --git a/src/gst/gstpispconvert.h b/src/gst/gstpispconvert.h index 41ac51a..7a751df 100644 --- a/src/gst/gstpispconvert.h +++ b/src/gst/gstpispconvert.h @@ -63,10 +63,6 @@ struct _GstPispConvertPrivate /* Crop settings per output */ pisp_be_crop_config crop[PISP_NUM_OUTPUTS]; - /* Cached crop/resize settings (to avoid redundant API calls) */ - pisp_be_crop_config applied_crop[PISP_NUM_OUTPUTS]; - libpisp::BackEnd::SmartResize applied_smart_resize[PISP_NUM_OUTPUTS]; - /* Input format info */ guint in_width; guint in_height;