VideoLAN 的 dav2d:以高效能解碼迎接 AV2 時代

新影片編碼器的出現持續推動壓縮效率的極限,使得在更低位元率下也能提供更高品質的影片。開放媒體聯盟(Alliance for Open Media,簡稱 AOMedia)在此創新領域走在前端,推出 AV2,作為廣受採用的 AV1 編碼器的繼任者。VideoLAN 以其 VLC 媒體播放器及高效能的 dav1d AV1 解碼器聞名,現在正推出 dav2d,這是一款新軟體解碼器,旨在成為所有平台上最快、最有效率的 AV2 解碼器。此發展至關重要,因為它為 AV2 的廣泛採用奠定基礎,就如同 dav1d 加速了 AV1 的推廣。

dav2d 在 Hacker News 上的首次公告,雖然因專案的 GitLab 實例短暫出現伺服器錯誤,但迅速引起了廣泛關注。社群討論突顯了對 AV2 的技術期待以及從一開始就擁有穩健軟體解碼器的策略重要性。

dav2d 是什麼?

dav2d 是 VideoLAN 為 AV2 影片編碼規範專門開發的新影片解碼器實作。其核心使命,如專案簡介所述,是成為「所有平台上最快的 AV2 解碼器」,強調其「小巧、可移植且極速」的設計。這項抱負對 VideoLAN 並不陌生;它呼應了 dav1d 的成功——這款 AV1 解碼器在硬體解碼普及之前,扮演了使 AV1 成為實用的關鍵角色。

有位評論者提供了關鍵背景說明:

Project description: dav2d is the fastest AV2 decoder on all platforms :) Targeted to be small, portable and very fast. If you're out of the loop like me: AV2 is the next-generation video coding specification from the Alliance for Open Media (AOMedia). Building on the foundation of AV1, AV2 is engineered to provide superior compression efficiency, enabling high-quality video delivery at significantly lower bitrates. It is optimized for the evolving demands of streaming, broadcasting, and real-time video conferencing. - from https://av2.aomedia.org/

AV2 的承諾

AV2 被定位為相較於 AV1 的重大飛躍。它在前代基礎上進一步提升,旨在提供更優秀的壓縮效率,從而在顯著降低位元率的同時仍能呈現高品質影片。對於當前在串流、廣播與即時視訊會議等領域常受頻寬限制的需求而言,這點尤為重要。

早期的洞見顯示 AV2 可能帶來顯著的提升:

AV2 video codec delivers 30% lower bitrate than AV1, final spec due in late 2025 (videocardz.com)

如果這 30% 的位元率降低得以實現,將會徹底改變內容的傳遞與消費方式,使得高畫質乃至超高畫質的內容在全球更易取得。然而,正如有評論指出,完整的效益只有在穩健的編碼器可用時才能顯現,而這一過程歷史上往往需要時間,正如 SVT-AV1 為 AV1 的開發所示。

技術實作與設計哲學

遵循 dav1d 成功的藍圖,dav2d 主要以 C 語言編寫,關鍵效能路徑則利用手寫組合語言。此方式允許對各種硬體架構進行精細的最佳化,將每一點效能都榨乾。

Mostly ASM for performance critical paths is a pattern that never gets old. The VideoLAN team did the same with dav1d and it paid off. Curious how much of dav2d ends up staying C as AV2 matures.

此選擇雖然以效能為導向,卻引發了關於編碼器記憶體安全性的討論:

We must not continue to develop media codecs in memory unsafe languages. Small, auditable sections can opt-out perhaps, but choosing default-unsafe for this type of software is close to professional negligence.

雖然記憶體安全是一個合理的關切,尤其在安全關鍵的軟體中更是如此,但 dav1d 的先例顯示,高度最佳化的 C 與組合語言能達到無與倫比的效能,這往往是影片解碼的首要需求。VideoLAN 團隊在此領域的專業表明,他們在效能與程式碼品質之間取得了謹慎的平衡。

對採用與硬體開發的影響

在 AV2 生命週期的早期階段就擁有如 dav2d 這樣高品質且高效能的軟體解碼器,預計將對其採用產生深遠影響。正如一位評論者優雅地指出的,它創造了一個「逆向先有雞還是先有蛋」的情境:

Dav1d was the surprisingly fast assembly implementation of AV1 decoding. Even for something in hand-coded platform-specific-assembly I think the general impression was that they'd done amazing work to really chase down every last bit of potential performance. It didn't initially exist when AV1 was first rolled out and its arrival was a step change in powering adoption on devices without hardware decoding. Dav2d is likely to play a similar role, but it exists from the start of AV2 and can build on the work of dav1d, so should have an even bigger effect. In a weird reverse chicken and egg scenario, having really good software decode that can be deployed will spur on hardware development and adoption due to network effects.

這意味著 dav2d 的可用性能加速 AV2 內容的部署,進而促使硬體製造商在晶片中加入 AV2 解碼功能,最終推動更廣泛的生態系採用。

更廣泛的背景與未來考量

討論亦涉及影片編碼領域的其他幾個面向:

  • 命名慣例dav2d 這個名稱遵循遞迴模式,類似於「GNU's Not Unix」,其中 Dav1d 是 AV1 解碼器,Dav2d 則是 AV2 解碼器。此點在最初因為流行的 YouTuber 或其他公眾人物而產生混淆時得到說明。
  • 生態系挑戰:開源編碼器領域並非沒有挑戰,包括專利爭議。某則評論提到對 Dolby 等實體可能攻擊 AV1 生態系的持續關切,凸顯 AOMedia 需要組織性的防禦。
  • 未來指令集:前瞻性的觀點質疑持續聚焦於「像 x86 或 ARM 這樣的舊指令集」,因為「本月出貨的 RVA23 主機板」暗示在 AV2 完全部署時,RISC-V 可能成為主流。這指出了未來適應性與更廣泛架構支援的需求。
  • 使用者體驗:部分評論反映了網路的一般狀況,指出機器人驗證、Cookie 同意以及 Cloudflare 挑戰等日益增加的摩擦,會在嘗試存取技術資源時降低使用者體驗。

隨著 dav2d 與 AV2 規範同步成熟,它在推動下一代高效能影片方面的角色將變得關鍵。專案的早期釋出以及 VideoLAN 已證實的實績,暗示 AV2 在各種平台與應用上的採用前景光明。

Sources