You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Merge pull request #296 from OpenShot/std-prefixes
Remove all 'using namespace' directives from headers
This commit is contained in:
@@ -58,7 +58,7 @@ Json::Value CacheBase::JsonValue() {
|
||||
|
||||
// Create root json object
|
||||
Json::Value root;
|
||||
stringstream max_bytes_stream;
|
||||
std::stringstream max_bytes_stream;
|
||||
max_bytes_stream << max_bytes;
|
||||
root["max_bytes"] = max_bytes_stream.str();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ using namespace std;
|
||||
using namespace openshot;
|
||||
|
||||
// Default constructor, no max bytes
|
||||
CacheDisk::CacheDisk(string cache_path, string format, float quality, float scale) : CacheBase(0) {
|
||||
CacheDisk::CacheDisk(std::string cache_path, std::string format, float quality, float scale) : CacheBase(0) {
|
||||
// Set cache type name
|
||||
cache_type = "CacheDisk";
|
||||
range_version = 0;
|
||||
@@ -50,7 +50,7 @@ CacheDisk::CacheDisk(string cache_path, string format, float quality, float scal
|
||||
};
|
||||
|
||||
// Constructor that sets the max bytes to cache
|
||||
CacheDisk::CacheDisk(string cache_path, string format, float quality, float scale, int64_t max_bytes) : CacheBase(max_bytes) {
|
||||
CacheDisk::CacheDisk(std::string cache_path, std::string format, float quality, float scale, int64_t max_bytes) : CacheBase(max_bytes) {
|
||||
// Set cache type name
|
||||
cache_type = "CacheDisk";
|
||||
range_version = 0;
|
||||
@@ -65,7 +65,7 @@ CacheDisk::CacheDisk(string cache_path, string format, float quality, float scal
|
||||
};
|
||||
|
||||
// Initialize cache directory
|
||||
void CacheDisk::InitPath(string cache_path) {
|
||||
void CacheDisk::InitPath(std::string cache_path) {
|
||||
QString qpath;
|
||||
|
||||
if (!cache_path.empty()) {
|
||||
@@ -103,7 +103,7 @@ void CacheDisk::CalculateRanges() {
|
||||
// Increment range version
|
||||
range_version++;
|
||||
|
||||
vector<int64_t>::iterator itr_ordered;
|
||||
std::vector<int64_t>::iterator itr_ordered;
|
||||
int64_t starting_frame = *ordered_frame_numbers.begin();
|
||||
int64_t ending_frame = *ordered_frame_numbers.begin();
|
||||
|
||||
@@ -116,9 +116,9 @@ void CacheDisk::CalculateRanges() {
|
||||
|
||||
// Add JSON object with start/end attributes
|
||||
// Use strings, since int64_ts are supported in JSON
|
||||
stringstream start_str;
|
||||
std::stringstream start_str;
|
||||
start_str << starting_frame;
|
||||
stringstream end_str;
|
||||
std::stringstream end_str;
|
||||
end_str << ending_frame;
|
||||
range["start"] = start_str.str();
|
||||
range["end"] = end_str.str();
|
||||
@@ -137,9 +137,9 @@ void CacheDisk::CalculateRanges() {
|
||||
|
||||
// Add JSON object with start/end attributes
|
||||
// Use strings, since int64_ts are supported in JSON
|
||||
stringstream start_str;
|
||||
std::stringstream start_str;
|
||||
start_str << starting_frame;
|
||||
stringstream end_str;
|
||||
std::stringstream end_str;
|
||||
end_str << ending_frame;
|
||||
range["start"] = start_str.str();
|
||||
range["end"] = end_str.str();
|
||||
@@ -302,7 +302,7 @@ std::shared_ptr<Frame> CacheDisk::GetSmallestFrame()
|
||||
std::shared_ptr<openshot::Frame> f;
|
||||
|
||||
// Loop through frame numbers
|
||||
deque<int64_t>::iterator itr;
|
||||
std::deque<int64_t>::iterator itr;
|
||||
int64_t smallest_frame = -1;
|
||||
for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr)
|
||||
{
|
||||
@@ -325,7 +325,7 @@ int64_t CacheDisk::GetBytes()
|
||||
int64_t total_bytes = 0;
|
||||
|
||||
// Loop through frames, and calculate total bytes
|
||||
deque<int64_t>::reverse_iterator itr;
|
||||
std::deque<int64_t>::reverse_iterator itr;
|
||||
for(itr = frame_numbers.rbegin(); itr != frame_numbers.rend(); ++itr)
|
||||
total_bytes += frame_size_bytes;
|
||||
|
||||
@@ -345,7 +345,7 @@ void CacheDisk::Remove(int64_t start_frame_number, int64_t end_frame_number)
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
|
||||
// Loop through frame numbers
|
||||
deque<int64_t>::iterator itr;
|
||||
std::deque<int64_t>::iterator itr;
|
||||
for(itr = frame_numbers.begin(); itr != frame_numbers.end();)
|
||||
{
|
||||
//deque<int64_t>::iterator current = itr++;
|
||||
@@ -358,7 +358,7 @@ void CacheDisk::Remove(int64_t start_frame_number, int64_t end_frame_number)
|
||||
}
|
||||
|
||||
// Loop through ordered frame numbers
|
||||
vector<int64_t>::iterator itr_ordered;
|
||||
std::vector<int64_t>::iterator itr_ordered;
|
||||
for(itr_ordered = ordered_frame_numbers.begin(); itr_ordered != ordered_frame_numbers.end();)
|
||||
{
|
||||
if (*itr_ordered >= start_frame_number && *itr_ordered <= end_frame_number)
|
||||
@@ -397,7 +397,7 @@ void CacheDisk::MoveToFront(int64_t frame_number)
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
|
||||
// Loop through frame numbers
|
||||
deque<int64_t>::iterator itr;
|
||||
std::deque<int64_t>::iterator itr;
|
||||
for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr)
|
||||
{
|
||||
if (*itr == frame_number)
|
||||
@@ -465,7 +465,7 @@ void CacheDisk::CleanUp()
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string CacheDisk::Json() {
|
||||
std::string CacheDisk::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -483,7 +483,7 @@ Json::Value CacheDisk::JsonValue() {
|
||||
root["path"] = path.path().toStdString();
|
||||
|
||||
Json::Value version;
|
||||
stringstream range_version_str;
|
||||
std::stringstream range_version_str;
|
||||
range_version_str << range_version;
|
||||
root["version"] = range_version_str.str();
|
||||
|
||||
@@ -492,7 +492,7 @@ Json::Value CacheDisk::JsonValue() {
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( json_ranges.c_str(),
|
||||
json_ranges.c_str() + json_ranges.size(), &ranges, &errors );
|
||||
delete reader;
|
||||
@@ -505,14 +505,14 @@ Json::Value CacheDisk::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void CacheDisk::SetJson(string value) {
|
||||
void CacheDisk::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -79,7 +79,7 @@ void CacheMemory::CalculateRanges() {
|
||||
// Increment range version
|
||||
range_version++;
|
||||
|
||||
vector<int64_t>::iterator itr_ordered;
|
||||
std::vector<int64_t>::iterator itr_ordered;
|
||||
int64_t starting_frame = *ordered_frame_numbers.begin();
|
||||
int64_t ending_frame = *ordered_frame_numbers.begin();
|
||||
|
||||
@@ -92,9 +92,9 @@ void CacheMemory::CalculateRanges() {
|
||||
|
||||
// Add JSON object with start/end attributes
|
||||
// Use strings, since int64_ts are supported in JSON
|
||||
stringstream start_str;
|
||||
std::stringstream start_str;
|
||||
start_str << starting_frame;
|
||||
stringstream end_str;
|
||||
std::stringstream end_str;
|
||||
end_str << ending_frame;
|
||||
range["start"] = start_str.str();
|
||||
range["end"] = end_str.str();
|
||||
@@ -113,9 +113,9 @@ void CacheMemory::CalculateRanges() {
|
||||
|
||||
// Add JSON object with start/end attributes
|
||||
// Use strings, since int64_ts are not supported in JSON
|
||||
stringstream start_str;
|
||||
std::stringstream start_str;
|
||||
start_str << starting_frame;
|
||||
stringstream end_str;
|
||||
std::stringstream end_str;
|
||||
end_str << ending_frame;
|
||||
range["start"] = start_str.str();
|
||||
range["end"] = end_str.str();
|
||||
@@ -178,7 +178,7 @@ std::shared_ptr<Frame> CacheMemory::GetSmallestFrame()
|
||||
std::shared_ptr<openshot::Frame> f;
|
||||
|
||||
// Loop through frame numbers
|
||||
deque<int64_t>::iterator itr;
|
||||
std::deque<int64_t>::iterator itr;
|
||||
int64_t smallest_frame = -1;
|
||||
for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr)
|
||||
{
|
||||
@@ -201,7 +201,7 @@ int64_t CacheMemory::GetBytes()
|
||||
int64_t total_bytes = 0;
|
||||
|
||||
// Loop through frames, and calculate total bytes
|
||||
deque<int64_t>::reverse_iterator itr;
|
||||
std::deque<int64_t>::reverse_iterator itr;
|
||||
for(itr = frame_numbers.rbegin(); itr != frame_numbers.rend(); ++itr)
|
||||
{
|
||||
total_bytes += frames[*itr]->GetBytes();
|
||||
@@ -223,7 +223,7 @@ void CacheMemory::Remove(int64_t start_frame_number, int64_t end_frame_number)
|
||||
const GenericScopedLock<CriticalSection> lock(*cacheCriticalSection);
|
||||
|
||||
// Loop through frame numbers
|
||||
deque<int64_t>::iterator itr;
|
||||
std::deque<int64_t>::iterator itr;
|
||||
for(itr = frame_numbers.begin(); itr != frame_numbers.end();)
|
||||
{
|
||||
if (*itr >= start_frame_number && *itr <= end_frame_number)
|
||||
@@ -235,7 +235,7 @@ void CacheMemory::Remove(int64_t start_frame_number, int64_t end_frame_number)
|
||||
}
|
||||
|
||||
// Loop through ordered frame numbers
|
||||
vector<int64_t>::iterator itr_ordered;
|
||||
std::vector<int64_t>::iterator itr_ordered;
|
||||
for(itr_ordered = ordered_frame_numbers.begin(); itr_ordered != ordered_frame_numbers.end();)
|
||||
{
|
||||
if (*itr_ordered >= start_frame_number && *itr_ordered <= end_frame_number)
|
||||
@@ -261,7 +261,7 @@ void CacheMemory::MoveToFront(int64_t frame_number)
|
||||
if (frames.count(frame_number))
|
||||
{
|
||||
// Loop through frame numbers
|
||||
deque<int64_t>::iterator itr;
|
||||
std::deque<int64_t>::iterator itr;
|
||||
for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr)
|
||||
{
|
||||
if (*itr == frame_number)
|
||||
@@ -321,7 +321,7 @@ void CacheMemory::CleanUp()
|
||||
|
||||
|
||||
// Generate JSON string of this object
|
||||
string CacheMemory::Json() {
|
||||
std::string CacheMemory::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -337,7 +337,7 @@ Json::Value CacheMemory::JsonValue() {
|
||||
Json::Value root = CacheBase::JsonValue(); // get parent properties
|
||||
root["type"] = cache_type;
|
||||
|
||||
stringstream range_version_str;
|
||||
std::stringstream range_version_str;
|
||||
range_version_str << range_version;
|
||||
root["version"] = range_version_str.str();
|
||||
|
||||
@@ -346,7 +346,7 @@ Json::Value CacheMemory::JsonValue() {
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( json_ranges.c_str(),
|
||||
json_ranges.c_str() + json_ranges.size(), &ranges, &errors );
|
||||
delete reader;
|
||||
@@ -359,14 +359,14 @@ Json::Value CacheMemory::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void CacheMemory::SetJson(string value) {
|
||||
void CacheMemory::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
using namespace openshot;
|
||||
|
||||
ChunkReader::ChunkReader(string path, ChunkVersion chunk_version)
|
||||
ChunkReader::ChunkReader(std::string path, ChunkVersion chunk_version)
|
||||
: path(path), chunk_size(24 * 3), is_open(false), version(chunk_version), local_reader(NULL)
|
||||
{
|
||||
// Check if folder exists?
|
||||
@@ -51,7 +51,7 @@ ChunkReader::ChunkReader(string path, ChunkVersion chunk_version)
|
||||
}
|
||||
|
||||
// Check if folder path existing
|
||||
bool ChunkReader::does_folder_exist(string path)
|
||||
bool ChunkReader::does_folder_exist(std::string path)
|
||||
{
|
||||
QDir dir(path.c_str());
|
||||
return dir.exists();
|
||||
@@ -61,12 +61,12 @@ bool ChunkReader::does_folder_exist(string path)
|
||||
void ChunkReader::load_json()
|
||||
{
|
||||
// Load path of chunk folder
|
||||
string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString();
|
||||
stringstream json_string;
|
||||
std::string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString();
|
||||
std::stringstream json_string;
|
||||
|
||||
// Read the JSON file
|
||||
ifstream myfile (json_path.c_str());
|
||||
string line = "";
|
||||
std::ifstream myfile (json_path.c_str());
|
||||
std::string line = "";
|
||||
if (myfile.is_open())
|
||||
{
|
||||
while (myfile.good())
|
||||
@@ -81,7 +81,7 @@ void ChunkReader::load_json()
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = Json::parseFromStream(rbuilder, json_string, &root, &errors);
|
||||
if (!success)
|
||||
// Raise exception
|
||||
@@ -170,10 +170,10 @@ void ChunkReader::Close()
|
||||
}
|
||||
|
||||
// get a formatted path of a specific chunk
|
||||
string ChunkReader::get_chunk_path(int64_t chunk_number, string folder, string extension)
|
||||
std::string ChunkReader::get_chunk_path(int64_t chunk_number, std::string folder, std::string extension)
|
||||
{
|
||||
// Create path of new chunk video
|
||||
stringstream chunk_count_string;
|
||||
std::stringstream chunk_count_string;
|
||||
chunk_count_string << chunk_number;
|
||||
QString padded_count = "%1"; //chunk_count_string.str().c_str();
|
||||
padded_count = padded_count.arg(chunk_count_string.str().c_str(), 6, '0');
|
||||
@@ -202,7 +202,7 @@ std::shared_ptr<Frame> ChunkReader::GetFrame(int64_t requested_frame)
|
||||
if (previous_location.number != location.number)
|
||||
{
|
||||
// Determine version of chunk
|
||||
string folder_name = "";
|
||||
std::string folder_name = "";
|
||||
switch (version)
|
||||
{
|
||||
case THUMBNAIL:
|
||||
@@ -217,12 +217,12 @@ std::shared_ptr<Frame> ChunkReader::GetFrame(int64_t requested_frame)
|
||||
}
|
||||
|
||||
// Load path of chunk video
|
||||
string chunk_video_path = get_chunk_path(location.number, folder_name, ".webm");
|
||||
std::string chunk_video_path = get_chunk_path(location.number, folder_name, ".webm");
|
||||
|
||||
// Close existing reader (if needed)
|
||||
if (local_reader)
|
||||
{
|
||||
cout << "Close READER" << endl;
|
||||
std::cout << "Close READER" << std::endl;
|
||||
// Close and delete old reader
|
||||
local_reader->Close();
|
||||
delete local_reader;
|
||||
@@ -230,7 +230,7 @@ std::shared_ptr<Frame> ChunkReader::GetFrame(int64_t requested_frame)
|
||||
|
||||
try
|
||||
{
|
||||
cout << "Load READER: " << chunk_video_path << endl;
|
||||
std::cout << "Load READER: " << chunk_video_path << std::endl;
|
||||
// Load new FFmpegReader
|
||||
local_reader = new FFmpegReader(chunk_video_path);
|
||||
local_reader->Open(); // open reader
|
||||
@@ -256,7 +256,7 @@ std::shared_ptr<Frame> ChunkReader::GetFrame(int64_t requested_frame)
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string ChunkReader::Json() {
|
||||
std::string ChunkReader::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -269,7 +269,7 @@ Json::Value ChunkReader::JsonValue() {
|
||||
Json::Value root = ReaderBase::JsonValue(); // get parent properties
|
||||
root["type"] = "ChunkReader";
|
||||
root["path"] = path;
|
||||
stringstream chunk_size_stream;
|
||||
std::stringstream chunk_size_stream;
|
||||
chunk_size_stream << chunk_size;
|
||||
root["chunk_size"] = chunk_size_stream.str();
|
||||
root["chunk_version"] = version;
|
||||
@@ -279,14 +279,14 @@ Json::Value ChunkReader::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void ChunkReader::SetJson(string value) {
|
||||
void ChunkReader::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
using namespace openshot;
|
||||
|
||||
ChunkWriter::ChunkWriter(string path, ReaderBase *reader) :
|
||||
ChunkWriter::ChunkWriter(std::string path, ReaderBase *reader) :
|
||||
local_reader(reader), path(path), chunk_size(24*3), chunk_count(1), frame_count(1), is_writing(false),
|
||||
default_extension(".webm"), default_vcodec("libvpx"), default_acodec("libvorbis"), last_frame_needed(false), is_open(false)
|
||||
{
|
||||
@@ -54,10 +54,10 @@ ChunkWriter::ChunkWriter(string path, ReaderBase *reader) :
|
||||
}
|
||||
|
||||
// get a formatted path of a specific chunk
|
||||
string ChunkWriter::get_chunk_path(int64_t chunk_number, string folder, string extension)
|
||||
std::string ChunkWriter::get_chunk_path(int64_t chunk_number, std::string folder, std::string extension)
|
||||
{
|
||||
// Create path of new chunk video
|
||||
stringstream chunk_count_string;
|
||||
std::stringstream chunk_count_string;
|
||||
chunk_count_string << chunk_number;
|
||||
QString padded_count = "%1"; //chunk_count_string.str().c_str();
|
||||
padded_count = padded_count.arg(chunk_count_string.str().c_str(), 6, '0');
|
||||
@@ -157,9 +157,9 @@ void ChunkWriter::WriteFrame(std::shared_ptr<Frame> frame)
|
||||
// Write the frames once it reaches the correct chunk size
|
||||
if (frame_count % chunk_size == 0 && frame_count >= chunk_size)
|
||||
{
|
||||
cout << "Done with chunk" << endl;
|
||||
cout << "frame_count: " << frame_count << endl;
|
||||
cout << "chunk_size: " << chunk_size << endl;
|
||||
std::cout << "Done with chunk" << std::endl;
|
||||
std::cout << "frame_count: " << frame_count << std::endl;
|
||||
std::cout << "chunk_size: " << chunk_size << std::endl;
|
||||
|
||||
// Pad an additional 12 frames
|
||||
for (int z = 0; z<12; z++)
|
||||
@@ -229,9 +229,9 @@ void ChunkWriter::Close()
|
||||
// Write the frames once it reaches the correct chunk size
|
||||
if (is_writing)
|
||||
{
|
||||
cout << "Final chunk" << endl;
|
||||
cout << "frame_count: " << frame_count << endl;
|
||||
cout << "chunk_size: " << chunk_size << endl;
|
||||
std::cout << "Final chunk" << std::endl;
|
||||
std::cout << "frame_count: " << frame_count << std::endl;
|
||||
std::cout << "chunk_size: " << chunk_size << std::endl;
|
||||
|
||||
// Pad an additional 12 frames
|
||||
for (int z = 0; z<12; z++)
|
||||
@@ -274,17 +274,17 @@ void ChunkWriter::Close()
|
||||
void ChunkWriter::write_json_meta_data()
|
||||
{
|
||||
// Load path of chunk folder
|
||||
string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString();
|
||||
std::string json_path = QDir::cleanPath(QString(path.c_str()) + QDir::separator() + "info.json").toStdString();
|
||||
|
||||
// Write JSON file
|
||||
ofstream myfile;
|
||||
std::ofstream myfile;
|
||||
myfile.open (json_path.c_str());
|
||||
myfile << local_reader->Json() << endl;
|
||||
myfile << local_reader->Json() << std::endl;
|
||||
myfile.close();
|
||||
}
|
||||
|
||||
// check for chunk folder
|
||||
void ChunkWriter::create_folder(string path)
|
||||
void ChunkWriter::create_folder(std::string path)
|
||||
{
|
||||
QDir dir(path.c_str());
|
||||
if (!dir.exists()) {
|
||||
@@ -303,5 +303,3 @@ void ChunkWriter::Open()
|
||||
{
|
||||
is_open = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
20
src/Clip.cpp
20
src/Clip.cpp
@@ -152,13 +152,13 @@ Clip::Clip(ReaderBase* new_reader) : resampler(NULL), audio_cache(NULL), reader(
|
||||
}
|
||||
|
||||
// Constructor with filepath
|
||||
Clip::Clip(string path) : resampler(NULL), audio_cache(NULL), reader(NULL), allocated_reader(NULL)
|
||||
Clip::Clip(std::string path) : resampler(NULL), audio_cache(NULL), reader(NULL), allocated_reader(NULL)
|
||||
{
|
||||
// Init all default settings
|
||||
init_settings();
|
||||
|
||||
// Get file extension (and convert to lower case)
|
||||
string ext = get_file_extension(path);
|
||||
std::string ext = get_file_extension(path);
|
||||
transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||
|
||||
// Determine if common video formats
|
||||
@@ -354,7 +354,7 @@ std::shared_ptr<Frame> Clip::GetFrame(int64_t requested_frame)
|
||||
}
|
||||
|
||||
// Get file extension
|
||||
string Clip::get_file_extension(string path)
|
||||
std::string Clip::get_file_extension(std::string path)
|
||||
{
|
||||
// return last part of path
|
||||
return path.substr(path.find_last_of(".") + 1);
|
||||
@@ -645,14 +645,14 @@ std::shared_ptr<Frame> Clip::GetOrCreateFrame(int64_t number)
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string Clip::Json() {
|
||||
std::string Clip::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
}
|
||||
|
||||
// Get all properties for a specific frame
|
||||
string Clip::PropertiesJSON(int64_t requested_frame) {
|
||||
std::string Clip::PropertiesJSON(int64_t requested_frame) {
|
||||
|
||||
// Generate JSON properties list
|
||||
Json::Value root;
|
||||
@@ -782,7 +782,7 @@ Json::Value Clip::JsonValue() {
|
||||
root["effects"] = Json::Value(Json::arrayValue);
|
||||
|
||||
// loop through effects
|
||||
list<EffectBase*>::iterator effect_itr;
|
||||
std::list<EffectBase*>::iterator effect_itr;
|
||||
for (effect_itr=effects.begin(); effect_itr != effects.end(); ++effect_itr)
|
||||
{
|
||||
// Get clip object from the iterator
|
||||
@@ -798,14 +798,14 @@ Json::Value Clip::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void Clip::SetJson(string value) {
|
||||
void Clip::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
@@ -943,7 +943,7 @@ void Clip::SetJsonValue(Json::Value root) {
|
||||
}
|
||||
|
||||
// Create new reader (and load properties)
|
||||
string type = root["reader"]["type"].asString();
|
||||
std::string type = root["reader"]["type"].asString();
|
||||
|
||||
if (type == "FFmpegReader") {
|
||||
|
||||
@@ -1025,7 +1025,7 @@ void Clip::RemoveEffect(EffectBase* effect)
|
||||
std::shared_ptr<Frame> Clip::apply_effects(std::shared_ptr<Frame> frame)
|
||||
{
|
||||
// Find Effects at this position and layer
|
||||
list<EffectBase*>::iterator effect_itr;
|
||||
std::list<EffectBase*>::iterator effect_itr;
|
||||
for (effect_itr=effects.begin(); effect_itr != effects.end(); ++effect_itr)
|
||||
{
|
||||
// Get clip object from the iterator
|
||||
|
||||
@@ -65,7 +65,7 @@ void ClipBase::SetJsonValue(Json::Value root) {
|
||||
}
|
||||
|
||||
// Generate JSON for a property
|
||||
Json::Value ClipBase::add_property_json(string name, float value, string type, string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) {
|
||||
Json::Value ClipBase::add_property_json(std::string name, float value, std::string type, std::string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) {
|
||||
|
||||
// Requested Point
|
||||
Point requested_point(requested_frame, requested_frame);
|
||||
@@ -101,7 +101,7 @@ Json::Value ClipBase::add_property_json(string name, float value, string type, s
|
||||
return prop;
|
||||
}
|
||||
|
||||
Json::Value ClipBase::add_property_choice_json(string name, int value, int selected_value) {
|
||||
Json::Value ClipBase::add_property_choice_json(std::string name, int value, int selected_value) {
|
||||
|
||||
// Create choice
|
||||
Json::Value new_choice = Json::Value(Json::objectValue);
|
||||
|
||||
@@ -53,7 +53,7 @@ Color::Color(Keyframe Red, Keyframe Green, Keyframe Blue, Keyframe Alpha)
|
||||
}
|
||||
|
||||
// Constructor which takes a HEX color code
|
||||
Color::Color(string color_hex)
|
||||
Color::Color(std::string color_hex)
|
||||
{
|
||||
// Create a QColor from hex
|
||||
QColor color(QString::fromStdString(color_hex));
|
||||
@@ -64,7 +64,7 @@ Color::Color(string color_hex)
|
||||
}
|
||||
|
||||
// Get the HEX value of a color at a specific frame
|
||||
string Color::GetColorHex(int64_t frame_number) {
|
||||
std::string Color::GetColorHex(int64_t frame_number) {
|
||||
|
||||
int r = red.GetInt(frame_number);
|
||||
int g = green.GetInt(frame_number);
|
||||
@@ -85,7 +85,7 @@ long Color::GetDistance(long R1, long G1, long B1, long R2, long G2, long B2)
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string Color::Json() {
|
||||
std::string Color::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -106,14 +106,14 @@ Json::Value Color::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void Color::SetJson(string value) {
|
||||
void Color::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -45,7 +45,7 @@ Coordinate::Coordinate(double x, double y) :
|
||||
|
||||
|
||||
// Generate JSON string of this object
|
||||
string Coordinate::Json() {
|
||||
std::string Coordinate::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -69,14 +69,14 @@ Json::Value Coordinate::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void Coordinate::SetJson(string value) {
|
||||
void Coordinate::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -246,7 +246,7 @@ std::shared_ptr<Frame> DecklinkReader::GetFrame(int64_t requested_frame)
|
||||
|
||||
|
||||
// Generate JSON string of this object
|
||||
string DecklinkReader::Json() {
|
||||
std::string DecklinkReader::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -264,14 +264,14 @@ Json::Value DecklinkReader::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void DecklinkReader::SetJson(string value) {
|
||||
void DecklinkReader::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -124,7 +124,7 @@ std::shared_ptr<Frame> DummyReader::GetFrame(int64_t requested_frame)
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string DummyReader::Json() {
|
||||
std::string DummyReader::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -142,14 +142,14 @@ Json::Value DummyReader::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void DummyReader::SetJson(string value) {
|
||||
void DummyReader::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -50,15 +50,15 @@ void EffectBase::InitEffectInfo()
|
||||
|
||||
// Display file information
|
||||
void EffectBase::DisplayInfo() {
|
||||
cout << fixed << setprecision(2) << boolalpha;
|
||||
cout << "----------------------------" << endl;
|
||||
cout << "----- Effect Information -----" << endl;
|
||||
cout << "----------------------------" << endl;
|
||||
cout << "--> Name: " << info.name << endl;
|
||||
cout << "--> Description: " << info.description << endl;
|
||||
cout << "--> Has Video: " << info.has_video << endl;
|
||||
cout << "--> Has Audio: " << info.has_audio << endl;
|
||||
cout << "----------------------------" << endl;
|
||||
std::cout << std::fixed << std::setprecision(2) << std::boolalpha;
|
||||
std::cout << "----------------------------" << std::endl;
|
||||
std::cout << "----- Effect Information -----" << std::endl;
|
||||
std::cout << "----------------------------" << std::endl;
|
||||
std::cout << "--> Name: " << info.name << std::endl;
|
||||
std::cout << "--> Description: " << info.description << std::endl;
|
||||
std::cout << "--> Has Video: " << info.has_video << std::endl;
|
||||
std::cout << "--> Has Audio: " << info.has_audio << std::endl;
|
||||
std::cout << "----------------------------" << std::endl;
|
||||
}
|
||||
|
||||
// Constrain a color value from 0 to 255
|
||||
@@ -74,7 +74,7 @@ int EffectBase::constrain(int color_value)
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string EffectBase::Json() {
|
||||
std::string EffectBase::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -98,14 +98,14 @@ Json::Value EffectBase::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void EffectBase::SetJson(string value) {
|
||||
void EffectBase::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -35,14 +35,14 @@ using namespace openshot;
|
||||
|
||||
|
||||
// Generate JSON string of this object
|
||||
string EffectInfo::Json() {
|
||||
std::string EffectInfo::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
}
|
||||
|
||||
// Create a new effect instance
|
||||
EffectBase* EffectInfo::CreateEffect(string effect_type) {
|
||||
EffectBase* EffectInfo::CreateEffect(std::string effect_type) {
|
||||
// Init the matching effect object
|
||||
if (effect_type == "Bars")
|
||||
return new Bars();
|
||||
|
||||
@@ -83,7 +83,7 @@ int hw_de_on = 0;
|
||||
AVHWDeviceType hw_de_av_device_type_global = AV_HWDEVICE_TYPE_NONE;
|
||||
#endif
|
||||
|
||||
FFmpegReader::FFmpegReader(string path)
|
||||
FFmpegReader::FFmpegReader(std::string path)
|
||||
: last_frame(0), is_seeking(0), seeking_pts(0), seeking_frame(0), seek_count(0),
|
||||
audio_pts_offset(99999), video_pts_offset(99999), path(path), is_video_seek(true), check_interlace(false),
|
||||
check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0),
|
||||
@@ -105,7 +105,7 @@ FFmpegReader::FFmpegReader(string path)
|
||||
Close();
|
||||
}
|
||||
|
||||
FFmpegReader::FFmpegReader(string path, bool inspect_reader)
|
||||
FFmpegReader::FFmpegReader(std::string path, bool inspect_reader)
|
||||
: last_frame(0), is_seeking(0), seeking_pts(0), seeking_frame(0), seek_count(0),
|
||||
audio_pts_offset(99999), video_pts_offset(99999), path(path), is_video_seek(true), check_interlace(false),
|
||||
check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0),
|
||||
@@ -293,7 +293,7 @@ void FFmpegReader::Open() {
|
||||
retry_decode_open = 0;
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
pCodecCtx->thread_count = min(FF_NUM_PROCESSORS, 16);
|
||||
pCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
|
||||
if (pCodec == NULL) {
|
||||
throw InvalidCodec("A valid video codec could not be found for this file.", path);
|
||||
@@ -528,7 +528,7 @@ void FFmpegReader::Open() {
|
||||
aCodecCtx = AV_GET_CODEC_CONTEXT(aStream, aCodec);
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
aCodecCtx->thread_count = min(FF_NUM_PROCESSORS, 16);
|
||||
aCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
|
||||
if (aCodec == NULL) {
|
||||
throw InvalidCodec("A valid audio codec could not be found for this file.", path);
|
||||
@@ -1282,8 +1282,8 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
|
||||
// Best fit or Stretch scaling (based on max timeline size * scaling keyframes)
|
||||
float max_scale_x = parent->scale_x.GetMaxPoint().co.Y;
|
||||
float max_scale_y = parent->scale_y.GetMaxPoint().co.Y;
|
||||
max_width = max(float(max_width), max_width * max_scale_x);
|
||||
max_height = max(float(max_height), max_height * max_scale_y);
|
||||
max_width = std::max(float(max_width), max_width * max_scale_x);
|
||||
max_height = std::max(float(max_height), max_height * max_scale_y);
|
||||
|
||||
} else if (parent->scale == SCALE_CROP) {
|
||||
// Cropping scale mode (based on max timeline size * cropped size * scaling keyframes)
|
||||
@@ -1295,11 +1295,11 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
|
||||
max_height * max_scale_y);
|
||||
// respect aspect ratio
|
||||
if (width_size.width() >= max_width && width_size.height() >= max_height) {
|
||||
max_width = max(max_width, width_size.width());
|
||||
max_height = max(max_height, width_size.height());
|
||||
max_width = std::max(max_width, width_size.width());
|
||||
max_height = std::max(max_height, width_size.height());
|
||||
} else {
|
||||
max_width = max(max_width, height_size.width());
|
||||
max_height = max(max_height, height_size.height());
|
||||
max_width = std::max(max_width, height_size.width());
|
||||
max_height = std::max(max_height, height_size.height());
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1480,7 +1480,7 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr
|
||||
// Add audio frame to list of processing audio frames
|
||||
{
|
||||
const GenericScopedLock <CriticalSection> lock(processingCriticalSection);
|
||||
processing_audio_frames.insert(pair<int, int>(previous_packet_location.frame, previous_packet_location.frame));
|
||||
processing_audio_frames.insert(std::pair<int, int>(previous_packet_location.frame, previous_packet_location.frame));
|
||||
}
|
||||
|
||||
while (pts_remaining_samples) {
|
||||
@@ -1503,7 +1503,7 @@ void FFmpegReader::ProcessAudioPacket(int64_t requested_frame, int64_t target_fr
|
||||
// Add audio frame to list of processing audio frames
|
||||
{
|
||||
const GenericScopedLock <CriticalSection> lock(processingCriticalSection);
|
||||
processing_audio_frames.insert(pair<int, int>(previous_packet_location.frame, previous_packet_location.frame));
|
||||
processing_audio_frames.insert(std::pair<int, int>(previous_packet_location.frame, previous_packet_location.frame));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1741,7 +1741,7 @@ void FFmpegReader::Seek(int64_t requested_frame) {
|
||||
seek_count++;
|
||||
|
||||
// If seeking near frame 1, we need to close and re-open the file (this is more reliable than seeking)
|
||||
int buffer_amount = max(OPEN_MP_NUM_PROCESSORS, 8);
|
||||
int buffer_amount = std::max(OPEN_MP_NUM_PROCESSORS, 8);
|
||||
if (requested_frame - buffer_amount < 20) {
|
||||
// Close and re-open file (basically seeking to frame 1)
|
||||
Close();
|
||||
@@ -1853,7 +1853,7 @@ void FFmpegReader::UpdatePTSOffset(bool is_video) {
|
||||
if (video_pts_offset == 99999) // Has the offset been set yet?
|
||||
{
|
||||
// Find the difference between PTS and frame number (no more than 10 timebase units allowed)
|
||||
video_pts_offset = 0 - max(GetVideoPTS(), (int64_t) info.video_timebase.ToInt() * 10);
|
||||
video_pts_offset = 0 - std::max(GetVideoPTS(), (int64_t) info.video_timebase.ToInt() * 10);
|
||||
|
||||
// debug output
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Video)", "video_pts_offset", video_pts_offset, "is_video", is_video);
|
||||
@@ -1863,7 +1863,7 @@ void FFmpegReader::UpdatePTSOffset(bool is_video) {
|
||||
if (audio_pts_offset == 99999) // Has the offset been set yet?
|
||||
{
|
||||
// Find the difference between PTS and frame number (no more than 10 timebase units allowed)
|
||||
audio_pts_offset = 0 - max(packet->pts, (int64_t) info.audio_timebase.ToInt() * 10);
|
||||
audio_pts_offset = 0 - std::max(packet->pts, (int64_t) info.audio_timebase.ToInt() * 10);
|
||||
|
||||
// debug output
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::UpdatePTSOffset (Audio)", "audio_pts_offset", audio_pts_offset, "is_video", is_video);
|
||||
@@ -1907,8 +1907,8 @@ int64_t FFmpegReader::ConvertVideoPTStoFrame(int64_t pts) {
|
||||
while (current_video_frame < frame) {
|
||||
if (!missing_video_frames.count(current_video_frame)) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ConvertVideoPTStoFrame (tracking missing frame)", "current_video_frame", current_video_frame, "previous_video_frame", previous_video_frame);
|
||||
missing_video_frames.insert(pair<int64_t, int64_t>(current_video_frame, previous_video_frame));
|
||||
missing_video_frames_source.insert(pair<int64_t, int64_t>(previous_video_frame, current_video_frame));
|
||||
missing_video_frames.insert(std::pair<int64_t, int64_t>(current_video_frame, previous_video_frame));
|
||||
missing_video_frames_source.insert(std::pair<int64_t, int64_t>(previous_video_frame, current_video_frame));
|
||||
}
|
||||
|
||||
// Mark this reader as containing missing frames
|
||||
@@ -2000,7 +2000,7 @@ AudioLocation FFmpegReader::GetAudioPTSLocation(int64_t pts) {
|
||||
for (int64_t audio_frame = previous_packet_location.frame; audio_frame < location.frame; audio_frame++) {
|
||||
if (!missing_audio_frames.count(audio_frame)) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::GetAudioPTSLocation (tracking missing frame)", "missing_audio_frame", audio_frame, "previous_audio_frame", previous_packet_location.frame, "new location frame", location.frame);
|
||||
missing_audio_frames.insert(pair<int64_t, int64_t>(audio_frame, previous_packet_location.frame - 1));
|
||||
missing_audio_frames.insert(std::pair<int64_t, int64_t>(audio_frame, previous_packet_location.frame - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2071,7 +2071,7 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::CheckMissingFrame", "requested_frame", requested_frame, "has_missing_frames", has_missing_frames, "missing_video_frames.size()", missing_video_frames.size(), "checked_count", checked_frames[requested_frame]);
|
||||
|
||||
// Missing frames (sometimes frame #'s are skipped due to invalid or missing timestamps)
|
||||
map<int64_t, int64_t>::iterator itr;
|
||||
std::map<int64_t, int64_t>::iterator itr;
|
||||
bool found_missing_frame = false;
|
||||
|
||||
// Special MP3 Handling (ignore more than 1 video frame)
|
||||
@@ -2084,8 +2084,8 @@ bool FFmpegReader::CheckMissingFrame(int64_t requested_frame) {
|
||||
if (checked_frames[requested_frame] > 8 && !missing_video_frames.count(requested_frame) &&
|
||||
!processing_audio_frames.count(requested_frame) && processed_audio_frames.count(requested_frame) &&
|
||||
last_frame && last_video_frame->has_image_data && aCodecId == AV_CODEC_ID_MP3 && (vCodecId == AV_CODEC_ID_MJPEGB || vCodecId == AV_CODEC_ID_MJPEG)) {
|
||||
missing_video_frames.insert(pair<int64_t, int64_t>(requested_frame, last_video_frame->number));
|
||||
missing_video_frames_source.insert(pair<int64_t, int64_t>(last_video_frame->number, requested_frame));
|
||||
missing_video_frames.insert(std::pair<int64_t, int64_t>(requested_frame, last_video_frame->number));
|
||||
missing_video_frames_source.insert(std::pair<int64_t, int64_t>(last_video_frame->number, requested_frame));
|
||||
missing_frames.Add(last_video_frame);
|
||||
}
|
||||
}
|
||||
@@ -2396,7 +2396,7 @@ void FFmpegReader::RemoveAVPacket(AVPacket *remove_packet) {
|
||||
/// Get the smallest video frame that is still being processed
|
||||
int64_t FFmpegReader::GetSmallestVideoFrame() {
|
||||
// Loop through frame numbers
|
||||
map<int64_t, int64_t>::iterator itr;
|
||||
std::map<int64_t, int64_t>::iterator itr;
|
||||
int64_t smallest_frame = -1;
|
||||
const GenericScopedLock <CriticalSection> lock(processingCriticalSection);
|
||||
for (itr = processing_video_frames.begin(); itr != processing_video_frames.end(); ++itr) {
|
||||
@@ -2411,7 +2411,7 @@ int64_t FFmpegReader::GetSmallestVideoFrame() {
|
||||
/// Get the smallest audio frame that is still being processed
|
||||
int64_t FFmpegReader::GetSmallestAudioFrame() {
|
||||
// Loop through frame numbers
|
||||
map<int64_t, int64_t>::iterator itr;
|
||||
std::map<int64_t, int64_t>::iterator itr;
|
||||
int64_t smallest_frame = -1;
|
||||
const GenericScopedLock <CriticalSection> lock(processingCriticalSection);
|
||||
for (itr = processing_audio_frames.begin(); itr != processing_audio_frames.end(); ++itr) {
|
||||
@@ -2424,7 +2424,7 @@ int64_t FFmpegReader::GetSmallestAudioFrame() {
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string FFmpegReader::Json() {
|
||||
std::string FFmpegReader::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -2443,14 +2443,14 @@ Json::Value FFmpegReader::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void FFmpegReader::SetJson(string value) {
|
||||
void FFmpegReader::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse(value.c_str(), value.c_str() + value.size(),
|
||||
&root, &errors);
|
||||
delete reader;
|
||||
|
||||
@@ -83,7 +83,7 @@ static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx, int6
|
||||
}
|
||||
#endif
|
||||
|
||||
FFmpegWriter::FFmpegWriter(string path) :
|
||||
FFmpegWriter::FFmpegWriter(std::string path) :
|
||||
path(path), fmt(NULL), oc(NULL), audio_st(NULL), video_st(NULL), audio_pts(0), video_pts(0), samples(NULL),
|
||||
audio_outbuf(NULL), audio_outbuf_size(0), audio_input_frame_size(0), audio_input_position(0),
|
||||
initial_audio_input_frame_size(0), img_convert_ctx(NULL), cache_size(8), num_of_rescalers(32),
|
||||
@@ -166,7 +166,7 @@ void FFmpegWriter::initialize_streams() {
|
||||
}
|
||||
|
||||
// Set video export options
|
||||
void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate) {
|
||||
void FFmpegWriter::SetVideoOptions(bool has_video, std::string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate) {
|
||||
// Set the video options
|
||||
if (codec.length() > 0) {
|
||||
AVCodec *new_codec;
|
||||
@@ -278,7 +278,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i
|
||||
}
|
||||
|
||||
// Set audio export options
|
||||
void FFmpegWriter::SetAudioOptions(bool has_audio, string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate) {
|
||||
void FFmpegWriter::SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate) {
|
||||
// Set audio options
|
||||
if (codec.length() > 0) {
|
||||
AVCodec *new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
@@ -313,11 +313,11 @@ void FFmpegWriter::SetAudioOptions(bool has_audio, string codec, int sample_rate
|
||||
}
|
||||
|
||||
// Set custom options (some codecs accept additional params)
|
||||
void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string value) {
|
||||
// Declare codec context
|
||||
AVCodecContext *c = NULL;
|
||||
AVStream *st = NULL;
|
||||
stringstream convert(value);
|
||||
std::stringstream convert(value);
|
||||
|
||||
if (info.has_video && stream == VIDEO_STREAM && video_st) {
|
||||
st = video_st;
|
||||
@@ -394,7 +394,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 39, 101)
|
||||
#if IS_FFMPEG_3_2
|
||||
if (hw_en_on) {
|
||||
av_opt_set_int(c->priv_data, "qp", min(stoi(value),63), 0); // 0-63
|
||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),63), 0); // 0-63
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -402,37 +402,37 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
#if (LIBAVCODEC_VERSION_MAJOR >= 58)
|
||||
case AV_CODEC_ID_AV1 :
|
||||
c->bit_rate = 0;
|
||||
av_opt_set_int(c->priv_data, "qp", min(stoi(value),63), 0); // 0-63
|
||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value),63), 0); // 0-63
|
||||
break;
|
||||
#endif
|
||||
case AV_CODEC_ID_VP8 :
|
||||
c->bit_rate = 10000000;
|
||||
av_opt_set_int(c->priv_data, "qp", max(min(stoi(value), 63), 4), 0); // 4-63
|
||||
av_opt_set_int(c->priv_data, "qp", std::max(std::min(std::stoi(value), 63), 4), 0); // 4-63
|
||||
break;
|
||||
case AV_CODEC_ID_VP9 :
|
||||
c->bit_rate = 0; // Must be zero!
|
||||
av_opt_set_int(c->priv_data, "qp", min(stoi(value), 63), 0); // 0-63
|
||||
if (stoi(value) == 0) {
|
||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 63), 0); // 0-63
|
||||
if (std::stoi(value) == 0) {
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
av_opt_set_int(c->priv_data, "lossless", 1, 0);
|
||||
}
|
||||
break;
|
||||
case AV_CODEC_ID_H264 :
|
||||
av_opt_set_int(c->priv_data, "qp", min(stoi(value), 51), 0); // 0-51
|
||||
if (stoi(value) == 0) {
|
||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 51), 0); // 0-51
|
||||
if (std::stoi(value) == 0) {
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
}
|
||||
break;
|
||||
case AV_CODEC_ID_H265 :
|
||||
av_opt_set_int(c->priv_data, "qp", min(stoi(value), 51), 0); // 0-51
|
||||
if (stoi(value) == 0) {
|
||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 51), 0); // 0-51
|
||||
if (std::stoi(value) == 0) {
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
av_opt_set_int(c->priv_data, "lossless", 1, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// For all other codecs assume a range of 0-63
|
||||
av_opt_set_int(c->priv_data, "qp", min(stoi(value), 63), 0); // 0-63
|
||||
av_opt_set_int(c->priv_data, "qp", std::min(std::stoi(value), 63), 0); // 0-63
|
||||
c->bit_rate = 0;
|
||||
}
|
||||
}
|
||||
@@ -450,7 +450,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
mbs = 380000.0;
|
||||
}
|
||||
else {
|
||||
mbs *= pow(0.912,info.video_bit_rate);
|
||||
mbs *= std::pow(0.912,info.video_bit_rate);
|
||||
}
|
||||
}
|
||||
c->bit_rate = (int)(mbs);
|
||||
@@ -461,30 +461,30 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
#if (LIBAVCODEC_VERSION_MAJOR >= 58)
|
||||
case AV_CODEC_ID_AV1 :
|
||||
c->bit_rate = 0;
|
||||
av_opt_set_int(c->priv_data, "crf", min(stoi(value),63), 0);
|
||||
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value),63), 0);
|
||||
break;
|
||||
#endif
|
||||
case AV_CODEC_ID_VP8 :
|
||||
c->bit_rate = 10000000;
|
||||
av_opt_set_int(c->priv_data, "crf", max(min(stoi(value), 63), 4), 0); // 4-63
|
||||
av_opt_set_int(c->priv_data, "crf", std::max(std::min(std::stoi(value), 63), 4), 0); // 4-63
|
||||
break;
|
||||
case AV_CODEC_ID_VP9 :
|
||||
c->bit_rate = 0; // Must be zero!
|
||||
av_opt_set_int(c->priv_data, "crf", min(stoi(value), 63), 0); // 0-63
|
||||
if (stoi(value) == 0) {
|
||||
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value), 63), 0); // 0-63
|
||||
if (std::stoi(value) == 0) {
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
av_opt_set_int(c->priv_data, "lossless", 1, 0);
|
||||
}
|
||||
break;
|
||||
case AV_CODEC_ID_H264 :
|
||||
av_opt_set_int(c->priv_data, "crf", min(stoi(value), 51), 0); // 0-51
|
||||
if (stoi(value) == 0) {
|
||||
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value), 51), 0); // 0-51
|
||||
if (std::stoi(value) == 0) {
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
}
|
||||
break;
|
||||
case AV_CODEC_ID_H265 :
|
||||
av_opt_set_int(c->priv_data, "crf", min(stoi(value), 51), 0); // 0-51
|
||||
if (stoi(value) == 0) {
|
||||
av_opt_set_int(c->priv_data, "crf", std::min(std::stoi(value), 51), 0); // 0-51
|
||||
if (std::stoi(value) == 0) {
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
av_opt_set_int(c->priv_data, "lossless", 1, 0);
|
||||
}
|
||||
@@ -497,7 +497,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
if (info.video_bit_rate > 42) {
|
||||
mbs = 380000.0;
|
||||
} else {
|
||||
mbs *= pow(0.912, info.video_bit_rate);
|
||||
mbs *= std::pow(0.912, info.video_bit_rate);
|
||||
}
|
||||
}
|
||||
c->bit_rate = (int) (mbs);
|
||||
@@ -509,7 +509,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
AV_OPTION_SET(st, c->priv_data, name.c_str(), value.c_str(), c);
|
||||
}
|
||||
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetOption (" + (string)name + ")", "stream == VIDEO_STREAM", stream == VIDEO_STREAM);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::SetOption (" + (std::string)name + ")", "stream == VIDEO_STREAM", stream == VIDEO_STREAM);
|
||||
|
||||
// Muxing dictionary is not part of the codec context.
|
||||
// Just reusing SetOption function to set popular multiplexing presets.
|
||||
@@ -529,7 +529,7 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value) {
|
||||
}
|
||||
|
||||
/// Determine if codec name is valid
|
||||
bool FFmpegWriter::IsValidCodec(string codec_name) {
|
||||
bool FFmpegWriter::IsValidCodec(std::string codec_name) {
|
||||
// Initialize FFMpeg, and register all formats and codecs
|
||||
AV_REGISTER_ALL
|
||||
|
||||
@@ -569,7 +569,7 @@ void FFmpegWriter::WriteHeader() {
|
||||
AV_SET_FILENAME(oc, path.c_str());
|
||||
|
||||
// Add general metadata (if any)
|
||||
for (std::map<string, string>::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) {
|
||||
for (std::map<std::string, std::string>::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) {
|
||||
av_dict_set(&oc->metadata, iter->first.c_str(), iter->second.c_str(), 0);
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ void FFmpegWriter::flush_encoders() {
|
||||
#endif // IS_FFMPEG_3_2
|
||||
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
}
|
||||
if (!got_packet) {
|
||||
stop_encoding = 1;
|
||||
@@ -881,7 +881,7 @@ void FFmpegWriter::flush_encoders() {
|
||||
// Write packet
|
||||
error_code = av_interleaved_write_frame(oc, &pkt);
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
}
|
||||
|
||||
// Deallocate memory (if needed)
|
||||
@@ -916,7 +916,7 @@ void FFmpegWriter::flush_encoders() {
|
||||
error_code = avcodec_encode_audio2(audio_codec, &pkt, NULL, &got_packet);
|
||||
#endif
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
}
|
||||
if (!got_packet) {
|
||||
stop_encoding = 1;
|
||||
@@ -942,7 +942,7 @@ void FFmpegWriter::flush_encoders() {
|
||||
// Write packet
|
||||
error_code = av_interleaved_write_frame(oc, &pkt);
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::flush_encoders ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
}
|
||||
|
||||
// deallocate memory for packet
|
||||
@@ -1254,9 +1254,9 @@ AVStream *FFmpegWriter::add_video_stream() {
|
||||
|
||||
AV_COPY_PARAMS_FROM_CONTEXT(st, c);
|
||||
#if (LIBAVFORMAT_VERSION_MAJOR < 58)
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "AVFMT_RAWPICTURE", AVFMT_RAWPICTURE);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (std::string)fmt->name + " : " + (std::string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "AVFMT_RAWPICTURE", AVFMT_RAWPICTURE);
|
||||
#else
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (std::string)fmt->name + " : " + (std::string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags);
|
||||
#endif
|
||||
|
||||
return st;
|
||||
@@ -1268,7 +1268,7 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st) {
|
||||
AV_GET_CODEC_FROM_STREAM(st, audio_codec)
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
audio_codec->thread_count = min(FF_NUM_PROCESSORS, 16);
|
||||
audio_codec->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
|
||||
// Find the audio encoder
|
||||
codec = avcodec_find_encoder_by_name(info.acodec.c_str());
|
||||
@@ -1326,7 +1326,7 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st) {
|
||||
audio_encoder_buffer = new uint8_t[audio_encoder_buffer_size];
|
||||
|
||||
// Add audio metadata (if any)
|
||||
for (std::map<string, string>::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) {
|
||||
for (std::map<std::string, std::string>::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) {
|
||||
av_dict_set(&st->metadata, iter->first.c_str(), iter->second.c_str(), 0);
|
||||
}
|
||||
|
||||
@@ -1339,7 +1339,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) {
|
||||
AV_GET_CODEC_FROM_STREAM(st, video_codec)
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
video_codec->thread_count = min(FF_NUM_PROCESSORS, 16);
|
||||
video_codec->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
|
||||
#if IS_FFMPEG_3_2
|
||||
if (hw_en_on && hw_en_supported) {
|
||||
@@ -1461,7 +1461,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) {
|
||||
av_dict_free(&opts);
|
||||
|
||||
// Add video metadata (if any)
|
||||
for (std::map<string, string>::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) {
|
||||
for (std::map<std::string, std::string>::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter) {
|
||||
av_dict_set(&st->metadata, iter->first.c_str(), iter->second.c_str(), 0);
|
||||
}
|
||||
|
||||
@@ -1796,12 +1796,12 @@ void FFmpegWriter::write_audio_packets(bool is_final) {
|
||||
/* write the compressed frame in the media file */
|
||||
int error_code = av_interleaved_write_frame(oc, &pkt);
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
}
|
||||
}
|
||||
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_audio_packets ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
}
|
||||
|
||||
// deallocate AVFrame
|
||||
@@ -1944,7 +1944,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
|
||||
/* write the compressed frame in the media file */
|
||||
int error_code = av_interleaved_write_frame(oc, &pkt);
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2004,10 +2004,10 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
|
||||
if (ret < 0 ) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet (Frame not sent)");
|
||||
if (ret == AVERROR(EAGAIN) ) {
|
||||
cerr << "Frame EAGAIN" << "\n";
|
||||
std::cerr << "Frame EAGAIN" << "\n";
|
||||
}
|
||||
if (ret == AVERROR_EOF ) {
|
||||
cerr << "Frame AVERROR_EOF" << "\n";
|
||||
std::cerr << "Frame AVERROR_EOF" << "\n";
|
||||
}
|
||||
avcodec_send_frame(video_codec, NULL);
|
||||
}
|
||||
@@ -2031,10 +2031,10 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
|
||||
// Write video packet (older than FFmpeg 3.2)
|
||||
error_code = avcodec_encode_video2(video_codec, &pkt, frame_final, &got_packet_ptr);
|
||||
if (error_code != 0) {
|
||||
cerr << "Frame AVERROR_EOF" << "\n";
|
||||
std::cerr << "Frame AVERROR_EOF" << "\n";
|
||||
}
|
||||
if (got_packet_ptr == 0) {
|
||||
cerr << "Frame gotpacket error" << "\n";
|
||||
std::cerr << "Frame gotpacket error" << "\n";
|
||||
}
|
||||
#else
|
||||
// Write video packet (even older versions of FFmpeg)
|
||||
@@ -2076,7 +2076,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
|
||||
/* write the compressed frame in the media file */
|
||||
int error_code = av_interleaved_write_frame(oc, &pkt);
|
||||
if (error_code < 0) {
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (std::string) av_err2str(error_code) + "]", "error_code", error_code);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ Frame::Frame() : number(1), pixel_ratio(1,1), channels(2), width(1), height(1),
|
||||
};
|
||||
|
||||
// Constructor - image only (48kHz audio silence)
|
||||
Frame::Frame(int64_t number, int width, int height, string color)
|
||||
Frame::Frame(int64_t number, int width, int height, std::string color)
|
||||
: number(number), pixel_ratio(1,1), channels(2), width(width), height(height), color(color),
|
||||
channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false),
|
||||
max_audio_sample(0)
|
||||
@@ -72,7 +72,7 @@ Frame::Frame(int64_t number, int samples, int channels) :
|
||||
};
|
||||
|
||||
// Constructor - image & audio
|
||||
Frame::Frame(int64_t number, int width, int height, string color, int samples, int channels)
|
||||
Frame::Frame(int64_t number, int width, int height, std::string color, int samples, int channels)
|
||||
: number(number), pixel_ratio(1,1), channels(channels), width(width), height(height), color(color),
|
||||
channel_layout(LAYOUT_STEREO), sample_rate(44100), qbuffer(NULL), has_audio_data(false), has_image_data(false),
|
||||
max_audio_sample(0)
|
||||
@@ -574,7 +574,7 @@ ChannelLayout Frame::ChannelsLayout()
|
||||
|
||||
|
||||
// Save the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG)
|
||||
void Frame::Save(string path, float scale, string format, int quality)
|
||||
void Frame::Save(std::string path, float scale, std::string format, int quality)
|
||||
{
|
||||
// Get preview image
|
||||
std::shared_ptr<QImage> previewImage = GetImage();
|
||||
@@ -605,8 +605,8 @@ void Frame::Save(string path, float scale, string format, int quality)
|
||||
}
|
||||
|
||||
// Thumbnail the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG)
|
||||
void Frame::Thumbnail(string path, int new_width, int new_height, string mask_path, string overlay_path,
|
||||
string background_color, bool ignore_aspect, string format, int quality, float rotate) {
|
||||
void Frame::Thumbnail(std::string path, int new_width, int new_height, std::string mask_path, std::string overlay_path,
|
||||
std::string background_color, bool ignore_aspect, std::string format, int quality, float rotate) {
|
||||
|
||||
// Create blank thumbnail image & fill background color
|
||||
std::shared_ptr<QImage> thumbnail = std::shared_ptr<QImage>(new QImage(new_width, new_height, QImage::Format_RGBA8888));
|
||||
@@ -729,7 +729,7 @@ int Frame::constrain(int color_value)
|
||||
}
|
||||
|
||||
// Add (or replace) pixel data to the frame (based on a solid color)
|
||||
void Frame::AddColor(int new_width, int new_height, string new_color)
|
||||
void Frame::AddColor(int new_width, int new_height, std::string new_color)
|
||||
{
|
||||
// Set color
|
||||
color = new_color;
|
||||
|
||||
@@ -675,7 +675,7 @@ void FrameMapper::Close()
|
||||
|
||||
|
||||
// Generate JSON string of this object
|
||||
string FrameMapper::Json() {
|
||||
std::string FrameMapper::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -693,14 +693,14 @@ Json::Value FrameMapper::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void FrameMapper::SetJson(string value) {
|
||||
void FrameMapper::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
@@ -820,7 +820,7 @@ void FrameMapper::ResampleMappedAudio(std::shared_ptr<Frame> frame, int64_t orig
|
||||
|
||||
if (error_code < 0)
|
||||
{
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FrameMapper::ResampleMappedAudio ERROR [" + (std::string)av_err2str(error_code) + "]", "error_code", error_code);
|
||||
throw ErrorEncodingVideo("Error while resampling audio in frame mapper", frame->number);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
|
||||
using namespace openshot;
|
||||
|
||||
ImageReader::ImageReader(string path) : path(path), is_open(false)
|
||||
ImageReader::ImageReader(std::string path) : path(path), is_open(false)
|
||||
{
|
||||
// Open and Close the reader, to populate its attributes (such as height, width, etc...)
|
||||
Open();
|
||||
Close();
|
||||
}
|
||||
|
||||
ImageReader::ImageReader(string path, bool inspect_reader) : path(path), is_open(false)
|
||||
ImageReader::ImageReader(std::string path, bool inspect_reader) : path(path), is_open(false)
|
||||
{
|
||||
// Open and Close the reader, to populate its attributes (such as height, width, etc...)
|
||||
if (inspect_reader) {
|
||||
@@ -136,7 +136,7 @@ std::shared_ptr<Frame> ImageReader::GetFrame(int64_t requested_frame)
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string ImageReader::Json() {
|
||||
std::string ImageReader::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -155,14 +155,14 @@ Json::Value ImageReader::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void ImageReader::SetJson(string value) {
|
||||
void ImageReader::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
using namespace openshot;
|
||||
|
||||
ImageWriter::ImageWriter(string path) :
|
||||
ImageWriter::ImageWriter(std::string path) :
|
||||
path(path), cache_size(8), is_writing(false), write_video_count(0), image_quality(75), number_of_loops(1),
|
||||
combine_frames(true), is_open(false)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ ImageWriter::ImageWriter(string path) :
|
||||
}
|
||||
|
||||
// Set video export options
|
||||
void ImageWriter::SetVideoOptions(string format, Fraction fps, int width, int height,
|
||||
void ImageWriter::SetVideoOptions(std::string format, Fraction fps, int width, int height,
|
||||
int quality, int loops, bool combine)
|
||||
{
|
||||
// Set frames per second (if provided)
|
||||
|
||||
@@ -307,7 +307,7 @@ bool Keyframe::IsIncreasing(int index)
|
||||
int64_t next_repeats = 0;
|
||||
|
||||
// Loop backwards and look for the next unique value
|
||||
for (vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
|
||||
for (std::vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
|
||||
previous_value = long(round((*backwards_it).Y));
|
||||
if (previous_value == current_value) {
|
||||
// Found same value
|
||||
@@ -319,7 +319,7 @@ bool Keyframe::IsIncreasing(int index)
|
||||
}
|
||||
|
||||
// Loop forwards and look for the next unique value
|
||||
for (vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
|
||||
for (std::vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
|
||||
next_value = long(round((*forwards_it).Y));
|
||||
if (next_value == current_value) {
|
||||
// Found same value
|
||||
@@ -340,7 +340,7 @@ bool Keyframe::IsIncreasing(int index)
|
||||
}
|
||||
|
||||
// Generate JSON string of this object
|
||||
string Keyframe::Json() {
|
||||
std::string Keyframe::Json() {
|
||||
|
||||
// Return formatted string
|
||||
return JsonValue().toStyledString();
|
||||
@@ -365,14 +365,14 @@ Json::Value Keyframe::JsonValue() {
|
||||
}
|
||||
|
||||
// Load JSON string into this object
|
||||
void Keyframe::SetJson(string value) {
|
||||
void Keyframe::SetJson(std::string value) {
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
Json::CharReader* reader(rbuilder.newCharReader());
|
||||
|
||||
string errors;
|
||||
std::string errors;
|
||||
bool success = reader->parse( value.c_str(),
|
||||
value.c_str() + value.size(), &root, &errors );
|
||||
delete reader;
|
||||
@@ -436,7 +436,7 @@ Fraction Keyframe::GetRepeatFraction(int64_t index)
|
||||
int64_t next_repeats = 0;
|
||||
|
||||
// Loop backwards and look for the next unique value
|
||||
for (vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
|
||||
for (std::vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
|
||||
previous_value = long(round((*backwards_it).Y));
|
||||
if (previous_value == current_value) {
|
||||
// Found same value
|
||||
@@ -448,7 +448,7 @@ Fraction Keyframe::GetRepeatFraction(int64_t index)
|
||||
}
|
||||
|
||||
// Loop forwards and look for the next unique value
|
||||
for (vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
|
||||
for (std::vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
|
||||
next_value = long(round((*forwards_it).Y));
|
||||
if (next_value == current_value) {
|
||||
// Found same value
|
||||
@@ -483,7 +483,7 @@ double Keyframe::GetDelta(int64_t index)
|
||||
int64_t next_repeats = 0;
|
||||
|
||||
// Loop backwards and look for the next unique value
|
||||
for (vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
|
||||
for (std::vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
|
||||
previous_value = long(round((*backwards_it).Y));
|
||||
if (previous_value == current_value) {
|
||||
// Found same value
|
||||
@@ -495,7 +495,7 @@ double Keyframe::GetDelta(int64_t index)
|
||||
}
|
||||
|
||||
// Loop forwards and look for the next unique value
|
||||
for (vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
|
||||
for (std::vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
|
||||
next_value = long(round((*forwards_it).Y));
|
||||
if (next_value == current_value) {
|
||||
// Found same value
|
||||
@@ -605,7 +605,7 @@ void Keyframe::PrintPoints() {
|
||||
Process();
|
||||
|
||||
cout << fixed << setprecision(4);
|
||||
for (vector<Point>::iterator it = Points.begin(); it != Points.end(); it++) {
|
||||
for (std::vector<Point>::iterator it = Points.begin(); it != Points.end(); it++) {
|
||||
Point p = *it;
|
||||
cout << p.co.X << "\t" << p.co.Y << endl;
|
||||
}
|
||||
@@ -619,7 +619,7 @@ void Keyframe::PrintValues() {
|
||||
cout << fixed << setprecision(4);
|
||||
cout << "Frame Number (X)\tValue (Y)\tIs Increasing\tRepeat Numerator\tRepeat Denominator\tDelta (Y Difference)" << endl;
|
||||
|
||||
for (vector<Coordinate>::iterator it = Values.begin() + 1; it != Values.end(); it++) {
|
||||
for (std::vector<Coordinate>::iterator it = Values.begin() + 1; it != Values.end(); it++) {
|
||||
Coordinate c = *it;
|
||||
cout << long(round(c.X)) << "\t" << c.Y << "\t" << IsIncreasing(c.X) << "\t" << GetRepeatFraction(c.X).num << "\t" << GetRepeatFraction(c.X).den << "\t" << GetDelta(c.X) << endl;
|
||||
}
|
||||
@@ -722,13 +722,13 @@ void Keyframe::ProcessSegment(int Segment, Point p1, Point p2) {
|
||||
double X_diff = p2.co.X - p1.co.X;
|
||||
double Y_diff = p2.co.Y - p1.co.Y;
|
||||
|
||||
vector<Coordinate> segment_coordinates;
|
||||
std::vector<Coordinate> segment_coordinates;
|
||||
segment_coordinates.push_back(p1.co);
|
||||
segment_coordinates.push_back(Coordinate(p1.co.X + (p1.handle_right.X * X_diff), p1.co.Y + (p1.handle_right.Y * Y_diff)));
|
||||
segment_coordinates.push_back(Coordinate(p1.co.X + (p2.handle_left.X * X_diff), p1.co.Y + (p2.handle_left.Y * Y_diff)));
|
||||
segment_coordinates.push_back(p2.co);
|
||||
|
||||
vector<Coordinate> raw_coordinates;
|
||||
std::vector<Coordinate> raw_coordinates;
|
||||
int64_t npts = segment_coordinates.size();
|
||||
int64_t icount, jcount;
|
||||
double step, t;
|
||||
@@ -904,7 +904,7 @@ void Keyframe::ScalePoints(double scale)
|
||||
void Keyframe::FlipPoints()
|
||||
{
|
||||
// Loop through each point
|
||||
vector<Point> FlippedPoints;
|
||||
std::vector<Point> FlippedPoints;
|
||||
for (int64_t point_index = 0, reverse_index = Points.size() - 1; point_index < Points.size(); point_index++, reverse_index--) {
|
||||
// Flip the points
|
||||
Point p = Points[point_index];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user