aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qsvenc.c
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2023-05-18 14:54:37 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2023-05-25 09:04:13 +0800
commitcf79dab8dff4be3a875cfe0b1e1025f4eb541623 (patch)
tree893ec584a02d2cd6f017c3be90b1ed46f96450c9 /libavcodec/qsvenc.c
parentcfdfd6aa723101f4bf089dc750b8389b203533f8 (diff)
downloadffmpeg-cf79dab8dff4be3a875cfe0b1e1025f4eb541623.tar.gz
lavc/qsvenc: avoid data copy if possible
The data copy is unnecessary for packed formats when frame width and height are aligned For example: $ ffmpeg -f lavfi -i testsrc=size=1920x1088 -vf "format=yuyv422" -c:v hevc_qsv -f null - Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r--libavcodec/qsvenc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2c38fbf0dc..b6813b3023 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -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);