summaryrefslogtreecommitdiff
path: root/v3/JpegCompressor.h (plain)
blob: a6454d21a6c49d5db9b6b0f3b20eb0227564cf07
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef HW_EMULATOR_CAMERA_JPEG_COMPRESSOR_H
18#define HW_EMULATOR_CAMERA_JPEG_COMPRESSOR_H
19
20/*
21 * Contains declaration of a class NV21JpegCompressor that encapsulates a
22 * converter between YV21, and JPEG formats.
23 */
24
25#include "JpegStub.h"
26#include <utils/threads.h>
27
28namespace android {
29
30/* Encapsulates a converter between YV12, and JPEG formats.
31 */
32class NV21JpegCompressor
33{
34public:
35 /* Constructs JpegCompressor instance. */
36 NV21JpegCompressor();
37 /* Destructs JpegCompressor instance. */
38 ~NV21JpegCompressor();
39
40 /****************************************************************************
41 * Public API
42 ***************************************************************************/
43
44public:
45 /* Compresses raw NV21 image into a JPEG.
46 * The compressed image will be saved in mStream member of this class. Use
47 * getCompressedSize method to obtain buffer size of the compressed image,
48 * and getCompressedImage to copy out the compressed image.
49 * Param:
50 * image - Raw NV21 image.
51 * width, height - Image dimensions.
52 * quality - JPEG quality.
53 * Return:
54 * NO_ERROR on success, or an appropriate error status.
55 *
56 */
57 status_t compressRawImage(const void* image,
58 int width,
59 int height,
60 int quality);
61
62 /* Get size of the compressed JPEG buffer.
63 * This method must be called only after a successful completion of
64 * compressRawImage call.
65 * Return:
66 * Size of the compressed JPEG buffer.
67 */
68 size_t getCompressedSize();
69
70 /* Copies out compressed JPEG buffer.
71 * This method must be called only after a successful completion of
72 * compressRawImage call.
73 * Param:
74 * buff - Buffer where to copy the JPEG. Must be large enough to contain the
75 * entire image.
76 */
77 void getCompressedImage(void* buff);
78
79 /****************************************************************************
80 * Class data
81 ***************************************************************************/
82
83protected:
84 /* Strides for Y (the first element), and UV (the second one) panes. */
85 int mStrides[2];
86
87private:
88 // library handle to dlopen
89 static void* mDl;
90 JpegStub mStub;
91};
92
93}; /* namespace android */
94
95#endif /* HW_EMULATOR_CAMERA_JPEG_COMPRESSOR_H */
96