blob: 85ba9206835c229f7204b2443c1898c6ced6171e [file] [log] [blame]
Andreas Huber53a76bd2009-10-06 16:20:44 -07001/*
2 * Copyright (C) 2009 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 COLOR_CONVERTER_H_
18
19#define COLOR_CONVERTER_H_
20
21#include <sys/types.h>
22
Andreas Huber9b8f9472009-10-09 09:06:06 -070023#include <stdint.h>
Andreas Huberf341eb52011-01-06 11:26:54 -080024#include <utils/Errors.h>
Andreas Huber9b8f9472009-10-09 09:06:06 -070025
Andreas Huber53a76bd2009-10-06 16:20:44 -070026#include <OMX_Video.h>
27
28namespace android {
29
30struct ColorConverter {
31 ColorConverter(OMX_COLOR_FORMATTYPE from, OMX_COLOR_FORMATTYPE to);
32 ~ColorConverter();
33
34 bool isValid() const;
35
Andreas Huberf341eb52011-01-06 11:26:54 -080036 status_t convert(
Andreas Huber1bb0ffd2010-11-22 13:06:35 -080037 const void *srcBits,
38 size_t srcWidth, size_t srcHeight,
39 size_t srcCropLeft, size_t srcCropTop,
40 size_t srcCropRight, size_t srcCropBottom,
41 void *dstBits,
42 size_t dstWidth, size_t dstHeight,
43 size_t dstCropLeft, size_t dstCropTop,
44 size_t dstCropRight, size_t dstCropBottom);
Andreas Huber53a76bd2009-10-06 16:20:44 -070045
46private:
Andreas Huber1bb0ffd2010-11-22 13:06:35 -080047 struct BitmapParams {
48 BitmapParams(
49 void *bits,
50 size_t width, size_t height,
51 size_t cropLeft, size_t cropTop,
52 size_t cropRight, size_t cropBottom);
53
54 size_t cropWidth() const;
55 size_t cropHeight() const;
56
57 void *mBits;
58 size_t mWidth, mHeight;
59 size_t mCropLeft, mCropTop, mCropRight, mCropBottom;
60 };
61
Andreas Huber53a76bd2009-10-06 16:20:44 -070062 OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat;
63 uint8_t *mClip;
64
65 uint8_t *initClip();
66
Andreas Huberf341eb52011-01-06 11:26:54 -080067 status_t convertCbYCrY(
Andreas Huber1bb0ffd2010-11-22 13:06:35 -080068 const BitmapParams &src, const BitmapParams &dst);
Andreas Huber53a76bd2009-10-06 16:20:44 -070069
Andreas Huberf341eb52011-01-06 11:26:54 -080070 status_t convertYUV420Planar(
Andreas Huber1bb0ffd2010-11-22 13:06:35 -080071 const BitmapParams &src, const BitmapParams &dst);
Andreas Huber53a76bd2009-10-06 16:20:44 -070072
Andreas Huberf341eb52011-01-06 11:26:54 -080073 status_t convertQCOMYUV420SemiPlanar(
Andreas Huber1bb0ffd2010-11-22 13:06:35 -080074 const BitmapParams &src, const BitmapParams &dst);
Andreas Huber53a76bd2009-10-06 16:20:44 -070075
Andreas Huberf341eb52011-01-06 11:26:54 -080076 status_t convertYUV420SemiPlanar(
Andreas Huber1bb0ffd2010-11-22 13:06:35 -080077 const BitmapParams &src, const BitmapParams &dst);
Andreas Huberc543a212010-06-30 10:32:20 -070078
Anu Sundararajand35df442011-06-22 12:24:46 -050079 status_t convertTIYUV420PackedSemiPlanar(
80 const BitmapParams &src, const BitmapParams &dst);
81
Andreas Huber53a76bd2009-10-06 16:20:44 -070082 ColorConverter(const ColorConverter &);
83 ColorConverter &operator=(const ColorConverter &);
84};
85
86} // namespace android
87
88#endif // COLOR_CONVERTER_H_