Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable platform decoder for aac and hevc #2752

Open
1 task done
uazo opened this issue Mar 11, 2024 · 11 comments
Open
1 task done

Enable platform decoder for aac and hevc #2752

uazo opened this issue Mar 11, 2024 · 11 comments

Comments

@uazo
Copy link

uazo commented Mar 11, 2024

Description

Remove the licensing problem caused by the possible inclusion of proprietary aac/hevc codec in ffmpeg decoders

Who's implementing?

  • I'm willing to implement this feature myself

The problem

I submit to your attention the possibility of enabling, for the time being only for windows and android, the activation of the proprietary codecs aac and hevc using the s.o. libraries, effectively removing the problem of the lack of licence required for the distribution of applications capable of decoding those streams.
I would appreciate your assessment of this and if you are interested in adopting it in ungoogled chromium, it would be a pleasure for me.

The linux version is still at the hypothesis stage, it would be nice to help each other in the development.

Possible solutions

Patch:

Alternatives

No response

Additional context

Context:

@PF4Public
Copy link
Contributor

Thanks @uazo!

There is one obstacle still: we haven't worked out how are we supposed to include patches from other projects, which are published under a different license other than that of ungoogled-chromium.

@uazo
Copy link
Author

uazo commented Mar 11, 2024

not a problem at all. you are of course authorised to use it.

@macchrome
Copy link

macchrome commented Mar 11, 2024

As an aside, The Chromium Authors will be introducing platform AC3/E-AC3 (Windows/macOS) in Chrome 124 - check out stazhu and the Chrome 124 betas.

WIN11_22H2+ supports platform kXHE_AAC: Enable-platform-aac-audio-and-h264-video.patch breaks that support.

Consider the changes that you've made to media/filters/win/media_foundation_audio_decoder.cc; platform kXHE_AAC and kAAC are mutually exclusive in WIN11_22H2+

@uazo
Copy link
Author

uazo commented Mar 12, 2024

@macchrome thanks for the report!

check out stazhu

what is stazhu?

Consider the changes that you've made to media/filters/win/media_foundation_audio_decoder.cc; platform kXHE_AAC and kAAC are mutually exclusive in WIN11_22H2+

do you mean this?

--- a/media/filters/win/media_foundation_audio_decoder.cc
+++ b/media/filters/win/media_foundation_audio_decoder.cc
@@ -96,11 +96,15 @@ absl::optional<MFT_REGISTER_TYPE_INFO> GetTypeInfo(
 #endif
 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
     case AudioCodec::kAAC:
+#if BUILDFLAG(ENABLE_PLATFORM_AAC_AUDIO)
+      return MFT_REGISTER_TYPE_INFO{MFMediaType_Audio, MFAudioFormat_AAC};
+#else
       if (config.profile() == AudioCodecProfile::kXHE_AAC &&
           base::win::GetVersion() >= base::win::Version::WIN11_22H2) {
         return MFT_REGISTER_TYPE_INFO{MFMediaType_Audio, MFAudioFormat_AAC};
       }
       [[fallthrough]];
+#endif // BUILDFLAG(ENABLE_PLATFORM_AAC_AUDIO)
 #endif

if config.profile() == AudioCodecProfile::kXHE_AAC is a condition that I did not remove, essentially.
are you saying this because you tried it? can you tell us how you tried it?

@uazo
Copy link
Author

uazo commented Mar 12, 2024

since you reminded me, I'm sorry I didn't mention it before, I forgot to say: in cromite I still made the decision not to support pass-through codecs being one of the ways to fingerprint the device and indeed this line removes support in android whereas in windows there is a gn flag on purpose.
that line should be removed from the patch for ungoogled chromium.

@macchrome
Copy link

  1. StaZhu: https://github.com/StaZhu/enable-chromium-ac3-ec3-system-decoding

  2. Specifically: base::win::GetVersion() >= base::win::Version::WIN11_22H2)

  3. Yes, I've tested the aac xhe-aac functionality: https://github.com/macchrome/winchrome/releases/tag/v122.6261.126-M122.0.6261.126-r1250580-Win64

Platform xhe-aac not available on Windows 11 < 22H2 - built with your patch and enable_platform_ac3_eac3_audio = true

Platform xhe-aac available on Windows 11 >= 22H2 and standard ffmpeg aac - ( enable_platform_ac3_eac3_audio = true)

xHE-AAC test page: https://www2.iis.fraunhofer.de/AAC/xhe-aac.html

I've also got some bloke complaining: macchrome/winchrome#136 - Discovery+ uses xHE-AAC!

@uazo
Copy link
Author

uazo commented Mar 12, 2024

neither in chrome nor in edge does that codec work (in w11).
can you tell me which gn args you use?

@macchrome
Copy link

Standard Google Release:

Google Chrome: 122.0.6261.39 (Official Build) (64-bit)
Revision: 9f0c18c86091cf6b458945aaca3eb549c15a3db9-refs/branch-heads/6261@{#741}
OS: Windows 11 Version 23H2 Enterprise (Build 22631.3155)

Just tested https://www2.iis.fraunhofer.de/AAC/xhe-aac.html - test streams all play.

My personal GN args (ungoogled): Windows x64 GNU/Linux cross compile:

target_os="win"
is_official_build = true
google_api_key=""
google_default_client_id=""
google_default_client_secret=""
use_official_google_api_keys = false
##chrome_pgo_phase = 0
current_cpu = "x64"
#enable_google_now = false
###enable_hotwording = false
enable_iterator_debugging = false
#####enable_nacl = true
ffmpeg_branding = "Chrome"
#######################jjjjjjjjjjjjjjjjjjj#is_component_build = false
#########################################is_debug = false
proprietary_codecs = true
##########################################################symbol_level = 0
host_cpu = "x64"
target_cpu = "x64"
#exclude_unwind_tables = true
#remove_webcore_debug_symbols = true
#enable_webrtc = false
enable_widevine = true
enable_media_foundation_widevine_cdm = true
#icu_use_data_file = true
#syzygy_optimize = true
#enable_hevc_demuxing = true
#enable_ac3_eac3_audio_demuxing = true
enable_platform_hevc = true
#enable_platform_encrypted_hevc=true
enable_hevc_parser_and_hw_decoder = true
###enable_platform_hevc_decoding = true
enable_platform_ac3_eac3_audio = true
enable_platform_mpeg_h_audio = true
enable_platform_dolby_vision = true
enable_platform_dts_audio = true
enable_mse_mpeg2ts_stream_parser = true
#enable_hls_sample_aes = true
enable_hls_demuxer = true
####################################################use_jumbo_build = true
use_thin_lto = true
thin_lto_enable_optimizations = true
######################################################################################full_wpo_on
#is_cfi = true
#use_lld = true
#mac_sdk_path = "/Users/bigchocolate/macchrome/MacOSX10.12.sdk"
#########
#########
###is_clang=false
clang_use_chrome_plugins=false
treat_warnings_as_errors=false
fatal_linker_warnings=false
use_ozone=false
use_sysroot=false
enable_remoting=false
enable_nacl=false
###enable_nacl_nonsfi=false
use_lld = true
clang_base_path="/volumes/disk4/chromium-122.0.6261.49/third_party/llvm-build/Release+Asserts"
###clang_base_path = "/home/acer/clang-8.0.1-win"
###clang_base_path = "c:\share\Chromium\chromium-103.0.5060.53\third_party\llvm-build\Release+Asserts"
###clang_base_path = "F:\share\LLVM-14.0.0\"
######################################################clang_base_path = "/volumes/disk2/clang-11.0.0"
#####clang_base_path = "/volumes/disk2/stage-final"
############clang_base_path = "/volumes/disk1/stage-final-93"
enable_dsyms = false
use_egl=true
enable_swiftshader=true
###optimize_webui=false
##use_gnome_keyring=false
use_unofficial_version_number=false
###fieldtrial_testing_like_official_build=true
###cc_wrapper="pump distcc"
###cc_wrapper="icecc"
enable_resource_allowlist_generation = false
###linux_use_bundled_binutils=false
is_clang=true
###enable_precompiled_headers = true
#v8_use_snapshot = true
#########################################################enable_vulkan = false
#########################################################angle_enable_vulkan = false
#angle_enable_vulkan_validation_layers = false
###########################################################dawn_enable_vulkan = false
#enable_vr = false
###closure_compile=false
###enable_js_type_check=false
enable_hangout_services_extension=false
##################### ungoogled
##enable_mdns=false
###enable_one_click_signin=false
enable_reading_list=false
enable_remoting=false
enable_service_discovery=false
exclude_unwind_tables=true
safe_browsing_mode=0
#################### ungoogled
enable_reporting=false
#concurrent_links=24
###############jumbo_build_excluded = ["ui"]
###enable_pdf=false
chrome_pgo_phase = 2
pgo_data_path="/volumes/disk4/chromium-122.0.6261.49/chrome-win64-6261-1708184559-2abfd14763019ebbaafde7e45adb95da337107f1-eec584c534302bf91cb20498a3d07a7c8f30d8a0.profdata"
##pgo_data_path="/volumes/disk3/chromium-110.0.5481.77/chrome-win64-5563-1678204501-75dd3a0ccbe314db3c5ccdd1e84dc32fa4cde684.profdata"
###sysroot="/volumes/disk2/chromium/src/build/linux/debian_bullseye_amd64-sysroot"
##################
##################
disable_fieldtrial_testing_config=true
############
mojo_media_host = "gpu"
mojo_media_services = ["video_decoder", "audio_decoder", "cdm"]
#mojo_media_services = ["video_decoder", "audio_decoder"]
#angle_enable_d3d11_compositor_native_window=true
#enable_runtime_media_renderer_selection=false
is_component_ffmpeg=false
build_with_tflite_lib=false
dcheck_always_on=false
####enable_stripping=false
is_debug=false
symbol_level=0
####is_official_build=false
####is_component_build=true
bundle_widevine_cdm = false
enable_media_foundation_widevine_cdm = false
enable_cdm_host_verification = false
ignore_missing_widevine_signing_cert = false
##use_webaudio_ffmpeg = false
use_webaudio_pffft = true
blink_symbol_level = 0
v8_symbol_level = 0
enable_screen_ai_service=false
enable_trace_logging=false
build_dawn_tests=false
################# NEW SHIT ##################
#angle_build_tests=false
##build_angle_perftests=false
#enable_perfetto_unittests=false
#skia_enable_skshaper_tests=false
#tint_build_unittests=false
#v8_enable_test_features=false
#rtc_enable_google_benchmarks=false
#rtc_disable_logging=false
##rtc_disable_metric=false
#rtc_disable_trace_events=false
##enable_rust=false
win_enable_cfg_guards = true

@uazo
Copy link
Author

uazo commented Mar 13, 2024

I assume the problem is due to these lines:

   aac_wave_format->wfx.cbSize = static_cast<WORD>(extra_size);
+#if BUILDFLAG(ENABLE_PLATFORM_AAC_AUDIO)
+  aac_wave_format->wPayloadType = 1;  // Audio Data Transport Stream (ADTS)
+#else
   aac_wave_format->wPayloadType = 0;  // RAW AAC
+#endif

in the code I find:

  // ADTS bitstream conversion shouldn't be enabled for xHE-AAC since it can't
  // be represented with only two bits for the profile.

Conversely, I enable conversion for all aac streams
I think it is sufficient to add an if on the format of the codec re-establishing raw in case of decoder_config.profile() == AudioCodecProfile::kXHE_AAC

about the cdm, sorry, but I can't help you with that, it's something I don't know yet.

@uazo
Copy link
Author

uazo commented Mar 13, 2024

I confirm that adding that simple if works.
in cromite won't be there though, it would introduce the possibility of understanding that the device is windows 11.

@macchrome
Copy link

Platform audio-visual (AV) decoding under Linux including xHE_ACC

https://github.com/macchrome/chromium/releases/tag/v123.6312.127-M123.0.6312.127-r1262506-portable-ungoogled-Lin64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants