Home | History | Annotate | Download | only in arc
      1 /* Copyright 2017 The Chromium OS Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file.
      4  */
      5 
      6 #ifndef HAL_USB_IMAGE_PROCESSOR_H_
      7 #define HAL_USB_IMAGE_PROCESSOR_H_
      8 
      9 #include <string>
     10 
     11 // FourCC pixel formats (defined as V4L2_PIX_FMT_*).
     12 #include <linux/videodev2.h>
     13 // Declarations of HAL_PIXEL_FORMAT_XXX.
     14 #include <system/graphics.h>
     15 
     16 #include <camera/CameraMetadata.h>
     17 #include "frame_buffer.h"
     18 
     19 namespace arc {
     20 
     21 // V4L2_PIX_FMT_YVU420(YV12) in ImageProcessor has alignment requirement.
     22 // The stride of Y, U, and V planes should a multiple of 16 pixels.
     23 struct ImageProcessor {
     24   // Calculate the output buffer size when converting to the specified pixel
     25   // format. |fourcc| is defined as V4L2_PIX_FMT_* in linux/videodev2.h.
     26   // Return 0 on error.
     27   static size_t GetConvertedSize(int fourcc, uint32_t width, uint32_t height);
     28 
     29   // Return whether this class supports the provided conversion.
     30   static bool SupportsConversion(uint32_t from_fourcc, uint32_t to_fourcc);
     31 
     32   // Convert format from |in_frame.fourcc| to |out_frame->fourcc|. Caller should
     33   // fill |data|, |buffer_size|, |width|, and |height| of |out_frame|. The
     34   // function will fill |out_frame->data_size|. Return non-zero error code on
     35   // failure; return 0 on success.
     36   static int ConvertFormat(const android::CameraMetadata& metadata,
     37                            const FrameBuffer& in_frame, FrameBuffer* out_frame);
     38 
     39   // Scale image size according to |in_frame| and |out_frame|. Only support
     40   // V4L2_PIX_FMT_YUV420 format. Caller should fill |data|, |width|, |height|,
     41   // and |buffer_size| of |out_frame|. The function will fill |data_size| and
     42   // |fourcc| of |out_frame|.
     43   static int Scale(const FrameBuffer& in_frame, FrameBuffer* out_frame);
     44 };
     45 
     46 }  // namespace arc
     47 
     48 #endif  // HAL_USB_IMAGE_PROCESSOR_H_
     49