Skip to main content

webp_encode

Function webp_encode 

Source
#[unsafe(export_name = "WebPEncode")]
pub unsafe extern "C" fn webp_encode( config: *const WebPConfig, picture: *mut WebPPicture, ) -> c_int
Expand description

Main encoding call: compresses the picture with config and writes the data through picture->writer. Returns 0 on error, recorded in picture->error_code; NULL arguments return 0.

The call lends the planes that C’s path reads or writes, and nothing when the configuration or the picture fails C’s validation. The translation encodes with zeroed copies of the statistics and of the extra_info map (one byte per macroblock): the statistics go back to *picture->stats once the validation has passed, where C resets and fills them. The map goes back to picture->extra_info when the lossy encoder ran, also after a failure (C fills it one macroblock at a time; the entries it did not reach are zero here and untouched in C), and when a lossless encoding succeeds, where C zeroes it.

§Safety

config is null or a valid configuration; picture is null or a valid picture whose planes are writable for its dimensions, whose memory fields are null or blocks of the platform malloc, and whose writer, stats and extra_info meet encode.h’s contract.