You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
3.2 KiB

  1. From 7e929dac100916fc45cb95e231025f3439c20156 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
  3. Date: Tue, 4 Sep 2018 11:45:35 +0300
  4. Subject: [PATCH] libfdk-aacenc: Allow enabling the ELDv2 profile
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. This is a new feature in FDK v2.
  9. Signed-off-by: Martin Storsjö <martin@martin.st>
  10. ---
  11. libavcodec/libfdk-aacenc.c | 27 ++++++++++++++++++++++++++-
  12. 1 file changed, 26 insertions(+), 1 deletion(-)
  13. diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
  14. index 92ad1762aea..f71a276403e 100644
  15. --- a/libavcodec/libfdk-aacenc.c
  16. +++ b/libavcodec/libfdk-aacenc.c
  17. @@ -36,6 +36,7 @@ typedef struct AACContext {
  18. HANDLE_AACENCODER handle;
  19. int afterburner;
  20. int eld_sbr;
  21. + int eld_v2;
  22. int signaling;
  23. int latm;
  24. int header_period;
  25. @@ -47,6 +48,9 @@ typedef struct AACContext {
  26. static const AVOption aac_enc_options[] = {
  27. { "afterburner", "Afterburner (improved quality)", offsetof(AACContext, afterburner), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
  28. { "eld_sbr", "Enable SBR for ELD (for SBR in other configurations, use the -profile parameter)", offsetof(AACContext, eld_sbr), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
  29. +#if FDKENC_VER_AT_LEAST(4, 0) // 4.0.0
  30. + { "eld_v2", "Enable ELDv2 (LD-MPS extension for ELD stereo signals)", offsetof(AACContext, eld_v2), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
  31. +#endif
  32. { "signaling", "SBR/PS signaling style", offsetof(AACContext, signaling), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, "signaling" },
  33. { "default", "Choose signaling implicitly (explicit hierarchical by default, implicit if global header is disabled)", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, "signaling" },
  34. { "implicit", "Implicit backwards compatible signaling", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, "signaling" },
  35. @@ -149,7 +153,28 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
  36. switch (avctx->channels) {
  37. case 1: mode = MODE_1; sce = 1; cpe = 0; break;
  38. - case 2: mode = MODE_2; sce = 0; cpe = 1; break;
  39. + case 2:
  40. +#if FDKENC_VER_AT_LEAST(4, 0) // 4.0.0
  41. + // (profile + 1) to map from profile range to AOT range
  42. + if (aot == FF_PROFILE_AAC_ELD + 1 && s->eld_v2) {
  43. + if ((err = aacEncoder_SetParam(s->handle, AACENC_CHANNELMODE,
  44. + 128)) != AACENC_OK) {
  45. + av_log(avctx, AV_LOG_ERROR, "Unable to enable ELDv2: %s\n",
  46. + aac_get_error(err));
  47. + goto error;
  48. + } else {
  49. + mode = MODE_212;
  50. + sce = 1;
  51. + cpe = 0;
  52. + }
  53. + } else
  54. +#endif
  55. + {
  56. + mode = MODE_2;
  57. + sce = 0;
  58. + cpe = 1;
  59. + }
  60. + break;
  61. case 3: mode = MODE_1_2; sce = 1; cpe = 1; break;
  62. case 4: mode = MODE_1_2_1; sce = 2; cpe = 1; break;
  63. case 5: mode = MODE_1_2_2; sce = 1; cpe = 2; break;