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