History

avcodec/libvpxenc: Apply codec options to alpha codec context

When encoding yuva420 (alpha) frames, the vpx encoder uses a second vpx_codec_ctx to encode the alpha stream. However, codec options were only being applied to the primary encoder. This patch updates codecctl_int and codecctl_intp to also apply codec options to the alpha codec context when encoding frames with alpha. This is necessary to take advantage of libvpx speed optimizations such as 'row-mt' and 'cpu-used' when encoding videos with alpha. Without this patch, the speed optimizations are only applied to the primary stream encoding, and the overall encoding is just as slow as it would be without the options specified.

Adam Chelminski committed 5 years ago

Commit 715f6321 parent 3008a932 files · +25 −3Browse files

Unified · Split

2 files
  1. libavcodec/libvpxenc.c +24 −2
  2. libavcodec/version.h +1 −1
libavcodec/libvpxenc.c+24−2
@@ -385,9 +385,20 @@ static av_cold int codecctl_int(AVCodecContext *avctx, · 384 unmodified lines
385 snprintf(buf, sizeof(buf), "Failed to set %s codec control",385 snprintf(buf, sizeof(buf), "Failed to set %s codec control",
386 ctlidstr[id]);386 ctlidstr[id]);
387 log_encoder_error(avctx, buf);387 log_encoder_error(avctx, buf);
388 return AVERROR(EINVAL);
388 }389 }
389 390
390 return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL);391 if (ctx->is_alpha) {
392 int res_alpha = vpx_codec_control(&ctx->encoder_alpha, id, val);
393 if (res_alpha != VPX_CODEC_OK) {
394 snprintf(buf, sizeof(buf), "Failed to set %s alpha codec control",
395 ctlidstr[id]);
396 log_encoder_error(avctx, buf);
397 return AVERROR(EINVAL);
398 }
399 }
400
401 return 0;
391}402}
392 403
393#if VPX_ENCODER_ABI_VERSION >= 12404#if VPX_ENCODER_ABI_VERSION >= 12
@@ -407,9 +418,20 @@ static av_cold int codecctl_intp(AVCodecContext *avctx, · 13 unmodified lines
407 snprintf(buf, sizeof(buf), "Failed to set %s codec control",418 snprintf(buf, sizeof(buf), "Failed to set %s codec control",
408 ctlidstr[id]);419 ctlidstr[id]);
409 log_encoder_error(avctx, buf);420 log_encoder_error(avctx, buf);
421 return AVERROR(EINVAL);
410 }422 }
411 423
412 return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL);424 if (ctx->is_alpha) {
425 int res_alpha = vpx_codec_control(&ctx->encoder_alpha, id, val);
426 if (res_alpha != VPX_CODEC_OK) {
427 snprintf(buf, sizeof(buf), "Failed to set %s alpha codec control",
428 ctlidstr[id]);
429 log_encoder_error(avctx, buf);
430 return AVERROR(EINVAL);
431 }
432 }
433
434 return 0;
413}435}
414#endif436#endif
415 437
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29 29
30#define LIBAVCODEC_VERSION_MAJOR 5930#define LIBAVCODEC_VERSION_MAJOR 59
31#define LIBAVCODEC_VERSION_MINOR 731#define LIBAVCODEC_VERSION_MINOR 7
32#define LIBAVCODEC_VERSION_MICRO 10232#define LIBAVCODEC_VERSION_MICRO 103
33 33
34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
35 LIBAVCODEC_VERSION_MINOR, \35 LIBAVCODEC_VERSION_MINOR, \

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