Skip to content

Commit

Permalink
dav1d
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlstrom-g committed May 1, 2024
1 parent 61caf48 commit a70febf
Show file tree
Hide file tree
Showing 330 changed files with 1,048 additions and 518 deletions.
1 change: 1 addition & 0 deletions starboard/linux/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ static_library("starboard_platform_sources") {

configs += [
"//starboard/build/config:starboard_implementation",
"//third_party/dav1d:public_dav1d_config",
"//third_party/de265_includes",
"//third_party/pulseaudio_includes",
]
Expand Down
2 changes: 1 addition & 1 deletion starboard/linux/x64x11/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ group("starboard_platform") {
]

deps = [
"//third_party/libdav1d:dav1d",
"//third_party/dav1d",
"//third_party/libjpeg-turbo:libjpeg",
"//third_party/libvpx",
]
Expand Down
8 changes: 4 additions & 4 deletions starboard/shared/libdav1d/dav1d_video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#include "starboard/memory.h"
#include "starboard/shared/starboard/player/filter/cpu_video_frame.h"
#include "starboard/shared/starboard/player/job_queue.h"
#include "third_party/libdav1d/include/dav1d/common.h"
#include "third_party/libdav1d/include/dav1d/data.h"
#include "third_party/libdav1d/include/dav1d/headers.h"
#include "third_party/libdav1d/include/dav1d/picture.h"
#include "third_party/dav1d/libdav1d/include/dav1d/common.h"
#include "third_party/dav1d/libdav1d/include/dav1d/data.h"
#include "third_party/dav1d/libdav1d/include/dav1d/headers.h"
#include "third_party/dav1d/libdav1d/include/dav1d/picture.h"

namespace starboard {
namespace shared {
Expand Down
2 changes: 1 addition & 1 deletion starboard/shared/libdav1d/dav1d_video_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef STARBOARD_SHARED_LIBDAV1D_DAV1D_VIDEO_DECODER_H_
#define STARBOARD_SHARED_LIBDAV1D_DAV1D_VIDEO_DECODER_H_

#include "third_party/libdav1d/include/dav1d/dav1d.h"
#include "third_party/dav1d/libdav1d/include/dav1d/dav1d.h"

#include <queue>
#include <string>
Expand Down
87 changes: 48 additions & 39 deletions third_party/libdav1d/BUILD.gn → third_party/dav1d/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
# Copyright 2023 The Cobalt Authors. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("dav1d_generated.gni")

import("//build/config/compiler/compiler.gni")
import("//build/config/sanitizers/sanitizers.gni")

assert(use_cobalt_customizations)

if (is_starboard) {
import("//starboard/build/nasm_assemble.gni")
} else {
import("//third_party/nasm/nasm_assemble.gni")
import("//third_party/nasm/nasm_assemble.gni")
}

# MemorySanitizer can't handle assembly, https://crbug.com/928357.
enable_nasm =
nasm_exists && (current_cpu == "x86" || current_cpu == "x64") && !is_msan
enable_nasm = (current_cpu == "x86" || current_cpu == "x64") && !is_msan

# Some older compilers can't handle AVX-512 instructions.
if (using_old_compiler) {
Expand All @@ -47,7 +33,7 @@ if (is_win) {
} else {
# Linux configuration files seem to work on Mac, so just reuse them.
if (enable_nasm) {
platform_config_root = "config/linux/$current_cpu"
platform_config_root = "config/linux/$current_cpu"
} else {
platform_config_root = "config/linux-noasm/$current_cpu"
}
Expand Down Expand Up @@ -98,13 +84,13 @@ config("public_dav1d_config") {
config("dav1d_config") {
configs = [ ":public_dav1d_config" ]
include_dirs = [
".",
"include",
"include/dav1d",
"libdav1d",
"libdav1d/include",
"libdav1d/include/dav1d",
platform_config_root,
]
if (is_win && !is_clang) {
include_dirs += [ "include/compat/msvc" ]
include_dirs += [ "libdav1d/include/compat/msvc" ]
}
}

Expand Down Expand Up @@ -134,12 +120,12 @@ if (enable_nasm) {
sources = x86_asm_sources

inputs = [
"src/ext/x86/x86inc.asm",
"libdav1d/src/ext/x86/x86inc.asm",
"$platform_config_root/config.asm",
]

include_dirs = [
"src/",
"libdav1d/src/",
platform_config_root,
]

Expand All @@ -161,13 +147,21 @@ if (enable_nasm) {
}

source_set("dav1d_headers") {
configs += [ ":dav1d_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":dav1d_config",
]

sources = c_headers
}

static_library("dav1d_8bit") {
configs += [ ":dav1d_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":dav1d_config",
]

sources = template_sources
if (current_cpu == "x86" || current_cpu == "x64") {
Expand All @@ -186,15 +180,18 @@ static_library("dav1d_8bit") {

static_library("dav1d_10bit") {
configs -= [
# "//build/config/compiler:chromium_code",
"//build/config/compiler:chromium_code",

# Disable coverage for the 10 bit version to avoid confusing the
# instrumentation about which version of the library is being run.
# dav1d_10 bit was selected for this, as it's less used than dav1d_8bit,
# which still has coverage enabled. See crbug.com/1030350.
# "//build/config/coverage:default_coverage",
"//build/config/coverage:default_coverage",
]
configs += [
"//build/config/compiler:no_chromium_code",
":dav1d_config",
]
configs += [ ":dav1d_config" ]

sources = template_sources
if (current_cpu == "x86" || current_cpu == "x64") {
Expand All @@ -214,11 +211,15 @@ static_library("dav1d_10bit") {
if (current_cpu == "x86" || current_cpu == "x64") {
static_library("dav1d_x86") {
sources = [
"src/x86/cpu.c",
"src/x86/cpu.h",
"libdav1d/src/x86/cpu.c",
"libdav1d/src/x86/cpu.h",
]

configs += [ ":dav1d_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":dav1d_config",
]
cflags = dav1d_copts

deps = [ ":dav1d_headers" ]
Expand All @@ -227,8 +228,8 @@ if (current_cpu == "x86" || current_cpu == "x64") {
} else if (current_cpu == "arm" || current_cpu == "arm64") {
static_library("dav1d_arm") {
sources = [
"src/arm/cpu.c",
"src/arm/cpu.h",
"libdav1d/src/arm/cpu.c",
"libdav1d/src/arm/cpu.h",
]

# These are not template based so should only be built once.
Expand All @@ -238,7 +239,11 @@ if (current_cpu == "x86" || current_cpu == "x64") {
sources += arm64_asm_sources
}

configs += [ ":dav1d_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":dav1d_config",
]

# Necessary to ensure macOS symbols end up with a _ prefix.
if (is_mac || is_ios) {
Expand All @@ -255,10 +260,14 @@ if (current_cpu == "x86" || current_cpu == "x64") {
static_library("dav1d") {
sources = c_sources
if (is_win) {
sources += [ "src/win32/thread.c" ]
sources += [ "libdav1d/src/win32/thread.c" ]
}

configs += [ ":dav1d_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":dav1d_config",
]
cflags = dav1d_copts

deps = [
Expand Down
3 changes: 3 additions & 0 deletions third_party/dav1d/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
monorail {
component: "Internals>Media>Codecs"
}
23 changes: 23 additions & 0 deletions third_party/dav1d/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright © 2018, VideoLAN and dav1d authors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 changes: 15 additions & 0 deletions third_party/dav1d/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
third_party {
identifier {
type: "ChromiumVersion"
value: "113.0.5672.134" # from https://chromereleases.googleblog.com/2023/05/stable-channel-update-for-chromeos_19.html
}
identifier {
type: "Git"
value: "https://chromium.googlesource.com/chromium/src.git"
version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02"
}
identifier {
type: "UpstreamSubdir"
value: "third_party/dav1d"
}
}
1 change: 1 addition & 0 deletions third_party/dav1d/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file://media/OWNERS
36 changes: 36 additions & 0 deletions third_party/dav1d/README.chromium
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Name: dav1d is an AV1 decoder :)
Short Name: dav1d
URL: https://code.videolan.org/videolan/dav1d
Version: master
License: 2-Clause BSD
License File: LICENSE
Security Critical: yes
Source: https://code.videolan.org/videolan/dav1d

--[ DESCRIPTION ] ------------------
This contains the source to the dav1d video decoder; used for AV1 decoding in
Chromium. The LICENSE file is copied from libdav1d/COPYING.


--[ UPDATING ] ------------------
To update run "git pull" within the libdav1d directory to sync your local copy
of the checkout to upstream. Then you need to update the configuration files
and source listing.

First have clang (//third_party/llvm-build/Release+Asserts/bin), clang-cl
(https://chromium.googlesource.com/chromium/src/+/lkgr/docs/win_cross.md),
and meson v0.55 or higher (https://github.com/mesonbuild/meson/releases) in
your path. Then you can run ./generate_configs.py

Next you should update the dav1d_generated.gni file, to do that run the
./generate_source.py command.

Hopefully all that works and then you can roll DEPS to the new revision with
all the updated configuration files. If not, you'll need to debug the bots :(


-- [ OPEN ISSUES ] ------------------
1. If Windows build fails on Linux, you may need to run:
`build/vs_toolchain.py update` to regenerate FUSE links.
2. If ARM build fails with an error around clock_gettime you likely need to
install gcc-arm-linux-gnueabihf and gcc-aarch64-linux-gnu packages.
50 changes: 50 additions & 0 deletions third_party/dav1d/config/linux/arm/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Autogenerated by the Meson build system.
* Do not edit, your changes will be lost.
*/

#pragma once

#define ARCH_AARCH64 0

#define ARCH_ARM 1

#define ARCH_PPC64LE 0

#define ARCH_X86 0

#define ARCH_X86_32 0

#define ARCH_X86_64 0

#define CONFIG_16BPC 1

#define CONFIG_8BPC 1

// #define CONFIG_LOG 1 -- Logging is controlled by Chromium

#define ENDIANNESS_BIG 0

#define HAVE_ASM 1

#define HAVE_AS_FUNC 0

#define HAVE_C11_GENERIC 1

#define HAVE_CLOCK_GETTIME 1

#define HAVE_DLSYM 1

#define HAVE_GETAUXVAL 1

#define HAVE_POSIX_MEMALIGN 1

// #define HAVE_PTHREAD_GETAFFINITY_NP 1 -- Controlled by Chomium

// #define HAVE_PTHREAD_SETAFFINITY_NP 1 -- Controlled by Chomium

#define HAVE_UNISTD_H 1

#define PIC 3

#define TRIM_DSP_FUNCTIONS 1
Loading

0 comments on commit a70febf

Please sign in to comment.