mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] media: cedrus: h264/h265: Improve aux buffer management
@ 2022-10-19 17:45 Jernej Skrabec
  2022-10-19 17:45 ` [PATCH 1/2] media: cedrus: h265: Associate mv col buffers with buffer Jernej Skrabec
  2022-10-19 17:45 ` [PATCH 2/2] media: cedrus: h264: Optimize mv col buffer allocation Jernej Skrabec
  0 siblings, 2 replies; 3+ messages in thread
From: Jernej Skrabec @ 2022-10-19 17:45 UTC (permalink / raw)
  To: mripard, paul.kocialkowski
  Cc: mchehab, gregkh, wens, samuel, hverkuil-cisco, linux-media,
	linux-staging, linux-arm-kernel, linux-sunxi, linux-kernel,
	Jernej Skrabec

Current handling of mv col aux buffers in h264 and h265 code is not
optimal. In h264 case, it allocates pool for worst case possible which
basically never happens with typical videos. This also prevents it from
working well on very memory constrained devices, where CMA pool is very
small. In h265 case, number of buffers in a pool is equal to number of
capture buffers allocated before streaming is started. If any capture
buffer is allocated afterwards, Cedrus gets bogus pointers. This might
cause memory corruption.

Solution is the same in both cases. Instead of using memory pool, do
individual allocations later, right before aux buffer is first used.
Such approach allocates just right amount of buffers of optimal size.

Proposed solution frees aux buffers in streaming off callback, which
is first possible occasion. I can move this to .buf_cleanup too, if you
think that it's more appropriate.

Finally, h265 patch can be considered as a fix (prevents overwriting
random memory). If deemed appropriate, fixes tag can be added.

Let me know what you think.

Best regards,
Jernej

Jernej Skrabec (2):
  media: cedrus: h265: Associate mv col buffers with buffer
  media: cedrus: h264: Optimize mv col buffer allocation

 drivers/staging/media/sunxi/cedrus/cedrus.h   |  16 +--
 .../staging/media/sunxi/cedrus/cedrus_h264.c  | 118 +++++++++---------
 .../staging/media/sunxi/cedrus/cedrus_h265.c  |  63 +++++-----
 3 files changed, 99 insertions(+), 98 deletions(-)

--
2.38.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-19 17:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 17:45 [PATCH 0/2] media: cedrus: h264/h265: Improve aux buffer management Jernej Skrabec
2022-10-19 17:45 ` [PATCH 1/2] media: cedrus: h265: Associate mv col buffers with buffer Jernej Skrabec
2022-10-19 17:45 ` [PATCH 2/2] media: cedrus: h264: Optimize mv col buffer allocation Jernej Skrabec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®