-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: aw <aw@pionix.de>
- Loading branch information
Showing
5 changed files
with
81 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "codec_helper.hpp" | ||
|
||
#include <vector> | ||
|
||
#include <cbv2g/iso_20/iso20_AC_Encoder.h> | ||
#include <cbv2g/iso_20/iso20_DC_Encoder.h> | ||
|
||
template <typename DocType> | ||
static EncodingTestResult encode(int (*encode_func)(exi_bitstream_t*, DocType*), DocType& request, | ||
const uint8_t* compare_data, std::size_t length) { | ||
// FIXME (aw): what general size to take here? | ||
uint8_t stream[256] = {}; | ||
exi_bitstream_t exi_stream_in; | ||
size_t pos1 = 0; | ||
int errn = 0; | ||
|
||
exi_bitstream_init(&exi_stream_in, stream, sizeof(stream), pos1, nullptr); | ||
|
||
if (0 != encode_func(&exi_stream_in, &request)) { | ||
return {false, false}; | ||
} | ||
|
||
// FIXME (aw): why +1? | ||
const auto encoded_stream = std::vector<uint8_t>(stream, stream + exi_bitstream_get_length(&exi_stream_in) + 1); | ||
|
||
const auto expected_exi_stream = std::vector<uint8_t>(compare_data, compare_data + length); | ||
|
||
return {true, encoded_stream == expected_exi_stream}; | ||
} | ||
|
||
template <> | ||
EncodingTestResult encode_iso20_and_test(iso20_ac_exiDocument& request, const uint8_t* compare_data, | ||
std::size_t length) { | ||
return encode(&encode_iso20_ac_exiDocument, request, compare_data, length); | ||
} | ||
|
||
template <> | ||
EncodingTestResult encode_iso20_and_test(iso20_dc_exiDocument& request, const uint8_t* compare_data, | ||
std::size_t length) { | ||
return encode(&encode_iso20_dc_exiDocument, request, compare_data, length); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <memory> | ||
|
||
#include <cbv2g/iso_20/iso20_AC_Encoder.h> | ||
|
||
struct EncodingTestResult { | ||
bool encoding_successful; | ||
bool bitstream_match; | ||
}; | ||
|
||
// FIXME (aw): the first parameter should be const ref, but the API of cbexigen doesn't respect that | ||
template <typename DocType> | ||
EncodingTestResult encode_iso20_and_test(DocType&, const uint8_t* compare_data, std::size_t length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters