mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:26:14 +00:00
avvideodec: ensure required mem alignment fixing avdec_h265 crashes with ximagesink/glimagesink
Make sure the alignment requirement in GstAllocationParams matches the GstVideoAlignment requirements. This fixes issues with avdec_h265 crashing in the avx2 code path when used with playbin and ximagesink/glimagesink as videosink. The internal video pool would allocate buffers with an alignment of 15 even though GstVideoAlignment specified a stride_align requirement of 31 (which comes from ffmpeg). https://bugzilla.gnome.org/show_bug.cgi?id=754120
This commit is contained in:
parent
fa8679b4d8
commit
a0ebef9637
1 changed files with 20 additions and 3 deletions
|
@ -616,16 +616,19 @@ dummy_free_buffer (void *opaque, uint8_t * data)
|
||||||
|
|
||||||
/* This function prepares the pool configuration for direct rendering. To use
|
/* This function prepares the pool configuration for direct rendering. To use
|
||||||
* this method, the codec should support direct rendering and the pool should
|
* this method, the codec should support direct rendering and the pool should
|
||||||
* support video meta and video alignement */
|
* support video meta and video alignment */
|
||||||
static void
|
static void
|
||||||
gst_ffmpegvideodec_prepare_dr_pool (GstFFMpegVidDec * ffmpegdec,
|
gst_ffmpegvideodec_prepare_dr_pool (GstFFMpegVidDec * ffmpegdec,
|
||||||
GstBufferPool * pool, GstVideoInfo * info, GstStructure * config)
|
GstBufferPool * pool, GstVideoInfo * info, GstStructure * config)
|
||||||
{
|
{
|
||||||
|
GstAllocationParams params;
|
||||||
GstVideoAlignment align;
|
GstVideoAlignment align;
|
||||||
|
GstAllocator *allocator = NULL;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint linesize_align[4];
|
gint linesize_align[4];
|
||||||
gint i;
|
gint i;
|
||||||
guint edge;
|
guint edge;
|
||||||
|
gsize max_align;
|
||||||
|
|
||||||
width = GST_VIDEO_INFO_WIDTH (info);
|
width = GST_VIDEO_INFO_WIDTH (info);
|
||||||
height = GST_VIDEO_INFO_HEIGHT (info);
|
height = GST_VIDEO_INFO_HEIGHT (info);
|
||||||
|
@ -651,8 +654,22 @@ gst_ffmpegvideodec_prepare_dr_pool (GstFFMpegVidDec * ffmpegdec,
|
||||||
/* add extra padding to match libav buffer allocation sizes */
|
/* add extra padding to match libav buffer allocation sizes */
|
||||||
align.padding_bottom++;
|
align.padding_bottom++;
|
||||||
|
|
||||||
|
gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms);
|
||||||
|
|
||||||
|
max_align = DEFAULT_STRIDE_ALIGN;
|
||||||
|
max_align |= params.align;
|
||||||
|
|
||||||
|
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||||
|
if (linesize_align[i] > 0)
|
||||||
|
max_align |= linesize_align[i] - 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
|
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
|
||||||
align.stride_align[i] = (linesize_align[i] > 0 ? linesize_align[i] - 1 : 0);
|
align.stride_align[i] = max_align;
|
||||||
|
|
||||||
|
params.align = max_align;
|
||||||
|
|
||||||
|
gst_buffer_pool_config_set_allocator (config, allocator, ¶ms);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ffmpegdec, "aligned dimension %dx%d -> %dx%d "
|
GST_DEBUG_OBJECT (ffmpegdec, "aligned dimension %dx%d -> %dx%d "
|
||||||
"padding t:%u l:%u r:%u b:%u, stride_align %d:%d:%d:%d",
|
"padding t:%u l:%u r:%u b:%u, stride_align %d:%d:%d:%d",
|
||||||
|
@ -1815,7 +1832,7 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
|
||||||
have_alignment =
|
have_alignment =
|
||||||
gst_buffer_pool_has_option (pool, GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
gst_buffer_pool_has_option (pool, GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||||
|
|
||||||
/* If have videometa, we never have to copy */
|
/* If we have videometa, we never have to copy */
|
||||||
if (have_videometa && have_pool && have_alignment &&
|
if (have_videometa && have_pool && have_alignment &&
|
||||||
gst_ffmpegviddec_can_direct_render (ffmpegdec)) {
|
gst_ffmpegviddec_can_direct_render (ffmpegdec)) {
|
||||||
gst_ffmpegvideodec_prepare_dr_pool (ffmpegdec, pool, &state->info, config);
|
gst_ffmpegvideodec_prepare_dr_pool (ffmpegdec, pool, &state->info, config);
|
||||||
|
|
Loading…
Reference in a new issue