Permalink
Browse files

remove ebur128 dependency of libinputaudio

  • Loading branch information...
1 parent b36a226 commit c1260149e2fdaa58aa6646d56010e3ea01db914c @jiixyj committed Nov 25, 2011
View
5 CMakeLists.txt
@@ -54,9 +54,7 @@ endif()
if(RSVG2_FOUND)
include_directories(SYSTEM ${RSVG2_INCLUDE_DIRS})
endif()
-if(SPEEXDSP_FOUND)
-include_directories(SYSTEM ${SPEEXDSP_INCLUDE_DIRS})
-else()
+if(NOT SPEEXDSP_FOUND)
add_definitions(-DEBUR128_USE_SPEEX_RESAMPLER=0)
endif()
if(FFMPEG_FOUND)
@@ -136,7 +134,6 @@ else()
endif()
-set(EBUR128_LINK_AGAINST_SCANNER TRUE)
add_subdirectory(libebur128)
add_subdirectory(libinputaudio)
if(GLIB_FOUND)
View
8 libebur128/CMakeLists.txt
@@ -1,16 +1,16 @@
cmake_minimum_required(VERSION 2.6.4)
include_directories(queue)
+if(SPEEXDSP_FOUND)
+ include_directories(SYSTEM ${SPEEXDSP_INCLUDE_DIRS})
+endif()
add_library(ebur128 ebur128.c)
+
if(SPEEXDSP_FOUND)
target_link_libraries(ebur128 ${SPEEXDSP_LIBRARIES})
endif()
-if(EBUR128_LINK_AGAINST_SCANNER)
- set_target_properties(ebur128 PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
-endif()
-
if(NOT WIN32)
target_link_libraries(ebur128 m)
endif()
View
6 libinputaudio/CMakeLists.txt
@@ -18,7 +18,7 @@ if(GLIB_FOUND)
if(SNDFILE_FOUND)
add_library(input_sndfile MODULE input_sndfile.c)
- target_link_libraries(input_sndfile ebur128 ${SNDFILE_LIBRARIES} ${INPUT_HELPERS})
+ target_link_libraries(input_sndfile ${SNDFILE_LIBRARIES} ${INPUT_HELPERS})
endif()
if(MPG123_FOUND)
@@ -33,7 +33,7 @@ if(GLIB_FOUND)
if(FFMPEG_FOUND)
add_library(input_ffmpeg MODULE input_ffmpeg.c)
- target_link_libraries(input_ffmpeg ebur128 ${FFMPEG_LIBRARIES} ${GLIB_LIBRARIES})
+ target_link_libraries(input_ffmpeg ${FFMPEG_LIBRARIES} ${GLIB_LIBRARIES})
endif()
if(GSTREAMER_FOUND)
@@ -43,7 +43,7 @@ if(GLIB_FOUND)
else()
add_library(input_gstreamer MODULE input_gstreamer.c)
endif()
- target_link_libraries(input_gstreamer ebur128 ${GLIB_LIBRARIES} ${GTK2_GOBJECT_LIBRARY} ${GSTREAMER_LIBRARIES})
+ target_link_libraries(input_gstreamer ${GLIB_LIBRARIES} ${GTK2_GOBJECT_LIBRARY} ${GSTREAMER_LIBRARIES})
endif()
if(SNDFILE_FOUND AND MPG123_FOUND AND MPCDEC_FOUND AND FFMPEG_FOUND)
View
2 libinputaudio/input.h
@@ -18,7 +18,7 @@ struct input_ops {
struct input_handle* (*handle_init)();
void (*handle_destroy)(struct input_handle** ih);
int (*open_file)(struct input_handle* ih, const char* filename);
- int (*set_channel_map)(struct input_handle* ih, ebur128_state* st);
+ int (*set_channel_map)(struct input_handle* ih, int* st);
int (*allocate_buffer)(struct input_handle* ih);
size_t (*get_total_frames)(struct input_handle* ih);
size_t (*read_frames)(struct input_handle* ih);
View
14 libinputaudio/input_ffmpeg.c
@@ -145,30 +145,30 @@ static int ffmpeg_open_file(struct input_handle* ih, const char* filename) {
return 1;
}
-static int ffmpeg_set_channel_map(struct input_handle* ih, ebur128_state* st) {
+static int ffmpeg_set_channel_map(struct input_handle* ih, int* st) {
if (ih->codec_context->channel_layout) {
unsigned int channel_map_index = 0;
int bit_counter = 0;
while (channel_map_index < (unsigned) ih->codec_context->channels) {
if (ih->codec_context->channel_layout & (1 << bit_counter)) {
switch (1 << bit_counter) {
case CH_FRONT_LEFT:
- ebur128_set_channel(st, channel_map_index, EBUR128_LEFT);
+ st[channel_map_index] = EBUR128_LEFT;
break;
case CH_FRONT_RIGHT:
- ebur128_set_channel(st, channel_map_index, EBUR128_RIGHT);
+ st[channel_map_index] = EBUR128_RIGHT;
break;
case CH_FRONT_CENTER:
- ebur128_set_channel(st, channel_map_index, EBUR128_CENTER);
+ st[channel_map_index] = EBUR128_CENTER;
break;
case CH_BACK_LEFT:
- ebur128_set_channel(st, channel_map_index, EBUR128_LEFT_SURROUND);
+ st[channel_map_index] = EBUR128_LEFT_SURROUND;
break;
case CH_BACK_RIGHT:
- ebur128_set_channel(st, channel_map_index, EBUR128_RIGHT_SURROUND);
+ st[channel_map_index] = EBUR128_RIGHT_SURROUND;
break;
default:
- ebur128_set_channel(st, channel_map_index, EBUR128_UNUSED);
+ st[channel_map_index] = EBUR128_UNUSED;
break;
}
++channel_map_index;
View
20 libinputaudio/input_gstreamer.c
@@ -252,26 +252,26 @@ static int gstreamer_open_file(struct input_handle* ih, const char* filename) {
}
}
-static int gstreamer_set_channel_map(struct input_handle* ih, ebur128_state* st) {
+static int gstreamer_set_channel_map(struct input_handle* ih, int* st) {
unsigned j;
- for (j = 0; j < st->channels; ++j) {
+ for (j = 0; j < ih->n_channels; ++j) {
switch (ih->channel_positions[j]) {
case GST_AUDIO_CHANNEL_POSITION_INVALID:
- ebur128_set_channel(st, j, EBUR128_UNUSED); break;
+ st[j] = EBUR128_UNUSED; break;
case GST_AUDIO_CHANNEL_POSITION_FRONT_MONO:
- ebur128_set_channel(st, j, EBUR128_CENTER); break;
+ st[j] = EBUR128_CENTER; break;
case GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT:
- ebur128_set_channel(st, j, EBUR128_LEFT); break;
+ st[j] = EBUR128_LEFT; break;
case GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT:
- ebur128_set_channel(st, j, EBUR128_RIGHT); break;
+ st[j] = EBUR128_RIGHT; break;
case GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER:
- ebur128_set_channel(st, j, EBUR128_CENTER); break;
+ st[j] = EBUR128_CENTER; break;
case GST_AUDIO_CHANNEL_POSITION_REAR_LEFT:
- ebur128_set_channel(st, j, EBUR128_LEFT_SURROUND); break;
+ st[j] = EBUR128_LEFT_SURROUND; break;
case GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT:
- ebur128_set_channel(st, j, EBUR128_RIGHT_SURROUND); break;
+ st[j] = EBUR128_RIGHT_SURROUND; break;
default:
- ebur128_set_channel(st, j, EBUR128_UNUSED); break;
+ st[j] = EBUR128_UNUSED; break;
}
}
return 0;
View
2 libinputaudio/input_mpcdec.c
@@ -58,7 +58,7 @@ static int mpcdec_open_file(struct input_handle* ih, const char* filename) {
return 0;
}
-static int mpcdec_set_channel_map(struct input_handle* ih, ebur128_state* st) {
+static int mpcdec_set_channel_map(struct input_handle* ih, int* st) {
(void) ih;
(void) st;
return 1;
View
2 libinputaudio/input_mpg123.c
@@ -84,7 +84,7 @@ static int mpg123_open_file(struct input_handle* ih, const char* filename) {
return 1;
}
-static int mpg123_set_channel_map(struct input_handle* ih, ebur128_state* st) {
+static int mpg123_set_channel_map(struct input_handle* ih, int* st) {
(void) ih;
(void) st;
return 1;
View
24 libinputaudio/input_sndfile.c
@@ -58,35 +58,35 @@ static int sndfile_open_file(struct input_handle* ih, const char* filename) {
}
}
-static int sndfile_set_channel_map(struct input_handle* ih, ebur128_state* st) {
+static int sndfile_set_channel_map(struct input_handle* ih, int* st) {
int result;
- int* channel_map = (int*) calloc(st->channels, sizeof(int));
+ int* channel_map = (int*) calloc(ih->file_info.channels, sizeof(int));
if (!channel_map) return 1;
result = sf_command(ih->file, SFC_GET_CHANNEL_MAP_INFO,
(void*) channel_map,
- (int) (st->channels * sizeof(int)));
+ (int) (ih->file_info.channels * sizeof(int)));
/* If sndfile found a channel map, set it with
* ebur128_set_channel_map */
if (result == SF_TRUE) {
unsigned j;
- for (j = 0; j < st->channels; ++j) {
+ for (j = 0; j < ih->file_info.channels; ++j) {
switch (channel_map[j]) {
case SF_CHANNEL_MAP_INVALID:
- ebur128_set_channel(st, j, EBUR128_UNUSED); break;
+ st[j] = EBUR128_UNUSED; break;
case SF_CHANNEL_MAP_MONO:
- ebur128_set_channel(st, j, EBUR128_CENTER); break;
+ st[j] = EBUR128_CENTER; break;
case SF_CHANNEL_MAP_LEFT:
- ebur128_set_channel(st, j, EBUR128_LEFT); break;
+ st[j] = EBUR128_LEFT; break;
case SF_CHANNEL_MAP_RIGHT:
- ebur128_set_channel(st, j, EBUR128_RIGHT); break;
+ st[j] = EBUR128_RIGHT; break;
case SF_CHANNEL_MAP_CENTER:
- ebur128_set_channel(st, j, EBUR128_CENTER); break;
+ st[j] = EBUR128_CENTER; break;
case SF_CHANNEL_MAP_REAR_LEFT:
- ebur128_set_channel(st, j, EBUR128_LEFT_SURROUND); break;
+ st[j] = EBUR128_LEFT_SURROUND; break;
case SF_CHANNEL_MAP_REAR_RIGHT:
- ebur128_set_channel(st, j, EBUR128_RIGHT_SURROUND); break;
+ st[j] = EBUR128_RIGHT_SURROUND; break;
default:
- ebur128_set_channel(st, j, EBUR128_UNUSED); break;
+ st[j] = EBUR128_UNUSED; break;
}
}
free(channel_map);
View
10 scanner/scanner-common.c
@@ -91,6 +91,7 @@ void init_state_and_scan_work_item(struct filename_list_node *fln, struct scan_o
struct input_handle* ih = NULL;
int r128_mode = EBUR128_MODE_I;
unsigned int i;
+ int *channel_map;
int result;
float *buffer = NULL;
@@ -123,7 +124,14 @@ void init_state_and_scan_work_item(struct filename_list_node *fln, struct scan_o
ops->get_samplerate(ih),
r128_mode);
- result = ops->set_channel_map(ih, fd->st);
+ channel_map = g_malloc(fd->st->channels * sizeof(int));
+ if (!ops->set_channel_map(ih, channel_map)) {
+ for (i = 0; i < fd->st->channels; ++i) {
+ ebur128_set_channel(fd->st, i, channel_map[i]);
+ }
+ }
+ free(channel_map);
+
if (fd->st->channels == 1 && opts->force_dual_mono) {
ebur128_set_channel(fd->st, 0, EBUR128_DUAL_MONO);
}

0 comments on commit c126014

Please sign in to comment.