Parker Schuh | 44f8692 | 2017-01-03 23:59:50 -0800 | [diff] [blame] | 1 | #ifndef _AOS_VISION_IMAGE_JPEGROUTINES_H_ |
| 2 | #define _AOS_VISION_IMAGE_JPEGROUTINES_H_ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <unistd.h> |
| 7 | #include "aos/vision/image/image_types.h" |
| 8 | |
| 9 | namespace aos { |
| 10 | namespace vision { |
| 11 | |
| 12 | // Returns true if successful false if an error was encountered. |
| 13 | // Will decompress data into out. Out must be of the right size |
| 14 | // as determined below. |
| 15 | bool ProcessJpeg(DataRef data, PixelRef *out); |
| 16 | |
| 17 | // Gets the format for the particular jpeg. |
| 18 | ImageFormat GetFmt(DataRef data); |
| 19 | |
| 20 | // Decodes jpeg from data. Will resize if necessary. |
| 21 | // (Should not be necessary in most normal cases). |
| 22 | // |
| 23 | // Consider this the canonical way to decode jpegs if no other |
| 24 | // choice is given. |
| 25 | inline bool DecodeJpeg(DataRef data, ImageValue *value) { |
| 26 | auto fmt = GetFmt(data); |
| 27 | if (!value->fmt().Equals(fmt)) { |
| 28 | *value = ImageValue(fmt); |
| 29 | } |
| 30 | return ProcessJpeg(data, value->data()); |
| 31 | } |
| 32 | |
| 33 | } // namespace vision |
| 34 | } // namespace aos |
| 35 | |
| 36 | #endif // _AOS_VISION_IMAGE_JPEGROUTINES_H_ |