OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 Google Inc. |
| 2 // |
| 3 // This code is licensed under the same terms as WebM: |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
| 6 // ----------------------------------------------------------------------------- |
| 7 // |
| 8 // Low-level API for VP8 decoder |
| 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) |
| 11 |
| 12 #ifndef WEBP_DECODE_WEBP_DECODE_VP8_H_ |
| 13 #define WEBP_DECODE_WEBP_DECODE_VP8_H_ |
| 14 |
| 15 #include "decode.h" |
| 16 |
| 17 #if defined(__cplusplus) || defined(c_plusplus) |
| 18 extern "C" { |
| 19 #endif |
| 20 |
| 21 //----------------------------------------------------------------------------- |
| 22 // Lower-level API |
| 23 // |
| 24 // Thes functions provide fine-grained control of the decoding process. |
| 25 // The call flow should resemble: |
| 26 // |
| 27 // VP8Io io; |
| 28 // VP8InitIo(&io); |
| 29 // io.data = data; |
| 30 // io.data_size = size; |
| 31 // /* customize io's functions (setup()/put()/teardown()) if needed. */ |
| 32 // |
| 33 // VP8Decoder* dec = VP8New(); |
| 34 // bool ok = VP8Decode(dec); |
| 35 // if (!ok) printf("Error: %s\n", VP8StatusMessage(dec)); |
| 36 // VP8Delete(dec); |
| 37 // return ok; |
| 38 |
| 39 // Input / Output |
| 40 typedef struct VP8Io VP8Io; |
| 41 struct VP8Io { |
| 42 // set by VP8GetHeaders() |
| 43 int width, height; // picture dimensions, in pixels |
| 44 |
| 45 // set before calling put() |
| 46 int mb_x, mb_y; // position of the current sample (in pixels) |
| 47 int mb_w, mb_h; // size of the current sample (usually 16x16) |
| 48 const uint8_t *y, *u, *v; // samples to copy |
| 49 int y_stride; // stride for luma |
| 50 int uv_stride; // stride for chroma |
| 51 |
| 52 void* opaque; // user data |
| 53 |
| 54 // called when fresh samples are available (1 block of 16x16 pixels) |
| 55 void (*put)(const VP8Io* io); |
| 56 |
| 57 // called just before starting to decode the blocks |
| 58 void (*setup)(const VP8Io* io); |
| 59 |
| 60 // called just after block decoding is finished |
| 61 void (*teardown)(const VP8Io* io); |
| 62 |
| 63 // Input buffer. |
| 64 uint32_t data_size; |
| 65 const uint8_t* data; |
| 66 }; |
| 67 |
| 68 // Main decoding object. This is an opaque structure. |
| 69 typedef struct VP8Decoder VP8Decoder; |
| 70 |
| 71 // Create a new decoder object. |
| 72 VP8Decoder* VP8New(); |
| 73 |
| 74 // Can be called to make sure 'io' is initialized properly. |
| 75 void VP8InitIo(VP8Io* const io); |
| 76 |
| 77 // Start decoding a new picture. Returns true if ok. |
| 78 int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io); |
| 79 |
| 80 // Decode a picture. Will call VP8GetHeaders() if it wasn't done already. |
| 81 int VP8Decode(VP8Decoder* const dec, VP8Io* const io); |
| 82 |
| 83 // Return current status of the decoder: |
| 84 // 0 = OK |
| 85 // 1 = OUT_OF_MEMORY |
| 86 // 2 = INVALID_PARAM |
| 87 // 3 = BITSTREAM_ERROR |
| 88 // 4 = UNSUPPORTED_FEATURE |
| 89 int VP8Status(VP8Decoder* const dec); |
| 90 |
| 91 // return readable string corresponding to the last status. |
| 92 const char* VP8StatusMessage(VP8Decoder* const dec); |
| 93 |
| 94 // Resets the decoder in its initial state, reclaiming memory. |
| 95 // Not a mandatory call between calls to VP8Decode(). |
| 96 void VP8Clear(VP8Decoder* const dec); |
| 97 |
| 98 // Destroy the decoder object. |
| 99 void VP8Delete(VP8Decoder* const dec); |
| 100 |
| 101 //----------------------------------------------------------------------------- |
| 102 |
| 103 #if defined(__cplusplus) || defined(c_plusplus) |
| 104 } // extern "C" |
| 105 #endif |
| 106 |
| 107 #endif // WEBP_DECODE_WEBP_DECODE_VP8_H_ |
OLD | NEW |