ColorConverter.h revision 1c8ed2e906576fd8d7fa03f577bdec518cbe13d7
1/*
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
23#include <stdint.h>
24
25#include <OMX_Video.h>
26
27namespace android {
28
29struct ColorConverter {
30    ColorConverter(OMX_COLOR_FORMATTYPE from, OMX_COLOR_FORMATTYPE to);
31    ~ColorConverter();
32
33    bool isValid() const;
34
35    void convert(
36            size_t width, size_t height,
37            const void *srcBits, size_t srcSkip,
38            void *dstBits, size_t dstSkip);
39
40private:
41    OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat;
42    uint8_t *mClip;
43
44    uint8_t *initClip();
45
46    void convertCbYCrY(
47            size_t width, size_t height,
48            const void *srcBits, size_t srcSkip,
49            void *dstBits, size_t dstSkip);
50
51    void convertYUV420Planar(
52            size_t width, size_t height,
53            const void *srcBits, size_t srcSkip,
54            void *dstBits, size_t dstSkip);
55
56    void convertQCOMYUV420SemiPlanar(
57            size_t width, size_t height,
58            const void *srcBits, size_t srcSkip,
59            void *dstBits, size_t dstSkip);
60
61    void convertYUV420SemiPlanar(
62            size_t width, size_t height,
63            const void *srcBits, size_t srcSkip,
64            void *dstBits, size_t dstSkip);
65
66    ColorConverter(const ColorConverter &);
67    ColorConverter &operator=(const ColorConverter &);
68};
69
70}  // namespace android
71
72#endif  // COLOR_CONVERTER_H_
73