huangcm
2025-02-24 69ed55dec4b2116a19e4cca4393cbc014fce5fb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * swapped_buffer.h - swapped buffer
 *
 *  Copyright (c) 2015 Intel Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author: Wind Yuan <feng.yuan@intel.com>
 */
 
#ifndef XCAM_SWAPPED_BUFFER_H
#define XCAM_SWAPPED_BUFFER_H
 
#include <xcam_std.h>
#include <buffer_pool.h>
 
namespace XCam {
 
class SwappedBuffer
    : public virtual BufferProxy
{
public:
    enum SwapFlags {
        SwapNone = 0,
        SwapY    = 1,
        SwapUV   = 2,
    };
 
    enum SwapOffsets {
        SwapYOffset0 = 0,
        SwapYOffset1 = 1,
        SwapUVOffset0 = 2,
        SwapUVOffset1 = 3,
    };
 
    enum InitOrder {
        OrderYMask = 0x000F,
        OrderY0Y1 = 0x0001,
        OrderY1Y0 = 0x0002,
        OrderUVMask = 0x0F00,
        OrderUV0UV1 = 0x0100,
        OrderUV1UV0 = 0x0200,
    };
 
protected:
    explicit SwappedBuffer (
        const VideoBufferInfo &info, const SmartPtr<BufferData> &data);
 
public:
    virtual ~SwappedBuffer ();
    void set_swap_info (uint32_t flags, uint32_t* offsets);
 
    SmartPtr<SwappedBuffer> swap_clone (
        SmartPtr<SwappedBuffer> self, uint32_t flags);
 
protected:
    virtual SmartPtr<SwappedBuffer> create_new_swap_buffer (
        const VideoBufferInfo &info, SmartPtr<BufferData> &data);
 
    bool swap_new_buffer_info (
        const VideoBufferInfo &in, uint32_t flags, VideoBufferInfo &out);
 
private:
    XCAM_DEAD_COPY (SwappedBuffer);
 
protected:
    uint32_t                   _swap_flags;
    uint32_t                   _swap_offsets[XCAM_VIDEO_MAX_COMPONENTS * 2];
};
 
}
 
#endif //XCAM_SWAPPED_BUFFER_H