(de)mux.h: wrap pseudo-code in /* */
easier to copy / read as a block Change-Id: Ia22689a13afd8ea2325dcdf432e35fc802d8177a
This commit is contained in:
parent
733a7faae4
commit
5416aab479
@ -12,37 +12,38 @@
|
||||
|
||||
// Code Example: Demuxing WebP data to extract all the frames, ICC profile
|
||||
// and EXIF/XMP metadata.
|
||||
//
|
||||
// WebPDemuxer* demux = WebPDemux(&webp_data);
|
||||
//
|
||||
// uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
|
||||
// uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
|
||||
// // ... (Get information about the features present in the WebP file).
|
||||
// uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
|
||||
//
|
||||
// // ... (Iterate over all frames).
|
||||
// WebPIterator iter;
|
||||
// if (WebPDemuxGetFrame(demux, 1, &iter)) {
|
||||
// do {
|
||||
// // ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
|
||||
// // ... and get other frame properties like width, height, offsets etc.
|
||||
// // ... see 'struct WebPIterator' below for more info).
|
||||
// } while (WebPDemuxNextFrame(&iter));
|
||||
// WebPDemuxReleaseIterator(&iter);
|
||||
// }
|
||||
//
|
||||
// // ... (Extract metadata).
|
||||
// WebPChunkIterator chunk_iter;
|
||||
// if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
|
||||
// // ... (Consume the ICC profile in 'chunk_iter.chunk').
|
||||
// WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
// if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
|
||||
// // ... (Consume the EXIF metadata in 'chunk_iter.chunk').
|
||||
// WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
// if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
|
||||
// // ... (Consume the XMP metadata in 'chunk_iter.chunk').
|
||||
// WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
// WebPDemuxDelete(demux);
|
||||
/*
|
||||
WebPDemuxer* demux = WebPDemux(&webp_data);
|
||||
|
||||
uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
|
||||
uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
|
||||
// ... (Get information about the features present in the WebP file).
|
||||
uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
|
||||
|
||||
// ... (Iterate over all frames).
|
||||
WebPIterator iter;
|
||||
if (WebPDemuxGetFrame(demux, 1, &iter)) {
|
||||
do {
|
||||
// ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
|
||||
// ... and get other frame properties like width, height, offsets etc.
|
||||
// ... see 'struct WebPIterator' below for more info).
|
||||
} while (WebPDemuxNextFrame(&iter));
|
||||
WebPDemuxReleaseIterator(&iter);
|
||||
}
|
||||
|
||||
// ... (Extract metadata).
|
||||
WebPChunkIterator chunk_iter;
|
||||
if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
|
||||
// ... (Consume the ICC profile in 'chunk_iter.chunk').
|
||||
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
|
||||
// ... (Consume the EXIF metadata in 'chunk_iter.chunk').
|
||||
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
|
||||
// ... (Consume the XMP metadata in 'chunk_iter.chunk').
|
||||
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
WebPDemuxDelete(demux);
|
||||
*/
|
||||
|
||||
#ifndef WEBP_WEBP_DEMUX_H_
|
||||
#define WEBP_WEBP_DEMUX_H_
|
||||
|
@ -17,32 +17,34 @@
|
||||
//
|
||||
// Code Example#1: Creating a MUX with image data, color profile and XMP
|
||||
// metadata.
|
||||
//
|
||||
// int copy_data = 0;
|
||||
// WebPMux* mux = WebPMuxNew();
|
||||
// // ... (Prepare image data).
|
||||
// WebPMuxSetImage(mux, &image, copy_data);
|
||||
// // ... (Prepare ICCP color profile data).
|
||||
// WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
|
||||
// // ... (Prepare XMP metadata).
|
||||
// WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
|
||||
// // Get data from mux in WebP RIFF format.
|
||||
// WebPMuxAssemble(mux, &output_data);
|
||||
// WebPMuxDelete(mux);
|
||||
// // ... (Consume output_data; e.g. write output_data.bytes to file).
|
||||
// WebPDataClear(&output_data);
|
||||
//
|
||||
/*
|
||||
int copy_data = 0;
|
||||
WebPMux* mux = WebPMuxNew();
|
||||
// ... (Prepare image data).
|
||||
WebPMuxSetImage(mux, &image, copy_data);
|
||||
// ... (Prepare ICCP color profile data).
|
||||
WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
|
||||
// ... (Prepare XMP metadata).
|
||||
WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
|
||||
// Get data from mux in WebP RIFF format.
|
||||
WebPMuxAssemble(mux, &output_data);
|
||||
WebPMuxDelete(mux);
|
||||
// ... (Consume output_data; e.g. write output_data.bytes to file).
|
||||
WebPDataClear(&output_data);
|
||||
*/
|
||||
|
||||
// Code Example#2: Get image and color profile data from a WebP file.
|
||||
//
|
||||
// int copy_data = 0;
|
||||
// // ... (Read data from file).
|
||||
// WebPMux* mux = WebPMuxCreate(&data, copy_data);
|
||||
// WebPMuxGetFrame(mux, 1, &image);
|
||||
// // ... (Consume image; e.g. call WebPDecode() to decode the data).
|
||||
// WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
||||
// // ... (Consume icc_data).
|
||||
// WebPMuxDelete(mux);
|
||||
// free(data);
|
||||
/*
|
||||
int copy_data = 0;
|
||||
// ... (Read data from file).
|
||||
WebPMux* mux = WebPMuxCreate(&data, copy_data);
|
||||
WebPMuxGetFrame(mux, 1, &image);
|
||||
// ... (Consume image; e.g. call WebPDecode() to decode the data).
|
||||
WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
||||
// ... (Consume icc_data).
|
||||
WebPMuxDelete(mux);
|
||||
free(data);
|
||||
*/
|
||||
|
||||
#ifndef WEBP_WEBP_MUX_H_
|
||||
#define WEBP_WEBP_MUX_H_
|
||||
|
Loading…
Reference in New Issue
Block a user