blob: 51050cde1f2987bc756a6f18ee8cb421075b566f [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:
Colin Crossb8c35f92017-04-27 16:15:51 -070033 VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0),
34 mRotationAngle(0), mData(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
Marco Nelissen04906862014-10-09 09:47:12 -070066 int32_t mRotationAngle; // rotation angle, clockwise, should be multiple of 90
67 // mData should be 64 bit aligned to prevent additional padding
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080068 uint8_t* mData; // Actual binary data
Marco Nelissen04906862014-10-09 09:47:12 -070069 // pad structure so it's the same size on 64 bit and 32 bit
70 char mPadding[8 - sizeof(mData)];
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080071};
72
73}; // namespace android
74
75#endif // ANDROID_VIDEO_FRAME_H