diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-08-10 18:55:29 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-08-10 18:56:34 +0300 |
commit | d6239d2f591872e9761f2059d97d474c1f5b676f (patch) | |
tree | 511326bd0b237c3a57bf539bef68d6eec8c7a41a | |
parent | d645cf6b338a0075f98e595a24106bec83382b63 (diff) | |
download | gst-libav-d6239d2f591872e9761f2059d97d474c1f5b676f.tar.gz |
Revert "avviddec: Remove usage of deprecated EDGE APIs"
This reverts commit 4284d791bc2c3ae716e4f99cedd870de9f575aec.
It causes crashes on various h264 and DNXHD/VC3 streams, where the
decoders write to arbitrary memory far after what we've allocated.
-rw-r--r-- | ext/libav/gstavviddec.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c index 0eadced..251823b 100644 --- a/ext/libav/gstavviddec.c +++ b/ext/libav/gstavviddec.c @@ -614,6 +614,7 @@ gst_ffmpegvideodec_prepare_dr_pool (GstFFMpegVidDec * ffmpegdec, gint width, height; gint linesize_align[4]; gint i; + guint edge; gsize max_align; width = GST_VIDEO_INFO_WIDTH (info); @@ -623,10 +624,22 @@ gst_ffmpegvideodec_prepare_dr_pool (GstFFMpegVidDec * ffmpegdec, avcodec_align_dimensions2 (ffmpegdec->context, &width, &height, linesize_align); - align.padding_top = 0; - align.padding_left = 0; - align.padding_right = width - GST_VIDEO_INFO_WIDTH (info); - align.padding_bottom = height - GST_VIDEO_INFO_HEIGHT (info); + if (ffmpegdec->context->flags & CODEC_FLAG_EMU_EDGE) + edge = 0; + else + edge = avcodec_get_edge_width (); + + /* increase the size for the padding */ + width += edge << 1; + height += edge << 1; + + align.padding_top = edge; + align.padding_left = edge; + align.padding_right = width - GST_VIDEO_INFO_WIDTH (info) - edge; + align.padding_bottom = height - GST_VIDEO_INFO_HEIGHT (info) - edge; + + /* add extra padding to match libav buffer allocation sizes */ + align.padding_bottom++; gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms); @@ -2064,7 +2077,6 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query) gst_buffer_unref (tmp); if (same_stride) { - GST_DEBUG_OBJECT (ffmpegdec, "Using downstream pool."); if (ffmpegdec->internal_pool) gst_object_unref (ffmpegdec->internal_pool); ffmpegdec->internal_pool = gst_object_ref (pool); @@ -2079,7 +2091,6 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query) if (have_videometa && ffmpegdec->internal_pool && ffmpegdec->pool_width == state->info.width && ffmpegdec->pool_height == state->info.height) { - GST_DEBUG_OBJECT (ffmpegdec, "Pushing from internal pool"); update_pool = TRUE; gst_object_unref (pool); pool = gst_object_ref (ffmpegdec->internal_pool); |