1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

hwframe: Allow hwaccel frame allocators to align surface sizes

Hardware accelerated decoding generally uses AVHWFramesContext for pool
allocation of hardware surfaces. These are setup to allocate surfaces
aligned to hardware and hwaccel API requirements. Due to the
architecture, av_hwframe_get_buffer() will return AVFrames with
the dimensions set to the aligned sizes.

This causes some decoders (like hevc) return these aligned size as
final frame size, instead of cropping them to the video's actual
dimensions. To make sure this doesn't happen, crop the frame to the
size the decoder expects when ff_get_buffer() is called.

Merges Libav commit 3fdf50f9e8.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Anton Khirnov 2017-06-22 20:05:12 +02:00 committed by wm4
parent f0bcedaf37
commit d14179e3d4

View File

@ -1528,8 +1528,12 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags
{
int ret;
if (avctx->hw_frames_ctx)
return av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
if (avctx->hw_frames_ctx) {
ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
frame->width = avctx->coded_width;
frame->height = avctx->coded_height;
return ret;
}
if ((ret = update_frame_pool(avctx, frame)) < 0)
return ret;