blob: 755a205dcc31176545f35cf64604a0b2570bae20 [file] [log] [blame]
Parker Schuh44f86922017-01-03 23:59:50 -08001#ifndef _AOS_VISION_IMAGE_JPEGROUTINES_H_
2#define _AOS_VISION_IMAGE_JPEGROUTINES_H_
3
Parker Schuh44f86922017-01-03 23:59:50 -08004#include "aos/vision/image/image_types.h"
5
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08006namespace aos::vision {
Parker Schuh44f86922017-01-03 23:59:50 -08007
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.
11bool ProcessJpeg(DataRef data, PixelRef *out);
12
13// Gets the format for the particular jpeg.
14ImageFormat 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.
21inline 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 Pleinesd99b1ee2024-02-02 20:56:44 -080029} // namespace aos::vision
Parker Schuh44f86922017-01-03 23:59:50 -080030
31#endif // _AOS_VISION_IMAGE_JPEGROUTINES_H_