xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/xcore/video_buffer.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * video_buffer.cpp - video buffer base
3  *
4  *  Copyright (c) 2014-2015 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Wind Yuan <feng.yuan@intel.com>
19  */
20 
21 #include "video_buffer.h"
22 #include <linux/videodev2.h>
23 
24 namespace XCam {
25 
VideoBufferPlanarInfo()26 VideoBufferPlanarInfo::VideoBufferPlanarInfo ()
27 {
28     width = 0;
29     height = 0;
30     pixel_bytes = 0;
31 }
32 
VideoBufferInfo()33 VideoBufferInfo::VideoBufferInfo ()
34 {
35     format = 0;
36     color_bits = 8;
37     width = 0;
38     height = 0;
39     aligned_width = 0;
40     aligned_height = 0;
41     size = 0;
42     components  = 0;
43     xcam_mem_clear (strides);
44     xcam_mem_clear (offsets);
45 }
46 
47 bool
init(uint32_t format,uint32_t width,uint32_t height,uint32_t aligned_width,uint32_t aligned_height,uint32_t size,bool compacted)48 VideoBufferInfo::init (
49     uint32_t format,
50     uint32_t width, uint32_t height,
51     uint32_t aligned_width, uint32_t aligned_height,
52     uint32_t size, bool compacted)
53 {
54 
55     XCamVideoBufferInfo *info = this;
56 
57     return (xcam_video_buffer_info_reset (
58                 info, format, width, height, aligned_width, aligned_height, size, compacted) == XCAM_RETURN_NO_ERROR);
59 }
60 
61 bool
fill(const XCamVideoBufferInfo & info)62 VideoBufferInfo::fill (const XCamVideoBufferInfo &info)
63 {
64 	format = info.format;
65 	color_bits = info.color_bits;
66 	width = info.width;
67 	height = info.height;
68 	aligned_width = info.aligned_width;
69 	aligned_height = info.aligned_height;
70 	size = info.size;
71 	components = info.components;
72 	for (int i = 0; i < XCAM_VIDEO_MAX_COMPONENTS; i++) {
73 		strides[i] = info.strides[i];
74 		offsets[i] = info.offsets[i];
75 	}
76 
77 	return true;
78 }
79 
80 bool
is_valid() const81 VideoBufferInfo::is_valid () const
82 {
83     return format && aligned_width && aligned_height && size;
84 }
85 
86 bool
get_planar_info(VideoBufferPlanarInfo & planar,const uint32_t index) const87 VideoBufferInfo::get_planar_info (
88     VideoBufferPlanarInfo &planar, const uint32_t index) const
89 {
90     const XCamVideoBufferInfo *info = this;
91     XCamVideoBufferPlanarInfo *planar_info = &planar;
92     return (xcam_video_buffer_get_planar_info (info, planar_info, index) == XCAM_RETURN_NO_ERROR);
93 }
94 
~VideoBuffer()95 VideoBuffer::~VideoBuffer ()
96 {
97 }
98 
99 }
100