Files
openvino/samples/cpp/common/format_reader/yuv_nv12.cpp
Ilya Churaev 0c9abf43a9 Updated copyright headers (#15124)
* Updated copyright headers

* Revert "Fixed linker warnings in docs snippets on Windows (#15119)"

This reverts commit 372699ec49.
2023-01-16 11:02:17 +04:00

37 lines
787 B
C++

// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
// clang-format off
#include <fstream>
#include <iostream>
#include <string>
#include "yuv_nv12.h"
// clang-format on
using namespace FormatReader;
YUV_NV12::YUV_NV12(const std::string& filename) {
auto pos = filename.rfind('.');
if (pos == std::string::npos)
return;
if (filename.substr(pos + 1) != "yuv")
return;
std::ifstream file(filename, std::ios::binary);
if (!file.is_open()) {
return;
}
file.seekg(0, file.end);
_size = file.tellg();
file.seekg(0, file.beg);
_data.reset(new unsigned char[_size], std::default_delete<unsigned char[]>());
file.read(reinterpret_cast<char*>(_data.get()), _size);
file.close();
}