Skip to content

Commit c9ff7f2

Browse files
authored
Merge branch 'master' into ios.x264.2
2 parents d33632f + e817ea3 commit c9ff7f2

63 files changed

Lines changed: 10189 additions & 2039 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
with:
3939
api-level: ${{ matrix.api-level }}
4040
script: |
41-
./gradlew build
41+
./gradlew buildDefaultDebug

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ test:
1414

1515

1616
verify: /tmp/akiyo_qcif.y4m
17-
./scripts/encapp_verify.py -i /tmp/akiyo_qcif.y4m -ddd
17+
./scripts/encapp_verify.py -i /tmp/akiyo_qcif.y4m
1818

1919

2020
build:
2121
./gradlew build
2222

2323
install:
24-
./gradlew installDebug
24+
./gradlew installDefaultDebug
2525

2626
clean:
2727
./gradlew clean

README.dev.md

Lines changed: 165 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,75 @@ For a description on how to use the tool, check [README.md](README.md).
77

88
# 1. Prerequisites
99

10-
In order to do encapp development, you need:
11-
* android sdk setup and environment variables set
12-
* android ndk
10+
## 1.1. Required Tools
1311

14-
Please note that since JDK 16 gradle versions < 7 are broken.
15-
This means that a JDK version >= 16 must be used for building.
12+
To develop encapp, you need the following tools installed:
1613

14+
### Android Development Tools
15+
adb push out/target/product/diamond/testcases/libmc2_tests/arm64/libmc2_tests /data/
1716

18-
# 2. Operation
17+
* **Android SDK** - Android Software Development Kit with environment variables properly set
18+
- Set `ANDROID_HOME` or `ANDROID_SDK_ROOT` environment variable
19+
- Add platform-tools to your PATH
20+
* **Android NDK** - Native Development Kit for C/C++ code compilation
21+
- Required for building native components
22+
* **Gradle** - Build automation tool (version 7.0 or higher)
23+
- Bundled with the project via Gradle Wrapper (`gradlew`)
1924

20-
## 2.1. set up the android SDK and NDK in the `local.properties` file.
25+
### Java Development Kit
2126

22-
Create a `local.properties` file with valid entries for the `ndk.dir` and
23-
`sdk.dir` variables.
27+
* **JDK 16 or higher** - Required for building with Gradle 7+
28+
- **Important:** Gradle versions < 7 are broken with JDK 16+
29+
- Verify installation: `java -version`
30+
31+
### Additional Tools
32+
33+
* **Protocol Buffer Compiler (protoc)** - Optional, only needed if modifying `.proto` files
34+
- Installation: See [main README section 1.1](README.md#11-external-tool-dependencies)
35+
* **Python 3.9+** - For running scripts and tests
36+
- Installation: See [main README section 1.2](README.md#12-python-dependencies)
37+
38+
## 1.2. iOS Development (Optional)
39+
40+
For iOS development, you additionally need:
41+
42+
* **Xcode** - Apple's IDE with iOS SDK
43+
* **Command Line Tools** - Install via `xcode-select --install`
44+
* **Valid iOS provisioning profile** - For device deployment
2445

25-
```
26-
$ cat local.properties
27-
ndk.dir: /opt/android_ndk/android-ndk-r19/
28-
sdk.dir: /opt/android_sdk/
29-
```
3046

31-
Note that this file should not be added to the repo.
47+
# 2. Building encapp
3248

33-
## 2.2. build the encapp app
49+
## 2.1. Set up Android SDK and NDK
3450

51+
Create a `local.properties` file in the project root with valid entries for the `ndk.dir` and `sdk.dir` variables:
52+
53+
```properties
54+
ndk.dir=/opt/android_ndk/android-ndk-r19/
55+
sdk.dir=/opt/android_sdk/
3556
```
57+
58+
**Note:** This file should not be added to version control (it's already in `.gitignore`).
59+
60+
## 2.2. Build the encapp App
61+
62+
Build the Android application using Gradle:
63+
64+
```bash
3665
$ ./gradlew clean
3766
$ ./gradlew build
3867
...
3968
BUILD SUCCESSFUL in 6s
4069
61 actionable tasks: 5 executed, 56 up-to-date
4170
```
4271

43-
## 2.3. run the `setup.sh` script to install encapp in your android device.
72+
The APK will be generated in `app/build/outputs/apk/debug/`.
4473

45-
```
74+
## 2.3. Install Using setup.sh Script
75+
76+
The `setup.sh` script builds and installs encapp on all connected devices:
77+
78+
```bash
4679
$ ./setup.sh
4780
...
4881
Installing APK 'com.facebook.encapp-v1.0-debug.apk' on 'Pixel - 10' for app:debug
@@ -52,21 +85,33 @@ BUILD SUCCESSFUL in 14s
5285
31 actionable tasks: 3 executed, 28 up-to-date
5386
```
5487

55-
## 2.4. run a quick encoding experiment with the app
88+
## 2.4. Manual Installation and Testing
5689

57-
Install the app.
58-
```
90+
Alternatively, manually install and test the app:
91+
92+
```bash
93+
# Install the APK
5994
$ adb install ./app/build/outputs/apk/debug/com.facebook.encapp-v1.0-debug.apk
60-
$ adb shell cmd package list package |grep encapp
95+
96+
# Verify installation
97+
$ adb shell cmd package list package | grep encapp
6198
package:com.facebook.encapp
6299
```
63100

64-
Run the `list_codecs` function.
101+
### Running Direct Tests
65102

66-
Note that, for the very first time you run the instrumentation codecs, the
67-
device will ask you for permission to access to `/sdcard/`.
103+
You can test encapp functionality directly using `adb` commands without the Python script.
68104

69-
Figure 1 shows ![an android device asking for permission to run encapp](doc/encapp_permission.jpeg)
105+
**List Available Codecs:**
106+
107+
```bash
108+
$ adb shell am start -W -e list_codecs a -e ui_hold_sec 3 com.facebook.encapp/.MainActivity
109+
```
110+
111+
**Note:** The first time you run encapp, the device will ask for permission to access `/sdcard/`.
112+
113+
![Android device asking for permission to run encapp](doc/encapp_permission.jpeg)
114+
*Figure 1: Permission dialog on first run*
70115

71116
```
72117
$ adb shell am start -W -e list_codecs a -e ui_hold_sec 3 com.facebook.encapp/.MainActivity
@@ -151,50 +196,119 @@ $ adb shell cat /sdcard/codecs.txt
151196
...
152197
```
153198

154-
## 3. Regression test
199+
# 3. Regression Testing
155200

156-
**NOTE: this is currently not working properly, it will be adressed.**
201+
**NOTE: This is currently not working properly and will be addressed in a future update.**
157202

158-
encapp_verify.py will run through the tests defined in 'tests/' folder and try to verify:
159-
* bitrate
160-
* key frames
161-
* temporal layers
162-
* long temporal references (Qualcomm ltr)
203+
The `encapp_verify.py` script runs through tests defined in the `tests/` folder and verifies:
204+
* Bitrate conformance
205+
* Key frame intervals
206+
* Temporal layer configuration
207+
* Long term references (LTR) - Qualcomm specific
163208

164-
Just like encapp.py overrides for input and encoder are available.
165-
Run the test just like they are defined:
209+
## 3.1. Basic Usage
166210

211+
Run all tests with default configuration:
212+
213+
```bash
214+
$ ./scripts/encapp_verify.py
167215
```
168-
$ encapp_verify.py
169-
```
170216

171-
Override the input, encoding resolution and codec:
217+
## 3.2. Override Options
218+
219+
Override input, encoding resolution, and codec:
220+
221+
```bash
222+
$ ./scripts/encapp_verify.py \
223+
-i /media/data/media_encapp/<encoded>.mp4 \
224+
-os 1920x1080 \
225+
-c encoder.avc
172226
```
173-
$ encapp_verify.py -i /media/johan/data/media_encapp/<encoded>.mp4 -os 1920x1080 -c encoder.avc
227+
228+
**Note:** This currently only works for encoded files, not raw files.
229+
230+
## 3.3. Run Specific Test
231+
232+
Override input and run a specific test:
233+
234+
```bash
235+
$ ./scripts/encapp_verify.py \
236+
-i /tmp/KristenAndSara_1280x720_60.yuv \
237+
-is 1280x720 \
238+
-if 30 \
239+
-os 1280x720 \
240+
-of 30 \
241+
-t <PATH>/encapp/tests/simple.qcif.json
174242
```
175-
This only works (for now) for encoded files and not raw files.
176243

177-
Override input and run specific test:
244+
**Important:** For raw input, both input and output resolution and fps must be specified, even though raw buffer encoding doesn't allow scaling (surface encoding does support scaling).
245+
246+
247+
# 4. System and Unit Testing
248+
249+
encapp includes both unit tests and system tests to ensure code quality and functionality.
250+
251+
## 4.1. Running All Tests
252+
253+
Run all tests using pytest:
254+
255+
```bash
256+
$ python3 -m pytest PATH_TO_REPO/encapp/scripts/tests/
178257
```
179-
$ encapp_verify.py -i /tmp/KristenAndSara_1280x720_60.yuv -is 1280x720 -if 30 -os 1280x720 -of 30 -t <PATH>/encapp/tests/simple.qcif.json
258+
259+
## 4.2. Test Types
260+
261+
### Unit Tests
262+
* Can be run without a device connected
263+
* Test individual components and functions in isolation
264+
* Fast execution
265+
266+
### System Tests
267+
* **Require a device connected**
268+
* Test end-to-end functionality with actual hardware
269+
* Requirements:
270+
- H.264 encoder and decoder support
271+
- Surface texture support
272+
273+
Set the target device:
274+
```bash
275+
$ export ANDROID_SERIAL=XXX
180276
```
181277

182-
For a raw input both input and output resolution and fps needs to be specified even if raw buffer will not allow scaling (which surface encoding does).
278+
## 4.3. Test Configuration
183279

280+
### Automatic Installation
184281

185-
## 4. System/Unit testing
186-
All current tests can be run with:
187-
python3 -m pytest PATH_TO_REPO/encapp/scripts/tests/
282+
By default, the latest build will be automatically installed on the device before running tests.
188283

189-
* The unit tests can be run without a device connected.
190-
* The system tests require a device connected. To pass all tests there needs to be a h264 encodera and decoder. It also needs to have surface textures available.
284+
### Using Existing Installation
285+
286+
To run tests using the currently installed application without reinstalling:
287+
288+
```bash
289+
$ export ENCAPP_ALWAYS_INSTALL=0
191290
```
192-
$ export ANDROID_SERIAL=XXX
291+
292+
This is useful for:
293+
- Faster test iterations during development
294+
- Testing a specific installed version
295+
- Avoiding repeated installations on slow devices
296+
297+
## 4.4. Running Specific Tests
298+
299+
Run tests from a specific file:
300+
```bash
301+
$ python3 -m pytest scripts/tests/test_specific.py
193302
```
194303

195-
By default the latest build will be installed on the device. Test can also be run using the currently installed application by setting:
304+
Run a specific test function:
305+
```bash
306+
$ python3 -m pytest scripts/tests/test_specific.py::test_function_name
196307
```
197-
$ export ENCAPP_ALWAYS_INSTALL=0
308+
309+
Run with verbose output:
310+
```bash
311+
$ python3 -m pytest -v scripts/tests/
198312
```
199313
## 5. native modules
200314

0 commit comments

Comments
 (0)