@@ -903,6 +903,24 @@ namespace {
903903 return mn;
904904 }
905905
906+ static std::vector<std::byte> make_canon_makernote_main_tag0038_long_bytes ()
907+ {
908+ std::vector<std::byte> mn;
909+ append_u16le (&mn, 1 );
910+ append_u16le (&mn, 0x0038 );
911+ append_u16le (&mn, 7 );
912+ append_u32le (&mn, 76 );
913+ append_u32le (&mn, 18U );
914+ append_u32le (&mn, 0 );
915+ EXPECT_EQ (mn.size (), 18U );
916+ append_u32le (&mn, 76U );
917+ append_bytes (&mn, " LP-E6NH" );
918+ while (mn.size () < 18U + 76U ) {
919+ mn.push_back (std::byte { 0 });
920+ }
921+ return mn;
922+ }
923+
906924 static std::vector<std::byte> make_canon_custom_functions1d_makernote ()
907925 {
908926 // Canon MakerNote with:
@@ -7755,6 +7773,32 @@ TEST(MakerNoteDecode, MarksCanonMainTag0038PlaceholderForByteBlob)
77557773 std::string_view (" Canon_0x0038" ));
77567774}
77577775
7776+ TEST (MakerNoteDecode, KeepsCanonMainTag0038BatteryTypeForLongByteBlob)
7777+ {
7778+ const std::vector<std::byte> mn
7779+ = make_canon_makernote_main_tag0038_long_bytes ();
7780+ const std::vector<std::byte> tiff = make_test_tiff_with_makernote (" Canon" ,
7781+ mn);
7782+
7783+ MetaStore store;
7784+ std::array<ExifIfdRef, 8 > ifds {};
7785+ ExifDecodeOptions options;
7786+ options.decode_makernote = true ;
7787+ const ExifDecodeResult res = decode_exif_tiff (tiff, store, ifds, options);
7788+ EXPECT_EQ (res.status , ExifDecodeStatus::Ok);
7789+
7790+ store.finalize ();
7791+ const std::span<const EntryId> ids = store.find_all (
7792+ exif_key (" mk_canon0" , 0x0038 ));
7793+ ASSERT_EQ (ids.size (), 1U );
7794+ const Entry& e = store.entry (ids[0 ]);
7795+ EXPECT_FALSE (any (e.flags , EntryFlags::ContextualName));
7796+ EXPECT_EQ (exif_entry_name (store, e, ExifTagNamePolicy::Canonical),
7797+ std::string_view (" BatteryType" ));
7798+ EXPECT_EQ (exif_entry_name (store, e, ExifTagNamePolicy::ExifToolCompat),
7799+ std::string_view (" BatteryType" ));
7800+ }
7801+
77587802TEST (MakerNoteDecode, SelectsCanonCustom350dTableFromCountFallback)
77597803{
77607804 const std::vector<std::byte> mn
@@ -8574,6 +8618,24 @@ TEST(MakerNoteDecode, PrefersCanonCameraInfoPsinfoFor1000dCohort)
85748618 ASSERT_EQ (store.find_all (exif_key (" mk_canon_psinfo_0" , 0x0090 )).size (), 1U );
85758619}
85768620
8621+ TEST (MakerNoteDecode, PrefersCanonCameraInfoPsinfoFor7dCohort)
8622+ {
8623+ std::vector<std::byte> mn = make_canon_camera_info_psinfo2_makernote ();
8624+ const std::vector<std::byte> tiff
8625+ = make_test_tiff_with_makernote_and_model (" Canon" , " Canon EOS 7D" , mn);
8626+
8627+ MetaStore store;
8628+ std::array<ExifIfdRef, 8 > ifds {};
8629+ ExifDecodeOptions options;
8630+ options.decode_makernote = true ;
8631+ const ExifDecodeResult res = decode_exif_tiff (tiff, store, ifds, options);
8632+ EXPECT_EQ (res.status , ExifDecodeStatus::Ok);
8633+
8634+ store.finalize ();
8635+ EXPECT_TRUE (store.find_all (exif_key (" mk_canon_psinfo2_0" , 0x0090 )).empty ());
8636+ ASSERT_EQ (store.find_all (exif_key (" mk_canon_psinfo_0" , 0x0090 )).size (), 1U );
8637+ }
8638+
85778639TEST (MakerNoteDecode, PrefersCanonCameraInfoPsinfo2For5dMarkIiiCohort)
85788640{
85798641 std::vector<std::byte> mn = make_canon_camera_info_psinfo2_makernote ();
@@ -8594,6 +8656,46 @@ TEST(MakerNoteDecode, PrefersCanonCameraInfoPsinfo2For5dMarkIiiCohort)
85948656 1U );
85958657}
85968658
8659+ TEST (MakerNoteDecode, PrefersCanonCameraInfoPsinfo2ForKissX7iCohort)
8660+ {
8661+ std::vector<std::byte> mn = make_canon_camera_info_psinfo2_makernote ();
8662+ const std::vector<std::byte> tiff
8663+ = make_test_tiff_with_makernote_and_model (" Canon" , " Canon EOS Kiss X7i" ,
8664+ mn);
8665+
8666+ MetaStore store;
8667+ std::array<ExifIfdRef, 8 > ifds {};
8668+ ExifDecodeOptions options;
8669+ options.decode_makernote = true ;
8670+ const ExifDecodeResult res = decode_exif_tiff (tiff, store, ifds, options);
8671+ EXPECT_EQ (res.status , ExifDecodeStatus::Ok);
8672+
8673+ store.finalize ();
8674+ EXPECT_TRUE (store.find_all (exif_key (" mk_canon_psinfo_0" , 0x0090 )).empty ());
8675+ ASSERT_EQ (store.find_all (exif_key (" mk_canon_psinfo2_0" , 0x0090 )).size (),
8676+ 1U );
8677+ }
8678+
8679+ TEST (MakerNoteDecode, PrefersCanonCameraInfoPsinfo2For1dXCohort)
8680+ {
8681+ std::vector<std::byte> mn = make_canon_camera_info_psinfo2_makernote ();
8682+ const std::vector<std::byte> tiff
8683+ = make_test_tiff_with_makernote_and_model (" Canon" , " Canon EOS-1D X" ,
8684+ mn);
8685+
8686+ MetaStore store;
8687+ std::array<ExifIfdRef, 8 > ifds {};
8688+ ExifDecodeOptions options;
8689+ options.decode_makernote = true ;
8690+ const ExifDecodeResult res = decode_exif_tiff (tiff, store, ifds, options);
8691+ EXPECT_EQ (res.status , ExifDecodeStatus::Ok);
8692+
8693+ store.finalize ();
8694+ EXPECT_TRUE (store.find_all (exif_key (" mk_canon_psinfo_0" , 0x0090 )).empty ());
8695+ ASSERT_EQ (store.find_all (exif_key (" mk_canon_psinfo2_0" , 0x0090 )).size (),
8696+ 1U );
8697+ }
8698+
85978699TEST (MakerNoteDecode,
85988700 FallsBackToCanonCameraInfoPictureStyleWhenPsinfo2TailIsInvalid)
85998701{
0 commit comments