Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yas-sim committed Sep 16, 2023
1 parent aca73b9 commit 088f0e9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 61 deletions.
16 changes: 10 additions & 6 deletions image_converter/image_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <algorithm>
#include <stdlib.h>

#define USE_OCV 1
#define USE_OCV 0

#if USE_OCV == 1
#include <opencv2/opencv.hpp>
Expand Down Expand Up @@ -293,9 +293,9 @@ void visualize_track_bufs2(bit_array track_data0, bit_array track_data1, size_t
void stitch_track_auto(disk_image *input_image, bool verbose) {
disk_image_base_properties prop = input_image->get_property();

const size_t search_range_bfr = 512; // search range before the 2nd index hole
const size_t search_range_aft = 512; // search range after the 2nd index hole
const size_t compare_byte_count = 256; // bytes ((IBM(168): Gap4=80, SYNC=12, IAM=4, Gap1=50, Sync=12, IDAM=4, CHRN=4, CRC=2), (ISO(54): Gap1=32, SYNC=12, IDAM=4, CHRN=4, CRC=2))
const size_t search_range_bfr = 256; // search range before the 2nd index hole
const size_t search_range_aft = 256; // search range after the 2nd index hole
const size_t compare_byte_count = 200; // bytes ((IBM(168): Gap4=80, SYNC=12, IAM=4, Gap1=50, Sync=12, IDAM=4, CHRN=4, CRC=2), (ISO(54): Gap1=32, SYNC=12, IDAM=4, CHRN=4, CRC=2))
const size_t bit_rate_2d = 500e3;
const size_t samples_per_byte = (prop.m_sampling_rate/prop.m_data_bit_rate) * 8;

Expand Down Expand Up @@ -363,8 +363,6 @@ void stitch_track_auto(disk_image *input_image, bool verbose) {
}
}

std::cout << dist_buf_ref.size() << ", " << dist_buf.size() << std::endl;

if(verbose) {
std::cout << "Min error=" << min_error << ", Stitch pos=" << min_offset << ", Top of 2nd spin=" << pos_top_of_2nd_spin <<std::endl;
}
Expand All @@ -383,6 +381,12 @@ void stitch_track_auto(disk_image *input_image, bool verbose) {
}
min_offset = pos_top_of_2nd_spin;
}
#else
if(min_error > dist_buf.size() * 6) { // reference: when compare_byte_count==180, min_error is around 500~800 when stitching succeeded.
if(verbose) {
std::cout << "*** Calculated error is very large." << std::endl;
}
}
#endif
tmp_track_data = bit_array{track_data};
track_data.resize(min_offset); // perform track data trimming
Expand Down
110 changes: 55 additions & 55 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
set(TEST_IMAGE_DIR ${CMAKE_SOURCE_DIR}/../fdc_bitstream_test)


add_library(testutil util.cpp)
target_include_directories(testutil PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(testutil disk_image)



add_executable(testRaw2d77 raw2d77.cpp)
target_link_libraries(testRaw2d77 disk_image testutil)

add_test(
NAME TEST_RAW_4MHz_TO_D77
COMMAND
testRaw2d77
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo-4MHz.raw"
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo.d77"
"${CMAKE_BINARY_DIR}"
)
add_test(
NAME TEST_RAW_8MHz_TO_D77
COMMAND
testRaw2d77
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo-8MHz.raw"
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo.d77"
"${CMAKE_BINARY_DIR}"
)



add_executable(testFormat format.cpp)
target_link_libraries(testFormat disk_image testutil)
add_test(
NAME TEST_FORMAT
COMMAND
testFormat
)



add_executable(testCompare compare.cpp)
target_link_libraries(testCompare disk_image testutil)


file(GLOB RAW_IMAGES "${TEST_IMAGE_DIR}/*.raw")

foreach(RAW_IMAGE IN LISTS RAW_IMAGES)
get_filename_component(RAW_IMAGE_BASE ${RAW_IMAGE} NAME_WE)
message("FILE=${RAW_IMAGE_BASE}")
add_test(
NAME "COMPARE_${RAW_IMAGE_BASE}"
COMMAND testCompare ${TEST_IMAGE_DIR}/${RAW_IMAGE_BASE}.d77 ${TEST_IMAGE_DIR}/${RAW_IMAGE_BASE}.raw ${TEST_IMAGE_DIR}/${RAW_IMAGE_BASE}.opt
) # Memo-to-myself: Put D77 first. RAW may have extra broken sector from overlap read.
endforeach()
set(TEST_IMAGE_DIR ${CMAKE_SOURCE_DIR}/../fdc_bitstream_test)


add_library(testutil util.cpp)
target_include_directories(testutil PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(testutil disk_image)



add_executable(testRaw2d77 raw2d77.cpp)
target_link_libraries(testRaw2d77 disk_image testutil)

add_test(
NAME TEST_RAW_4MHz_TO_D77
COMMAND
testRaw2d77
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo-4MHz.raw"
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo.d77"
"${CMAKE_BINARY_DIR}"
)
add_test(
NAME TEST_RAW_8MHz_TO_D77
COMMAND
testRaw2d77
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo-8MHz.raw"
"${CMAKE_SOURCE_DIR}/test_data/2019FM77AVDemo.d77"
"${CMAKE_BINARY_DIR}"
)



add_executable(testFormat format.cpp)
target_link_libraries(testFormat disk_image testutil)
add_test(
NAME TEST_FORMAT
COMMAND
testFormat
)



add_executable(testCompare compare.cpp)
target_link_libraries(testCompare disk_image testutil)


file(GLOB RAW_IMAGES "${TEST_IMAGE_DIR}/*.raw")

foreach(RAW_IMAGE IN LISTS RAW_IMAGES)
get_filename_component(RAW_IMAGE_BASE ${RAW_IMAGE} NAME_WE)
#message("FILE=${RAW_IMAGE_BASE}")
add_test(
NAME "COMPARE_${RAW_IMAGE_BASE}"
COMMAND testCompare ${TEST_IMAGE_DIR}/${RAW_IMAGE_BASE}.d77 ${TEST_IMAGE_DIR}/${RAW_IMAGE_BASE}.raw ${TEST_IMAGE_DIR}/${RAW_IMAGE_BASE}.opt
) # Memo-to-myself: Put D77 first. RAW may have extra broken sector from overlap read.
endforeach()

0 comments on commit 088f0e9

Please sign in to comment.