Skip to content

Commit 8be5217

Browse files
author
Isaac
committed
Dav1d build
1 parent 79c3d87 commit 8be5217

File tree

11 files changed

+252
-0
lines changed

11 files changed

+252
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ url=../tgcalls.git
2929
[submodule "submodules/LottieCpp/lottiecpp"]
3030
path = submodules/LottieCpp/lottiecpp
3131
url = https://github.com/ali-fareed/lottiecpp.git
32+
[submodule "third-party/dav1d/dav1d"]
33+
path = third-party/dav1d/dav1d
34+
url = https://github.com/ali-fareed/dav1d.git

WORKSPACE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ http_file(
3333
sha256 = "f794ed92ccb4e9b6619a77328f313497d7decf8fb7e047ba35a348b838e0e1e2",
3434
)
3535

36+
http_file(
37+
name = "meson_tar_gz",
38+
urls = ["https://github.com/mesonbuild/meson/releases/download/1.6.0/meson-1.6.0.tar.gz"],
39+
sha256 = "999b65f21c03541cf11365489c1fad22e2418bb0c3d50ca61139f2eec09d5496",
40+
)
41+
42+
http_file(
43+
name = "ninja-mac_zip",
44+
urls = ["https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-mac.zip"],
45+
sha256 = "89a287444b5b3e98f88a945afa50ce937b8ffd1dcc59c555ad9b1baf855298c9",
46+
)
47+
3648
http_archive(
3749
name = "appcenter_sdk",
3850
urls = ["https://github.com/microsoft/appcenter-sdk-apple/releases/download/4.1.1/AppCenter-SDK-Apple-4.1.1.zip"],

submodules/FFMpegBinding/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ objc_library(
1818
],
1919
deps = [
2020
"//submodules/ffmpeg",
21+
"//third-party/dav1d",
22+
],
23+
sdk_frameworks = [
24+
"CoreMedia",
2125
],
2226
visibility = [
2327
"//visibility:public",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import <Foundation/Foundation.h>
2+
#import <CoreMedia/CoreMedia.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
CMFormatDescriptionRef _Nullable createAV1FormatDescription(NSData *bitstreamData) CF_RETURNS_RETAINED;
7+
8+
NS_ASSUME_NONNULL_END

submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegAVFormatContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern int FFMpegCodecIdH264;
2828
extern int FFMpegCodecIdHEVC;
2929
extern int FFMpegCodecIdMPEG4;
3030
extern int FFMpegCodecIdVP9;
31+
extern int FFMpegCodecIdAV1;
3132

3233
@class FFMpegAVCodecContext;
3334

submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegBinding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
#import <FFMpegBinding/FFMpegRemuxer.h>
1313
#import <FFMpegBinding/FFMpegLiveMuxer.h>
1414
#import <FFMpegBinding/FrameConverter.h>
15+
#import <FFMpegBinding/Dav1dBinding.h>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#import <FFMpegBinding/Dav1dBinding.h>
2+
3+
#import "dav1d/dav1d.h"
4+
5+
/*static CFDataRef ff_videotoolbox_av1c_extradata_create(Dav1dSequenceHeader *header) {
6+
uint8_t *buf;
7+
CFDataRef data;
8+
9+
header->
10+
11+
buf = malloc(s->seq_data_ref->size + 4);
12+
if (!buf)
13+
return NULL;
14+
buf[0] = 0x81; // version and marker (constant)
15+
buf[1] = s->raw_seq->seq_profile << 5 | s->raw_seq->seq_level_idx[0];
16+
buf[2] = s->raw_seq->seq_tier[0] << 7 |
17+
s->raw_seq->color_config.high_bitdepth << 6 |
18+
s->raw_seq->color_config.twelve_bit << 5 |
19+
s->raw_seq->color_config.mono_chrome << 4 |
20+
s->raw_seq->color_config.subsampling_x << 3 |
21+
s->raw_seq->color_config.subsampling_y << 2 |
22+
s->raw_seq->color_config.chroma_sample_position;
23+
24+
if (s->raw_seq->initial_display_delay_present_flag)
25+
buf[3] = 0 << 5 |
26+
s->raw_seq->initial_display_delay_present_flag << 4 |
27+
s->raw_seq->initial_display_delay_minus_1[0];
28+
else
29+
buf[3] = 0x00;
30+
memcpy(buf + 4, s->seq_data_ref->data, s->seq_data_ref->size);
31+
data = CFDataCreate(kCFAllocatorDefault, buf, s->seq_data_ref->size + 4);
32+
av_free(buf);
33+
return data;
34+
}*/
35+
36+
CMFormatDescriptionRef _Nullable createAV1FormatDescription(NSData *bitstreamData) CF_RETURNS_RETAINED {
37+
Dav1dSequenceHeader header;
38+
if (dav1d_parse_sequence_header(&header, bitstreamData.bytes, bitstreamData.length) != 0) {
39+
return nil;
40+
}
41+
42+
return nil;
43+
}
44+

submodules/FFMpegBinding/Sources/FFMpegAVFormatContext.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
int FFMpegCodecIdHEVC = AV_CODEC_ID_HEVC;
1212
int FFMpegCodecIdMPEG4 = AV_CODEC_ID_MPEG4;
1313
int FFMpegCodecIdVP9 = AV_CODEC_ID_VP9;
14+
int FFMpegCodecIdAV1 = AV_CODEC_ID_AV1;
1415

1516
@interface FFMpegAVFormatContext () {
1617
AVFormatContext *_impl;

third-party/dav1d/BUILD

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
2+
generated_headers = [
3+
"vcs_version.h",
4+
]
5+
6+
headers = [
7+
"compat/msvc/stdatomic.h",
8+
"compat/gcc/stdatomic.h",
9+
"compat/getopt.h",
10+
"common/dump.h",
11+
"common/frame.h",
12+
"common/bitdepth.h",
13+
"common/attributes.h",
14+
"common/validate.h",
15+
"common/intops.h",
16+
"dav1d/picture.h",
17+
"dav1d/version.h",
18+
"dav1d/data.h",
19+
"dav1d/headers.h",
20+
"dav1d/common.h",
21+
"dav1d/dav1d.h",
22+
]
23+
24+
libs = [
25+
"dav1d",
26+
]
27+
28+
filegroup(
29+
name = "dav1d_sources",
30+
srcs = glob([
31+
"dav1d/**/*"
32+
]),
33+
)
34+
35+
genrule(
36+
name = "dav1d_build",
37+
srcs = [
38+
"build-dav1d-bazel.sh",
39+
"arm64-iPhoneSimulator.meson",
40+
":dav1d_sources",
41+
"@meson_tar_gz//file",
42+
"@ninja-mac_zip//file",
43+
],
44+
cmd_bash =
45+
"""
46+
set -ex
47+
48+
if [ "$(TARGET_CPU)" == "ios_arm64" ]; then
49+
BUILD_ARCH="arm64"
50+
elif [ "$(TARGET_CPU)" == "ios_sim_arm64" ]; then
51+
BUILD_ARCH="sim_arm64"
52+
else
53+
echo "Unsupported architecture $(TARGET_CPU)"
54+
fi
55+
56+
BUILD_DIR="$(RULEDIR)/build_$${BUILD_ARCH}"
57+
rm -rf "$$BUILD_DIR"
58+
mkdir -p "$$BUILD_DIR"
59+
60+
MESON_DIR="$$(pwd)/$$BUILD_DIR/meson"
61+
rm -rf "$$MESON_DIR"
62+
mkdir -p "$$MESON_DIR"
63+
tar -xzf "$(location @meson_tar_gz//file)" -C "$$MESON_DIR"
64+
65+
NINJA_DIR="$$(pwd)/$$BUILD_DIR/ninja"
66+
rm -rf "$$NINJA_DIR"
67+
mkdir -p "$$NINJA_DIR"
68+
unzip "$(location @ninja-mac_zip//file)" -d "$$NINJA_DIR"
69+
70+
cp $(location :build-dav1d-bazel.sh) "$$BUILD_DIR/"
71+
cp $(location :arm64-iPhoneSimulator.meson) "$$BUILD_DIR/"
72+
73+
SOURCE_PATH="third-party/dav1d/dav1d"
74+
75+
cp -R "$$SOURCE_PATH" "$$BUILD_DIR/"
76+
77+
mkdir -p "$$BUILD_DIR/Public/dav1d"
78+
mkdir -p "$$BUILD_DIR/Public/compat"
79+
mkdir -p "$$BUILD_DIR/Public/common"
80+
81+
PATH="$$PATH:$$MESON_DIR/meson-1.6.0:$$NINJA_DIR" sh $$BUILD_DIR/build-dav1d-bazel.sh $$BUILD_ARCH "$$BUILD_DIR"
82+
""" +
83+
"\n".join([
84+
"cp -f \"$$BUILD_DIR/dav1d/build/include/{}\" \"$(location Public/{})\"".format(header, header) for header in generated_headers
85+
]) +
86+
"\n" +
87+
"\n".join([
88+
"cp -f \"$$BUILD_DIR/dav1d/include/{}\" \"$(location Public/{})\"".format(header, header) for header in headers
89+
]) +
90+
"\n" +
91+
"\n".join([
92+
"cp -f \"$$BUILD_DIR/dav1d/build/src/lib{}.a\" \"$(location Public/dav1d/lib/lib{}.a)\"".format(lib, lib) for lib in libs
93+
]),
94+
outs = ["Public/" + x for x in generated_headers] +
95+
["Public/" + x for x in headers] +
96+
["Public/dav1d/lib/lib{}.a".format(x) for x in libs],
97+
visibility = [
98+
"//visibility:public",
99+
]
100+
)
101+
102+
cc_library(
103+
name = "dav1d_lib",
104+
srcs = [":Public/dav1d/lib/lib" + x + ".a" for x in libs]
105+
)
106+
107+
objc_library(
108+
name = "dav1d",
109+
module_name = "dav1d",
110+
enable_modules = True,
111+
hdrs = [":Public/" + x for x in generated_headers],
112+
includes = [
113+
"Public",
114+
],
115+
deps = [
116+
":dav1d_lib",
117+
],
118+
visibility = [
119+
"//visibility:public",
120+
],
121+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[binaries]
2+
c = ['clang', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
3+
cpp = ['clang++', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
4+
objc = ['clang', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
5+
objcpp = ['clang++', '-arch', 'arm64', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
6+
ar = 'ar'
7+
strip = 'strip'
8+
9+
[built-in options]
10+
c_args = ['-mios-simulator-version-min=11.0']
11+
cpp_args = ['-mios-simulator-version-min=11.0']
12+
c_link_args = ['-mios-simulator-version-min=11.0']
13+
cpp_link_args = ['-mios-simulator-version-min=11.0']
14+
objc_args = ['-mios-simulator-version-min=11.0']
15+
objcpp_args = ['-mios-simulator-version-min=11.0']
16+
17+
[properties]
18+
root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer'
19+
needs_exe_wrapper = true
20+
21+
[host_machine]
22+
system = 'darwin'
23+
subsystem = 'ios-simulator'
24+
kernel = 'xnu'
25+
cpu_family = 'arm64'
26+
cpu = 'arm64'
27+
endian = 'little'

0 commit comments

Comments
 (0)