VpcUtils.h 1.25 KB
#include "dvpp_headers.h"
#include "depend_headers.h"
#include "DvppDataMemory.hpp"

#include <map>

class VpcUtils{
public:

    static VpcUtils* getInstance(int devId) {
        static std::map<int, VpcUtils*> mapUtils;
        VpcUtils* singleton = nullptr;
        if (mapUtils.find(devId) == mapUtils.end()) {
            singleton = new VpcUtils();
			singleton->init(devId);
            mapUtils[devId] = singleton;
        } else {
            singleton = mapUtils[devId];
        }
		return singleton;
	}

    VpcUtils();
    ~VpcUtils();

    int init(int);

    DvppDataMemory* convert2bgr(acldvppPicDesc *input, int out_width, int out_height, bool key_frame);

    DvppDataMemory* convert2bgr(DvppDataMemory* inMem);

    DvppDataMemory* resize(acldvppPicDesc *inputDesc_, int out_width, int out_height);

    DvppDataMemory* resize(DvppDataMemory* inMem, int out_width, int out_height);

    DvppDataMemory* crop(DvppDataMemory* devMem, AreaInfo obj);

    vector<DvppDataMemory*> crop_batch(DvppDataMemory* devMem, const vector<AreaInfo> objs);

private:
    void check_area(AreaInfo& area, int width, int height);

private:
    aclrtContext context_;
    aclrtStream stream_;
    int m_devId;
    acldvppChannelDesc *dvppChannelDesc_ ;
    string m_dec_name;
};