summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMaxym Dmytrychenko <maxim.d33@gmail.com>2018-07-30 18:02:37 +0200
committerMaxym Dmytrychenko <maxim.d33@gmail.com>2018-08-06 22:30:18 +0200
commit325aa63dd1a3abc2453914d0bc111d297833d725 (patch)
treed0f4f8da934f3daafcc03535fecaea8a4fa86909 /libavcodec
parentf89ec87afaf0d1abb6d450253b0b348fd554533b (diff)
qsv: enforcing continuous memory layout
we need to make sure that memory allocation for Y/UV planes is continuous and re-used from a pool Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/qsvenc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index e349a075f5..c74b3ae31a 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1014,7 +1014,6 @@ static void clear_unused_frames(QSVEncContext *q)
QSVFrame *cur = q->work_frames;
while (cur) {
if (cur->used && !cur->surface.Data.Locked) {
- av_frame_unref(cur->frame);
cur->used = 0;
}
cur = cur->next;
@@ -1082,16 +1081,23 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
}
} else {
/* make a copy if the input is not padded as libmfx requires */
- if (frame->height & 31 || frame->linesize[0] & (q->width_align - 1)) {
+ /* and to make allocation continious for data[0]/data[1] */
+ if ((frame->height & 31 || frame->linesize[0] & (q->width_align - 1)) ||
+ (frame->data[1] - frame->data[0] != frame->linesize[0] * FFALIGN(qf->frame->height, q->height_align))) {
qf->frame->height = FFALIGN(frame->height, q->height_align);
qf->frame->width = FFALIGN(frame->width, q->width_align);
- ret = ff_get_buffer(q->avctx, qf->frame, AV_GET_BUFFER_FLAG_REF);
- if (ret < 0)
- return ret;
+ qf->frame->format = frame->format;
+
+ if (!qf->frame->data[0]) {
+ ret = av_frame_get_buffer(qf->frame, q->width_align);
+ if (ret < 0)
+ return ret;
+ }
qf->frame->height = frame->height;
qf->frame->width = frame->width;
+
ret = av_frame_copy(qf->frame, frame);
if (ret < 0) {
av_frame_unref(qf->frame);