• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * soft_copy_task.cpp - soft copy implementation
3  *
4  *  Copyright (c) 2017 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: Yinhang Liu <yinhangx.liu@intel.com>
19  */
20 
21 #include "soft_copy_task.h"
22 
23 namespace XCam {
24 
25 namespace XCamSoftTasks {
26 
27 template <typename ImageT>
copy_line(const ImageT * in,ImageT * out,const uint32_t y,const uint32_t size)28 static inline void copy_line (const ImageT *in, ImageT *out, const uint32_t y, const uint32_t size)
29 {
30     const typename ImageT::Type *in_ptr = in->get_buf_ptr (0, y);
31     typename ImageT::Type *out_ptr = out->get_buf_ptr (0, y);
32 
33     memcpy (out_ptr, in_ptr, size);
34 }
35 
36 XCamReturn
work_range(const SmartPtr<Arguments> & base,const WorkRange & range)37 XCamSoftTasks::CopyTask::work_range (const SmartPtr<Arguments> &base, const WorkRange &range)
38 {
39     SmartPtr<CopyTask::Args> args = base.dynamic_cast_ptr<CopyTask::Args> ();
40     XCAM_ASSERT (args.ptr ());
41 
42     UcharImage *in_luma = args->in_luma.ptr (), *out_luma = args->out_luma.ptr ();
43     Uchar2Image *in_uv = args->in_uv.ptr (), *out_uv = args->out_uv.ptr ();
44     XCAM_ASSERT (in_luma && in_uv);
45     XCAM_ASSERT (out_luma && out_uv);
46 
47     uint32_t luma_size = in_luma->get_width () * in_luma->pixel_size ();
48     uint32_t uv_size = in_uv->get_width () * in_uv->pixel_size ();
49     for (uint32_t y = range.pos[1]; y < range.pos[1] + range.pos_len[1]; ++y) {
50         uint32_t luma_y = y * 2;
51         copy_line<UcharImage> (in_luma, out_luma, luma_y, luma_size);
52         copy_line<UcharImage> (in_luma, out_luma, luma_y + 1, luma_size);
53 
54         uint32_t uv_y = y;
55         copy_line<Uchar2Image> (in_uv, out_uv, uv_y, uv_size);
56     }
57 
58     XCAM_LOG_DEBUG ("CopyTask work on range:[x:%d, width:%d, y:%d, height:%d]",
59                     range.pos[0], range.pos_len[0], range.pos[1], range.pos_len[1]);
60 
61     return XCAM_RETURN_NO_ERROR;
62 }
63 
64 }
65 
66 }
67