openH264-enable-ARM-ARM64-optimizations.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. From: csagan5 <32685696+csagan5@users.noreply.github.com>
  2. Date: Sat, 20 Jan 2018 21:17:27 +0100
  3. Subject: openH264: enable ARM/ARM64 optimizations
  4. Enable the optimizations not only for ChromeOS but for all compatbile ARM/ARM64 architectures
  5. Limit threads auto-detect only for iOS
  6. ---
  7. content/renderer/media_recorder/h264_encoder.cc | 6 ++---
  8. third_party/openh264/BUILD.gn | 31 +++++++++++++++++++------
  9. 2 files changed, 27 insertions(+), 10 deletions(-)
  10. diff --git a/content/renderer/media_recorder/h264_encoder.cc b/content/renderer/media_recorder/h264_encoder.cc
  11. --- a/content/renderer/media_recorder/h264_encoder.cc
  12. +++ b/content/renderer/media_recorder/h264_encoder.cc
  13. @@ -150,11 +150,11 @@ void H264Encoder::ConfigureEncoderOnEncodingTaskRunner(const gfx::Size& size) {
  14. init_params.iRCMode = RC_OFF_MODE;
  15. }
  16. -#if defined(OS_CHROMEOS)
  17. - init_params.iMultipleThreadIdc = 0;
  18. -#else
  19. +#if defined(OS_MACOSX)
  20. // Threading model: Set to 1 due to https://crbug.com/583348.
  21. init_params.iMultipleThreadIdc = 1;
  22. +#else
  23. + init_params.iMultipleThreadIdc = 0;
  24. #endif
  25. // TODO(mcasas): consider reducing complexity if there are few CPUs available.
  26. diff --git a/third_party/openh264/BUILD.gn b/third_party/openh264/BUILD.gn
  27. --- a/third_party/openh264/BUILD.gn
  28. +++ b/third_party/openh264/BUILD.gn
  29. @@ -16,11 +16,16 @@ config("config") {
  30. # HAVE_NEON and __chromeos__ are needed for enabling NEON on ChromeOS
  31. # devices.
  32. defines += [
  33. - "HAVE_NEON",
  34. "__chromeos__",
  35. ]
  36. }
  37. + if (target_cpu == "arm" || target_cpu == "arm64") {
  38. + defines += [
  39. + "HAVE_NEON",
  40. + ]
  41. + }
  42. +
  43. # GCC and clang flags. MSVS (is_win && !is_clang) does not use cflags.
  44. if (!is_win || is_clang) {
  45. cflags += [
  46. @@ -125,8 +130,12 @@ if (use_assembler) {
  47. source_set("common") {
  48. sources = openh264_common_sources
  49. - if (is_chromeos && target_cpu == "arm") {
  50. - sources += openh264_common_sources_asm_arm
  51. + if (is_chromeos || is_android) {
  52. + if (target_cpu == "arm") {
  53. + sources += openh264_common_sources_asm_arm
  54. + } else if (target_cpu == "arm64") {
  55. + sources += openh264_common_sources_asm_arm64
  56. + }
  57. }
  58. include_dirs = openh264_common_include_dirs
  59. @@ -151,8 +160,12 @@ source_set("common") {
  60. source_set("processing") {
  61. sources = openh264_processing_sources
  62. - if (is_chromeos && target_cpu == "arm") {
  63. - sources += openh264_processing_sources_asm_arm
  64. + if (is_chromeos || is_android) {
  65. + if (target_cpu == "arm") {
  66. + sources += openh264_processing_sources_asm_arm
  67. + } else if (target_cpu == "arm64") {
  68. + sources += openh264_processing_sources_asm_arm64
  69. + }
  70. }
  71. include_dirs = openh264_processing_include_dirs
  72. @@ -170,8 +183,12 @@ source_set("processing") {
  73. source_set("encoder") {
  74. sources = openh264_encoder_sources
  75. - if (is_chromeos && target_cpu == "arm") {
  76. - sources += openh264_encoder_sources_asm_arm
  77. + if (is_chromeos || is_android) {
  78. + if (target_cpu == "arm") {
  79. + sources += openh264_encoder_sources_asm_arm
  80. + } else if (target_cpu == "arm64") {
  81. + sources += openh264_encoder_sources_asm_arm64
  82. + }
  83. }
  84. include_dirs = openh264_encoder_include_dirs
  85. --
  86. 2.11.0