pcm/AudioCompress: convert to C++

This commit is contained in:
Max Kellermann 2023-03-13 11:56:06 +01:00
parent d712c3b408
commit 2d7068a09d
5 changed files with 16 additions and 25 deletions

View File

@ -7,7 +7,7 @@
#include "filter/Prepared.hxx"
#include "pcm/Buffer.hxx"
#include "pcm/AudioFormat.hxx"
#include "pcm/AudioCompress/compress.h"
#include "pcm/Normalizer.hxx"
#include <string.h>

View File

@ -1,13 +1,14 @@
// SPDX-License-Identifier: LGPL-2.1
// (c)2007 busybee (http://beesbuzz.biz/
// Copyright The Music Player Daemon Project
// Based on AudioCompress (c)2007 busybee (http://beesbuzz.biz/
#include "Normalizer.hxx"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "compress.h"
/*** Default configuration stuff ***/
#define TARGET 16384 /*!< Target level (on a scale of 0-32767) */
@ -34,8 +35,8 @@ struct Compressor {
struct Compressor *Compressor_new(unsigned int history)
{
struct Compressor *obj = malloc(sizeof(struct Compressor));
if (obj == NULL)
Compressor *obj = (Compressor *)malloc(sizeof(struct Compressor));
if (obj == nullptr)
/* out of memory, not much we can do */
abort();
@ -43,7 +44,7 @@ struct Compressor *Compressor_new(unsigned int history)
obj->prefs.maxgain = GAINMAX;
obj->prefs.smooth = GAINSMOOTH;
obj->peaks = obj->gain = obj->clipped = NULL;
obj->peaks = obj->gain = obj->clipped = nullptr;
obj->bufsz = 0;
obj->pos = 0;
@ -65,8 +66,8 @@ void Compressor_delete(struct Compressor *obj)
static int *resizeArray(int *data, int newsz, int oldsz)
{
data = realloc(data, newsz*sizeof(int));
if (data == NULL)
data = (int *)realloc(data, newsz*sizeof(int));
if (data == nullptr)
/* out of memory, not much we can do */
abort();

View File

@ -1,10 +1,10 @@
// SPDX-License-Identifier: LGPL-2.1
// (c)2007 busybee (http://beesbuzz.biz/
// Copyright The Music Player Daemon Project
// Based on AudioCompress (c)2007 busybee (http://beesbuzz.biz/
#ifndef COMPRESS_H
#define COMPRESS_H
#pragma once
#include <stdint.h>
#include <cstdint>
//! Configuration values for the compressor object
struct CompressorConfig {
@ -15,10 +15,6 @@ struct CompressorConfig {
struct Compressor;
#ifdef __cplusplus
extern "C" {
#endif
//! Create a new compressor (use history value of 0 for default)
struct Compressor *Compressor_new(unsigned int history);
@ -34,12 +30,6 @@ struct CompressorConfig *Compressor_getConfig(struct Compressor *);
//! Process 16-bit signed data
void Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count);
#ifdef __cplusplus
}
#endif
//! TODO: Compressor_Process_int32, Compressor_Process_float, others as needed
//! TODO: functions for getting at the peak/gain/clip history buffers (for monitoring)
#endif

View File

@ -47,7 +47,7 @@ pcm_sources = [
'GlueResampler.cxx',
'FallbackResampler.cxx',
'ConfiguredResampler.cxx',
'AudioCompress/compress.c',
'Normalizer.cxx',
'ReplayGainAnalyzer.cxx',
'MixRampAnalyzer.cxx',
'MixRampGlue.cxx',

View File

@ -7,7 +7,7 @@
*
*/
#include "pcm/AudioCompress/compress.h"
#include "pcm/Normalizer.hxx"
#include "pcm/AudioParser.hxx"
#include "pcm/AudioFormat.hxx"
#include "util/PrintException.hxx"