Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3dd8beb3
Commit
3dd8beb3
authored
Jan 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/faad: use the newer NeAAC* API
Drop support for the old faacDec* API.
parent
ae77406b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
93 deletions
+37
-93
faad.m4
m4/faad.m4
+11
-52
faad_decoder_plugin.c
src/decoder/faad_decoder_plugin.c
+26
-41
No files found.
m4/faad.m4
View file @
3dd8beb3
...
@@ -23,77 +23,36 @@ if test x$enable_aac = xyes; then
...
@@ -23,77 +23,36 @@ if test x$enable_aac = xyes; then
AC_CHECK_DECL(FAAD2_VERSION,,enable_aac=no,[#include <faad.h>])
AC_CHECK_DECL(FAAD2_VERSION,,enable_aac=no,[#include <faad.h>])
fi
fi
if test x$enable_aac = xyes; then
if test x$enable_aac = xyes; then
AC_CHECK_DECL(faacDecInit2,,enable_aac=no,[#include <faad.h>])
fi
if test x$enable_aac = xyes; then
AC_CHECK_LIB(faad,faacDecInit2,,enable_aac=no)
if test x$enable_aac = xno; then
enable_aac=yes
AC_CHECK_LIB(faad,NeAACDecInit2,,enable_aac=no)
AC_CHECK_LIB(faad,NeAACDecInit2,,enable_aac=no)
fi
fi
fi
if test x$enable_aac = xyes; then
if test x$enable_aac = xyes; then
AC_MSG_CHECKING(that FAAD2 uses buffer and bufferlen)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
int main() {
char buffer;
long bufferlen = 0;
faacDecHandle decoder;
faacDecFrameInfo frameInfo;
faacDecConfigurationPtr config;
unsigned char channels;
long sampleRate;
mp4AudioSpecificConfig mp4ASC;
decoder = faacDecOpen();
config = faacDecGetCurrentConfiguration(decoder);
config->outputFormat = FAAD_FMT_16BIT;
faacDecSetConfiguration(decoder,config);
AudioSpecificConfig(&buffer, bufferlen, &mp4ASC);
faacDecInit(decoder,&buffer,bufferlen,&sampleRate,&channels);
faacDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
faacDecDecode(decoder,&frameInfo,&buffer,bufferlen);
return 0;
}
])],[AC_MSG_RESULT(yes);AC_DEFINE(HAVE_FAAD_BUFLEN_FUNCS,1,[Define if FAAD2 uses buflen in function calls])],[AC_MSG_RESULT(no);
AC_MSG_CHECKING(that FAAD2 can even be used)
AC_MSG_CHECKING(that FAAD2 can even be used)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
#include <faad.h>
int main() {
int main() {
char buffer;
char buffer;
faac
DecHandle decoder;
NeAAC
DecHandle decoder;
faac
DecFrameInfo frameInfo;
NeAAC
DecFrameInfo frameInfo;
faac
DecConfigurationPtr config;
NeAAC
DecConfigurationPtr config;
unsigned char channels;
unsigned char channels;
long sampleRate;
long sampleRate;
long bufferlen = 0;
long bufferlen = 0;
unsigned long dummy1_32;
unsigned char dummy2_8, dummy3_8, dummy4_8, dummy5_8, dummy6_8,
dummy7_8, dummy8_8;
decoder =
faac
DecOpen();
decoder =
NeAAC
DecOpen();
config =
faac
DecGetCurrentConfiguration(decoder);
config =
NeAAC
DecGetCurrentConfiguration(decoder);
config->outputFormat = FAAD_FMT_16BIT;
config->outputFormat = FAAD_FMT_16BIT;
faacDecSetConfiguration(decoder,config);
NeAACDecSetConfiguration(decoder,config);
AudioSpecificConfig(&buffer,&dummy1_32,&dummy2_8,
NeAACDecInit(decoder,&buffer,bufferlen,&sampleRate,&channels);
&dummy3_8,&dummy4_8,&dummy5_8,
NeAACDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
&dummy6_8,&dummy7_8,&dummy8_8);
NeAACDecDecode(decoder,&frameInfo,&buffer,bufferlen);
faacDecInit(decoder,&buffer,&sampleRate,&channels);
NeAACDecClose(decoder);
faacDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
faacDecDecode(decoder,&frameInfo,&buffer);
faacDecClose(decoder);
return 0;
return 0;
}
}
])],AC_MSG_RESULT(yes),[AC_MSG_RESULT(no);enable_aac=no])
])],AC_MSG_RESULT(yes),[AC_MSG_RESULT(no);enable_aac=no])
])
fi
fi
if test x$enable_aac = xyes; then
if test x$enable_aac = xyes; then
AC_CHECK_MEMBERS([faacDecConfiguration.downMatrix,faacDecConfiguration.dontUpSampleImplicitSBR,faacDecFrameInfo.samplerate],,,[#include <faad.h>])
AC_DEFINE(HAVE_FAAD,1,[Define to use FAAD2 for AAC decoding])
AC_DEFINE(HAVE_FAAD,1,[Define to use FAAD2 for AAC decoding])
else
else
AC_MSG_WARN([faad2 lib needed for MP4/AAC support -- disabling MP4/AAC support])
AC_MSG_WARN([faad2 lib needed for MP4/AAC support -- disabling MP4/AAC support])
...
@@ -121,7 +80,7 @@ int main() {
...
@@ -121,7 +80,7 @@ int main() {
unsigned char channels;
unsigned char channels;
uint32_t sample_rate;
uint32_t sample_rate;
faac
DecInit2(NULL, NULL, 0, &sample_rate, &channels);
NeAAC
DecInit2(NULL, NULL, 0, &sample_rate, &channels);
return 0;
return 0;
}
}
])],
])],
...
...
src/decoder/faad_decoder_plugin.c
View file @
3dd8beb3
...
@@ -23,16 +23,18 @@
...
@@ -23,16 +23,18 @@
#include "audio_check.h"
#include "audio_check.h"
#include "tag_handler.h"
#include "tag_handler.h"
#define AAC_MAX_CHANNELS 6
#include <neaacdec.h>
#include <glib.h>
#include <assert.h>
#include <assert.h>
#include <unistd.h>
#include <unistd.h>
#include <faad.h>
#include <glib.h>
#undef G_LOG_DOMAIN
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "faad"
#define G_LOG_DOMAIN "faad"
#define AAC_MAX_CHANNELS 6
static
const
unsigned
adts_sample_rates
[]
=
static
const
unsigned
adts_sample_rates
[]
=
{
96000
,
88200
,
64000
,
48000
,
44100
,
32000
,
24000
,
22050
,
{
96000
,
88200
,
64000
,
48000
,
44100
,
32000
,
24000
,
22050
,
16000
,
12000
,
11025
,
8000
,
7350
,
0
,
0
,
0
16000
,
12000
,
11025
,
8000
,
7350
,
0
,
0
,
0
...
@@ -239,11 +241,11 @@ faad_song_duration(struct decoder_buffer *buffer, struct input_stream *is)
...
@@ -239,11 +241,11 @@ faad_song_duration(struct decoder_buffer *buffer, struct input_stream *is)
}
}
/**
/**
* Wrapper for
faac
DecInit() which works around some API
* Wrapper for
NeAAC
DecInit() which works around some API
* inconsistencies in libfaad.
* inconsistencies in libfaad.
*/
*/
static
bool
static
bool
faad_decoder_init
(
faac
DecHandle
decoder
,
struct
decoder_buffer
*
buffer
,
faad_decoder_init
(
NeAAC
DecHandle
decoder
,
struct
decoder_buffer
*
buffer
,
struct
audio_format
*
audio_format
,
GError
**
error_r
)
struct
audio_format
*
audio_format
,
GError
**
error_r
)
{
{
union
{
union
{
...
@@ -271,10 +273,8 @@ faad_decoder_init(faacDecHandle decoder, struct decoder_buffer *buffer,
...
@@ -271,10 +273,8 @@ faad_decoder_init(faacDecHandle decoder, struct decoder_buffer *buffer,
return
false
;
return
false
;
}
}
nbytes
=
faacDecInit
(
decoder
,
u
.
out
,
nbytes
=
NeAACDecInit
(
decoder
,
u
.
out
,
#ifdef HAVE_FAAD_BUFLEN_FUNCS
length
,
length
,
#endif
sample_rate_p
,
&
channels
);
sample_rate_p
,
&
channels
);
if
(
nbytes
<
0
)
{
if
(
nbytes
<
0
)
{
g_set_error
(
error_r
,
faad_decoder_quark
(),
0
,
g_set_error
(
error_r
,
faad_decoder_quark
(),
0
,
...
@@ -289,12 +289,12 @@ faad_decoder_init(faacDecHandle decoder, struct decoder_buffer *buffer,
...
@@ -289,12 +289,12 @@ faad_decoder_init(faacDecHandle decoder, struct decoder_buffer *buffer,
}
}
/**
/**
* Wrapper for
faac
DecDecode() which works around some API
* Wrapper for
NeAAC
DecDecode() which works around some API
* inconsistencies in libfaad.
* inconsistencies in libfaad.
*/
*/
static
const
void
*
static
const
void
*
faad_decoder_decode
(
faac
DecHandle
decoder
,
struct
decoder_buffer
*
buffer
,
faad_decoder_decode
(
NeAAC
DecHandle
decoder
,
struct
decoder_buffer
*
buffer
,
faac
DecFrameInfo
*
frame_info
)
NeAAC
DecFrameInfo
*
frame_info
)
{
{
union
{
union
{
/* deconst hack for libfaad */
/* deconst hack for libfaad */
...
@@ -302,20 +302,13 @@ faad_decoder_decode(faacDecHandle decoder, struct decoder_buffer *buffer,
...
@@ -302,20 +302,13 @@ faad_decoder_decode(faacDecHandle decoder, struct decoder_buffer *buffer,
void
*
out
;
void
*
out
;
}
u
;
}
u
;
size_t
length
;
size_t
length
;
void
*
result
;
u
.
in
=
decoder_buffer_read
(
buffer
,
&
length
);
u
.
in
=
decoder_buffer_read
(
buffer
,
&
length
);
if
(
u
.
in
==
NULL
)
if
(
u
.
in
==
NULL
)
return
NULL
;
return
NULL
;
result
=
faacDecDecode
(
decoder
,
frame_info
,
return
NeAACDecDecode
(
decoder
,
frame_info
,
u
.
out
u
.
out
,
length
);
#ifdef HAVE_FAAD_BUFLEN_FUNCS
,
length
#endif
);
return
result
;
}
}
/**
/**
...
@@ -328,8 +321,6 @@ faad_get_file_time_float(struct input_stream *is)
...
@@ -328,8 +321,6 @@ faad_get_file_time_float(struct input_stream *is)
{
{
struct
decoder_buffer
*
buffer
;
struct
decoder_buffer
*
buffer
;
float
length
;
float
length
;
faacDecHandle
decoder
;
faacDecConfigurationPtr
config
;
buffer
=
decoder_buffer_new
(
NULL
,
is
,
buffer
=
decoder_buffer_new
(
NULL
,
is
,
FAAD_MIN_STREAMSIZE
*
AAC_MAX_CHANNELS
);
FAAD_MIN_STREAMSIZE
*
AAC_MAX_CHANNELS
);
...
@@ -339,11 +330,12 @@ faad_get_file_time_float(struct input_stream *is)
...
@@ -339,11 +330,12 @@ faad_get_file_time_float(struct input_stream *is)
bool
ret
;
bool
ret
;
struct
audio_format
audio_format
;
struct
audio_format
audio_format
;
decoder
=
faac
DecOpen
();
NeAACDecHandle
decoder
=
NeAAC
DecOpen
();
config
=
faacDecGetCurrentConfiguration
(
decoder
);
NeAACDecConfigurationPtr
config
=
NeAACDecGetCurrentConfiguration
(
decoder
);
config
->
outputFormat
=
FAAD_FMT_16BIT
;
config
->
outputFormat
=
FAAD_FMT_16BIT
;
faac
DecSetConfiguration
(
decoder
,
config
);
NeAAC
DecSetConfiguration
(
decoder
,
config
);
decoder_buffer_fill
(
buffer
);
decoder_buffer_fill
(
buffer
);
...
@@ -351,7 +343,7 @@ faad_get_file_time_float(struct input_stream *is)
...
@@ -351,7 +343,7 @@ faad_get_file_time_float(struct input_stream *is)
if
(
ret
)
if
(
ret
)
length
=
0
;
length
=
0
;
faac
DecClose
(
decoder
);
NeAAC
DecClose
(
decoder
);
}
}
decoder_buffer_free
(
buffer
);
decoder_buffer_free
(
buffer
);
...
@@ -381,9 +373,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -381,9 +373,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
{
{
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
float
total_time
=
0
;
float
total_time
=
0
;
faacDecHandle
decoder
;
struct
audio_format
audio_format
;
struct
audio_format
audio_format
;
faacDecConfigurationPtr
config
;
bool
ret
;
bool
ret
;
uint16_t
bit_rate
=
0
;
uint16_t
bit_rate
=
0
;
struct
decoder_buffer
*
buffer
;
struct
decoder_buffer
*
buffer
;
...
@@ -395,17 +385,14 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -395,17 +385,14 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
/* create the libfaad decoder */
/* create the libfaad decoder */
decoder
=
faac
DecOpen
();
NeAACDecHandle
decoder
=
NeAAC
DecOpen
();
config
=
faacDecGetCurrentConfiguration
(
decoder
);
NeAACDecConfigurationPtr
config
=
NeAACDecGetCurrentConfiguration
(
decoder
);
config
->
outputFormat
=
FAAD_FMT_16BIT
;
config
->
outputFormat
=
FAAD_FMT_16BIT
;
#ifdef HAVE_FAACDECCONFIGURATION_DOWNMATRIX
config
->
downMatrix
=
1
;
config
->
downMatrix
=
1
;
#endif
#ifdef HAVE_FAACDECCONFIGURATION_DONTUPSAMPLEIMPLICITSBR
config
->
dontUpSampleImplicitSBR
=
0
;
config
->
dontUpSampleImplicitSBR
=
0
;
#endif
NeAACDecSetConfiguration
(
decoder
,
config
);
faacDecSetConfiguration
(
decoder
,
config
);
while
(
!
decoder_buffer_is_full
(
buffer
)
&&
while
(
!
decoder_buffer_is_full
(
buffer
)
&&
!
input_stream_lock_eof
(
is
)
&&
!
input_stream_lock_eof
(
is
)
&&
...
@@ -420,7 +407,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -420,7 +407,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
if
(
!
ret
)
{
if
(
!
ret
)
{
g_warning
(
"%s"
,
error
->
message
);
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
g_error_free
(
error
);
faac
DecClose
(
decoder
);
NeAAC
DecClose
(
decoder
);
return
;
return
;
}
}
...
@@ -433,7 +420,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -433,7 +420,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
do
{
do
{
size_t
frame_size
;
size_t
frame_size
;
const
void
*
decoded
;
const
void
*
decoded
;
faac
DecFrameInfo
frame_info
;
NeAAC
DecFrameInfo
frame_info
;
/* find the next frame */
/* find the next frame */
...
@@ -448,7 +435,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -448,7 +435,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
if
(
frame_info
.
error
>
0
)
{
if
(
frame_info
.
error
>
0
)
{
g_warning
(
"error decoding AAC stream: %s
\n
"
,
g_warning
(
"error decoding AAC stream: %s
\n
"
,
faac
DecGetErrorMessage
(
frame_info
.
error
));
NeAAC
DecGetErrorMessage
(
frame_info
.
error
));
break
;
break
;
}
}
...
@@ -458,14 +445,12 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -458,14 +445,12 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
break
;
break
;
}
}
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
if
(
frame_info
.
samplerate
!=
audio_format
.
sample_rate
)
{
if
(
frame_info
.
samplerate
!=
audio_format
.
sample_rate
)
{
g_warning
(
"sample rate changed from %u to %lu"
,
g_warning
(
"sample rate changed from %u to %lu"
,
audio_format
.
sample_rate
,
audio_format
.
sample_rate
,
(
unsigned
long
)
frame_info
.
samplerate
);
(
unsigned
long
)
frame_info
.
samplerate
);
break
;
break
;
}
}
#endif
decoder_buffer_consume
(
buffer
,
frame_info
.
bytesconsumed
);
decoder_buffer_consume
(
buffer
,
frame_info
.
bytesconsumed
);
...
@@ -486,7 +471,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
...
@@ -486,7 +471,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
/* cleanup */
/* cleanup */
faac
DecClose
(
decoder
);
NeAAC
DecClose
(
decoder
);
}
}
static
bool
static
bool
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment