diff --git a/.gitattributes b/.gitattributes index 312239f..7521c8a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ -test/stimulus_ref.wav filter=lfs diff=lfs merge=lfs -text +test/stimulus_ref.flac filter=lfs diff=lfs merge=lfs -text test/stimulus_test.wav filter=lfs diff=lfs merge=lfs -text diff --git a/Makefile.am b/Makefile.am index d2261e6..15d998d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,4 +4,4 @@ SUBDIRS = src doc EXTRA_DIST=INSTALL.Windows vs/gstpeaq.props \ vs/gstpeaq.vcxproj vs/peaq.vcxproj vs/gstpeaq.sln \ INSTALL.OSX xcode/GstPEAQ.xcodeproj/project.pbxproj \ - test/stimulus_ref.wav test/stimulus_test.wav + test/stimulus_ref.flac test/stimulus_test.wav diff --git a/README b/README index 13d0710..fcc90be 100644 --- a/README +++ b/README @@ -27,8 +27,9 @@ for details. GstPEAQ comes as a GStreamer plugin providing an element named "peaq". The element has two sink pads, "ref" and "test" for reference and test signal, respectively. The computed ODG can be obtained by reading the "odg" property. -For the common case that reference and test signal are available as WAV files, -a command line utility "peaq" is provided that can simply be invoked as +For the common case that reference and test signal are available as WAV files +(or in another format readable by GStreamer), a command line utility "peaq" is +provided that can simply be invoked as peaq [--advanced] {REFFILE} {TESTFILE} where --advanced chooses the advanced version of the algorithm (the basic version is used by default), and {REFFILE} and {TESTFILE} give the reference diff --git a/src/peaq.c b/src/peaq.c index 64608ff..acd2a37 100644 --- a/src/peaq.c +++ b/src/peaq.c @@ -74,6 +74,13 @@ my_bus_callback (GstBus * bus, GstMessage * message, gpointer data) return TRUE; } +static void on_pad_added(GstElement *element, GstPad *pad, gpointer data) { + GstElement *sink = (GstElement *)data; + GstPad *sinkpad = gst_element_get_static_pad(sink, "sink"); + gst_pad_link(pad, sinkpad); + gst_object_unref(sinkpad); +} + int main(int argc, char *argv[]) { @@ -81,8 +88,8 @@ main(int argc, char *argv[]) GError *error = NULL; GOptionContext *context; GOptionGroup *option_group; - GstElement *pipeline, *ref_source, *ref_parser, *ref_converter, *ref_resample, - *test_source, *test_parser, *test_converter, *test_resample, *peaq; + GstElement *pipeline, *ref_source, *ref_decodebin, *ref_converter, *ref_resample, + *test_source, *test_decodebin, *test_converter, *test_resample, *peaq; gchar *reffilename; gchar *testfilename; @@ -156,11 +163,6 @@ main(int argc, char *argv[]) puts ("Error: filesrc element could not be instantiated"); exit (2); } - ref_parser = gst_element_factory_make ("wavparse", "ref_wav-parser"); - if (!ref_parser) { - puts ("Error: wavparse element could not be instantiated"); - exit (2); - } g_object_set (G_OBJECT (ref_source), "location", reffilename, NULL); ref_converter = gst_element_factory_make ("audioconvert", "ref-converter"); if (!ref_converter) { @@ -172,16 +174,18 @@ main(int argc, char *argv[]) puts ("Error: audioresample element could not be instantiated"); exit (2); } + ref_decodebin = gst_element_factory_make("decodebin", "ref_decodebin"); + if (!ref_decodebin) { + puts("Error: decodebin element could not be instantiated"); + return 2; + } + g_signal_connect(ref_decodebin, "pad-added", G_CALLBACK(on_pad_added), ref_converter); + test_source = gst_element_factory_make ("filesrc", "test_file-source"); if (!test_source) { puts ("Error: filesrc element could not be instantiated"); exit (2); } - test_parser = gst_element_factory_make ("wavparse", "test_wav-parser"); - if (!test_parser) { - puts ("Error: wavparse element could not be instantiated"); - exit (2); - } g_object_set (G_OBJECT (test_source), "location", testfilename, NULL); test_converter = gst_element_factory_make ("audioconvert", "test-converter"); if (!test_converter) { @@ -193,18 +197,22 @@ main(int argc, char *argv[]) puts ("Error: audioresample element could not be instantiated"); exit (2); } + test_decodebin = gst_element_factory_make("decodebin", "test_decodebin"); + if (!test_decodebin) { + puts("Error: decodebin element could not be instantiated"); + return 2; + } + g_signal_connect(test_decodebin, "pad-added", G_CALLBACK(on_pad_added), test_converter); gst_bin_add_many (GST_BIN (pipeline), - ref_source, ref_parser, ref_converter, ref_resample, - test_source, test_parser, test_converter, test_resample, + ref_source, ref_decodebin, ref_converter, ref_resample, + test_source, test_decodebin, test_converter, test_resample, peaq, NULL); - gst_element_link (ref_source, ref_parser); - gst_element_link (ref_parser, ref_converter); + gst_element_link(ref_source, ref_decodebin); gst_element_link (ref_converter, ref_resample); gst_element_link_pads (ref_resample, "src", peaq, "ref"); - gst_element_link (test_source, test_parser); - gst_element_link (test_parser, test_converter); + gst_element_link(test_source, test_decodebin); gst_element_link (test_converter, test_resample); gst_element_link_pads (test_resample, "src", peaq, "test"); @@ -220,12 +228,8 @@ main(int argc, char *argv[]) g_printf ("Distortion Index: %.3f\n", di); gst_object_unref (peaq); - g_main_loop_unref (loop); - gst_deinit (); return 0; } - - diff --git a/src/runtest-1.0.sh b/src/runtest-1.0.sh index d924412..3ab2da5 100755 --- a/src/runtest-1.0.sh +++ b/src/runtest-1.0.sh @@ -50,10 +50,18 @@ if [ x$ODG != x-2.007 ]; then fi ODG=`LC_ALL=C ./peaq --gst-disable-segtrap --gst-debug-level=2 --gst-plugin-load=.libs/libgstpeaq.so \ - ${srcdir}/../test/stimulus_ref.wav ${srcdir}/../test/stimulus_test.wav \ + ${srcdir}/../test/stimulus_ref.flac ${srcdir}/../test/stimulus_test.wav \ | grep "Objective Difference Grade:" | cut -d " " -f4` echo $ODG if [ x$ODG != x-1.077 ]; then exit 1 fi +ODG=`LC_ALL=C ./peaq --gst-disable-segtrap --gst-debug-level=2 --gst-plugin-load=.libs/libgstpeaq.so \ + ${srcdir}/../test/stimulus_test.wav ${srcdir}/../test/stimulus_ref.flac \ +| grep "Objective Difference Grade:" | cut -d " " -f4` +echo $ODG +if [ x$ODG != x-3.096 ]; then + exit 1 +fi + exit 0 diff --git a/test/stimulus_ref.flac b/test/stimulus_ref.flac new file mode 100644 index 0000000..57be8c8 --- /dev/null +++ b/test/stimulus_ref.flac @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b09d488989926b66899486b1e02cb37f4801ded18c3589fad3b5f1726219143d +size 873917 diff --git a/test/stimulus_ref.wav b/test/stimulus_ref.wav deleted file mode 100644 index f6dca94..0000000 --- a/test/stimulus_ref.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:907a6e3fd0ece2d5a2e1bbbb17d436dbbf02099b12622517511d4a269081c2da -size 1910460 diff --git a/vs/runtest-win32.ps1 b/vs/runtest-win32.ps1 index 5a6466c..3df92d0 100644 --- a/vs/runtest-win32.ps1 +++ b/vs/runtest-win32.ps1 @@ -50,8 +50,15 @@ if ($ODG -ne -2.007) { $ODG = [convert]::ToDouble(( ` Invoke-Expression ("$PSScriptRoot\win32\Release\peaq.exe --gst-plugin-load=$PSScriptRoot\win32\Release\gstpeaq.dll " + ` - "$PSScriptRoot\..\test\stimulus_ref.wav $PSScriptRoot\..\test\stimulus_test.wav") ` + "$PSScriptRoot\..\test\stimulus_ref.flac $PSScriptRoot\..\test\stimulus_test.wav") ` | Select-String -Pattern 'Objective Difference Grade: (.*)').Matches.Groups[1].Value) if ($ODG -ne -1.077) { throw "$ODG -ne -1.077" } +$ODG = [convert]::ToDouble(( ` + Invoke-Expression ("$PSScriptRoot\win32\Release\peaq.exe --gst-plugin-load=$PSScriptRoot\win32\Release\gstpeaq.dll " + ` + "$PSScriptRoot\..\test\stimulus_test.wav $PSScriptRoot\..\test\stimulus_ref.flac ") ` + | Select-String -Pattern 'Objective Difference Grade: (.*)').Matches.Groups[1].Value) +if ($ODG -ne -3.096) { + throw "$ODG -ne -3.096" +} diff --git a/vs/runtest-x64.ps1 b/vs/runtest-x64.ps1 index 9b1a5c8..51e52db 100644 --- a/vs/runtest-x64.ps1 +++ b/vs/runtest-x64.ps1 @@ -50,8 +50,15 @@ if ($ODG -ne -2.007) { $ODG = [convert]::ToDouble(( ` Invoke-Expression ("$PSScriptRoot\x64\Release\peaq.exe --gst-plugin-load=$PSScriptRoot\x64\Release\gstpeaq.dll " + ` - "$PSScriptRoot\..\test\stimulus_ref.wav $PSScriptRoot\..\test\stimulus_test.wav") ` + "$PSScriptRoot\..\test\stimulus_ref.flac $PSScriptRoot\..\test\stimulus_test.wav") ` | Select-String -Pattern 'Objective Difference Grade: (.*)').Matches.Groups[1].Value) if ($ODG -ne -1.077) { throw "$ODG -ne -1.077" } +$ODG = [convert]::ToDouble(( ` + Invoke-Expression ("$PSScriptRoot\x64\Release\peaq.exe --gst-plugin-load=$PSScriptRoot\x64\Release\gstpeaq.dll " + ` + "$PSScriptRoot\..\test\stimulus_test.wav $PSScriptRoot\..\test\stimulus_ref.flac ") ` + | Select-String -Pattern 'Objective Difference Grade: (.*)').Matches.Groups[1].Value) +if ($ODG -ne -3.096) { + throw "$ODG -ne -3.096" +}