void cFontLoader:: ExportDFFToFile(tDistanceFontHandle font, const Twine& in_path /*= ""*/) { auto& dff = DistanceFont(font); size_t face_size = cSerialization::SerializedSize(dff.Face()); cDFFFile pair(dff, face_size); AlignedBuffer<16> buffer; cSerialization::SerializeLZMA(pair,buffer); cStringRef file_data(buffer.ptr<char>(), buffer.size()); try{ if (sys::path::has_filename(in_path)) { WriteFileToDisk(file_data, in_path); } else { cSmallVector<char, 256> path_buf; cStringRef temp_path = in_path.toNullTerminatedStringRef(path_buf); sys::path::append(path_buf, in_path, dff.FontName() + ".dff"); cStringRef full_path(path_buf.data(), path_buf.size()); WriteFileToDisk(file_data, full_path); } } catch (const Exception& e) { Log::Warn("Swallowed exception while trying to write dff file: %s", e.what()); } }
void Scheduler::process_audio(AVPacket& pkt, AlignedBuffer<int16_t>& buf) { if (!has_audio) return; uint8_t *data = pkt.data; size_t size = pkt.size; size_t written = 0; while (pkt.size > 0) { int out_size = buf.size() * sizeof(int16_t) - written; audio_lock.lock(); int ret = avcodec_decode_audio3(file->audio().ctx, &buf[written / sizeof(int16_t)], &out_size, &pkt); audio_lock.unlock(); if (ret <= 0) break; pkt.size -= ret; pkt.data += ret; written += out_size; } pkt.data = data; pkt.size = size; audio_lock.lock(); audio->write(&buf[0], written / 2); audio_lock.unlock(); avlock.lock(); audio_written += written; if (pkt.pts != (int64_t)AV_NOPTS_VALUE) audio_pts = pkt.pts * av_q2d(file->audio().time_base) - audio->delay(); else if (pkt.dts != (int64_t)AV_NOPTS_VALUE) audio_pts = pkt.dts * av_q2d(file->audio().time_base) - audio->delay(); audio_pts_ts = get_time(); avlock.unlock(); }
AlignedBuffer<Properties>::AlignedBuffer(const AlignedBuffer& other) noexcept : AlignedBuffer() { resize(other.size()); set(0, other.size(), other.get(0)); } // end of Buffer::AlignedBuffer