@@ -1910,7 +1910,8 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
/* make a copy if the input is not padded as libmfx requires */
/* and to make allocation continious for data[0]/data[1] */
if ((frame->height & (q->height_align - 1) || frame->linesize[0] & (q->width_align - 1)) ||
- (frame->data[1] - frame->data[0] != frame->linesize[0] * FFALIGN(qf->frame->height, q->height_align))) {
+ ((frame->format == AV_PIX_FMT_NV12 || frame->format == AV_PIX_FMT_P010 || frame->format == AV_PIX_FMT_P012) &&
+ (frame->data[1] - frame->data[0] != frame->linesize[0] * FFALIGN(qf->frame->height, q->height_align)))) {
int tmp_w, tmp_h;
qf->frame->height = tmp_h = FFALIGN(frame->height, q->height_align);
qf->frame->width = tmp_w = FFALIGN(frame->width, q->width_align);