Skip to content

Commit

Permalink
Fix misguided brace style
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspeloquin committed Apr 9, 2020
1 parent d31c35d commit 629eef1
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 237 deletions.
18 changes: 6 additions & 12 deletions decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ bool same_file(FILE *, FILE *);
class Sox_init {
public:
Sox_init() : _valid(false) {}
~Sox_init()
{
~Sox_init() {
if (_valid)
sox_quit();
}
Expand Down Expand Up @@ -227,8 +226,7 @@ Flac_decoder::next_frame(struct flacsplit::Frame &frame) {

FLAC__StreamDecoderWriteStatus
Flac_decoder::write_callback(const FLAC__Frame *frame,
const FLAC__int32 *const *buffer)
{
const FLAC__int32 *const *buffer) {
if (!_last_buffer.get())
// the number of channels should be constant
_last_buffer.reset(new const FLAC__int32 *[
Expand All @@ -249,8 +247,7 @@ Flac_decoder::write_callback(const FLAC__Frame *frame,
}

FLAC__StreamDecoderSeekStatus
Flac_decoder::seek_callback(FLAC__uint64 absolute_byte_offset)
{
Flac_decoder::seek_callback(FLAC__uint64 absolute_byte_offset) {
long off = absolute_byte_offset;
if (static_cast<FLAC__uint64>(off) != absolute_byte_offset)
throw std::runtime_error("bad offset");
Expand All @@ -261,8 +258,7 @@ Flac_decoder::seek_callback(FLAC__uint64 absolute_byte_offset)
}

FLAC__StreamDecoderTellStatus
Flac_decoder::tell_callback(FLAC__uint64 *absolute_byte_offset)
{
Flac_decoder::tell_callback(FLAC__uint64 *absolute_byte_offset) {
long off = ftell(_fp);
if (off < 0)
return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
Expand All @@ -271,8 +267,7 @@ Flac_decoder::tell_callback(FLAC__uint64 *absolute_byte_offset)
}

FLAC__StreamDecoderLengthStatus
Flac_decoder::length_callback(FLAC__uint64 *stream_length)
{
Flac_decoder::length_callback(FLAC__uint64 *stream_length) {
struct stat st;
if (fstat(fileno(_fp), &st))
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
Expand Down Expand Up @@ -345,8 +340,7 @@ Wave_decoder::next_frame(struct flacsplit::Frame &frame) {
}

enum flacsplit::file_format
get_file_format(FILE *fp)
{
get_file_format(FILE *fp) {
const char *const RIFF = "RIFF";
const char *const WAVE = "WAVE";
const char *const FLAC = "fLaC";
Expand Down
21 changes: 7 additions & 14 deletions encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,12 @@ class Flac_encoder :
FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *) override;

private:
virtual void set_meta(const flacsplit::Music_info &track)
{
virtual void set_meta(const flacsplit::Music_info &track) {
set_meta(track, true);
}
void set_meta(const flacsplit::Music_info &, bool);

FLAC__StreamMetadata *cast_metadata(FLAC::Metadata::Prototype &meta)
{
FLAC__StreamMetadata *cast_metadata(FLAC::Metadata::Prototype &meta) {
return const_cast<FLAC__StreamMetadata *>(
static_cast<const FLAC__StreamMetadata *>(meta));
}
Expand Down Expand Up @@ -152,8 +150,7 @@ Flac_encoder::add_frame(const struct flacsplit::Frame &frame) {

void
Flac_encoder::set_meta(const flacsplit::Music_info &track,
bool add_replaygain_padding)
{
bool add_replaygain_padding) {
using FLAC::Metadata::VorbisComment;

const std::string &album = track.album();
Expand Down Expand Up @@ -232,8 +229,7 @@ Flac_encoder::set_meta(const flacsplit::Music_info &track,

#if 0
FLAC__StreamEncoderReadStatus
Flac_encoder::read_callback(FLAC__byte *buffer, size_t *bytes)
{
Flac_encoder::read_callback(FLAC__byte *buffer, size_t *bytes) {
//FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE
//FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM
//FLAC__STREAM_ENCODER_READ_STATUS_ABORT
Expand All @@ -244,16 +240,14 @@ Flac_encoder::read_callback(FLAC__byte *buffer, size_t *bytes)

FLAC__StreamEncoderWriteStatus
Flac_encoder::write_callback(const FLAC__byte *buffer, size_t bytes,
unsigned /*samples*/, unsigned /*current_frame*/)
{
unsigned /*samples*/, unsigned /*current_frame*/) {
if (fwrite(buffer, bytes, 1, _fp))
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
}

FLAC__StreamEncoderSeekStatus
Flac_encoder::seek_callback(FLAC__uint64 absolute_byte_offset)
{
Flac_encoder::seek_callback(FLAC__uint64 absolute_byte_offset) {
long off = absolute_byte_offset;
if (static_cast<FLAC__uint64>(off) !=
absolute_byte_offset) {
Expand All @@ -266,8 +260,7 @@ Flac_encoder::seek_callback(FLAC__uint64 absolute_byte_offset)
}

FLAC__StreamEncoderTellStatus
Flac_encoder::tell_callback(FLAC__uint64 *absolute_byte_offset)
{
Flac_encoder::tell_callback(FLAC__uint64 *absolute_byte_offset) {
long off = ftell(_fp);
if (off < 0)
return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
Expand Down
10 changes: 5 additions & 5 deletions encode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ class Basic_encoder {
virtual void add_frame(const struct Frame &) = 0;

virtual bool finish() = 0;

//virtual void set_meta(const Music_info &) = 0;
};

class Encoder : public Basic_encoder {
public:
struct Bad_format : std::exception {
virtual ~Bad_format() throw () {}
virtual const char *what() const throw ()
{ return "bad format"; }
virtual ~Bad_format() noexcept {}

virtual const char *what() const noexcept override {
return "bad format";
}
};

//! \throw Bad_format
Expand Down
3 changes: 1 addition & 2 deletions errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#include "errors.hpp"

flacsplit::Unix_error::Unix_error(int errnum)
{
flacsplit::Unix_error::Unix_error(int errnum) {
this->errnum = errnum < 0 ? errno : errnum;
msg = strerror(this->errnum);
}
Expand Down
4 changes: 2 additions & 2 deletions errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct Bad_format : std::exception {
struct Bad_samplefreq : std::exception {
virtual ~Bad_samplefreq() noexcept {}

const char *what() const noexcept {
const char *what() const noexcept override {
return "bad sample frequency";
}
};
Expand All @@ -47,7 +47,7 @@ struct Not_enough_samples : public std::exception {

virtual ~Not_enough_samples() noexcept {}

const char *what() const noexcept {
const char *what() const noexcept override {
return _msg.c_str();
}

Expand Down
27 changes: 9 additions & 18 deletions gain_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ static const Float_t ABButter[9][2*BUTTER_ORDER + 1] = {

static void
filter_yule(const Float_t *input, Float_t *output, size_t nSamples,
const Float_t *kernel)
{
const Float_t *kernel) {
while (nSamples--) {
/* 1e-10 is a hack to avoid slowdown because of denormals */
*output = 1e-10 + input[ 0] * kernel[ 0] -
Expand All @@ -256,8 +255,7 @@ filter_yule(const Float_t *input, Float_t *output, size_t nSamples,

static void
filter_butter(const Float_t *input, Float_t *output, size_t nSamples,
const Float_t *kernel)
{
const Float_t *kernel) {
while (nSamples--) {
*output = input[0] * kernel[0] -
output[-1] * kernel[1] + input[-1] * kernel[2] -
Expand All @@ -268,8 +266,7 @@ filter_butter(const Float_t *input, Float_t *output, size_t nSamples,
}

enum replaygain_status
replaygain_reset_frequency(struct replaygain_ctx *ctx, unsigned long freq)
{
replaygain_reset_frequency(struct replaygain_ctx *ctx, unsigned long freq) {
/* zero out initial values */
memset(ctx->linprebuf, 0, sizeof(Float_t) * MAX_ORDER);
memset(ctx->rinprebuf, 0, sizeof(Float_t) * MAX_ORDER);
Expand Down Expand Up @@ -307,8 +304,7 @@ replaygain_reset_frequency(struct replaygain_ctx *ctx, unsigned long freq)
}

struct replaygain_ctx *
replaygain_alloc(unsigned long freq, enum replaygain_status *out_status)
{
replaygain_alloc(unsigned long freq, enum replaygain_status *out_status) {
struct replaygain_ctx *ctx;
enum replaygain_status status;

Expand Down Expand Up @@ -338,14 +334,12 @@ replaygain_alloc(unsigned long freq, enum replaygain_status *out_status)
}

static inline Float_t
fsqr(const Float_t d)
{
fsqr(const Float_t d) {
return d * d;
}

static Float_t
peak_value(const Float_t *samples, size_t num_samples)
{
peak_value(const Float_t *samples, size_t num_samples) {
Float_t peak = 0.0;
while (num_samples--) {
Float_t sample = *samples++;
Expand All @@ -359,8 +353,7 @@ peak_value(const Float_t *samples, size_t num_samples)

enum replaygain_status
replaygain_analyze(struct replaygain_ctx *ctx, const Float_t *lsamples,
const Float_t *rsamples, size_t num_samples, unsigned channels)
{
const Float_t *rsamples, size_t num_samples, unsigned channels) {
unsigned long batchsamples;
unsigned long cursamplepos;
size_t copy_samples;
Expand Down Expand Up @@ -531,8 +524,7 @@ replaygain_analyze(struct replaygain_ctx *ctx, const Float_t *lsamples,
}

Float_t
replaygain_adjustment(const struct replaygain_value *out)
{
replaygain_adjustment(const struct replaygain_value *out) {
uint32_t elems;
int32_t upper;
size_t i;
Expand All @@ -555,8 +547,7 @@ replaygain_adjustment(const struct replaygain_value *out)
}

void
replaygain_pop(struct replaygain_ctx *ctx, struct replaygain_value *out)
{
replaygain_pop(struct replaygain_ctx *ctx, struct replaygain_value *out) {
memcpy(out, &ctx->value, sizeof(ctx->value));

memset(&ctx->value, 0, sizeof(ctx->value));
Expand Down
42 changes: 19 additions & 23 deletions gain_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@ __BEGIN_DECLS
* \return The context, which must be passed to
* <code>replaygain_free()</code> when finished
*/
struct replaygain_ctx *
replaygain_alloc(unsigned long samplefreq,
enum replaygain_status *out_status);
struct replaygain_ctx *replaygain_alloc(unsigned long samplefreq,
enum replaygain_status *out_status);

__INLINE void replaygain_free(struct replaygain_ctx *ctx);
__INLINE void replaygain_free(struct replaygain_ctx *ctx);

/** Reset the sampling frequency
*
Expand All @@ -138,9 +137,8 @@ __INLINE void replaygain_free(struct replaygain_ctx *ctx);
* \retval REPLAYGAIN_ERR_SAMPLEFREQ
* \retval REPLAYGAIN_OK
*/
enum replaygain_status
replaygain_reset_frequency(struct replaygain_ctx *ctx,
unsigned long freq);
enum replaygain_status replaygain_reset_frequency(struct replaygain_ctx *ctx,
unsigned long freq);

/** Accumulate samples into a calculation
*
Expand All @@ -155,63 +153,61 @@ enum replaygain_status
* \retval REPLAYGAIN_ERROR Bad number of channels or some exceptional
* error
*/
enum replaygain_status
replaygain_analyze(struct replaygain_ctx *ctx,
const double *left_samples, const double *right_samples,
size_t num_samples, unsigned num_channels);
enum replaygain_status replaygain_analyze(struct replaygain_ctx *ctx,
const double *left_samples,
const double *right_samples, size_t num_samples,
unsigned num_channels);

/** Return current calculation, reset context
*
* \param ctx Analyzing context
* \param[out] out The accumulated Replaygain sample
*/
void replaygain_pop(struct replaygain_ctx *ctx,
struct replaygain_value *out);
void replaygain_pop(struct replaygain_ctx *ctx,
struct replaygain_value *out);

/** Combine result of one sample with another
*
* \param sum The accumulated value
* \param addition The value to add to <code>sum</code>
*/
__INLINE void replaygain_accum(struct replaygain_value *sum,
const struct replaygain_value *addition);
__INLINE void replaygain_accum(struct replaygain_value *sum,
const struct replaygain_value *addition);

/** Decibal adjustment for a sample
*
* \param value A value calculation
* \return How many decibals to adjust by
*/
double replaygain_adjustment(const struct replaygain_value *value);
double replaygain_adjustment(
const struct replaygain_value *value);

/** Peak level of all samples.
*
* \param value A value calculation
* \return Peak level normalized to [0,1]
*/
__INLINE double replaygain_peak(const struct replaygain_value *value);
__INLINE double replaygain_peak(const struct replaygain_value *value);




__INLINE void
replaygain_free(struct replaygain_ctx *ctx)
{
replaygain_free(struct replaygain_ctx *ctx) {
free(ctx);
}

__INLINE void
replaygain_accum(struct replaygain_value *sum,
const struct replaygain_value *addition)
{
const struct replaygain_value *addition) {
for (size_t i = 0; i < ANALYZE_SIZE; i++)
sum->value[i] += addition->value[i];
if (addition->peak > sum->peak)
sum->peak = addition->peak;
}

__INLINE double
replaygain_peak(const struct replaygain_value *sum)
{
replaygain_peak(const struct replaygain_value *sum) {
const double MAX = (double)(1 << 15);
return sum->peak / MAX;
}
Expand Down
Loading

0 comments on commit 629eef1

Please sign in to comment.