Skip to content

Commit 687221a

Browse files
committed
Include READMEs directly due to broken cargo readme.
1 parent 91a60b5 commit 687221a

6 files changed

Lines changed: 38 additions & 514 deletions

File tree

README.md

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
[![crates.io-badge]][crates.io-url]
32
[![docs.rs-badge]][docs.rs-url]
43
![license-badge]
@@ -11,11 +10,11 @@ Idiomatic and low-level bindings for [OpenH264](https://github.com/cisco/openh26
1110

1211
![sample_image](https://media.githubusercontent.com/media/ralfbiedert/openh264-rs/master/gfx/title3.jpg)
1312

14-
1513
### Example API
1614

1715
**Decode** some H.264 bitstream to YUV:
18-
```rust
16+
17+
```rust,ignore
1918
use openh264::decoder::Decoder;
2019
use openh264::nal_units;
2120
@@ -30,9 +29,9 @@ for packet in nal_units(h264_in) {
3029
}
3130
```
3231

33-
3432
And **encode** the same YUV back to H.264:
35-
```rust
33+
34+
```rust,ignore
3635
use openh264::encoder::Encoder;
3736
3837
let mut encoder = Encoder::new()?;
@@ -45,21 +44,21 @@ let bitstream = encoder.encode(&yuv)?;
4544

4645
Test results on various platforms:
4746

48-
| Platform | Compiled | Unit Tested |
49-
| --- | --- | --- |
50-
| `x86_64-pc-windows-msvc` |||
51-
| `x86_64-pc-windows-gnu` |||
52-
| `x86_64-unknown-linux-gnu` |||
53-
| `x86_64-apple-darwin` |||
54-
| `i686-unknown-linux-gnu` |||
55-
| `i686-pc-windows-msvc` |||
56-
| `i686-pc-windows-gnu` |||
57-
| `armv7-unknown-linux-gnueabihf` || - |
58-
| `aarch64-unknown-linux-gnu` || - |
59-
| `aarch64-apple-darwin` || - |
60-
| `aarch64-pc-windows-msvc` || - |
61-
| `aarch64-linux-android` | 🆗<sup>1</sup> | - |
62-
| `wasm32-unknown-unknown` | ❌<sup>2</sup> | - |
47+
| Platform | Compiled | Unit Tested |
48+
|---------------------------------|----------------|-------------|
49+
| `x86_64-pc-windows-msvc` | | |
50+
| `x86_64-pc-windows-gnu` | | |
51+
| `x86_64-unknown-linux-gnu` | | |
52+
| `x86_64-apple-darwin` | | |
53+
| `i686-unknown-linux-gnu` | | |
54+
| `i686-pc-windows-msvc` | | |
55+
| `i686-pc-windows-gnu` | | |
56+
| `armv7-unknown-linux-gnueabihf` | | - |
57+
| `aarch64-unknown-linux-gnu` | | - |
58+
| `aarch64-apple-darwin` | | - |
59+
| `aarch64-pc-windows-msvc` | | - |
60+
| `aarch64-linux-android` | 🆗<sup>1</sup> | - |
61+
| `wasm32-unknown-unknown` | ❌<sup>2</sup> | - |
6362

6463
✅ works out of the box;
6564
🆗 the usual shenanigans required;
@@ -68,12 +67,11 @@ Test results on various platforms:
6867
<sup>1</sup> via `cargo build --target <platform>`, [needs `CXX` set](https://cheats.rs/#cross-compilation) and `libc++_shared.so`. <br/>
6968
<sup>2</sup> unclear if could ever work, investigation welcome
7069

71-
7270
### Performance
7371

7472
Tested on a Ryzen 9 7950X3D, Windows 11, single threaded de- and encoding:
7573

76-
```
74+
```text,ignore
7775
-- Default --
7876
test decode_yuv_single_1920x1080 ... bench: 5,696,370.00 ns/iter (+/- 1,892,038.50)
7977
test decode_yuv_single_512x512_cabac ... bench: 1,103,065.00 ns/iter (+/- 49,763.50)
@@ -91,37 +89,33 @@ test encode_512x512_from_yuv ... bench: 1,828,287.50 ns/iter (+/- 190,
9189
-- Color Conversion if "target-cpu=native" --
9290
test convert_yuv_to_rgb_1920x1080 ... bench: 1,362,640.00 ns/iter (+/- 23,317.00)
9391
test convert_yuv_to_rgb_512x512 ... bench: 174,687.50 ns/iter (+/- 7,185.75)
92+
test convert_rgb8_to_yuv_1920x1080 ... bench: 369,210.00 ns/iter (+/- 53,579.00)
93+
test convert_rgb8_to_yuv_512x512 ... bench: 52,333.59 ns/iter (+/- 4,818.80)
9494
```
9595

9696
### Compile Features
9797

9898
- `source` - Uses the bundled OpenH264 source; works out of the box (default).
9999
- `libloading` - You'll need to provide Cisco's prebuilt library.
100100

101-
102101
### FAQ
103102

104103
- **How does `openh264-sys2` differ from `openh264-sys`?**
105104

106-
We directly ship OpenH264 source code and provide simple, hand-crafted compilation via `cc` in `build.rs`. Our`openh264-sys2` crate should compile via `cargo build` out of the box on most platforms, and cross-compile via `cargo build --target ...` as
107-
long as the environment variable `CXX` is properly set.
105+
We directly ship OpenH264 source code and provide simple, hand-crafted compilation via `cc` in `build.rs`. Our `openh264-sys2` crate should compile via `cargo build` out of the box on most platforms, and cross-compile via `cargo build --target ...` as long as the environment variable `CXX` is properly set.
108106

109107
- **Which exact OpenH264 version does this use?**
110108

111109
See [this file](https://github.com/ralfbiedert/openh264-rust/tree/master/openh264-sys2/upstream/VERSION) for the upstream URL and Git hash used on latest master.
112110

113111
- **I need to fix an important OpenH264 security hole, how can I update the library?**
114112

115-
Cisco's OpenH264 library is contained in `openh264-sys2/upstream`. Updating is as simple as [pulling their latest source](https://github.com/cisco/openh264),
116-
and running `update_openh264.sh` (and, if APIs changed, `regen-bindings.bat`).
113+
Cisco's OpenH264 library is contained in `openh264-sys2/upstream`. Updating is as simple as [pulling their latest source](https://github.com/cisco/openh264), and running `update_openh264.sh` (and, if APIs changed, `regen-bindings.bat`).
117114

118115

119116
- **I heard Rust is super-safe, will this make decoding my videos safe too?**
120117

121-
No. Below a thin Rust layer we rely on a _very complex_ C library, and an equally complex standard. Apart from Rust being a
122-
much nicer language to work with, depending on this project will give you _no_ additional safety guarantees as far as video
123-
handling is concerned. FYI, this is _not_ making a statement about OpenH264, but about the realities of securing +50k lines
124-
of C against attacks.
118+
No. Below a thin Rust layer we rely on a _very complex_ C library, and an equally complex standard. Apart from Rust being a much nicer language to work with, depending on this project will give you _no_ additional safety guarantees as far as video handling is concerned. FYI, this is _not_ making a statement about OpenH264, but about the realities of securing +50k lines of C against attacks.
125119

126120

127121
- **Feature X is missing or broken, will you fix it?**
@@ -131,33 +125,23 @@ test convert_yuv_to_rgb_512x512 ... bench: 174,687.50 ns/iter (+/- 7,18
131125

132126
- **Can I get a performance boost?**
133127

134-
- Make sure you have the command `nasm` somewhere in your PATH for your current platform (should be a single, standalone
135-
executable you don't even need to install). If found by `build.rs` it should be used automatically for an up to 3x speed
136-
boost for encoding / decoding.
137-
- Also compile your project with `target-cpu=native` for a 3x speed boost for YUV-to-RGB conversion (e.g., check
138-
our `.cargo/config.toml` how you can easily do that for your project. Note this only works if you are an application,
139-
not a library wrapping us).
128+
- Make sure you have the command `nasm` somewhere in your PATH for your current platform (should be a single, standalone executable you don't even need to install). If found by `build.rs` it should be used automatically for an up to 3x speed boost for encoding / decoding.
129+
- Also compile your project with `target-cpu=native` for a 3x speed boost for YUV-to-RGB conversion (e.g., check our `.cargo/config.toml` how you can easily do that for your project. Note this only works if you are an application, not a library wrapping us).
140130

141131

142132
- **Decoder::decode() returned an error, is this a bug?**
143133

144-
Maybe. Probably not. Some encoders can write data OpenH264 doesn't understand, and if _all_ frames fail this could either
145-
be your encoder doing exotic things, OpenH264 not having implemented a certain feature, or
146-
us having a bug.
134+
Maybe. Probably not. Some encoders can write data OpenH264 doesn't understand, and if _all_ frames fail this could either be your encoder doing exotic things, OpenH264 not having implemented a certain feature, or us having a bug.
147135

148-
If only _some_ frames fail the most likely reasons are your encoder injecting _some_ special
149-
packets or transmission errors. In other words, unless you have a controlled setup you should not terminate on
150-
the first error(s), but simply continue decoding and hope for the decoder to recover.
136+
If only _some_ frames fail the most likely reasons are your encoder injecting _some_ special packets or transmission errors. In other words, unless you have a controlled setup you should not terminate on the first error(s), but simply continue decoding and hope for the decoder to recover.
151137

152-
FWIW, we consider OpenH264's `h264dec` the reference decoder. If you can get it to emit YUV it would be a bug
153-
if we can't. However, any stream / frame it fails on is pretty much a _wontfix_ for us.
138+
FWIW, we consider OpenH264's `h264dec` the reference decoder. If you can get it to emit YUV it would be a bug if we can't. However, any stream / frame it fails on is pretty much a _wontfix_ for us.
154139

155140

156141
- **What's the deal with the `source` and `libloading` features?**
157142

158143
See [this issue](https://github.com/ralfbiedert/openh264-rs/issues/43).
159144

160-
161145
### Contributing
162146

163147
PRs are very welcome. Feel free to submit PRs and fixes right away. You can open issues if you want to discuss things, but due to time restrictions on my side the project will have to rely on people contributing.
@@ -168,19 +152,18 @@ Especially needed:
168152
- [ ] User-pluggable and color conversions
169153
- [ ] WASM investigation (either patch, or evidence it can't be fixed)
170154
- [ ] Feedback which platforms successfully built on
171-
- [ ] Faster RGB-to-YUV conversion similar to the current SIMD YUV-to-RGB one.
172-
- [x] Faster YUV-to-RGB conversion (done in [#66](https://github.com/ralfbiedert/openh264-rs/pull/66))
173155

174-
Big shout-out to all the [contributors](https://github.com/ralfbiedert/openh264-rs/graphs/contributors) who have filed
175-
PRs so far.
156+
Big shout-out to all the [contributors](https://github.com/ralfbiedert/openh264-rs/graphs/contributors) who have filed PRs so far.
176157

177158
Special thanks to:
178159

179-
- Jannik Schleicher for addressing the long-standing issue of faster YUV-to-RGB conversion, which resulted in a more than 3x speedup.
180-
160+
- Jannik Schleicher for 3x faster YUV-to-RGB conversion.
161+
- Charlie Zheng for 14x faster RGB-to-YUV conversion.
181162

182163
### Changelog
183164

165+
- **v0.9** - Edition change to 2024.
166+
- **v0.8** - API changes.
184167
- **v0.7** - UX improvements, encoder options, SIMD YUV-to-RGB.
185168
- **v0.6** - Encoder supports dynamic resolution; API cleanup.
186169
- **v0.5** - Can now use built-in source, or Cisco's prebuilt library.

openh264-sys2/src/lib.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
1-
//!
2-
//! [![Latest Version]][crates.io]
3-
//! [![docs]][docs.rs]
4-
//! ![BSD-2]
5-
//! [![Rust](https://img.shields.io/badge/rust-1.65%2B-blue.svg?maxAge=3600)](https://github.com/ralfbiedert/openh264-rust)
6-
//!
7-
//!
8-
//! This low-level crate used by [openh264](https://crates.io/crates/openh264)
9-
//! contains
10-
//!
11-
//! - a fully self-contained version of OpenH264
12-
//! - alternatively, a libloading wrapper around precompiled OpenH264 binaries
13-
//! - `unsafe` Rust bindings
14-
//! - build logic that should work "out of the box" on most platforms (sans bugs)
15-
//!
16-
//! [Latest Version]: https://img.shields.io/crates/v/openh264-sys2.svg
17-
//! [crates.io]: https://crates.io/crates/openh264-sys2
18-
//! [BSD-2]: https://img.shields.io/badge/license-BSD2-blue.svg
19-
//! [docs]: https://docs.rs/openh264-sys2/badge.svg
20-
//! [docs.rs]: https://docs.rs/openh264-sys2/
21-
221
#![allow(non_snake_case)]
232
#![allow(unpredictable_function_pointer_comparisons)]
243
#![allow(non_camel_case_types)]
254
#![allow(non_upper_case_globals)]
265
#![allow(clippy::missing_safety_doc)]
6+
#![doc = include_str!("../README.md")]
277

288
mod error;
299

openh264/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license.workspace = true
1010
repository.workspace = true
1111
rust-version.workspace = true
1212
version.workspace = true
13+
readme = "../README.md"
1314

1415
exclude = [
1516
"**/*.h264",

0 commit comments

Comments
 (0)