History

vaapi_encode: Warn if input has cropping information

Cropping is not supported by VAAPI encode.

Mark Thompson committed 7 years ago

Commit 909bced1 parent ef2f89b2 files · +23 −0Browse files

Unified · Split

2 files
  1. libavcodec/vaapi_encode.c +19 −0
  2. libavcodec/vaapi_encode.h +4 −0
libavcodec/vaapi_encode.c+19−0
@@ -913,6 +913,21 @@ static int vaapi_encode_clear_old(AVCodecContext *avctx) · 912 unmodified lines
913913 return 0;
914914 }
915915
916+static int vaapi_encode_check_frame(AVCodecContext *avctx,
917+ const AVFrame *frame)
918+{
919+ VAAPIEncodeContext *ctx = avctx->priv_data;
920+
921+ if ((frame->crop_top || frame->crop_bottom ||
922+ frame->crop_left || frame->crop_right) && !ctx->crop_warned) {
923+ av_log(avctx, AV_LOG_WARNING, "Cropping information on input "
924+ "frames ignored due to lack of API support.\n");
925+ ctx->crop_warned = 1;
926+ }
927+
928+ return 0;
929+}
930+
916931 int ff_vaapi_encode_send_frame(AVCodecContext *avctx, const AVFrame *frame)
917932 {
918933 VAAPIEncodeContext *ctx = avctx->priv_data;
@@ -923,6 +938,10 @@ int ff_vaapi_encode_send_frame(AVCodecContext *avctx, const AVFrame *frame) · 4 unmodified lines
923938 av_log(avctx, AV_LOG_DEBUG, "Input frame: %ux%u (%"PRId64").\n",
924939 frame->width, frame->height, frame->pts);
925940
941+ err = vaapi_encode_check_frame(avctx, frame);
942+ if (err < 0)
943+ return err;
944+
926945 pic = vaapi_encode_alloc(avctx);
927946 if (!pic)
928947 return AVERROR(ENOMEM);
libavcodec/vaapi_encode.h+4−0
@@ -314,6 +314,10 @@ typedef struct VAAPIEncodeContext { · 313 unmodified lines
314314 int idr_counter;
315315 int gop_counter;
316316 int end_of_stream;
317+
318+ // The encoder does not support cropping information, so warn about
319+ // it the first time we encounter any nonzero crop fields.
320+ int crop_warned;
317321 } VAAPIEncodeContext;
318322
319323 enum {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t