File: test_va_api_config_attribs.cpp

package info (click to toggle)
libva-utils 2.10.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,872 kB
  • sloc: ansic: 46,524; cpp: 13,613; sh: 4,166; makefile: 359
file content (143 lines) | stat: -rw-r--r-- 5,425 bytes parent folder | download | duplicates (3)
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
/*
 * Copyright (C) 2016 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.
 */

#include "test_va_api_fixture.h"

namespace VAAPI {

class VAAPIConfigAttribs
    : public VAAPIFixture
    , public ::testing::WithParamInterface<std::tuple<VAProfile, VAEntrypoint> >
{
public:
    VAAPIConfigAttribs()
        : profile(::testing::get<0>(GetParam()))
        , entrypoint(::testing::get<1>(GetParam()))
    { }

protected:
    const VAProfile& profile;
    const VAEntrypoint& entrypoint;

    virtual void SetUp()
    {
        VAAPIFixture::SetUp();
        doInitialize();
        ASSERT_FALSE(HasFailure());
    }

    virtual void TearDown()
    {
        doTerminate();
        VAAPIFixture::TearDown();
    }

    void validateConfigAttributes(const ConfigAttributes& actual,
        const ConfigAttributes& supported) const
    {
        const size_t size(actual.size());
        ASSERT_EQ(size, supported.size());

        // Require that actual and supported are in the same order, by type
        for (size_t i(0); i < size; ++i) {
            const VAConfigAttrib& aAttrib = actual[i];
            const VAConfigAttrib& sAttrib = supported[i];

            ASSERT_EQ(aAttrib.type, sAttrib.type);

            // NOTE: If an attribute was not explicitly set by user/app during
            // createConfig (as is the case for GetConfigAttribs test), then
            // all known drivers currently return the same value from
            // vaQueryConfigAttributes as returned from vaGetConfigAttributes.
            // However, there are several bitfield-type attributes that can
            // only take on "one" choice from the supported value relayed in the
            // bitfield from vaGetConfigAttributes.  It still remains to be
            // clarified whether drivers should actually return the "default"
            // chosen value from vaQueryConfigAttributes when it is not
            // specified by user/app during createConfig.  Hence, for now, for
            // bitfield-type attributes we only require that the actual value
            // is equal-to or a "subset" of the supported value.

            switch (aAttrib.type) {
            // Read/write bitfield attribute can be a subset of supported values
            case VAConfigAttribRTFormat:
            case VAConfigAttribRateControl:
            case VAConfigAttribDecSliceMode:
            case VAConfigAttribEncPackedHeaders:
            case VAConfigAttribEncInterlaced:
            case VAConfigAttribFEIFunctionType:
                EXPECT_EQ(sAttrib.value & aAttrib.value, aAttrib.value);
                break;

            // read-only and/or non-bitfield attributes
            default:
                EXPECT_EQ(sAttrib.value, aAttrib.value);
            }
        }
    }
};

TEST_P(VAAPIConfigAttribs, GetConfigAttribs)
{
    // The driver must support creating a config without any user specified
    // attributes, in which case the driver will use it's own defaults.  The
    // app should be able to query those default attributes for such created
    // config via vaQueryConfigAttributes.  Those default attribute values
    // should be consistent with supported attribute values returned by
    // vaGetConfigAttributes.

    if (not isSupported(profile, entrypoint)) {
        skipTest(profile, entrypoint);
        return;
    }

    // create config without attributes (i.e. use driver defaults)
    createConfig(profile, entrypoint);

    // query default attributes from the config we just created
    ConfigAttributes actual;
    queryConfigAttributes(profile, entrypoint, actual);

    // we're done with the config
    destroyConfig();

    // copy the actual attributes and reset their values so we
    // can get the supported values for them.
    ConfigAttributes supported = actual;
    std::for_each(supported.begin(), supported.end(),
        [](VAConfigAttrib& s) { s.value = 0; });

    // get supported config attribute values
    getConfigAttributes(profile, entrypoint, supported);

    // verify actual config attribute values are supported values
    validateConfigAttributes(actual, supported);
}

INSTANTIATE_TEST_CASE_P(
    Attributes, VAAPIConfigAttribs,
    ::testing::Combine(::testing::ValuesIn(g_vaProfiles),
        ::testing::ValuesIn(g_vaEntrypoints)));

} // namespace VAAPI