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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::ffi::{CString, c_void};
use std::os::raw::{c_char, c_int};
use libc::{size_t, c_float};
use crate::sys::webp::{
    self as webp_sys,
    WebPConfig,
    WebPPicture,
};

/// Picture is uninitialized.
pub fn empty_lossless_webp_picture() -> WebPPicture {
    WebPPicture {
        use_argb: 1,

        // YUV input
        colorspace: webp_sys::WEBP_YUV420,
        width: 0,
        height: 0,
        y: std::ptr::null_mut(),
        u: std::ptr::null_mut(),
        v: std::ptr::null_mut(),
        y_stride: 0,
        uv_stride: 0,
        a: std::ptr::null_mut(),
        a_stride: 0,
        pad1: [0, 0],
        
        // ARGB input
        argb: std::ptr::null_mut(),
        argb_stride: 0,
        pad2: [
            0,
            0,
            0,
        ],

        // OUTPUT
        writer: None,
        custom_ptr: std::ptr::null_mut(),
        extra_info_type: 0,
        extra_info: std::ptr::null_mut(),
        
        // STATS AND REPORTS
        stats: std::ptr::null_mut(),
        error_code: webp_sys::VP8_ENC_OK,
        progress_hook: None,
        user_data: std::ptr::null_mut(),
        
        // padding for later use
        pad3: [0, 0, 0],
        
        // Unused for now
        pad4: std::ptr::null_mut(),
        pad5: std::ptr::null_mut(),

        // padding for later use
        pad6: [0, 0, 0, 0, 0, 0, 0, 0],

        // PRIVATE FIELDS
        memory_: std::ptr::null_mut(),
        memory_argb_: std::ptr::null_mut(),
        pad7: [std::ptr::null_mut(), std::ptr::null_mut()],
    }
}

/// Picture is uninitialized.
pub fn empty_lossy_webp_picture() -> WebPPicture {
    let mut picture = empty_lossless_webp_picture();
    picture.use_argb = 0;
    picture
}