The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright (C) 2008 The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef ANDROID_VIDEO_FRAME_H |
| 19 | #define ANDROID_VIDEO_FRAME_H |
| 20 | |
| 21 | #include <stdint.h> |
| 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <utils/Log.h> |
| 25 | |
| 26 | namespace android { |
| 27 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | // Represents a color converted (RGB-based) video frame |
| 29 | // with bitmap pixels stored in FrameBuffer |
| 30 | class VideoFrame |
| 31 | { |
| 32 | public: |
Christer Fletcher | 10db452 | 2012-09-13 10:28:39 +0200 | [diff] [blame] | 33 | VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0), mData(0), |
| 34 | mRotationAngle(0) {} |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 35 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | VideoFrame(const VideoFrame& copy) { |
| 37 | mWidth = copy.mWidth; |
| 38 | mHeight = copy.mHeight; |
| 39 | mDisplayWidth = copy.mDisplayWidth; |
| 40 | mDisplayHeight = copy.mDisplayHeight; |
| 41 | mSize = copy.mSize; |
| 42 | mData = NULL; // initialize it first |
| 43 | if (mSize > 0 && copy.mData != NULL) { |
| 44 | mData = new uint8_t[mSize]; |
| 45 | if (mData != NULL) { |
| 46 | memcpy(mData, copy.mData, mSize); |
| 47 | } else { |
| 48 | mSize = 0; |
| 49 | } |
| 50 | } |
Christer Fletcher | 10db452 | 2012-09-13 10:28:39 +0200 | [diff] [blame] | 51 | mRotationAngle = copy.mRotationAngle; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | ~VideoFrame() { |
| 55 | if (mData != 0) { |
| 56 | delete[] mData; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // Intentional public access modifier: |
| 61 | uint32_t mWidth; |
| 62 | uint32_t mHeight; |
| 63 | uint32_t mDisplayWidth; |
| 64 | uint32_t mDisplayHeight; |
| 65 | uint32_t mSize; // Number of bytes in mData |
| 66 | uint8_t* mData; // Actual binary data |
James Dong | ce0feba | 2010-11-08 16:04:27 -0800 | [diff] [blame] | 67 | int32_t mRotationAngle; // rotation angle, clockwise |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | }; // namespace android |
| 71 | |
| 72 | #endif // ANDROID_VIDEO_FRAME_H |