File: simple_edit.cpp

package info (click to toggle)
rust-dolby-vision 3.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 904 kB
  • sloc: ansic: 246; cpp: 30; makefile: 29
file content (48 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <chrono>
#include <iostream>
#include <fstream>
#include <iterator>
#include <vector>

extern "C"
{
#include "helpers.h"
}

int main(void) {
    std::ifstream input("../../assets/tests/fel_orig.bin", std::ios::binary);

    const std::vector<uint8_t> buf(
        (std::istreambuf_iterator<char>(input)),
        (std::istreambuf_iterator<char>()));

    input.close();

    auto start = std::chrono::high_resolution_clock::now();

    DoviRpuOpaque *rpu = dovi_parse_unspec62_nalu(buf.data(), buf.size());
    const DoviRpuDataHeader *header = dovi_rpu_get_header(rpu);

    // Only converts profile 7 as they are guaranteed to be HDR10 base
    if (header && header->guessed_profile == 7) {
        // Convert the base to 8.1 compatible
        // Also handles removing mapping for FEL
        int ret = dovi_convert_rpu_with_mode(rpu, 2);

        // Final video has letterboxing completely cropped
        ret = dovi_rpu_set_active_area_offsets(rpu, 0, 0, 0, 0);

        const DoviData *rpu_payload = dovi_write_unspec62_nalu(rpu);
        
        // Do something with the edited payload
        dovi_data_free(rpu_payload);
    }

    if (header)
        dovi_rpu_free_header(header);

    dovi_rpu_free(rpu);

    auto end = std::chrono::high_resolution_clock::now();
    std::cout << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << " μs";
}