blob: 24cacbb0e2d67f243435acff56b3c3e85df50e09
1 | /* |
2 | * Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
3 | * |
4 | * This source code is subject to the terms and conditions defined in the |
5 | * file 'LICENSE' which is part of this source code package. |
6 | * |
7 | * Description: |
8 | */ |
9 | #include "CopyProcessor.h" |
10 | #include <MesonLog.h> |
11 | |
12 | CopyProcessor::CopyProcessor() { |
13 | } |
14 | |
15 | CopyProcessor::~CopyProcessor() { |
16 | } |
17 | |
18 | int32_t CopyProcessor::setup() { |
19 | return 0; |
20 | } |
21 | |
22 | int32_t CopyProcessor::process( |
23 | std::shared_ptr<DrmFramebuffer> & inputfb, |
24 | std::shared_ptr<DrmFramebuffer> & outfb) { |
25 | |
26 | void * inmem = NULL, * outmem = NULL; |
27 | int infmt = am_gralloc_get_format (inputfb->mBufferHandle); |
28 | int outfmt = am_gralloc_get_format (outfb->mBufferHandle); |
29 | int w = am_gralloc_get_width(inputfb->mBufferHandle); |
30 | int h = am_gralloc_get_height(inputfb->mBufferHandle); |
31 | int instride = am_gralloc_get_stride_in_pixel(inputfb->mBufferHandle); |
32 | int outstride = am_gralloc_get_stride_in_pixel(outfb->mBufferHandle); |
33 | |
34 | //MESON_LOGD("CopyProcessor %dx%d(%d,%d), fmt %d, %d", |
35 | // w, h, instride, outstride, infmt, outfmt); |
36 | |
37 | if (inputfb->lock(&inmem) == 0 && outfb->lock(&outmem) == 0) { |
38 | char * src = (char *)inmem; |
39 | char * dst = (char *)outmem; |
40 | |
41 | if (infmt == HAL_PIXEL_FORMAT_RGB_888 && |
42 | outfmt == HAL_PIXEL_FORMAT_RGB_888) { |
43 | for (int ir = 0; ir < h; ir++) { |
44 | memcpy(dst, src, w * 3); |
45 | src += instride * 3; |
46 | dst += outstride * 3; |
47 | } |
48 | } |
49 | |
50 | inputfb->unlock(); |
51 | outfb->unlock(); |
52 | } |
53 | |
54 | return 0; |
55 | } |
56 | |
57 | int32_t CopyProcessor::teardown() { |
58 | return 0; |
59 | } |
60 | |
61 |