Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
[Shinon] Works
Browse files Browse the repository at this point in the history
  • Loading branch information
Ristellise committed Oct 1, 2021
1 parent adeea33 commit 31e235a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build/git_version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define BUILD_GIT_VERSION_NUMBER 9213
#define BUILD_GIT_VERSION_STRING "9213"
#define BUILD_GIT_VERSION_NUMBER 9214
#define BUILD_GIT_VERSION_STRING "9214"
#define TAGGED_RELEASE 0
#define INSTALLER_VERSION '2.0.0'
#define RESOURCE_BASE_VERSION 2, 0, 0
13 changes: 7 additions & 6 deletions libaegisub/audio/provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ template<typename Source>
class DownmixToMono {
Source src;
int channels;
bool asAmplitudeEnv;
public:
DownmixToMono(Source src, int channels) :src(src), channels(channels) {}
DownmixToMono(Source src, int channels, bool asAmpEnv = false) :src(src), channels(channels), asAmplitudeEnv(asAmpEnv) {}
int16_t operator[](size_t idx) const {
int ret = 0;
// Just average the channels together
Expand All @@ -73,7 +74,7 @@ class DownmixToMono {
}

namespace agi {
void AudioProvider::FillBufferInt16Mono(int16_t* buf, int64_t start, int64_t count) const {
void AudioProvider::FillBufferInt16Mono(int16_t* buf, int64_t start, int64_t count, bool asAmplitude) const {
if (!float_samples && bytes_per_sample == 2 && channels == 1) {
FillBuffer(buf, start, count);
return;
Expand Down Expand Up @@ -102,18 +103,18 @@ void AudioProvider::FillBufferInt16Mono(int16_t* buf, int64_t start, int64_t cou
if (float_samples) {
if (bytes_per_sample == sizeof(float))
for (int64_t i = 0; i < count; ++i)
buf[i] = DownmixToMono<ConvertFloatToInt16<float> >(ConvertFloatToInt16<float>(reinterpret_cast<float*>(buff)), channels)[i];
buf[i] = DownmixToMono<ConvertFloatToInt16<float> >(ConvertFloatToInt16<float>(reinterpret_cast<float*>(buff)), channels, asAmplitude)[i];
else if (bytes_per_sample == sizeof(double))
for (int64_t i = 0; i < count; ++i)
buf[i] = DownmixToMono<ConvertFloatToInt16<double> >(ConvertFloatToInt16<double>(reinterpret_cast<double*>(buff)), channels)[i];
buf[i] = DownmixToMono<ConvertFloatToInt16<double> >(ConvertFloatToInt16<double>(reinterpret_cast<double*>(buff)), channels, asAmplitude)[i];
}
else {
if (bytes_per_sample == sizeof(uint8_t))
for (int64_t i = 0; i < count; ++i)
buf[i] = DownmixToMono<ConvertUInt8ToInt16>(ConvertUInt8ToInt16(reinterpret_cast<uint8_t*>(buff)), channels)[i];
buf[i] = DownmixToMono<ConvertUInt8ToInt16>(ConvertUInt8ToInt16(reinterpret_cast<uint8_t*>(buff)), channels, asAmplitude)[i];
else
for (int64_t i = 0; i < count; ++i)
buf[i] = DownmixToMono<ConvertIntToInt16>(ConvertIntToInt16(buff, bytes_per_sample), channels)[i];
buf[i] = DownmixToMono<ConvertIntToInt16>(ConvertIntToInt16(buff, bytes_per_sample), channels, asAmplitude)[i];
}
}
free(buff);
Expand Down
3 changes: 1 addition & 2 deletions libaegisub/audio/provider_hd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class HDAudioProvider final : public AudioProviderWrapper {
if ((uint64_t)num_samples * bytes_per_sample * channels > fs::FreeSpace(dir))
throw AudioProviderError("Not enough free disk space in " + dir.string() + " to cache the audio");

return format("audio-%lld-%lld", time(nullptr),
boost::interprocess::ipcdetail::get_current_process_id());
return "audio";
}

public:
Expand Down
2 changes: 1 addition & 1 deletion libaegisub/audio/provider_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LockAudioProvider final : public agi::AudioProviderWrapper {
source->GetAudio(buf, start, count);
}

void FillBufferInt16Mono(int16_t *buf, int64_t start, int64_t count) const override {
void FillBufferInt16Mono(int16_t *buf, int64_t start, int64_t count, bool _) const override {
std::unique_lock<std::mutex> lock(mutex);
source->GetInt16MonoAudio(buf, start, count);
}
Expand Down
1 change: 1 addition & 0 deletions libaegisub/common/ycbcr_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ double matrix_coefficients[][3] = {
{.2126, .7152, .0722}, // BT.709
{.3, .59, .11}, // FCC
{.212, .701, .087}, // SMPTE 240M
{.2627, .014, .0593} // BT.2020
};

void row_mult(std::array<double, 9>& arr, std::array<double, 3> values) {
Expand Down
2 changes: 1 addition & 1 deletion libaegisub/include/libaegisub/audio/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AudioProvider {
bool float_samples = false;

virtual void FillBuffer(void *buf, int64_t start, int64_t count) const = 0;
virtual void FillBufferInt16Mono(int16_t* buf, int64_t start, int64_t count) const;
virtual void FillBufferInt16Mono(int16_t* buf, int64_t start, int64_t count, bool asAmplitude=false) const;

void ZeroFill(void *buf, int64_t count) const;

Expand Down
3 changes: 2 additions & 1 deletion libaegisub/include/libaegisub/ycbcr_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ enum class ycbcr_matrix {
bt601,
bt709,
fcc,
smpte_240m
smpte_240m,
bt2020
};

enum class ycbcr_range {
Expand Down
7 changes: 6 additions & 1 deletion src/resolution_resampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ static const std::string names[] = {
"TV.601", "PC.601",
"TV.709", "PC.709",
"TV.FCC", "PC.FCC",
"TV.240M", "PC.240M"
"TV.240M", "PC.240M",
"TV.2020", "PC.2020",

};

YCbCrMatrix MatrixFromString(std::string const& str) {
Expand Down Expand Up @@ -200,6 +202,7 @@ namespace {
case YCbCrMatrix::tv_709: case YCbCrMatrix::pc_709: return agi::ycbcr_matrix::bt709;
case YCbCrMatrix::tv_fcc: case YCbCrMatrix::pc_fcc: return agi::ycbcr_matrix::fcc;
case YCbCrMatrix::tv_240m: case YCbCrMatrix::pc_240m: return agi::ycbcr_matrix::smpte_240m;
case YCbCrMatrix::tv_2020: case YCbCrMatrix::pc_2020: return agi::ycbcr_matrix::bt2020;
}
throw agi::InternalError("Invalid matrix");
}
Expand All @@ -211,11 +214,13 @@ namespace {
case YCbCrMatrix::tv_709:
case YCbCrMatrix::tv_fcc:
case YCbCrMatrix::tv_240m:
case YCbCrMatrix::tv_2020:
return agi::ycbcr_range::tv;
case YCbCrMatrix::pc_601:
case YCbCrMatrix::pc_709:
case YCbCrMatrix::pc_fcc:
case YCbCrMatrix::pc_240m:
case YCbCrMatrix::pc_2020:
return agi::ycbcr_range::pc;
}
throw agi::InternalError("Invalid matrix");
Expand Down
4 changes: 3 additions & 1 deletion src/resolution_resampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ enum class YCbCrMatrix : int {
tv_fcc,
pc_fcc,
tv_240m,
pc_240m
pc_240m,
tv_2020,
pc_2020,
};

YCbCrMatrix MatrixFromString(std::string const& str);
Expand Down

0 comments on commit 31e235a

Please sign in to comment.