jpeg_encode_accelerator.mojom 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2018 The Chromium 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. module chromeos_camera.mojom;
  5. import "components/chromeos_camera/common/dmabuf.mojom";
  6. import "media/mojo/mojom/media_types.mojom";
  7. // Encode errors (see components/chromeos_camera/jpeg_encode_accelerator.h).
  8. enum EncodeStatus {
  9. ENCODE_OK,
  10. HW_JPEG_ENCODE_NOT_SUPPORTED,
  11. THREAD_CREATION_FAILED,
  12. INVALID_ARGUMENT,
  13. INACCESSIBLE_OUTPUT_BUFFER,
  14. PARSE_IMAGE_FAILED,
  15. PLATFORM_FAILURE,
  16. };
  17. // GPU process interface exposed to the browser for encoding JPEG images.
  18. interface JpegEncodeAccelerator {
  19. // Initializes the JPEG encoder. Should be called once per encoder
  20. // construction and before using EncodeWithFD(). This call returns true if
  21. // initialization is successful.
  22. Initialize() => (bool success);
  23. // TODO(wtlee): To be deprecated. (crbug.com/944705)
  24. //
  25. // Encodes the given buffer that contains one I420 image.
  26. // |input_fd| and |output_fd| are file descriptors of shared memory.
  27. // The image is encoded from memory of |input_fd|
  28. // with size |input_buffer_size|. |task_id| is used to distinguish different
  29. // tasks. The dimension of I420 image is |coded_size_width| and
  30. // |coded_size_height|.
  31. // |exif_fd| is the shared memory buffer, with |exif_buffer_size| as size,
  32. // containing Exif data which will be put onto APP1 segment in the output
  33. // JPEG image.
  34. // Encoded JPEG image will be put onto memory associated with |output_fd|
  35. // with allocated size |output_buffer_size|.
  36. // Returns |task_id| and |error| in a callback to notify the
  37. // encode status. |status| is the status code. |encoded_buffer_size| is the
  38. // actual size of the encoded JPEG.
  39. EncodeWithFD(int32 task_id, handle input_fd, uint32 input_buffer_size,
  40. int32 coded_size_width, int32 coded_size_height,
  41. handle exif_fd, uint32 exif_buffer_size,
  42. handle output_fd, uint32 output_buffer_size)
  43. => (int32 task_id, uint32 encoded_buffer_size, EncodeStatus status);
  44. // Encodes the given DMA-buf. |task_id| is used to distinguish different
  45. // tasks. The size of input image defined in |coded_size_width| and
  46. // |coded_size_height| and the format |input_format| represents by its fourcc
  47. // value. The plane information of input DMA-buf and output DMA-buf is stored
  48. // in |input_planes| and |output_planes| respectively. Although the actual
  49. // amount of buffers could be equal to or less than the number of planes, the
  50. // amount of plane information |input_planes| and |output_planes| should be
  51. // same as the number of planes. |exif_handle| is the shared memory buffer,
  52. // with |exif_buffer_size| as size, containing Exif data which will be put
  53. // onto APP1 segment in the output JPEG image. |quality| is the quality of
  54. // JPEG image. The range is from 1~100. High value means high quality. When
  55. // the task ends, it returns |status| as the status code and
  56. // |encoded_buffer_size| is the actual size of the encoded JPEG.
  57. EncodeWithDmaBuf(
  58. int32 task_id,
  59. uint32 input_format,
  60. array<DmaBufPlane> input_planes,
  61. array<DmaBufPlane> output_planes,
  62. handle exif_handle,
  63. uint32 exif_buffer_size,
  64. int32 coded_size_width,
  65. int32 coded_size_height,
  66. int32 quality)
  67. => (uint32 encoded_buffer_size, EncodeStatus status);
  68. };