Skip to content

Commit

Permalink
Add libgav1 in third_party
Browse files Browse the repository at this point in the history
This add libgav1 [1] in chromium third_party. The plan is to use OBU parser for
AV1 HW decoder in chromium. That said, the sw decoder is not used in chromium
immediately after this CL.

[1] https://chromium.googlesource.com/codecs/libgav1/

Bug: 1000988, b:142835450
Test: compile chrome
Change-Id: I14e42ca0108f96f5931adb7bcad93a1df735f437
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880887
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Max Moroz <mmoroz@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Johann Koenig <johannkoenig@google.com>
Cr-Commit-Position: refs/heads/master@{#737661}
  • Loading branch information
Hirokazu Honda authored and Commit Bot committed Feb 3, 2020
1 parent a00a991 commit fa7af2b
Show file tree
Hide file tree
Showing 11 changed files with 424 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ check_targets = [
"//third_party/libdrm/*",
"//third_party/libevdev/*",
"//third_party/libexif/*",
"//third_party/libgav1/*",
"//third_party/libjingle/*",

# "//third_party/libjingle_xmpp/*", # 30ish errors
Expand Down
3 changes: 3 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,9 @@ deps = {
'src/third_party/emoji-segmenter/src':
Var('chromium_git') + '/external/github.com/google/emoji-segmenter.git' + '@' + Var('emoji_segmenter_revision'),

'src/third_party/libgav1/src':
Var('chromium_git') + '/codecs/libgav1.git' + '@' + '16e312f5066806284b080665545aef1fa51818a4',

# Chrome OS touchpad gestures library.
'src/third_party/gestures/gestures': {
'url': Var('chromium_git') + '/chromiumos/platform/gestures.git' + '@' + '74f55100df966280d305d5d5ada824605f875839',
Expand Down
1 change: 1 addition & 0 deletions media/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include_rules = [
"+third_party/dav1d",
"+third_party/ffmpeg",
"+third_party/libaom",
"+third_party/libgav1",
"+third_party/libvpx",
"+third_party/libyuv",
"+third_party/opus",
Expand Down
1 change: 1 addition & 0 deletions media/media_options.gni
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import("//build/config/jumbo.gni")
import("//media/gpu/args.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/libaom/options.gni")
import("//third_party/libgav1/options.gni")

# Do not expand this list without double-checking with OWNERS, this is a list of
# all targets which roll up into the //media component. It controls visibility
Expand Down
1 change: 1 addition & 0 deletions third_party/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
/libevdev/src
/libexif/sources
/libFuzzer/src
/libgav1/src
/libgifcodec
/libprotobuf-mutator/src
/libipp/libipp
Expand Down
48 changes: 48 additions & 0 deletions third_party/libgav1/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//third_party/libgav1/libgav1_srcs.gni")
import("//third_party/libgav1/options.gni")

config("libgav1_chromium_config") {
include_dirs = [
"src",
"src/src",
]

defines = [
"LIBGAV1_MAX_BITDEPTH=10",
"LIBGAV1_THREADPOOL_USE_STD_MUTEX", # to avoid abseil dependency.
]
}

if (use_libgav1) {
# Separate from libgav1 because utils/constants.cc and constants.cc generates
# the same object file, constants.o.
source_set("libgav1_utils") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":libgav1_chromium_config",
]

sources = gav1_utils_sources
}

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

public_deps = [ ":libgav1_utils" ]

# TODO(hiroh): Minimize source as small as obu parser can be built.
sources = gav1_common_sources
sources += gav1_dsp_sources
sources += gav1_gav1_sources
sources += gav1_tile_sources
}
}
5 changes: 5 additions & 0 deletions third_party/libgav1/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tomfinegan@chromium.org
johannkoenig@google.com
jzern@google.com

# COMPONENT: Internals>Media>Codecs
28 changes: 28 additions & 0 deletions third_party/libgav1/README.chromium
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Name: libgav1
Short Name: libgav1
URL: https://chromium.googlesource.com/codecs/libgav1/
Version: 0
Date: Wednesday November 13 2019
Branch: master
Commit: 16e312f5066806284b080665545aef1fa51818a4
License: Apache 2.0
License File: libgav1/LICENSE
Security Critical: yes
Source: https://chromium.googlesource.com/codecs/libgav1/

Description:
A Main profile (0) & High profile (1) compliant AV1 decoder.

Please follow these steps to update libgav1 src code
1. Update the code:
roll_dep.py \
-r <libgav1 OWNER> \
--log-limit 20 \
--roll-to <libvpx hash> \
src/third_party/libgav1/src

Use the generated commit message for the roll.

2. Generate .gni and update Date and Commit in README.chromium
cd third_party/libvpx
go run generate_libgav1_src_gni.go
137 changes: 137 additions & 0 deletions third_party/libgav1/generate_libgav1_src_gni.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// How to run.
// `go run generate_libgav1_src_gni.go.` at //third_party/libgav1.
// libgav1_src.gni is generated.
package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"sort"
"strings"
)

const (
gniFile = "libgav1_srcs.gni"
commonPrefix = "//third_party/libgav1/"
srcDir = "./src/src"
header = `# This file is generated. Do not edit.`
)

func getCppFiles(dir string) []string {
files, err := ioutil.ReadDir(dir)
if err != nil {
panic(err)
}

var paths []string
for _, file := range files {
if file.IsDir() {
paths = append(paths, getCppFiles(filepath.Join(dir, file.Name()))...)
}
ext := filepath.Ext(file.Name())
if ext == ".cc" || ext == ".h" {
paths = append(paths, filepath.Join(dir, file.Name()))
}
}
return paths
}

func getTopDirs(dir string) []string {
files, _ := ioutil.ReadDir(dir)
var paths []string
for _, file := range files {
if file.IsDir() {
paths = append(paths, filepath.Join(dir, file.Name()))
}
}
return paths
}

func format(dir string, files []string, file *os.File) {
sourcesName := "gav1_" + dir + "_sources"
fmt.Fprintf(file, "\n%s = [\n", sourcesName)
for _, f := range files {
fmt.Fprintf(file, " \"%s%s\",\n", commonPrefix, f)
}
fmt.Fprintf(file, "]\n")
}

func updateReadme() {
gitCmd := exec.Command("bash", "-c", "git --no-pager log -1 --format=\"%cd%n%H\" --date=format:\"%A %B %d %Y\"")
gitCmd.Dir = "src"
out, err := gitCmd.Output()
if err != nil {
panic(fmt.Sprintf("failed to execute git command: %v", err))
}

vals := strings.Split(string(out), "\n")

if len(vals) < 2 {
panic(fmt.Sprintf("unexpected git log result: %v %v", vals))
}
date := vals[0]
hash := vals[1]

sedCmd := exec.Command("sed", "-E", "-i.back", "-e",
fmt.Sprintf("s/^(Date:)[[:space:]]+.*$/\\1 %s/", date), "-e",
fmt.Sprintf("s/^(Commit:)[[:space:]]+[a-f0-9]{40}/\\1 %s/", hash),
"README.chromium")
if err := sedCmd.Run(); err != nil {
panic(fmt.Sprintf("failed to execute sed command: %v %v", sedCmd, err))
}

rmCmd := exec.Command("rm", "README.chromium.back")
if rmCmd.Run() != nil {
panic(fmt.Sprintf("failed to execute rm command: %v", err))
}
}

func main() {
files := getCppFiles(srcDir)
topDirs := getTopDirs(srcDir)
m := make(map[string][]string)
for _, f := range files {
found := false
for _, d := range topDirs {
if strings.HasPrefix(f, d) {
bd := filepath.Base(d)
m[bd] = append(m[bd], f)
found = true
break
}
}
if !found {
m["common"] = append(m["common"], f)
}
}

if err := os.RemoveAll(gniFile); err != nil {
panic(err)
}

file, err := os.OpenFile(gniFile, os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
panic(err)
}
fmt.Fprintf(file, "%s\n", header)

var keys []string
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)

for _, k := range keys {
v := m[k]
format(k, v, file)
}

updateReadme()
}
Loading

0 comments on commit fa7af2b

Please sign in to comment.