blob: 5dd425bf245c21b7a684e1931f5c28842365eb4c [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
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
26namespace android {
27
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080028// Represents a color converted (RGB-based) video frame
29// with bitmap pixels stored in FrameBuffer
30class VideoFrame
31{
32public:
Christer Fletcher10db4522012-09-13 10:28:39 +020033 VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0), mData(0),
34 mRotationAngle(0) {}
Glenn Kastene53b9ea2012-03-12 16:29:55 -070035
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080036 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 Fletcher10db4522012-09-13 10:28:39 +020051 mRotationAngle = copy.mRotationAngle;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080052 }
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 Dongce0feba2010-11-08 16:04:27 -080067 int32_t mRotationAngle; // rotation angle, clockwise
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080068};
69
70}; // namespace android
71
72#endif // ANDROID_VIDEO_FRAME_H