//! MakerNotes tag definitions for major camera manufacturers.
//!
//! Covers the most common maker note tags for Canon, Nikon, Sony,
//! Olympus, Pentax, Panasonic, Fujifilm, Samsung.

use crate::metadata::makernotes::Manufacturer;

/// Lookup tag name by manufacturer and tag ID.
pub fn lookup(manufacturer: Manufacturer, tag_id: u16) -> (&'static str, &'static str) {
    let table = match manufacturer {
        Manufacturer::Canon => CANON_TAGS,
        Manufacturer::Nikon | Manufacturer::NikonOld => NIKON_TAGS,
        Manufacturer::Sony => SONY_TAGS,
        Manufacturer::Pentax => PENTAX_MAIN_IFD_TAGS, // Main IFD overrides to avoid generated table collisions
        Manufacturer::Olympus | Manufacturer::OlympusNew => OLYMPUS_TAGS,
        Manufacturer::Panasonic => PANASONIC_TAGS,
        Manufacturer::Fujifilm => FUJIFILM_TAGS,
        Manufacturer::Samsung => SAMSUNG_TAGS,
        Manufacturer::Sigma => SIGMA_TAGS,
        Manufacturer::Casio => CASIO_TAGS,
        Manufacturer::CasioType2 => &[][..], // Uses inline table below
        Manufacturer::Apple => APPLE_TAGS,
        Manufacturer::Ricoh
        | Manufacturer::Minolta
        | Manufacturer::Google
        | Manufacturer::DJI
        | Manufacturer::GE
        | Manufacturer::Sanyo
        | Manufacturer::Jvc => &[][..],
        Manufacturer::Unknown => &[][..], // Will fallback to generated tables
    };

    for &(id, name, desc) in table {
        if id == tag_id {
            return (name, desc);
        }
    }

    // Fallback to generated tables
    let gen_table = match manufacturer {
        Manufacturer::Canon => Some(super::generated::GENERATED_CANON_TAGS),
        Manufacturer::Nikon | Manufacturer::NikonOld => {
            Some(super::generated::GENERATED_NIKON_TAGS)
        }
        Manufacturer::Sony => Some(super::generated::GENERATED_SONY_TAGS),
        Manufacturer::Olympus | Manufacturer::OlympusNew => {
            Some(super::generated::GENERATED_OLYMPUS_TAGS)
        }
        Manufacturer::Pentax => Some(super::generated::GENERATED_PENTAX_TAGS),
        Manufacturer::Panasonic => Some(super::generated::GENERATED_PANASONIC_TAGS),
        Manufacturer::Fujifilm => Some(super::generated::GENERATED_FUJIFILM_TAGS),
        Manufacturer::Samsung => Some(super::generated::GENERATED_SAMSUNG_TAGS),
        _ => None,
    };

    if let Some(gen) = gen_table {
        for &(id, name) in gen {
            if id == tag_id as u32 {
                return (name, name);
            }
        }
    }

    // Pentax sub-table tags
    if manufacturer == Manufacturer::Pentax {
        for &(id, name) in PENTAX_SUB_TAGS {
            if id == tag_id {
                return (name, name);
            }
        }
    }

    // Olympus sub-IFD tags (Equipment, CameraSettings, FocusInfo, etc.)
    if manufacturer == Manufacturer::Olympus || manufacturer == Manufacturer::OlympusNew {
        for &(id, name) in OLYMPUS_SUB_TAGS {
            if id == tag_id {
                return (name, name);
            }
        }
    }

    // Tags for manufacturers not in generated tables (JVC, GE, Motorola, Sanyo)
    let extra: &[(u16, &str)] = &[
        (0x0002, "CPUVersions"),
        (0x0003, "Quality"),         // JVC
        (0x00FF, "MakerNoteOffset"), // Sanyo
        (0x0200, "SpecialMode"),
        (0x0201, "SanyoQuality"),
        (0x0202, "Macro"),
        (0x0204, "DigitalZoom"),
        (0x0207, "GEModel"),
        (0x020E, "SequentialShot"),
        (0x020F, "WideRange"),
        (0x0210, "ColorAdjustmentMode"),
        (0x0213, "QuickShot"),
        (0x0214, "SelfTimer"),
        (0x0216, "VoiceMemo"),
        (0x0217, "RecordShutterRelease"),
        (0x0218, "FlickerReduce"),
        (0x0219, "OpticalZoomOn"),
        (0x021B, "DigitalZoomOn"),
        (0x021D, "LightSourceSpecial"),
        (0x021E, "Resaved"),
        (0x021F, "SceneSelect"),
        (0x0223, "ManualFocusDistance"),
        (0x0224, "SequenceShotInterval"),
        (0x0225, "FlashMode"),
        (0x0300, "GEMake"),
        (0x5500, "BuildNumber"),
        (0x5501, "SerialNumber"), // Motorola
        (0x6420, "CustomRendered"),
        (0x64D0, "DriveMode"),
        (0x665E, "Sensor"),
        (0x6705, "ManufactureDate"),
    ];

    // Casio Type 2 tags (separate from Type 1 to avoid ID collisions)
    if manufacturer == Manufacturer::CasioType2 {
        let casio2: &[(u16, &str)] = &[
            (0x0002, "PreviewImageSize"),
            (0x0003, "PreviewImageLength"),
            (0x0004, "PreviewImageStart"),
            (0x0008, "QualityMode"),
            (0x0009, "CasioImageSize"),
            (0x000D, "FocusMode"),
            (0x0014, "ISO"),
            (0x0019, "WhiteBalance"),
            (0x001D, "FocalLength"),
            (0x001F, "Saturation"),
            (0x0020, "Contrast"),
            (0x0021, "Sharpness"),
            (0x0E00, "PrintIM"),
            (0x2000, "PreviewImage"),
            (0x2001, "FirmwareDate"),
            (0x2011, "WhiteBalanceBias"),
            (0x2012, "WhiteBalance"),
            (0x2021, "AFPointPosition"),
            (0x2022, "ObjectDistance"),
            (0x2034, "FlashDistance"),
            (0x3000, "RecordMode"),
            (0x3001, "ReleaseMode"),
            (0x3002, "Quality"),
            (0x3003, "FocusMode"),
            (0x3006, "HometownCity"),
            (0x3007, "BestShotMode"),
            (0x3008, "AutoISO"),
            (0x3014, "ISO"),
            (0x3015, "ColorMode"),
            (0x3016, "Enhancement"),
            (0x3017, "ColorFilter"),
            (0x301B, "ArtMode"),
            (0x3020, "ImageStabilization"),
            (0x302A, "LightingMode"),
        ];
        for &(id, name) in casio2 {
            if id == tag_id {
                return (name, name);
            }
        }
    }

    // Ricoh-specific tags from Perl Ricoh.pm
    if manufacturer == Manufacturer::Ricoh {
        let ricoh: &[(u16, &str)] = &[
            (0x0001, "MakerNoteType"),
            (0x0002, "FirmwareVersion"),
            (0x0005, "InternalSerialNumber"),
            (0x0E00, "PrintIM"),
            (0x1000, "RecordingFormat"),
            (0x1001, "ImageInfo"),
            (0x1003, "Sharpness"),
            (0x1004, "WhiteBalanceFineTune"),
            (0x1006, "FocusMode"),
            (0x100B, "FlashExposureComp"),
            (0x100E, "DynamicRangeExpansion"),
            (0x100F, "NoiseReduction"),
            (0x1012, "Contrast"),
            (0x1013, "Saturation"),
            (0x1014, "Sharpness"),
            (0x1500, "FocalLength"),
        ];
        for &(id, name) in ricoh {
            if id == tag_id {
                return (name, name);
            }
        }
    }
    // Restrict extra table to Unknown/Google/DJI/Sanyo/JVC manufacturers only
    if manufacturer == Manufacturer::Unknown
        || manufacturer == Manufacturer::Google
        || manufacturer == Manufacturer::DJI
        || manufacturer == Manufacturer::Sanyo
        || manufacturer == Manufacturer::Jvc
    {
        for &(id, name) in extra {
            if id == tag_id {
                return (name, name);
            }
        }
    }

    // Minolta-specific tags
    if manufacturer == Manufacturer::Minolta {
        let minolta: &[(u16, &str)] = &[
            (0x0000, "MakerNoteVersion"),
            (0x0040, "CompressedImageSize"),
            (0x0081, "PreviewImage"),
            (0x0088, "PreviewImageStart"),
            (0x0089, "PreviewImageLength"),
            (0x0100, "SceneMode"),
            (0x0101, "ColorMode"),
            (0x0102, "MinoltaQuality"),
            (0x0104, "FlashExposureComp"),
            (0x0105, "Teleconverter"),
            (0x0107, "ImageStabilization"),
            (0x010B, "ColorTemperature"),
            (0x010C, "LensType"),
            (0x0113, "ImageStabilization"),
            (0x0115, "WhiteBalance"),
            (0x0E00, "PrintIM"),
        ];
        for &(id, name) in minolta {
            if id == tag_id {
                return (name, name);
            }
        }
    }

    // GE-specific tag lookup
    if manufacturer == Manufacturer::GE {
        let ge_tags: &[(u16, &str)] = &[(0x0202, "Macro"), (0x0207, "GEModel"), (0x0300, "GEMake")];
        for &(id, name) in ge_tags {
            if id == tag_id {
                return (name, name);
            }
        }
    }

    // DataDump (0x0F00) for Sanyo
    if (manufacturer == Manufacturer::Unknown || manufacturer == Manufacturer::Sanyo)
        && tag_id == 0x0F00
    {
        return ("DataDump", "DataDump");
    }

    ("Unknown", "Unknown MakerNote Tag")
}

// Tag table format: (tag_id, name, description)

static CANON_TAGS: &[(u16, &str, &str)] = &[
    (0x0001, "CanonCameraSettings", "Camera Settings"),
    (0x0002, "CanonFocalLength", "Focal Length"),
    // (0x0003, "CanonFlashInfo", "Flash Info"), // Unknown/SubDirectory in Perl
    (0x0004, "CanonShotInfo", "Shot Info"),
    (0x0005, "CanonPanorama", "Panorama"),
    (0x0006, "CanonImageType", "Image Type"),
    (0x0007, "CanonFirmwareVersion", "Firmware Version"),
    (0x0008, "FileNumber", "File Number"),
    (0x0009, "OwnerName", "Owner Name"),
    (0x000A, "CanonColorInfo1", "Color Data 1"),
    (0x000C, "SerialNumber", "Serial Number"),
    (0x000D, "CanonCameraInfo", "Camera Info"),
    (0x000E, "CanonFileLength", "File Length"),
    (0x000F, "CustomFunctions", "Custom Functions"),
    (0x0010, "CanonModelID", "Model ID"),
    (0x0011, "MovieInfo", "Movie Info"),
    (0x0012, "CanonAFInfo", "AF Info"),
    (0x0013, "ThumbnailImageValidArea", "Thumbnail Valid Area"),
    (0x0015, "SerialNumberFormat", "Serial Number Format"),
    (0x001A, "SuperMacro", "Super Macro"),
    (0x001C, "DateStampMode", "Date Stamp Mode"),
    (0x001D, "MyColors", "My Colors"),
    (0x001E, "FirmwareRevision", "Firmware Revision"),
    (0x0023, "Categories", "Categories"),
    (0x0024, "FaceDetect1", "Face Detect 1"),
    (0x0025, "FaceDetect2", "Face Detect 2"),
    (0x0026, "CanonAFInfo2", "AF Info 2"),
    (0x0028, "ImageUniqueID", "Image Unique ID"),
    (0x002F, "WBShiftAB_GM", "WB Shift AB/GM"),
    (0x0035, "TimeInfo", "Time Info"),
    (0x0038, "BatteryType", "Battery Type"),
    (0x003C, "AFInfo3", "AF Info 3"),
    // (0x0093, "CanonSerialInfo", "Serial Number Info"), // Unknown/SubDirectory in Perl
    (0x0095, "LensModel", "Lens Model"),
    (0x0096, "InternalSerialNumber", "Internal Serial Number"),
    (0x0097, "DustRemovalData", "Dust Removal Data"),
    (0x0098, "CropInfo", "Crop Info"),
    (0x0099, "CustomFunctions2", "Custom Functions 2"),
    (0x009A, "AspectInfo", "Aspect Info"),
    (0x00A0, "ProcessingInfo", "Processing Info"),
    (0x00A8, "Unknown", "Unknown"), // Prevent generated table collision
    (0x00AA, "MeasuredColor", "Measured Color"),
    (0x00B4, "ColorSpace", "Color Space"),
    (0x00D0, "VRDOffset", "VRD Offset"),
    (0x00E0, "SensorInfo", "Sensor Info"),
    (0x4001, "ColorData", "Color Data"),
    (0x4002, "CRWParam", "CRW Param"),
    (0x4003, "ColorInfo", "Color Info"),
    (0x4005, "Flavor", "Flavor"),
    (0x4008, "PictureStyleUserDef", "Picture Style User Def"),
    (0x4009, "PictureStylePC", "Picture Style PC"),
    (0x4010, "CustomPictureStyleFileName", "Custom Picture Style"),
    (0x4013, "AFMicroAdj", "AF Micro Adjust"),
    (0x4015, "VignettingCorr", "Vignetting Correction"),
    (0x4016, "VignettingCorr2", "Vignetting Correction 2"),
    (0x4018, "LightingOpt", "Lighting Optimization"),
    (0x4019, "LensInfo", "Lens Info"),
    (0x4020, "AmbienceInfo", "Ambience Info"),
    (0x4024, "FilterInfo", "Filter Info"),
    (0x4025, "HDRInfo", "HDR Info"),
    (0x4028, "AFConfig", "AF Config"),
    (0x403F, "RawBurstModeRoll", "Raw Burst Mode Roll"),
];

static NIKON_TAGS: &[(u16, &str, &str)] = &[
    (0x0001, "MakerNoteVersion", "Maker Note Version"),
    (0x0002, "ISO", "ISO"),
    (0x0003, "ColorMode", "Color Mode"),
    (0x0004, "Quality", "Quality"),
    (0x0005, "WhiteBalance", "White Balance"),
    (0x0006, "Sharpness", "Sharpness"),
    (0x0007, "FocusMode", "Focus Mode"),
    (0x0008, "FlashSetting", "Flash Setting"),
    (0x0009, "FlashType", "Flash Type"),
    (0x000A, "Unknown", "Unknown"), // Prevent generated table collision
    (0x000B, "WhiteBalanceFineTune", "White Balance Fine Tune"),
    (0x000C, "WBRBLevels", "WB RB Levels"),
    (0x000D, "ProgramShift", "Program Shift"),
    (0x000E, "ExposureDifference", "Exposure Difference"),
    (0x000F, "ISOSelection", "ISO Selection"),
    (0x0010, "DataDump", "Data Dump"),
    (0x0011, "PreviewIFD", "Preview IFD"),
    (0x0012, "FlashExposureComp", "Flash Exposure Comp"),
    (0x0013, "ISOSetting", "ISO Setting"),
    (0x0016, "ImageBoundary", "Image Boundary"),
    (0x0017, "ExternalFlashExposureComp", "External Flash Comp"),
    (0x0018, "FlashExposureBracketValue", "Flash Bracket Value"),
    (0x0019, "ExposureBracketValue", "Exposure Bracket Value"),
    (0x001A, "ImageProcessing", "Image Processing"),
    (0x001B, "CropHiSpeed", "Crop Hi Speed"),
    (0x001C, "ExposureTuning", "Exposure Tuning"),
    (0x001D, "SerialNumber", "Serial Number"),
    (0x001E, "ColorSpace", "Color Space"),
    (0x001F, "VRInfo", "VR Info"),
    (0x0020, "ImageAuthentication", "Image Authentication"),
    (0x0021, "FaceDetect", "Face Detect"),
    (0x0022, "ActiveD-Lighting", "Active D-Lighting"),
    (0x0023, "PictureControlData", "Picture Control"),
    (0x0024, "WorldTime", "World Time"),
    (0x0025, "ISOInfo", "ISO Info"),
    (0x002A, "VignetteControl", "Vignette Control"),
    (0x002B, "DistortInfo", "Distort Info"),
    (0x002C, "UnknownInfo", "Unknown Info"),
    (0x0032, "UnknownInfo2", "Unknown Info 2"),
    (0x0034, "ShutterMode", "Shutter Mode"),
    (0x0035, "HDRInfo", "HDR Info"),
    (0x0039, "LocationInfo", "Location Info"),
    (0x003D, "BlackLevel", "Black Level"),
    (0x0045, "CropArea", "Crop Area"),
    (0x004E, "NikonSettings", "Nikon Settings"),
    (0x0080, "ImageAdjustment", "Image Adjustment"),
    (0x0081, "ToneComp", "Tone Compensation"),
    (0x0082, "AuxiliaryLens", "Auxiliary Lens"),
    (0x0083, "LensType", "Lens Type"),
    (0x0084, "Lens", "Lens"),
    (0x0085, "ManualFocusDistance", "Manual Focus Distance"),
    (0x0086, "DigitalZoom", "Digital Zoom"),
    (0x0087, "FlashMode", "Flash Mode"),
    (0x0088, "AFInfo", "AF Info"),
    (0x0089, "ShootingMode", "Shooting Mode"),
    (0x008B, "LensFStops", "Lens F-Stops"),
    (0x008C, "ContrastCurve", "Contrast Curve"),
    (0x008D, "ColorHue", "Color Hue"),
    (0x008F, "SceneMode", "Scene Mode"),
    (0x0090, "LightSource", "Light Source"),
    (0x0091, "ShotInfo", "Shot Info"),
    (0x0092, "HueAdjustment", "Hue Adjustment"),
    (0x0093, "NEFCompression", "NEF Compression"),
    (0x0094, "Saturation", "Saturation"),
    (0x0095, "NoiseReduction", "Noise Reduction"),
    (0x0096, "NEFLinearizationTable", "NEF Linearization Table"),
    (0x0097, "ColorBalance", "Color Balance"),
    (0x0098, "LensData", "Lens Data"),
    (0x0099, "RawImageCenter", "Raw Image Center"),
    (0x009A, "SensorPixelSize", "Sensor Pixel Size"),
    (0x009C, "SceneAssist", "Scene Assist"),
    (0x009E, "RetouchHistory", "Retouch History"),
    (0x00A0, "SerialNumber", "Serial Number"),
    (0x00A2, "ImageDataSize", "Image Data Size"),
    (0x00A5, "ImageCount", "Image Count"),
    (0x00A6, "DeletedImageCount", "Deleted Image Count"),
    (0x00A7, "ShutterCount", "Shutter Count"),
    (0x00A8, "FlashInfo", "Flash Info"),
    (0x00A9, "ImageOptimization", "Image Optimization"),
    (0x00AA, "Saturation", "Saturation"),
    (0x00AB, "VariProgram", "Vari Program"),
    (0x00AC, "ImageStabilization", "Image Stabilization"),
    (0x00AD, "AFResponse", "AF Response"),
    (0x00B0, "MultiExposure", "Multi Exposure"),
    (0x00B1, "HighISONoiseReduction", "High ISO Noise Reduction"),
    (0x00B3, "ToningEffect", "Toning Effect"),
    (0x00B7, "AFInfo2", "AF Info 2"),
    (0x00B8, "FileInfo", "File Info"),
    (0x00B9, "AFTune", "AF Tune"),
    (0x00C3, "BarometerInfo", "Barometer Info"),
    (0x0E00, "PrintIM", "Print Image Matching"),
    (0x0E01, "NikonCaptureData", "Nikon Capture Data"),
    (0x0E09, "NikonCaptureVersion", "Nikon Capture Version"),
    (0x0E0E, "NikonCaptureOffsets", "Nikon Capture Offsets"),
    (0x0E10, "NikonScanIFD", "Nikon Scan IFD"),
    (
        0x0E22,
        "NikonCaptureEditVersions",
        "Nikon Capture Edit Versions",
    ),
];

static SONY_TAGS: &[(u16, &str, &str)] = &[
    (0x0102, "Quality", "Quality"),
    (0x0104, "FlashExposureComp", "Flash Exposure Comp"),
    (0x0105, "Teleconverter", "Teleconverter"),
    (0x0112, "WhiteBalanceFineTune", "White Balance Fine Tune"),
    (0x0114, "CameraSettings", "Camera Settings"),
    (0x0115, "WhiteBalance", "White Balance"),
    (0x0116, "ExtraInfo", "Extra Info"),
    (0x0E00, "PrintIM", "Print Image Matching"),
    (0x1000, "MultiBurstMode", "Multi Burst Mode"),
    (0x1001, "MultiBurstImageWidth", "Multi Burst Image Width"),
    (0x1002, "MultiBurstImageHeight", "Multi Burst Image Height"),
    (0x1003, "Panorama", "Panorama"),
    (0x2001, "PreviewImage", "Preview Image"),
    (0x2002, "Rating", "Rating"),
    (0x2004, "Contrast", "Contrast"),
    (0x2005, "Saturation", "Saturation"),
    (0x2006, "Sharpness", "Sharpness"),
    (0x2007, "Brightness", "Brightness"),
    (0x2008, "LongExposureNoiseReduction", "Long Exposure NR"),
    (0x2009, "HighISONoiseReduction", "High ISO NR"),
    (0x200A, "HDR", "HDR"),
    (0x200B, "MultiFrameNoiseReduction", "Multi Frame NR"),
    (0x200E, "PictureEffect", "Picture Effect"),
    (0x200F, "SoftSkinEffect", "Soft Skin Effect"),
    (0x2010, "VignettingCorrection", "Vignetting Correction"),
    (0x2011, "LateralChromaticAberration", "Lateral CA"),
    (0x2012, "DistortionCorrection", "Distortion Correction"),
    (0x2013, "WBShiftAB_GM", "WB Shift AB/GM"),
    (0x2016, "AutoPortraitFramed", "Auto Portrait Framed"),
    (0x2017, "FlashAction", "Flash Action"),
    (0x201B, "FocusMode", "Focus Mode"),
    (0x201C, "AFAreaMode", "AF Area Mode"),
    (0x201E, "AFPointSelected", "AF Point Selected"),
    (0x3000, "ShotInfo", "Shot Info"),
    (0xB000, "FileFormat", "File Format"),
    (0xB001, "SonyModelID", "Sony Model ID"),
    (0xB020, "CreativeStyle", "Creative Style"),
    (0xB021, "ColorTemperature", "Color Temperature"),
    (0xB022, "ColorCompensationFilter", "Color Comp Filter"),
    (0xB023, "SceneMode", "Scene Mode"),
    (0xB024, "ZoneMatching", "Zone Matching"),
    (0xB025, "DynamicRangeOptimizer", "Dynamic Range Optimizer"),
    (0xB026, "ImageStabilization", "Image Stabilization"),
    (0xB027, "LensType", "Lens Type"),
    (0xB028, "MinoltaMakerNote", "Minolta Maker Note"),
    (0xB029, "ColorMode", "Color Mode"),
    (0xB02B, "FullImageSize", "Full Image Size"),
    (0xB040, "Macro", "Macro"),
    (0xB041, "ExposureMode", "Exposure Mode"),
    (0xB042, "FocusMode2", "Focus Mode 2"),
    (0xB043, "AFMode", "AF Mode"),
    (0xB044, "AFIlluminator", "AF Illuminator"),
    (0xB047, "JPEGQuality", "JPEG Quality"),
    (0xB048, "FlashLevel", "Flash Level"),
    (0xB049, "ReleaseMode", "Release Mode"),
    (0xB04A, "SequenceNumber", "Sequence Number"),
    (0xB04B, "Anti-Blur", "Anti-Blur"),
    (0xB04E, "LongExposureNoiseReduction2", "Long Exposure NR 2"),
    (0xB04F, "DynamicRangeOptimizer2", "DRO 2"),
    (0xB050, "HighISONoiseReduction2", "High ISO NR 2"),
    (0xB052, "IntelligentAuto", "Intelligent Auto"),
    (0xB054, "WhiteBalance2", "White Balance 2"),
];

static OLYMPUS_TAGS: &[(u16, &str, &str)] = &[
    (0x0000, "MakerNoteVersion", "Maker Note Version"),
    (0x0001, "MinoltaCameraSettingsOld", "Camera Settings"),
    (0x0003, "MinoltaCameraSettings", "Camera Settings"),
    (0x0040, "CompressedImageSize", "Compressed Image Size"),
    (0x0081, "PreviewImageData", "Preview Image"),
    (0x0088, "PreviewImageStart", "Preview Image Start"),
    (0x0089, "PreviewImageLength", "Preview Image Length"),
    (0x0100, "ThumbnailImage", "Thumbnail Image"),
    (0x0104, "BodyFirmwareVersion", "Body Firmware Version"),
    (0x0200, "SpecialMode", "Special Mode"),
    (0x0201, "Quality", "Quality"),
    (0x0202, "Macro", "Macro"),
    (0x0203, "BWMode", "BW Mode"),
    (0x0204, "DigitalZoom", "Digital Zoom"),
    (0x0205, "FocalPlaneDiagonal", "Focal Plane Diagonal"),
    (0x0206, "LensDistortionParams", "Lens Distortion Params"),
    (0x0207, "CameraType", "Camera Type"),
    (0x0208, "TextInfo", "Text Info"),
    (0x0209, "CameraID", "Camera ID"),
    (0x020B, "EpsonImageWidth", "Image Width"),
    (0x020C, "EpsonImageHeight", "Image Height"),
    (0x020D, "EpsonSoftware", "Software"),
    (0x0300, "PreCaptureFrames", "Pre Capture Frames"),
    (0x0302, "OneTouchWB", "One Touch WB"),
    (0x0404, "SerialNumber", "Serial Number"),
    (0x1000, "ShutterSpeedValue", "Shutter Speed"),
    (0x1001, "ISOValue", "ISO"),
    (0x1002, "ApertureValue", "Aperture"),
    (0x1003, "BrightnessValue", "Brightness"),
    (0x1004, "FlashMode", "Flash Mode"),
    (0x1005, "FlashDevice", "Flash Device"),
    (0x1006, "ExposureCompensation", "Exposure Compensation"),
    (0x1007, "SensorTemperature", "Sensor Temperature"),
    (0x1008, "LensTemperature", "Lens Temperature"),
    (0x100B, "FocusMode", "Focus Mode"),
    (0x100C, "ManualFocusDistance", "Manual Focus Distance"),
    (0x100D, "ZoomStepCount", "Zoom Step Count"),
    (0x100E, "FocusStepCount", "Focus Step Count"),
    (0x100F, "Sharpness", "Sharpness"),
    (0x1010, "FlashChargeLevel", "Flash Charge Level"),
    (0x1011, "ColorMatrix", "Color Matrix"),
    (0x1012, "BlackLevel", "Black Level"),
    (0x1015, "WhiteBalanceMode", "White Balance Mode"),
    (0x1017, "RedBalance", "Red Balance"),
    (0x1018, "BlueBalance", "Blue Balance"),
    (0x101A, "SerialNumber2", "Serial Number 2"),
    (0x1023, "FlashExposureComp", "Flash Exposure Comp"),
    (0x1024, "InternalFlashTable", "Internal Flash Table"),
    (0x1025, "ExternalFlashGValue", "External Flash G Value"),
    (0x1026, "ExternalFlashBounce", "External Flash Bounce"),
    (0x1027, "ExternalFlashZoom", "External Flash Zoom"),
    (0x1028, "ExternalFlashMode", "External Flash Mode"),
    (0x1029, "Contrast", "Contrast"),
    (0x102A, "SharpnessFactor", "Sharpness Factor"),
    (0x102B, "ColorControl", "Color Control"),
    (0x102C, "ValidBits", "Valid Bits"),
    (0x102D, "CoringFilter", "Coring Filter"),
    (0x102E, "OlympusImageWidth", "Image Width"),
    (0x102F, "OlympusImageHeight", "Image Height"),
    (0x1034, "CompressionRatio", "Compression Ratio"),
    (0x1035, "PreviewImageValid", "Preview Image Valid"),
    (0x1036, "PreviewImageStart2", "Preview Image Start"),
    (0x1037, "PreviewImageLength2", "Preview Image Length"),
    (0x1038, "AFResult", "AF Result"),
    (0x1039, "CCDScanMode", "CCD Scan Mode"),
    (0x103A, "NoiseReduction", "Noise Reduction"),
    (0x103B, "FocusStepInfinity", "Focus Step Infinity"),
    (0x103C, "FocusStepNear", "Focus Step Near"),
    (0x103D, "LightValueCenter", "Light Value Center"),
    (0x103E, "LightValuePeriphery", "Light Value Periphery"),
    (0x2010, "Equipment", "Equipment"),
    (0x2020, "CameraSettings", "Camera Settings 2"),
    (0x2030, "RawDevelopment", "Raw Development"),
    (0x2031, "RawDev2", "Raw Development 2"),
    (0x2040, "ImageProcessing", "Image Processing"),
    (0x2050, "FocusInfo", "Focus Info"),
    (0x2100, "Olympus2100", "Olympus 2100"),
    (0x2200, "Olympus2200", "Olympus 2200"),
    (0x2300, "Olympus2300", "Olympus 2300"),
    (0x2400, "Olympus2400", "Olympus 2400"),
    (0x2500, "Olympus2500", "Olympus 2500"),
    (0x2600, "Olympus2600", "Olympus 2600"),
    (0x2700, "Olympus2700", "Olympus 2700"),
    (0x2800, "Olympus2800", "Olympus 2800"),
    (0x2900, "Olympus2900", "Olympus 2900"),
    (0x3000, "RawInfo", "Raw Info"),
    (0x4000, "MainInfo", "Main Info"),
];

static PANASONIC_TAGS: &[(u16, &str, &str)] = &[
    (0x0001, "ImageQuality", "Image Quality"),
    (0x0002, "FirmwareVersion", "Firmware Version"),
    (0x0003, "WhiteBalance", "White Balance"),
    (0x0007, "FocusMode", "Focus Mode"),
    (0x000F, "AFAreaMode", "AF Area Mode"),
    (0x001A, "ImageStabilization", "Image Stabilization"),
    (0x001C, "MacroMode", "Macro Mode"),
    (0x001F, "ShootingMode", "Shooting Mode"),
    (0x0020, "Audio", "Audio"),
    (0x0023, "WhiteBalanceBias", "White Balance Bias"),
    (0x0024, "FlashBias", "Flash Bias"),
    (0x0025, "InternalSerialNumber", "Internal Serial Number"),
    (0x0026, "PanasonicExifVersion", "Exif Version"),
    (0x0028, "ColorEffect", "Color Effect"),
    (0x0029, "TimeSincePowerOn", "Time Since Power On"),
    (0x002A, "BurstMode", "Burst Mode"),
    (0x002B, "SequenceNumber", "Sequence Number"),
    (0x002C, "ContrastMode", "Contrast Mode"),
    (0x002D, "NoiseReduction", "Noise Reduction"),
    (0x002E, "SelfTimer", "Self Timer"),
    (0x0030, "Rotation", "Rotation"),
    (0x0031, "AFAssistLamp", "AF Assist Lamp"),
    (0x0032, "ColorMode", "Color Mode"),
    (0x0033, "BabyAge", "Baby Age"),
    (0x0034, "OpticalZoomMode", "Optical Zoom Mode"),
    (0x0035, "ConversionLens", "Conversion Lens"),
    (0x0036, "TravelDay", "Travel Day"),
    // 0x003A-0x004D: use generated table (has correct WorldTimeLocation, ProgramISO, etc.)
    // 0x0046-0x004D: LensType etc. are in generated table
    (0x0051, "LensType", "Lens Type"),
    (0x0052, "LensSerialNumber2", "Lens Serial Number 2"),
    (0x0059, "Transform", "Transform"),
    (0x005D, "IntelligentExposure", "Intelligent Exposure"),
    (0x0060, "LensFirmwareVersion2", "Lens Firmware"),
    (0x0061, "FaceRecInfo", "Face Recognition Info"),
    (0x0062, "FlashWarning", "Flash Warning"),
    (0x0065, "Title", "Title"),
    (0x0066, "BabyName", "Baby Name"),
    (0x0067, "Location", "Location"),
    (0x0069, "Country", "Country"),
    (0x006B, "State", "State"),
    (0x006D, "City", "City"),
    (0x006F, "Landmark", "Landmark"),
    (0x0070, "IntelligentResolution", "Intelligent Resolution"),
    (0x0077, "BurstSpeed", "Burst Speed"),
    (0x0079, "IntelligentDRange", "Intelligent D-Range"),
    (0x007C, "ClearRetouch", "Clear Retouch"),
    (0x0080, "City2", "City 2"),
    (0x0086, "ManometerPressure", "Barometric Pressure"),
    (0x0089, "PhotoStyle", "Photo Style"),
    (0x008A, "ShadingCompensation", "Shading Compensation"),
    (0x008C, "AccelerometerZ", "Accelerometer Z"),
    (0x008D, "AccelerometerX", "Accelerometer X"),
    (0x008E, "AccelerometerY", "Accelerometer Y"),
    (0x008F, "CameraOrientation", "Camera Orientation"),
    (0x0090, "RollAngle", "Roll Angle"),
    (0x0091, "PitchAngle", "Pitch Angle"),
    (0x0093, "SweepPanoramaDirection", "Sweep Panorama Direction"),
    (0x0094, "SweepPanoramaFieldOfView", "Sweep Panorama FOV"),
    (0x0096, "TimerRecording", "Timer Recording"),
    (0x009D, "InternalNDFilter", "Internal ND Filter"),
    (0x009E, "HDR", "HDR"),
    (0x009F, "ShutterType", "Shutter Type"),
    (0x00A3, "ClearRetouchValue", "Clear Retouch Value"),
    (0x00AB, "TouchAE", "Touch AE"),
    (0x0E00, "PrintIM", "Print Image Matching"),
    (0x8000, "MakerNoteVersion", "Maker Note Version"),
    (0x8001, "SceneMode", "Scene Mode"),
    (0x8004, "WBRedLevel", "WB Red Level"),
    (0x8005, "WBGreenLevel", "WB Green Level"),
    (0x8006, "WBBlueLevel", "WB Blue Level"),
    // 0x8007 FlashFired: disabled in Perl (conflicts with EXIF)
    (0x8008, "TextStamp", "Text Stamp"),
    (0x8009, "TextStamp", "Text Stamp"), // same name as 0x8008 in Perl
    (0x8010, "BabyAge", "Baby Age"),     // Perl: BabyAge (not BabyAge2)
    (0x8012, "Transform2", "Transform 2"),
];

static FUJIFILM_TAGS: &[(u16, &str, &str)] = &[
    (0x0000, "Version", "Version"),
    (0x0010, "InternalSerialNumber", "Internal Serial Number"),
    (0x1000, "Quality", "Quality"),
    (0x1001, "Sharpness", "Sharpness"),
    (0x1002, "WhiteBalance", "White Balance"),
    (0x1003, "Saturation", "Saturation"),
    (0x1004, "Contrast", "Contrast"),
    (0x1005, "ColorTemperature", "Color Temperature"),
    (0x1006, "Contrast2", "Contrast 2"),
    (0x100A, "WhiteBalanceFineTune", "White Balance Fine Tune"),
    (0x100B, "NoiseReduction", "Noise Reduction"),
    (0x100E, "HighISONoiseReduction", "High ISO Noise Reduction"),
    (0x1010, "FujiFlashMode", "Flash Mode"),
    (0x1011, "FlashExposureComp", "Flash Exposure Comp"),
    (0x1020, "Macro", "Macro"),
    (0x1021, "FocusMode", "Focus Mode"),
    (0x1022, "AFMode", "AF Mode"),
    (0x1023, "FocusPixel", "Focus Pixel"),
    (0x1030, "SlowSync", "Slow Sync"),
    (0x1031, "PictureMode", "Picture Mode"),
    (0x1032, "ExposureCount", "Exposure Count"),
    (0x1033, "EXRAuto", "EXR Auto"),
    (0x1034, "EXRMode", "EXR Mode"),
    (0x1040, "ShadowTone", "Shadow Tone"),
    (0x1041, "HighlightTone", "Highlight Tone"),
    (0x1044, "DigitalZoom", "Digital Zoom"),
    (
        0x1045,
        "LensModulationOptimizer",
        "Lens Modulation Optimizer",
    ),
    (0x1047, "GrainEffect", "Grain Effect"),
    (0x1048, "ColorChromeEffect", "Color Chrome Effect"),
    (0x1049, "BWAdjustment", "BW Adjustment"),
    (0x104D, "CropMode", "Crop Mode"),
    (0x104E, "ColorChromeFXBlue", "Color Chrome FX Blue"),
    (0x1050, "ShutterType", "Shutter Type"),
    (0x1100, "AutoBracketing", "Auto Bracketing"),
    (0x1101, "SequenceNumber", "Sequence Number"),
    (0x1103, "DriveSettings", "Drive Settings"),
    (0x1201, "AdvancedFilter", "Advanced Filter"),
    (0x1210, "ColorMode", "Color Mode"),
    (0x1300, "BlurWarning", "Blur Warning"),
    (0x1301, "FocusWarning", "Focus Warning"),
    (0x1302, "ExposureWarning", "Exposure Warning"),
    (0x1304, "GEImageSize", "GE Image Size"),
    (0x1400, "DynamicRange", "Dynamic Range"),
    (0x1401, "FilmMode", "Film Simulation"),
    (0x1402, "DynamicRangeSetting", "Dynamic Range Setting"),
    (
        0x1403,
        "DevelopmentDynamicRange",
        "Development Dynamic Range",
    ),
    (0x1404, "MinFocalLength", "Min Focal Length"),
    (0x1405, "MaxFocalLength", "Max Focal Length"),
    (0x1406, "MaxApertureAtMinFocal", "Max Aperture At Min Focal"),
    (0x1407, "MaxApertureAtMaxFocal", "Max Aperture At Max Focal"),
    (0x140B, "AutoDynamicRange", "Auto Dynamic Range"),
    (0x1422, "ImageStabilization", "Image Stabilization"),
    (0x1431, "Rating", "Rating"),
    (0x1436, "ImageGeneration", "Image Generation"),
    (0x1438, "ImageCount", "Image Count"),
    (0x4100, "FacesDetected", "Faces Detected"),
    (0x4200, "NumFaceElements", "Num Face Elements"),
];

static SAMSUNG_TAGS: &[(u16, &str, &str)] = &[
    (0x0001, "MakerNoteVersion", "Maker Note Version"),
    (0x0002, "DeviceType", "Device Type"),
    (0x0003, "SamsungModelID", "Model ID"),
    (0x0021, "FaceDetect", "Face Detect"),
    (0x0030, "FaceRecognition", "Face Recognition"),
    (0x0040, "RawDataByteOrder", "Raw Data Byte Order"),
    (0x0050, "WhiteBalanceSetup", "White Balance Setup"),
    (0x0100, "FirmwareName", "Firmware Name"),
    (0x0101, "SerialNumber", "Serial Number"),
    (0xA001, "LensType", "Lens Type"),
    (0xA002, "LensModel", "Lens Model"),
    (0xA003, "LensFirmware", "Lens Firmware"),
    (0xA010, "SensorAreas", "Sensor Areas"),
    (0xA011, "ColorSpace", "Color Space"),
    (0xA012, "SmartRange", "Smart Range"),
    (0xA013, "ExposureBiasValue", "Exposure Bias"),
    (0xA014, "ISO", "ISO"),
    (0xA018, "ExposureTime", "Exposure Time"),
    (0xA019, "FNumber", "F Number"),
    (0xA01A, "FocalLengthIn35mmFormat", "Focal Length 35mm"),
    (0xA020, "EncryptionKey", "Encryption Key"),
    (0xA021, "WB_RGGBLevelsUncorrected", "WB RGGB Levels"),
    (0xA022, "WB_RGGBLevelsAuto", "WB RGGB Auto"),
    (0xA023, "WB_RGGBLevelsIlluminator1", "WB RGGB Illuminator 1"),
    (0xA024, "WB_RGGBLevelsIlluminator2", "WB RGGB Illuminator 2"),
    (0xA028, "WB_RGGBLevelsBlack", "WB RGGB Black"),
    (0xA030, "ColorMatrix", "Color Matrix"),
    (0xA031, "ColorMatrixSRGB", "Color Matrix sRGB"),
    (0xA032, "ColorMatrixAdobeRGB", "Color Matrix Adobe RGB"),
    (0xA040, "ToneCurve1", "Tone Curve 1"),
    (0xA041, "ToneCurve2", "Tone Curve 2"),
    (0xA042, "ToneCurve3", "Tone Curve 3"),
    (0xA043, "ToneCurve4", "Tone Curve 4"),
];

static SIGMA_TAGS: &[(u16, &str, &str)] = &[
    (0x0002, "SerialNumber", "Serial Number"),
    (0x0003, "DriveMode", "Drive Mode"),
    (0x0004, "ResolutionMode", "Resolution Mode"),
    (0x0005, "AFMode", "AF Mode"),
    (0x0006, "FocusSetting", "Focus Setting"),
    (0x0007, "WhiteBalance", "White Balance"),
    (0x0008, "ExposureMode", "Exposure Mode"),
    (0x0009, "MeteringMode", "Metering Mode"),
    (0x000A, "LensFocalRange", "Lens Focal Range"),
    (0x000B, "ColorSpace", "Color Space"),
    (0x000C, "ExposureCompensation", "Exposure Compensation"),
    (0x000D, "Contrast", "Contrast"),
    (0x000E, "Shadow", "Shadow"),
    (0x000F, "Highlight", "Highlight"),
    (0x0010, "Saturation", "Saturation"),
    (0x0011, "Sharpness", "Sharpness"),
    (0x0012, "X3FillLight", "X3 Fill Light"),
    (0x0014, "ColorAdjustment", "Color Adjustment"),
    (0x0015, "AdjustmentMode", "Adjustment Mode"),
    (0x0016, "Quality", "Quality"),
    (0x0017, "Firmware", "Firmware"),
    (0x0018, "Software", "Software"),
    (0x0019, "AutoBracket", "Auto Bracket"),
    // Tags 0x001a-0x003d (DP2 and similar models, MakerNoteSigmaVer < 3)
    (0x001a, "PreviewImageStart", "Preview Image Start"),
    (0x001b, "PreviewImageLength", "Preview Image Length"),
    (0x001c, "PreviewImageSize", "Preview Image Size"),
    (0x001d, "MakerNoteVersion", "Maker Note Version"),
    (0x001f, "AFPoint", "AF Point"),
    (0x0022, "FileFormat", "File Format"),
    (0x0024, "Calibration", "Calibration"),
    (0x002c, "ColorMode", "Color Mode"),
    (0x0030, "LensApertureRange", "Lens Aperture Range"),
    (0x0033, "ExposureTime2", "Exposure Time 2"),
    (0x0034, "BurstShot", "Burst Shot"),
    (0x0035, "ExposureCompensation", "Exposure Compensation"),
    (0x0039, "SensorTemperature", "Sensor Temperature"),
    (0x003a, "FlashExposureComp", "Flash Exposure Comp"),
    (0x003b, "Firmware", "Firmware"),
    (0x003c, "WhiteBalance", "White Balance"),
    (0x003d, "PictureMode", "Picture Mode"),
];

static CASIO_TAGS: &[(u16, &str, &str)] = &[
    (0x0001, "RecordingMode", "Recording Mode"),
    (0x0002, "Quality", "Quality"),
    (0x0003, "FocusMode", "Focus Mode"),
    (0x0004, "FlashMode", "Flash Mode"),
    (0x0005, "FlashIntensity", "Flash Intensity"),
    (0x0006, "ObjectDistance", "Object Distance"),
    (0x0007, "WhiteBalance", "White Balance"),
    (0x000A, "DigitalZoom", "Digital Zoom"),
    (0x000B, "Sharpness", "Sharpness"),
    (0x000C, "Contrast", "Contrast"),
    (0x000D, "Saturation", "Saturation"),
    (0x0014, "ISO", "ISO"),
    (0x0015, "FirmwareDate", "Firmware Date"),
    (0x0016, "Enhancement", "Enhancement"),
    (0x0017, "ColorFilter", "Color Filter"),
    (0x0018, "AFPoint", "AF Point"),
    (0x0019, "FlashIntensity2", "Flash Intensity"),
    (0x0E00, "PrintIM", "Print IM"),
    (0x2001, "PreviewThumbnail", "Preview Thumbnail"),
    (0x3000, "RecordingMode2", "Recording Mode 2"),
    (0x3001, "Quality2", "Quality 2"),
    (0x3002, "FocusMode2", "Focus Mode 2"),
    (0x3003, "FlashMode2", "Flash Mode 2"),
    (0x3006, "ISO2", "ISO 2"),
    (0x3007, "WhiteBalance2", "White Balance 2"),
    (0x3008, "FocalLength", "Focal Length"),
    (0x3009, "Saturation2", "Saturation 2"),
    (0x300A, "Contrast2", "Contrast 2"),
    (0x300B, "Sharpness2", "Sharpness 2"),
    (0x300D, "ColorMode", "Color Mode"),
    (0x300E, "Enhancement2", "Enhancement 2"),
    (0x300F, "ColorFilter2", "Color Filter 2"),
    (0x3014, "CCDSensitivity", "CCD Sensitivity"),
    (0x3015, "LightingMode", "Lighting Mode"),
    (0x3016, "Quality3", "Quality 3"),
    (0x3017, "DynamicRange", "Dynamic Range"),
];

static APPLE_TAGS: &[(u16, &str, &str)] = &[
    (0x0001, "MakerNoteVersion", "MakerNoteVersion"),
    // (0x0002, "AEMatrix", "AEMatrix"), // Unknown=>1 in Perl, suppressed
    (0x0003, "RunTime", "RunTime"),
    (0x0004, "AEStable", "AEStable"),
    (0x0005, "AETarget", "AETarget"),
    (0x0006, "AEAverage", "AEAverage"),
    (0x0007, "AFStable", "AFStable"),
    (0x0008, "AccelerationVector", "AccelerationVector"),
    (0x000A, "HDRImageType", "HDRImageType"),
    (0x000B, "BurstUUID", "BurstUUID"),
    (0x000C, "FocusDistanceRange", "FocusDistanceRange"),
    (0x000F, "OISMode", "OISMode"),
    (0x0011, "ContentIdentifier", "ContentIdentifier"),
    (0x0014, "ImageCaptureType", "ImageCaptureType"),
    (0x0015, "ImageUniqueID", "ImageUniqueID"),
    (0x0017, "LivePhotoVideoIndex", "LivePhotoVideoIndex"),
    (0x0019, "ImageProcessingFlags", "ImageProcessingFlags"),
    (0x001A, "QualityHint", "QualityHint"),
    (0x001D, "LuminanceNoiseAmplitude", "LuminanceNoiseAmplitude"),
    (0x001F, "PhotosAppFeatureFlags", "PhotosAppFeatureFlags"),
    (0x0020, "ImageCaptureRequestID", "ImageCaptureRequestID"),
    (0x0021, "HDRHeadroom", "HDRHeadroom"),
    (0x0023, "AFPerformance", "AFPerformance"),
    (0x0025, "SceneFlags", "SceneFlags"),
    (0x0026, "SignalToNoiseRatioType", "SignalToNoiseRatioType"),
    (0x0027, "SignalToNoiseRatio", "SignalToNoiseRatio"),
    (0x002B, "PhotoIdentifier", "PhotoIdentifier"),
    (0x002D, "ColorTemperature", "ColorTemperature"),
    (0x002E, "CameraType", "CameraType"),
    (0x002F, "FocusPosition", "FocusPosition"),
    (0x0030, "HDRGain", "HDRGain"),
    (0x0038, "AFMeasuredDepth", "AFMeasuredDepth"),
    (0x003D, "AFConfidence", "AFConfidence"),
    (0x003E, "ColorCorrectionMatrix", "ColorCorrectionMatrix"),
    (
        0x003F,
        "GreenGhostMitigationStatus",
        "GreenGhostMitigationStatus",
    ),
    (0x0040, "SemanticStyle", "SemanticStyle"),
    (
        0x0041,
        "SemanticStyleRenderingVer",
        "SemanticStyleRenderingVer",
    ),
    (0x0042, "SemanticStylePreset", "SemanticStylePreset"),
    (0x004E, "Apple_0x004e", "Apple_0x004e"),
    (0x004F, "Apple_0x004f", "Apple_0x004f"),
    (0x0054, "Apple_0x0054", "Apple_0x0054"),
    (0x005A, "Apple_0x005a", "Apple_0x005a"),
];
static OLYMPUS_SUB_TAGS: &[(u16, &str)] = &[
    (0x0000, "EquipmentVersion"),
    (0x0100, "CameraType2"),
    (0x0101, "SerialNumber"),
    (0x0102, "InternalSerialNumber"),
    (0x0103, "FocalPlaneDiagonal"),
    (0x0104, "BodyFirmwareVersion"),
    (0x0201, "LensType"),
    (0x0202, "LensSerialNumber"),
    (0x0203, "LensModel"),
    (0x0204, "LensFirmwareVersion"),
    (0x0205, "MaxApertureAtMinFocal"),
    (0x0206, "MaxApertureAtMaxFocal"),
    (0x0207, "MinFocalLength"),
    (0x0208, "MaxFocalLength"),
    (0x020A, "MaxAperture"),
    (0x020B, "LensProperties"),
    (0x0301, "Extender"),
    (0x0302, "ExtenderSerialNumber"),
    (0x0303, "ExtenderModel"),
    (0x0304, "ExtenderFirmwareVersion"),
    (0x0403, "ConversionLens"),
    (0x1000, "FlashType"),
    (0x1001, "FlashModel"),
    (0x1002, "FlashFirmwareVersion"),
    (0x1003, "FlashSerialNumber"),
    (0x0000, "CameraSettingsVersion"),
    (0x0100, "PreviewImageValid"),
    (0x0101, "PreviewImageStart"),
    (0x0102, "PreviewImageLength"),
    (0x0200, "ExposureMode"),
    (0x0201, "AELock"),
    (0x0202, "MeteringMode"),
    (0x0203, "ExposureShift"),
    (0x0204, "NDFilter"),
    (0x0300, "MacroMode"),
    (0x0301, "FocusMode"),
    (0x0302, "FocusProcess"),
    (0x0303, "AFSearch"),
    (0x0304, "AFAreas"),
    (0x0305, "AFPointSelected"),
    (0x0306, "AFFineTune"),
    (0x0307, "AFFineTuneAdj"),
    (0x0308, "FocusBracketStepSize"),
    (0x0309, "AISubjectTrackingMode"),
    (0x030A, "AFTargetInfo"),
    (0x030B, "SubjectDetectInfo"),
    (0x0400, "FlashMode"),
    (0x0401, "FlashExposureComp"),
    (0x0403, "FlashRemoteControl"),
    (0x0404, "FlashControlMode"),
    (0x0405, "FlashIntensity"),
    (0x0406, "ManualFlashStrength"),
    (0x0500, "WhiteBalance2"),
    (0x0501, "WhiteBalanceTemperature"),
    (0x0502, "WhiteBalanceBracket"),
    (0x0503, "CustomSaturation"),
    (0x0504, "ModifiedSaturation"),
    (0x0505, "ContrastSetting"),
    (0x0506, "SharpnessSetting"),
    (0x0507, "ColorSpace"),
    (0x0509, "SceneMode"),
    (0x050A, "NoiseReduction"),
    (0x050B, "DistortionCorrection"),
    (0x050C, "ShadingCompensation"),
    (0x050D, "CompressionFactor"),
    (0x050F, "Gradation"),
    (0x0520, "PictureMode"),
    (0x0521, "PictureModeSaturation"),
    (0x0522, "PictureModeHue"),
    (0x0523, "PictureModeContrast"),
    (0x0524, "PictureModeSharpness"),
    (0x0525, "PictureModeBWFilter"),
    (0x0526, "PictureModeTone"),
    (0x0527, "NoiseFilter"),
    (0x0529, "ArtFilter"),
    (0x052C, "MagicFilter"),
    (0x052D, "PictureModeEffect"),
    (0x052E, "ToneLevel"),
    (0x052F, "ArtFilterEffect"),
    (0x0532, "ColorCreatorEffect"),
    (0x0537, "MonochromeProfileSettings"),
    (0x0538, "FilmGrainEffect"),
    (0x0539, "ColorProfileSettings"),
    (0x053A, "MonochromeVignetting"),
    (0x053B, "MonochromeColor"),
    (0x0600, "DriveMode"),
    (0x0601, "PanoramaMode"),
    (0x0603, "ImageQuality2"),
    (0x0604, "ImageStabilization"),
    (0x0804, "StackedImage"),
    (0x0821, "ISOAutoSettings"),
    (0x0900, "ManometerPressure"),
    (0x0901, "ManometerReading"),
    (0x0902, "ExtendedWBDetect"),
    (0x0903, "RollAngle"),
    (0x0904, "PitchAngle"),
    (0x0908, "DateTimeUTC"),
    (0x0000, "RawDevVersion"),
    (0x0100, "RawDevExposureBiasValue"),
    (0x0101, "RawDevWhiteBalanceValue"),
    (0x0102, "RawDevWBFineAdjustment"),
    (0x0103, "RawDevGrayPoint"),
    (0x0104, "RawDevSaturationEmphasis"),
    (0x0105, "RawDevMemoryColorEmphasis"),
    (0x0106, "RawDevContrastValue"),
    (0x0107, "RawDevSharpnessValue"),
    (0x0108, "RawDevColorSpace"),
    (0x0109, "RawDevEngine"),
    (0x010A, "RawDevNoiseReduction"),
    (0x010B, "RawDevEditStatus"),
    (0x010C, "RawDevSettings"),
    (0x0000, "ImageProcessingVersion"),
    (0x0100, "WB_RBLevels"),
    (0x0102, "WB_RBLevels3000K"),
    (0x0103, "WB_RBLevels3300K"),
    (0x0104, "WB_RBLevels3600K"),
    (0x0105, "WB_RBLevels3900K"),
    (0x0106, "WB_RBLevels4000K"),
    (0x0107, "WB_RBLevels4300K"),
    (0x0108, "WB_RBLevels4500K"),
    (0x0109, "WB_RBLevels4800K"),
    (0x010A, "WB_RBLevels5300K"),
    (0x010B, "WB_RBLevels6000K"),
    (0x010C, "WB_RBLevels6600K"),
    (0x010D, "WB_RBLevels7500K"),
    (0x010E, "WB_RBLevelsCWB1"),
    (0x010F, "WB_RBLevelsCWB2"),
    (0x0110, "WB_RBLevelsCWB3"),
    (0x0111, "WB_RBLevelsCWB4"),
    (0x0113, "WB_GLevel3000K"),
    (0x0114, "WB_GLevel3300K"),
    (0x0115, "WB_GLevel3600K"),
    (0x0116, "WB_GLevel3900K"),
    (0x0117, "WB_GLevel4000K"),
    (0x0118, "WB_GLevel4300K"),
    (0x0119, "WB_GLevel4500K"),
    (0x011A, "WB_GLevel4800K"),
    (0x011B, "WB_GLevel5300K"),
    (0x011C, "WB_GLevel6000K"),
    (0x011D, "WB_GLevel6600K"),
    (0x011E, "WB_GLevel7500K"),
    (0x011F, "WB_GLevel"),
    (0x0200, "ColorMatrix"),
    (0x0300, "Enhancer"),
    (0x0301, "EnhancerValues"),
    (0x0310, "CoringFilter"),
    (0x0311, "CoringValues"),
    (0x0600, "BlackLevel2"),
    (0x0610, "GainBase"),
    (0x0611, "ValidBits"),
    (0x0612, "CropLeft"),
    (0x0613, "CropTop"),
    (0x0614, "CropWidth"),
    (0x0615, "CropHeight"),
    (0x0635, "UnknownBlock1"),
    (0x0636, "UnknownBlock2"),
    (0x0805, "SensorCalibration"),
    (0x1010, "NoiseReduction2"),
    (0x1011, "DistortionCorrection2"),
    (0x1012, "ShadingCompensation2"),
    (0x101C, "MultipleExposureMode"),
    (0x1103, "UnknownBlock3"),
    (0x1104, "UnknownBlock4"),
    (0x1112, "AspectRatio"),
    (0x1113, "AspectFrame"),
    (0x1200, "FacesDetected"),
    (0x1201, "FaceDetectArea"),
    (0x1202, "MaxFaces"),
    (0x1203, "FaceDetectFrameSize"),
    (0x1207, "FaceDetectFrameCrop"),
    (0x1306, "CameraTemperature"),
    (0x1900, "KeystoneCompensation"),
    (0x1901, "KeystoneDirection"),
    (0x1906, "KeystoneValue"),
    (0x2110, "GNDFilterType"),
    (0x0000, "FocusInfoVersion"),
    // (0x0209, "AutoFocus"), // Unknown=>1 in Perl
    (0x0210, "SceneDetect"),
    // (0x0211, "SceneArea"), // Unknown=>1 in Perl
    // (0x0212, "SceneDetectData"), // Unknown=>1 in Perl
    (0x0300, "ZoomStepCount"),
    (0x0301, "FocusStepCount"),
    (0x0303, "FocusStepInfinity"),
    (0x0304, "FocusStepNear"),
    (0x0305, "FocusDistance"),
    (0x0308, "AFPoint"),
    (0x031B, "AFPointDetails"),
    (0x0328, "AFInfo"),
    (0x1201, "ExternalFlash"),
    // (0x1203, "ExternalFlashGuideNumber"), // Unknown=>1 in Perl
    (0x1204, "ExternalFlashBounce"),
    (0x1205, "ExternalFlashZoom"),
    (0x1208, "InternalFlash"),
    (0x1209, "ManualFlash"),
    (0x120A, "MacroLED"),
    (0x1500, "SensorTemperature"),
];
/// Pentax main IFD tag overrides — these take priority over generated table to avoid
/// sub-table offset collisions (e.g. generated has 0x0e="SensorTemperature2" from a sub-table,
/// but main IFD tag 0x000e is "AFPointSelected").
static PENTAX_MAIN_IFD_TAGS: &[(u16, &str, &str)] = &[
    (0x0000, "PentaxVersion", "Pentax Version"),
    (0x0001, "PentaxModelType", "Pentax Model Type"),
    (0x0002, "PreviewImageSize", "Preview Image Size"),
    (0x0003, "PreviewImageLength", "Preview Image Length"),
    (0x0004, "PreviewImageStart", "Preview Image Start"),
    (0x0005, "PentaxModelID", "Pentax Model ID"),
    (0x0006, "Date", "Date"),
    (0x0007, "Time", "Time"),
    (0x0008, "Quality", "Quality"),
    (0x000b, "PictureMode", "Picture Mode"),
    (0x000c, "FlashMode", "Flash Mode"),
    (0x000d, "FocusMode", "Focus Mode"),
    (0x000e, "AFPointSelected", "AF Point Selected"),
    (0x000f, "AFPointsInFocus", "AF Points In Focus"),
    (0x0010, "DataScaling", "Data Scaling"), // actually FocusPosition for some models
    (0x0011, "AFPointSelected2", "AF Point Selected 2"),
    (0x0012, "ExposureTime", "Exposure Time"),
    (0x0013, "FNumber", "F Number"),
    (0x0014, "ISO", "ISO"),
    (0x0016, "ExposureCompensation", "Exposure Compensation"),
    (0x0017, "MeteringMode", "Metering Mode"),
    (0x0018, "AutoBracketing", "Auto Bracketing"),
    (0x0019, "WhiteBalance", "White Balance"),
    (0x001a, "WhiteBalanceMode", "White Balance Mode"),
    (0x001d, "FocalLength", "Focal Length"),
    (0x001f, "Saturation", "Saturation"),
    (0x0020, "Contrast", "Contrast"),
    (0x0021, "Sharpness", "Sharpness"),
    (0x0022, "WorldTimeLocation", "World Time Location"),
    (0x0023, "HometownCity", "Hometown City"),
    (0x0024, "DestinationCity", "Destination City"),
    (0x0025, "HometownDST", "Hometown DST"),
    (0x0026, "DestinationDST", "Destination DST"),
    (0x0027, "DSPFirmwareVersion", "DSP Firmware Version"),
    (0x0028, "CPUFirmwareVersion", "CPU Firmware Version"),
    (0x002d, "EffectiveLV", "Effective LV"),
    (0x0032, "ImageEditing", "Image Editing"),
    (0x0033, "PictureMode", "Picture Mode"),
    (0x0034, "DriveMode", "Drive Mode"),
    (0x0037, "ColorSpace", "Color Space"),
    (0x003d, "DataScaling", "Data Scaling"),
    (0x003e, "PreviewImageBorders", "Preview Image Borders"),
    (0x003f, "LensRec", "Lens Rec"),
    (0x0040, "SensitivityAdjust", "Sensitivity Adjust"),
    (0x0041, "ImageEditCount", "Image Edit Count"),
    (0x0047, "CameraTemperature", "Camera Temperature"),
    (0x0048, "AELock", "AE Lock"),
    (0x0049, "NoiseReduction", "Noise Reduction"),
    (0x004d, "FlashExposureComp", "Flash Exposure Comp"),
    (0x004f, "ImageTone", "Image Tone"),
    (0x0050, "ColorTemperature", "Color Temperature"),
    (0x005c, "ShakeReductionInfo", "Shake Reduction Info"),
    (0x005d, "ShutterCount", "Shutter Count"),
    (0x0062, "RawDevelopmentProcess", "Raw Development Process"),
    (0x0200, "BlackPoint", "Black Point"),
    (0x0201, "WhitePoint", "White Point"),
    (0x0205, "CameraSettings", "Camera Settings"),
    (0x0206, "AEInfo", "AE Info"),
    (0x0207, "LensInfo", "Lens Info"),
    (0x0208, "FlashInfo", "Flash Info"),
    (0x0209, "AEMeteringSegments", "AE Metering Segments"),
    (0x020a, "FlashMeteringSegments", "Flash Metering Segments"),
    (
        0x020b,
        "SlaveFlashMeteringSegments",
        "Slave Flash Metering Segments",
    ),
    (0x020d, "WB_RGGBLevelsDaylight", "WB_RGGBLevelsDaylight"),
    (0x020e, "WB_RGGBLevelsShade", "WB_RGGBLevelsShade"),
    (0x020f, "WB_RGGBLevelsCloudy", "WB_RGGBLevelsCloudy"),
    (0x0210, "WB_RGGBLevelsTungsten", "WB_RGGBLevelsTungsten"),
    (
        0x0211,
        "WB_RGGBLevelsFluorescentD",
        "WB_RGGBLevelsFluorescentD",
    ),
    (
        0x0212,
        "WB_RGGBLevelsFluorescentN",
        "WB_RGGBLevelsFluorescentN",
    ),
    (
        0x0213,
        "WB_RGGBLevelsFluorescentW",
        "WB_RGGBLevelsFluorescentW",
    ),
    (0x0214, "WB_RGGBLevelsFlash", "WB_RGGBLevelsFlash"),
    (0x0215, "CameraInfo", "Camera Info"),
    (0x0216, "BatteryInfo", "Battery Info"),
    (0x021f, "AFInfo", "AF Info"),
    (0x0222, "ColorInfo", "Color Info"),
];

static PENTAX_SUB_TAGS: &[(u16, &str)] = &[
    (0x0000, "AEExposureTime"),
    (0x0001, "AEAperture"),
    (0x0002, "AE_ISO"),
    (0x0003, "AEXv"),
    (0x0004, "AEBXv"),
    (0x0005, "AEMinExposureTime"),
    (0x0006, "AEProgramMode"),
    (0x0007, "AEFlags"),
    (0x0008, "AEApertureSteps"),
    (0x0009, "AEMaxAperture"),
    (0x000A, "AEMaxAperture2"),
    (0x000B, "AEMinAperture"),
    (0x000C, "AEMeteringMode"),
    (0x000D, "AEWhiteBalance"),
    (0x000E, "FlashExposureCompSet"),
    (0x0015, "LevelIndicator"),
    (0x0000, "AFPointsUnknown1"),
    (0x0002, "AFPointsUnknown2"),
    (0x0004, "AFPredictor"),
    (0x0007, "AFIntegrationTime"),
    (0x000B, "AFPointsInFocus"),
    (0x0014, "AFPointValues"),
    (0x012A, "AFPointsSelected"),
    (0x018F, "AFPointsUnknown"),
    (0x01FA, "LiveView"),
    (0x01FD, "AFHold"),
    (0x021F, "FirstFrameActionInAFC"),
    (0x0220, "ActionInAFCCont"),
    (0x0221, "AFCHold"),
    (0x0960, "SubjectRecognition"),
    (0x0000, "LensType"),
    (0x0003, "LensData"),
    (0x0000, "FlashStatus"),
    (0x0001, "InternalFlashMode"),
    (0x0002, "ExternalFlashMode"),
    (0x0003, "InternalFlashStrength"),
    (0x0019, "ExternalFlashExposureComp"),
    (0x001A, "ExternalFlashBounce"),
    (0x0000, "PictureMode2"),
    (0x0002, "FlashOptions"),
    (0x0003, "AFPointMode"),
    (0x0004, "AFPointSelected2"),
    (0x0006, "ISOFloor"),
    (0x0007, "DriveMode2"),
    (0x0008, "ExposureBracketStepSize"),
    (0x0009, "BracketShotNumber"),
    (0x000A, "WhiteBalanceSet"),
    (0x000D, "RawAndJpgRecording"),
    (0x0010, "FlashOptions2"),
    (0x0012, "TvExposureTimeSetting"),
    (0x0013, "AvApertureSetting"),
    (0x0014, "SvISOSetting"),
    (0x0015, "BaseExposureCompensation"),
    (0x0001, "CameraOrientation"),
    (0x0002, "BodyBatteryADNoLoad"),
    (0x0003, "BodyBatteryADLoad"),
    (0x0004, "GripBatteryADNoLoad"),
    (0x0005, "GripBatteryADLoad"),
    (0x0006, "BodyBatteryVoltage3"),
    (0x0008, "BodyBatteryVoltage4"),
    (0x0010, "GripBatteryState"),
    (0x0011, "GripBatteryPercent"),
    (0x0012, "GripBatteryVoltage"),
    (0x0000, "PentaxModelID"),
    (0x0001, "ManufactureDate"),
    (0x0002, "ProductionCode"),
    (0x0000, "SRResult"),
    (0x0001, "ShakeReduction"),
    (0x0002, "SRHalfPressTime"),
    (0x0003, "SRFocalLength"),
    (0x0003, "ExtenderStatus"),
    (0x0000, "WhiteBalanceAutoAdjustment"),
    (0x0001, "TungstenAWB"),
    (0x0002, "HometownCity"),
    (0x0003, "DestinationCity"),
];
pub static OLYMPUS_CAMERA_SETTINGS: &[(u16, &str)] = &[
    (0x0000, "CameraSettingsVersion"),
    (0x0100, "PreviewImageValid"),
    (0x0101, "PreviewImageStart"),
    (0x0102, "PreviewImageLength"),
    (0x0200, "ExposureMode"),
    (0x0201, "AELock"),
    (0x0202, "MeteringMode"),
    (0x0203, "ExposureShift"),
    (0x0204, "NDFilter"),
    (0x0300, "MacroMode"),
    (0x0301, "FocusMode"),
    (0x0302, "FocusProcess"),
    (0x0303, "AFSearch"),
    (0x0304, "AFAreas"),
    (0x0305, "AFPointSelected"),
    (0x0306, "AFFineTune"),
    (0x0307, "AFFineTuneAdj"),
    (0x0308, "FocusBracketStepSize"),
    (0x0309, "AISubjectTrackingMode"),
    (0x030A, "AFTargetInfo"),
    (0x030B, "SubjectDetectInfo"),
    (0x0400, "FlashMode"),
    (0x0401, "FlashExposureComp"),
    (0x0403, "FlashRemoteControl"),
    (0x0404, "FlashControlMode"),
    (0x0405, "FlashIntensity"),
    (0x0406, "ManualFlashStrength"),
    (0x0500, "WhiteBalance2"),
    (0x0501, "WhiteBalanceTemperature"),
    (0x0502, "WhiteBalanceBracket"),
    (0x0503, "CustomSaturation"),
    (0x0504, "ModifiedSaturation"),
    (0x0505, "ContrastSetting"),
    (0x0506, "SharpnessSetting"),
    (0x0507, "ColorSpace"),
    (0x0509, "SceneMode"),
    (0x050A, "NoiseReduction"),
    (0x050B, "DistortionCorrection"),
    (0x050C, "ShadingCompensation"),
    (0x050D, "CompressionFactor"),
    (0x050F, "Gradation"),
    (0x0520, "PictureMode"),
    (0x0521, "PictureModeSaturation"),
    (0x0522, "PictureModeHue"),
    (0x0523, "PictureModeContrast"),
    (0x0524, "PictureModeSharpness"),
    (0x0525, "PictureModeBWFilter"),
    (0x0526, "PictureModeTone"),
    (0x0527, "NoiseFilter"),
    (0x0529, "ArtFilter"),
    (0x052C, "MagicFilter"),
    (0x052D, "PictureModeEffect"),
    (0x052E, "ToneLevel"),
    (0x052F, "ArtFilterEffect"),
    (0x0532, "ColorCreatorEffect"),
    (0x0537, "MonochromeProfileSettings"),
    (0x0538, "FilmGrainEffect"),
    (0x0539, "ColorProfileSettings"),
    (0x053A, "MonochromeVignetting"),
    (0x053B, "MonochromeColor"),
    (0x0600, "DriveMode"),
    (0x0601, "PanoramaMode"),
    (0x0603, "ImageQuality2"),
    (0x0604, "ImageStabilization"),
    (0x0804, "StackedImage"),
    (0x0821, "ISOAutoSettings"),
    (0x0900, "ManometerPressure"),
    (0x0901, "ManometerReading"),
    (0x0902, "ExtendedWBDetect"),
    (0x0903, "RollAngle"),
    (0x0904, "PitchAngle"),
    (0x0908, "DateTimeUTC"),
];
pub static OLYMPUS_EQUIPMENT: &[(u16, &str)] = &[
    (0x0000, "EquipmentVersion"),
    (0x0100, "CameraType2"),
    (0x0101, "SerialNumber"),
    (0x0102, "InternalSerialNumber"),
    (0x0103, "FocalPlaneDiagonal"),
    (0x0104, "BodyFirmwareVersion"),
    (0x0201, "LensType"),
    (0x0202, "LensSerialNumber"),
    (0x0203, "LensModel"),
    (0x0204, "LensFirmwareVersion"),
    (0x0205, "MaxApertureAtMinFocal"),
    (0x0206, "MaxApertureAtMaxFocal"),
    (0x0207, "MinFocalLength"),
    (0x0208, "MaxFocalLength"),
    (0x020A, "MaxAperture"),
    (0x020B, "LensProperties"),
    (0x0301, "Extender"),
    (0x0302, "ExtenderSerialNumber"),
    (0x0303, "ExtenderModel"),
    (0x0304, "ExtenderFirmwareVersion"),
    (0x0403, "ConversionLens"),
    (0x1000, "FlashType"),
    (0x1001, "FlashModel"),
    (0x1002, "FlashFirmwareVersion"),
    (0x1003, "FlashSerialNumber"),
];
pub static OLYMPUS_FOCUS_INFO: &[(u16, &str)] = &[
    (0x0000, "FocusInfoVersion"),
    (0x0210, "SceneDetect"),
    (0x0300, "ZoomStepCount"),
    (0x0301, "FocusStepCount"),
    (0x0303, "FocusStepInfinity"),
    (0x0304, "FocusStepNear"),
    (0x0305, "FocusDistance"),
    (0x0308, "AFPoint"),
    (0x031B, "AFPointDetails"),
    (0x0328, "AFInfo"),
    (0x1201, "ExternalFlash"),
    (0x1204, "ExternalFlashBounce"),
    (0x1205, "ExternalFlashZoom"),
    (0x1208, "InternalFlash"),
    (0x1209, "ManualFlash"),
    (0x120A, "MacroLED"),
    (0x1500, "SensorTemperature"),
    (0x1600, "ImageStabilization"),
];
pub static OLYMPUS_IMAGE_PROCESSING: &[(u16, &str)] = &[
    (0x0000, "ImageProcessingVersion"),
    (0x0100, "WB_RBLevels"),
    (0x0102, "WB_RBLevels3000K"),
    (0x0103, "WB_RBLevels3300K"),
    (0x0104, "WB_RBLevels3600K"),
    (0x0105, "WB_RBLevels3900K"),
    (0x0106, "WB_RBLevels4000K"),
    (0x0107, "WB_RBLevels4300K"),
    (0x0108, "WB_RBLevels4500K"),
    (0x0109, "WB_RBLevels4800K"),
    (0x010A, "WB_RBLevels5300K"),
    (0x010B, "WB_RBLevels6000K"),
    (0x010C, "WB_RBLevels6600K"),
    (0x010D, "WB_RBLevels7500K"),
    (0x010E, "WB_RBLevelsCWB1"),
    (0x010F, "WB_RBLevelsCWB2"),
    (0x0110, "WB_RBLevelsCWB3"),
    (0x0111, "WB_RBLevelsCWB4"),
    (0x0113, "WB_GLevel3000K"),
    (0x0114, "WB_GLevel3300K"),
    (0x0115, "WB_GLevel3600K"),
    (0x0116, "WB_GLevel3900K"),
    (0x0117, "WB_GLevel4000K"),
    (0x0118, "WB_GLevel4300K"),
    (0x0119, "WB_GLevel4500K"),
    (0x011A, "WB_GLevel4800K"),
    (0x011B, "WB_GLevel5300K"),
    (0x011C, "WB_GLevel6000K"),
    (0x011D, "WB_GLevel6600K"),
    (0x011E, "WB_GLevel7500K"),
    (0x011F, "WB_GLevel"),
    (0x0200, "ColorMatrix"),
    (0x0300, "Enhancer"),
    (0x0301, "EnhancerValues"),
    (0x0310, "CoringFilter"),
    (0x0311, "CoringValues"),
    (0x0600, "BlackLevel2"),
    (0x0610, "GainBase"),
    (0x0611, "ValidBits"),
    (0x0612, "CropLeft"),
    (0x0613, "CropTop"),
    (0x0614, "CropWidth"),
    (0x0615, "CropHeight"),
    (0x0635, "UnknownBlock1"),
    (0x0636, "UnknownBlock2"),
    (0x0805, "SensorCalibration"),
    (0x1010, "NoiseReduction2"),
    (0x1011, "DistortionCorrection2"),
    (0x1012, "ShadingCompensation2"),
    (0x101C, "MultipleExposureMode"),
    (0x1103, "UnknownBlock3"),
    (0x1104, "UnknownBlock4"),
    (0x1112, "AspectRatio"),
    (0x1113, "AspectFrame"),
    (0x1200, "FacesDetected"),
    (0x1201, "FaceDetectArea"),
    (0x1202, "MaxFaces"),
    (0x1203, "FaceDetectFrameSize"),
    (0x1207, "FaceDetectFrameCrop"),
    (0x1306, "CameraTemperature"),
    (0x1900, "KeystoneCompensation"),
    (0x1901, "KeystoneDirection"),
    (0x1906, "KeystoneValue"),
    (0x2110, "GNDFilterType"),
];
pub static OLYMPUS_RAW_DEV: &[(u16, &str)] = &[
    (0x0000, "RawDevVersion"),
    (0x0100, "RawDevExposureBiasValue"),
    (0x0101, "RawDevWhiteBalanceValue"),
    (0x0102, "RawDevWBFineAdjustment"),
    (0x0103, "RawDevGrayPoint"),
    (0x0104, "RawDevSaturationEmphasis"),
    (0x0105, "RawDevMemoryColorEmphasis"),
    (0x0106, "RawDevContrastValue"),
    (0x0107, "RawDevSharpnessValue"),
    (0x0108, "RawDevColorSpace"),
    (0x0109, "RawDevEngine"),
    (0x010A, "RawDevNoiseReduction"),
    (0x010B, "RawDevEditStatus"),
    (0x010C, "RawDevSettings"),
];

// Olympus LensType print conversion
// Key format: sprintf("%x %.2x %.2x", byte0, byte2, byte3)
static OLYMPUS_LENS_TYPES: &[(&str, &str)] = &[
    ("0 00 00", "None"),
    ("0 01 00", "Olympus Zuiko Digital ED 50mm F2.0 Macro"),
    ("0 01 01", "Olympus Zuiko Digital 40-150mm F3.5-4.5"),
    ("0 01 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6"),
    ("0 02 00", "Olympus Zuiko Digital ED 150mm F2.0"),
    ("0 02 10", "Olympus M.Zuiko Digital 17mm F2.8 Pancake"),
    ("0 03 00", "Olympus Zuiko Digital ED 300mm F2.8"),
    (
        "0 03 10",
        "Olympus M.Zuiko Digital ED 14-150mm F4.0-5.6 [II]",
    ),
    ("0 04 10", "Olympus M.Zuiko Digital ED 9-18mm F4.0-5.6"),
    ("0 05 00", "Olympus Zuiko Digital 14-54mm F2.8-3.5"),
    ("0 05 01", "Olympus Zuiko Digital Pro ED 90-250mm F2.8"),
    ("0 05 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6 L"),
    ("0 06 00", "Olympus Zuiko Digital ED 50-200mm F2.8-3.5"),
    ("0 06 01", "Olympus Zuiko Digital ED 8mm F3.5 Fisheye"),
    ("0 06 10", "Olympus M.Zuiko Digital ED 40-150mm F4.0-5.6"),
    ("0 07 00", "Olympus Zuiko Digital 11-22mm F2.8-3.5"),
    ("0 07 01", "Olympus Zuiko Digital 18-180mm F3.5-6.3"),
    ("0 07 10", "Olympus M.Zuiko Digital ED 12mm F2.0"),
    ("0 08 01", "Olympus Zuiko Digital 70-300mm F4.0-5.6"),
    ("0 08 10", "Olympus M.Zuiko Digital ED 75-300mm F4.8-6.7"),
    ("0 09 10", "Olympus M.Zuiko Digital 14-42mm F3.5-5.6 II"),
    ("0 10 01", "Kenko Tokina Reflex 300mm F6.3 MF Macro"),
    ("0 10 10", "Olympus M.Zuiko Digital ED 12-50mm F3.5-6.3 EZ"),
    ("0 11 10", "Olympus M.Zuiko Digital 45mm F1.8"),
    ("0 12 10", "Olympus M.Zuiko Digital ED 60mm F2.8 Macro"),
    ("0 13 10", "Olympus M.Zuiko Digital 14-42mm F3.5-5.6 II R"),
    ("0 14 10", "Olympus M.Zuiko Digital ED 40-150mm F4.0-5.6 R"),
    ("0 15 00", "Olympus Zuiko Digital ED 7-14mm F4.0"),
    ("0 15 10", "Olympus M.Zuiko Digital ED 75mm F1.8"),
    ("0 16 10", "Olympus M.Zuiko Digital 17mm F1.8"),
    ("0 17 00", "Olympus Zuiko Digital Pro ED 35-100mm F2.0"),
    ("0 18 00", "Olympus Zuiko Digital 14-45mm F3.5-5.6"),
    ("0 18 10", "Olympus M.Zuiko Digital ED 75-300mm F4.8-6.7 II"),
    ("0 19 10", "Olympus M.Zuiko Digital ED 12-40mm F2.8 Pro"),
    ("0 20 00", "Olympus Zuiko Digital 35mm F3.5 Macro"),
    ("0 20 10", "Olympus M.Zuiko Digital ED 40-150mm F2.8 Pro"),
    ("0 21 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6 EZ"),
    ("0 22 00", "Olympus Zuiko Digital 17.5-45mm F3.5-5.6"),
    ("0 22 10", "Olympus M.Zuiko Digital 25mm F1.8"),
    ("0 23 00", "Olympus Zuiko Digital ED 14-42mm F3.5-5.6"),
    ("0 23 10", "Olympus M.Zuiko Digital ED 7-14mm F2.8 Pro"),
    ("0 24 00", "Olympus Zuiko Digital ED 40-150mm F4.0-5.6"),
    ("0 24 10", "Olympus M.Zuiko Digital ED 300mm F4.0 IS Pro"),
    ("0 25 10", "Olympus M.Zuiko Digital ED 8mm F1.8 Fisheye Pro"),
    ("0 26 10", "Olympus M.Zuiko Digital ED 12-100mm F4.0 IS Pro"),
    ("0 27 10", "Olympus M.Zuiko Digital ED 30mm F3.5 Macro"),
    ("0 28 10", "Olympus M.Zuiko Digital ED 25mm F1.2 Pro"),
    ("0 29 10", "Olympus M.Zuiko Digital ED 17mm F1.2 Pro"),
    ("0 30 00", "Olympus Zuiko Digital ED 50-200mm F2.8-3.5 SWD"),
    ("0 30 10", "Olympus M.Zuiko Digital ED 45mm F1.2 Pro"),
    ("0 31 00", "Olympus Zuiko Digital ED 12-60mm F2.8-4.0 SWD"),
    ("0 32 00", "Olympus Zuiko Digital ED 14-35mm F2.0 SWD"),
    ("0 32 10", "Olympus M.Zuiko Digital ED 12-200mm F3.5-6.3"),
    ("0 33 00", "Olympus Zuiko Digital 25mm F2.8"),
    (
        "0 33 10",
        "Olympus M.Zuiko Digital 150-400mm F4.5 TC1.25x IS Pro",
    ),
    ("0 34 00", "Olympus Zuiko Digital ED 9-18mm F4.0-5.6"),
    ("0 34 10", "Olympus M.Zuiko Digital ED 12-45mm F4.0 Pro"),
    ("0 35 00", "Olympus Zuiko Digital 14-54mm F2.8-3.5 II"),
    ("0 35 10", "Olympus M.Zuiko 100-400mm F5.0-6.3"),
    ("0 36 10", "Olympus M.Zuiko Digital ED 8-25mm F4 Pro"),
    ("0 37 10", "Olympus M.Zuiko Digital ED 40-150mm F4.0 Pro"),
    ("0 38 10", "Olympus M.Zuiko Digital ED 20mm F1.4 Pro"),
    (
        "0 39 10",
        "Olympus M.Zuiko Digital ED 90mm F3.5 Macro IS Pro",
    ),
    ("0 40 10", "Olympus M.Zuiko Digital ED 150-600mm F5.0-6.3"),
    (
        "0 41 10",
        "OM System M.Zuiko Digital ED 50-200mm F2.8 IS Pro",
    ),
    ("1 01 00", "Sigma 18-50mm F3.5-5.6 DC"),
    ("1 01 10", "Sigma 30mm F2.8 EX DN"),
    ("1 02 00", "Sigma 55-200mm F4.0-5.6 DC"),
    ("1 02 10", "Sigma 19mm F2.8 EX DN"),
    ("1 03 00", "Sigma 18-125mm F3.5-5.6 DC"),
    ("1 03 10", "Sigma 30mm F2.8 DN | A"),
    ("1 04 00", "Sigma 18-125mm F3.5-5.6 DC"),
    ("1 04 10", "Sigma 19mm F2.8 DN | A"),
    ("1 05 00", "Sigma 30mm F1.4 EX DC HSM"),
    ("1 05 10", "Sigma 60mm F2.8 DN | A"),
    ("1 06 00", "Sigma APO 50-500mm F4.0-6.3 EX DG HSM"),
    ("1 06 10", "Sigma 30mm F1.4 DC DN | C"),
    ("1 07 00", "Sigma Macro 105mm F2.8 EX DG"),
    ("1 07 10", "Sigma 16mm F1.4 DC DN | C (017)"),
    ("1 08 00", "Sigma APO Macro 150mm F2.8 EX DG HSM"),
    ("1 09 00", "Sigma 18-50mm F2.8 EX DC Macro"),
    ("1 10 00", "Sigma 24mm F1.8 EX DG Aspherical Macro"),
    ("1 11 00", "Sigma APO 135-400mm F4.5-5.6 DG"),
    ("1 12 00", "Sigma APO 300-800mm F5.6 EX DG HSM"),
    ("1 13 00", "Sigma 30mm F1.4 EX DC HSM"),
    ("1 14 00", "Sigma APO 50-500mm F4.0-6.3 EX DG HSM"),
    ("1 15 00", "Sigma 10-20mm F4.0-5.6 EX DC HSM"),
    ("1 16 00", "Sigma APO 70-200mm F2.8 II EX DG Macro HSM"),
    ("1 17 00", "Sigma 50mm F1.4 EX DG HSM"),
    ("2 01 00", "Leica D Vario Elmarit 14-50mm F2.8-3.5 Asph."),
    ("2 01 10", "Lumix G Vario 14-45mm F3.5-5.6 Asph. Mega OIS"),
    ("2 02 00", "Leica D Summilux 25mm F1.4 Asph."),
    ("2 02 10", "Lumix G Vario 45-200mm F4.0-5.6 Mega OIS"),
    (
        "2 03 00",
        "Leica D Vario Elmar 14-50mm F3.8-5.6 Asph. Mega OIS",
    ),
    ("2 03 01", "Leica D Vario Elmar 14-50mm F3.8-5.6 Asph."),
    (
        "2 03 10",
        "Lumix G Vario HD 14-140mm F4.0-5.8 Asph. Mega OIS",
    ),
    ("2 04 00", "Leica D Vario Elmar 14-150mm F3.5-5.6"),
    ("2 04 10", "Lumix G Vario 7-14mm F4.0 Asph."),
    ("2 05 10", "Lumix G 20mm F1.7 Asph."),
    ("2 06 10", "Leica DG Macro-Elmarit 45mm F2.8 Asph. Mega OIS"),
    ("2 07 10", "Lumix G Vario 14-42mm F3.5-5.6 Asph. Mega OIS"),
    ("2 08 10", "Lumix G Fisheye 8mm F3.5"),
    ("2 09 10", "Lumix G Vario 100-300mm F4.0-5.6 Mega OIS"),
    ("2 10 10", "Lumix G 14mm F2.5 Asph."),
    ("2 11 10", "Lumix G 12.5mm F12 3D"),
    ("2 12 10", "Leica DG Summilux 25mm F1.4 Asph."),
    (
        "2 13 10",
        "Lumix G X Vario PZ 45-175mm F4.0-5.6 Asph. Power OIS",
    ),
    (
        "2 14 10",
        "Lumix G X Vario PZ 14-42mm F3.5-5.6 Asph. Power OIS",
    ),
    ("2 15 10", "Lumix G X Vario 12-35mm F2.8 Asph. Power OIS"),
    ("2 16 10", "Lumix G Vario 45-150mm F4.0-5.6 Asph. Mega OIS"),
    ("2 17 10", "Lumix G X Vario 35-100mm F2.8 Power OIS"),
    (
        "2 18 10",
        "Lumix G Vario 14-42mm F3.5-5.6 II Asph. Mega OIS",
    ),
    ("2 19 10", "Lumix G Vario 14-140mm F3.5-5.6 Asph. Power OIS"),
    ("2 20 10", "Lumix G Vario 12-32mm F3.5-5.6 Asph. Mega OIS"),
    ("2 21 10", "Leica DG Nocticron 42.5mm F1.2 Asph. Power OIS"),
    ("2 22 10", "Leica DG Summilux 15mm F1.7 Asph."),
    ("2 23 10", "Lumix G Vario 35-100mm F4.0-5.6 Asph. Mega OIS"),
    ("2 24 10", "Lumix G Macro 30mm F2.8 Asph. Mega OIS"),
    ("2 25 10", "Lumix G 42.5mm F1.7 Asph. Power OIS"),
    ("2 26 10", "Lumix G 25mm F1.7 Asph."),
    (
        "2 27 10",
        "Leica DG Vario-Elmar 100-400mm F4.0-6.3 Asph. Power OIS",
    ),
    ("2 28 10", "Lumix G Vario 12-60mm F3.5-5.6 Asph. Power OIS"),
    ("2 29 10", "Leica DG Summilux 12mm F1.4 Asph."),
    (
        "2 30 10",
        "Leica DG Vario-Elmarit 12-60mm F2.8-4 Asph. Power OIS",
    ),
    ("2 31 10", "Lumix G Vario 45-200mm F4.0-5.6 II"),
    ("2 32 10", "Lumix G Vario 100-300mm F4.0-5.6 II"),
    ("2 33 10", "Lumix G X Vario 12-35mm F2.8 II Asph. Power OIS"),
    ("2 34 10", "Lumix G Vario 35-100mm F2.8 II"),
    ("2 35 10", "Leica DG Vario-Elmarit 8-18mm F2.8-4 Asph."),
    ("2 36 10", "Leica DG Elmarit 200mm F2.8 Power OIS"),
    (
        "2 37 10",
        "Leica DG Vario-Elmarit 50-200mm F2.8-4 Asph. Power OIS",
    ),
    ("2 38 10", "Leica DG Vario-Summilux 10-25mm F1.7 Asph."),
    ("2 39 10", "Leica DG Summilux 25mm F1.4 II Asph."),
    ("2 40 10", "Leica DG Vario-Summilux 25-50mm F1.7 Asph."),
    ("2 41 10", "Leica DG Summilux 9mm F1.7 Asph."),
    ("3 01 00", "Leica D Vario Elmarit 14-50mm F2.8-3.5 Asph."),
    ("3 02 00", "Leica D Summilux 25mm F1.4 Asph."),
    ("5 01 10", "Tamron 14-150mm F3.5-5.8 Di III"),
    ("18 01 10", "Venus Optics Laowa 50mm F2.8 2x Macro"),
    ("f7 03 10", "LAOWA C&D-Dreamer MFT 7.5mm F2.0"),
    ("f7 10 10", "LAOWA C&D-Dreamer MFT 6.0mm F2.0"),
    ("ff32 02 10", "Xiaoyi 42.5mm F1.8"),
];

pub fn olympus_lens_type_name(key: &str) -> Option<&'static str> {
    OLYMPUS_LENS_TYPES
        .iter()
        .find(|&&(k, _)| k == key)
        .map(|&(_, v)| v)
}

// Olympus Extender print conversion
// Key format: sprintf("%x %.2x", byte0, byte2)
static OLYMPUS_EXTENDER_TYPES: &[(&str, &str)] = &[
    ("0 00", "None"),
    ("0 04", "Olympus Zuiko Digital EC-14 1.4x Teleconverter"),
    ("0 08", "Olympus EX-25 Extension Tube"),
    ("0 10", "Olympus Zuiko Digital EC-20 2.0x Teleconverter"),
];

pub fn olympus_extender_name(key: &str) -> Option<&'static str> {
    OLYMPUS_EXTENDER_TYPES
        .iter()
        .find(|&&(k, _)| k == key)
        .map(|&(_, v)| v)
}
