File: VDecAccelVA.h

package info (click to toggle)
libva-utils 2.4.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,776 kB
  • sloc: ansic: 46,124; cpp: 11,832; sh: 4,166; makefile: 346
file content (145 lines) | stat: -rwxr-xr-x 5,396 bytes parent folder | download
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * * Copyright (C) 2018 Intel Corporation. All Rights Reserved.
 * *
 ** Permission is hereby granted, free of charge, to any person obtaining a
 * * copy of this software and associated documentation files (the
 * * "Software"), to deal in the Software without restriction, including
 * * without limitation the rights to use, copy, modify, merge, publish,
 * * distribute, sub license, and/or sell copies of the Software, and to
 * * permit persons to whom the Software is furnished to do so, subject to
 * * the following conditions:
 * *
 * * The above copyright notice and this permission notice (including the
 * * next paragraph) shall be included in all copies or substantial portions
 * * of the Software.
 * *
 * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 * * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * */

/**
 * @file VDecAccelVA.h
 * @brief LibVA decode accelerator declaration
 */

#ifndef MV_ACCELERATOR_VAAPI_DECODE_H
#define MV_ACCELERATOR_VAAPI_DECODE_H

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <map>
#include <vector>
#include <algorithm>
#include <va/va.h>
#include "DecodeParamBuffer.h"

#include <X11/Xlib.h>
typedef Display*     HDISP;

namespace mvaccel
{
/**
 * @brief LibVA decode accelerator
 */
class VDecAccelVAImpl
{
public:
    VDecAccelVAImpl(void* device);
    VDecAccelVAImpl();
    virtual ~VDecAccelVAImpl();

    // VDecAccel interface
    virtual int         Open();
    virtual void        Close();
    virtual uint32_t    GetSurfaceID(uint32_t index);
    bool                DecodePicture();
    void                bind_buffer(uint8_t* base);

protected:
    // GfxSurfaceAccess interface
    uint32_t    get_width(VASurfaceID id);
    uint32_t    get_height(VASurfaceID id);
    uint32_t    get_stride(VASurfaceID id);
    uint8_t*    lock_surface(VASurfaceID id, bool write);
    void        unlock_surface(VASurfaceID id);
    void*       get_raw(VASurfaceID id);
    void*       get_device(VASurfaceID id);

    typedef std::vector<VAConfigAttrib>     VAConfigAttribArray;
    typedef std::vector<VASurfaceAttrib>    VASurfaceAttribArray;

    // Member functions inherit by children
    virtual bool    is_config_compatible(DecodeDesc& desc);
    virtual bool    is_rt_foramt_supported(DecodeDesc& desc);
    virtual void    prepare_config_attribs(
                        DecodeDesc& desc,
                        VAConfigAttribArray& attribs);
    virtual void    prepare_surface_attribs(
                        DecodeDesc& desc,
                        VASurfaceAttribArray& attribs,
                        bool bDecodeDownsamplingHinted);

    // Member fucntions NOT inherit by children
    bool        is_slice_mode_supported(DecodeDesc& desc);
    bool        is_encryption_supported(DecodeDesc& desc);
    bool        is_sfc_config_supported(DecodeDesc& desc);
    VAStatus    render_picture(VAContextID& vaContextID);
    VAStatus    query_status();
    VAStatus    create_surface(
                    uint32_t width,
                    uint32_t height,
                    VASurfaceAttribArray& vaAttribs,
                    VASurfaceID& vaID);
    void        delete_surface(VASurfaceID& vaID);
    void        create_decode_desc();
    int         check_process_pipeline_caps(DecodeDesc& desc);
    int         create_resources();

protected:
    // VA ID & Handles
    VADisplay       m_vaDisplay;    /**< @brief VA hardware device */
    VAProfile       m_vaProfile;    /**< @brief Video decoder profile */
    VAEntrypoint    m_vaEntrypoint; /**< @brief VA entry point */
    VAConfigID      m_vaConfigID;   /**< @brief VA decode config id*/
    VAContextID     m_vaContextID;  /**< @brief Video decoder context */

    // VASurfaces id and attributes
    std::vector<VASurfaceID>    m_vaIDs;
    VASurfaceAttribArray        m_vaSurfAttribs;

    uint32_t    m_surfaceType;   /**< @brief surface type */

    // Gfx surface access management
    std::map<VASurfaceID, VAImage>      m_images;   /**< @brief buf pointer */

    enum SFC
    {
        MAX_IN_W,
        MAX_IN_H,
        MIN_IN_W,
        MIN_IN_H,
        MAX_OUT_W,
        MAX_OUT_H,
        MIN_OUT_W,
        MIN_OUT_H,
        NEW_W,
        NEW_H,
    };

    DecodeDesc                    m_DecodeDesc;       /**< @brief decode discription */
    VARectangle                   m_rectSrc;          /**< @brief Rectangle for source input */
    VARectangle                   m_rectSFC;          /**< @brief Rectangle for SFC output */
    std::vector<uint32_t>         m_in4CC;            /**< @brief input FOURCC */
    std::vector<uint32_t>         m_out4CC;           /**< @brief output FOURCC */
    std::map<SFC,uint32_t>        m_sfcSize;          /**< @brief SFC sizes */
    std::vector<VASurfaceID>      m_sfcIDs;           /**< @brief sfc surfaces */
    VAProcPipelineParameterBuffer m_vaProcBuffer;     /**< @brief sfc pipeline buffer */
};
} // namespace mvaccel
#endif // MV_ACCELERATOR_VAAPI_DECODE_H