mirror of
https://github.com/nu774/fdkaac.git
synced 2025-03-12 23:10:08 +01:00
process 32-bit input if possible (i.e. respect aac:INT_PCM type)
switch AAC-FDK from pcm16 to pcm32: typedef LONG INT_PCM; #define SAMPLE_BITS 32
This commit is contained in:
parent
130e249ebf
commit
353e4fcd7a
@ -247,7 +247,7 @@ FAIL:
|
|||||||
|
|
||||||
int aac_encode_frame(HANDLE_AACENCODER encoder,
|
int aac_encode_frame(HANDLE_AACENCODER encoder,
|
||||||
const pcm_sample_description_t *format,
|
const pcm_sample_description_t *format,
|
||||||
const int16_t *input, unsigned iframes,
|
const INT_PCM *input, unsigned iframes,
|
||||||
aacenc_frame_t *output)
|
aacenc_frame_t *output)
|
||||||
{
|
{
|
||||||
uint32_t ilen = iframes * format->channels_per_frame;
|
uint32_t ilen = iframes * format->channels_per_frame;
|
||||||
@ -258,9 +258,9 @@ int aac_encode_frame(HANDLE_AACENCODER encoder,
|
|||||||
void *obufs[1];
|
void *obufs[1];
|
||||||
INT ibuf_ids[] = { IN_AUDIO_DATA };
|
INT ibuf_ids[] = { IN_AUDIO_DATA };
|
||||||
INT obuf_ids[] = { OUT_BITSTREAM_DATA };
|
INT obuf_ids[] = { OUT_BITSTREAM_DATA };
|
||||||
INT ibuf_sizes[] = { ilen * sizeof(int16_t) };
|
INT ibuf_sizes[] = { ilen * sizeof(INT_PCM) };
|
||||||
INT obuf_sizes[1];
|
INT obuf_sizes[1];
|
||||||
INT ibuf_el_sizes[] = { sizeof(int16_t) };
|
INT ibuf_el_sizes[] = { sizeof(INT_PCM) };
|
||||||
INT obuf_el_sizes[] = { 1 };
|
INT obuf_el_sizes[] = { 1 };
|
||||||
AACENC_ERROR err;
|
AACENC_ERROR err;
|
||||||
unsigned channel_mode, obytes;
|
unsigned channel_mode, obytes;
|
||||||
|
@ -50,7 +50,7 @@ int aacenc_init(HANDLE_AACENCODER *encoder, const aacenc_param_t *params,
|
|||||||
|
|
||||||
int aac_encode_frame(HANDLE_AACENCODER encoder,
|
int aac_encode_frame(HANDLE_AACENCODER encoder,
|
||||||
const pcm_sample_description_t *format,
|
const pcm_sample_description_t *format,
|
||||||
const int16_t *input, unsigned iframes,
|
const INT_PCM *input, unsigned iframes,
|
||||||
aacenc_frame_t *output);
|
aacenc_frame_t *output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -521,7 +521,7 @@ int encode(aacenc_param_ex_t *params, pcm_reader_t *reader,
|
|||||||
HANDLE_AACENCODER encoder, uint32_t frame_length,
|
HANDLE_AACENCODER encoder, uint32_t frame_length,
|
||||||
m4af_ctx_t *m4af)
|
m4af_ctx_t *m4af)
|
||||||
{
|
{
|
||||||
int16_t *ibuf = 0, *ip;
|
INT_PCM *ibuf = 0, *ip;
|
||||||
aacenc_frame_t obuf[2] = {{ 0 }}, *obp;
|
aacenc_frame_t obuf[2] = {{ 0 }}, *obp;
|
||||||
unsigned flip = 0;
|
unsigned flip = 0;
|
||||||
int nread = 1;
|
int nread = 1;
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#if HAVE_STDINT_H
|
#if HAVE_STDINT_H
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <assert.h>
|
||||||
|
#include <fdk-aac/aacenc_lib.h>
|
||||||
#include "pcm_reader.h"
|
#include "pcm_reader.h"
|
||||||
|
|
||||||
typedef struct pcm_sint16_converter_t {
|
typedef struct pcm_sint16_converter_t {
|
||||||
@ -57,12 +59,18 @@ static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
|
|||||||
count = nframes * sfmt->channels_per_frame;
|
count = nframes * sfmt->channels_per_frame;
|
||||||
if (PCM_IS_FLOAT(sfmt)) {
|
if (PCM_IS_FLOAT(sfmt)) {
|
||||||
float *ip = self->pivot;
|
float *ip = self->pivot;
|
||||||
int16_t *op = buffer;
|
INT_PCM *op = buffer;
|
||||||
|
#if SAMPLE_BITS == 16
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
op[i] = pcm_clip(ip[i] * 32768.0, -32768.0, 32767.0);
|
op[i] = (int16_t)pcm_clip(ip[i] * 32768.0, -32768.0, 32767.0);
|
||||||
|
#else
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
|
op[i] = (int32_t)pcm_clip(ip[i] * 2147483648.0, -2147483648.0, 2147483647.0);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
int32_t *ip = self->pivot;
|
int32_t *ip = self->pivot;
|
||||||
int16_t *op = buffer;
|
INT_PCM *op = buffer;
|
||||||
|
#if SAMPLE_BITS == 16
|
||||||
if (sfmt->bits_per_channel <= 16) {
|
if (sfmt->bits_per_channel <= 16) {
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
op[i] = ip[i] >> 16;
|
op[i] = ip[i] >> 16;
|
||||||
@ -72,6 +80,10 @@ static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
|
|||||||
op[i] = (n == 0x8000) ? 0x7fff : n;
|
op[i] = (n == 0x8000) ? 0x7fff : n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
|
op[i] = ip[i];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return nframes;
|
return nframes;
|
||||||
}
|
}
|
||||||
@ -94,14 +106,16 @@ pcm_reader_t *pcm_open_sint16_converter(pcm_reader_t *reader)
|
|||||||
pcm_sint16_converter_t *self = 0;
|
pcm_sint16_converter_t *self = 0;
|
||||||
pcm_sample_description_t *fmt;
|
pcm_sample_description_t *fmt;
|
||||||
|
|
||||||
|
assert((SAMPLE_BITS>>3) == sizeof(INT_PCM));
|
||||||
|
|
||||||
if ((self = calloc(1, sizeof(pcm_sint16_converter_t))) == 0)
|
if ((self = calloc(1, sizeof(pcm_sint16_converter_t))) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
self->src = reader;
|
self->src = reader;
|
||||||
self->vtbl = &my_vtable;
|
self->vtbl = &my_vtable;
|
||||||
memcpy(&self->format, pcm_get_format(reader), sizeof(self->format));
|
memcpy(&self->format, pcm_get_format(reader), sizeof(self->format));
|
||||||
fmt = &self->format;
|
fmt = &self->format;
|
||||||
fmt->bits_per_channel = 16;
|
fmt->bits_per_channel = SAMPLE_BITS;
|
||||||
fmt->sample_type = PCM_TYPE_SINT;
|
fmt->sample_type = PCM_TYPE_SINT;
|
||||||
fmt->bytes_per_frame = 2 * fmt->channels_per_frame;
|
fmt->bytes_per_frame = sizeof(INT_PCM) * fmt->channels_per_frame;
|
||||||
return (pcm_reader_t *)self;
|
return (pcm_reader_t *)self;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user