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
385385 snprintf(buf, sizeof(buf), "Failed to set %s codec control",
386386 ctlidstr[id]);
387387 log_encoder_error(avctx, buf);
388+ return AVERROR(EINVAL);
388389 }
389390
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;
391402 }
392403
393404 #if VPX_ENCODER_ABI_VERSION >= 12
@@ -407,9 +418,20 @@ static av_cold int codecctl_intp(AVCodecContext *avctx, · 13 unmodified lines
407418 snprintf(buf, sizeof(buf), "Failed to set %s codec control",
408419 ctlidstr[id]);
409420 log_encoder_error(avctx, buf);
421+ return AVERROR(EINVAL);
410422 }
411423
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;
413435 }
414436 #endif
415437
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 59
3131 #define LIBAVCODEC_VERSION_MINOR 7
32−#define LIBAVCODEC_VERSION_MICRO 102
32+#define LIBAVCODEC_VERSION_MICRO 103
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3535 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