File: parameters_dumper.h

package info (click to toggle)
libvpl-tools 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,652 kB
  • sloc: cpp: 107,469; python: 4,303; ansic: 3,202; sh: 159; lisp: 52; makefile: 13
file content (73 lines) | stat: -rw-r--r-- 3,463 bytes parent folder | download | duplicates (2)
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
/*############################################################################
  # Copyright (C) 2005 Intel Corporation
  #
  # SPDX-License-Identifier: MIT
  ############################################################################*/

#ifndef __PARAMETERS_DUMPER_H__
#define __PARAMETERS_DUMPER_H__
#include "sample_defs.h"

class CParametersDumper {
protected:
    static void SerializeFrameInfoStruct(std::ostream& sstr,
                                         const char* prefix,
                                         mfxFrameInfo& info);
    static void SerializeMfxInfoMFXStruct(std::ostream& sstr, const char* prefix, mfxInfoMFX& info);
    static void SerializeExtensionBuffer(std::ostream& sstr,
                                         const char* prefix,
                                         mfxExtBuffer* pExtBuffer);
    static void SerializeVPPCompInputStream(std::ostream& sstr,
                                            const char* prefix,
                                            mfxVPPCompInputStream& info);

    template <class T>
    static mfxStatus GetUnitParams(T* pMfxUnit,
                                   const mfxVideoParam* pPresetParams,
                                   mfxVideoParam* pOutParams) {
        memset(pOutParams, 0, sizeof(mfxVideoParam));
        mfxExtBuffer** paramsArray = new mfxExtBuffer*[pPresetParams->NumExtParam];
        for (int paramNum = 0; paramNum < pPresetParams->NumExtParam; paramNum++) {
            mfxExtBuffer* buf    = pPresetParams->ExtParam[paramNum];
            mfxExtBuffer* newBuf = (mfxExtBuffer*)new mfxU8[buf->BufferSz];
            memset(newBuf, 0, buf->BufferSz);
            newBuf->BufferId      = buf->BufferId;
            newBuf->BufferSz      = buf->BufferSz;
            paramsArray[paramNum] = newBuf;
        }
        pOutParams->NumExtParam = pPresetParams->NumExtParam;
        pOutParams->ExtParam    = paramsArray;

        mfxStatus sts = pMfxUnit->GetVideoParam(pOutParams);
        MSDK_CHECK_STATUS_SAFE(sts,
                               "Cannot read configuration from encoder: GetVideoParam failed",
                               ClearExtBuffs(pOutParams));

        return MFX_ERR_NONE;
    }

    static void ClearExtBuffs(mfxVideoParam* params) {
        // Cleaning params array
        for (int paramNum = 0; paramNum < params->NumExtParam; paramNum++) {
            delete[] params->ExtParam[paramNum];
        }
        delete[] params->ExtParam;
        params->ExtParam    = NULL;
        params->NumExtParam = 0;
    }

public:
    static void SerializeVideoParamStruct(std::ostream& sstr,
                                          const char* sectionName,
                                          mfxVideoParam& info,
                                          bool shouldUseVPPSection = false);
    static mfxStatus DumpLibraryConfiguration(std::string fileName,
                                              MFXVideoDECODE* pMfxDec,
                                              MFXVideoVPP* pMfxVPP,
                                              MFXVideoENCODE* pMfxEnc,
                                              const mfxVideoParam* pDecoderPresetParams,
                                              const mfxVideoParam* pVPPPresetParams,
                                              const mfxVideoParam* pEncoderPresetParams);
    static void ShowConfigurationDiff(std::ostream& sstr1, std::ostream& sstr2);
};
#endif