Project

General

Profile

Exif.Sony1.AFInfo ยป exiv2-sony_AFInfo.patch

Mihail Zenkov, 14 Aug 2016 11:28

View differences:

exiv2-0.25/src/sonymn.cpp
288 288
        { 65535, N_("n/a") }
289 289
    };
290 290

  
291
    // This is a simple substitution cipher, so use a hardcoded translation table for speed.
292
    // The formula is: c = (b*b*b) % 249, where c is the enciphered data byte
293
    // (note that bytes with values 249-255 are not translated, and 0-1, 82-84,
294
    // 165-167 and 248 have the same enciphered value)
295
    uint8_t decipher(uint8_t v) {
296
        const uint8_t table[256] = {
297
            0x0,  0x1,  0x32, 0xb1, 0xa,  0xe,  0x87, 0x28, 0x2,  0xcc, 0xca, 0xad, 0x1b, 0xdc, 0x8,  0xed,
298
            0x64, 0x86, 0xf0, 0x4f, 0x8c, 0x6c, 0xb8, 0xcb, 0x69, 0xc4, 0x2c, 0x3,  0x97, 0xb6, 0x93, 0x7c,
299
            0x14, 0xf3, 0xe2, 0x3e, 0x30, 0x8e, 0xd7, 0x60, 0x1c, 0xa1, 0xab, 0x37, 0xec, 0x75, 0xbe, 0x23,
300
            0x15, 0x6a, 0x59, 0x3f, 0xd0, 0xb9, 0x96, 0xb5, 0x50, 0x27, 0x88, 0xe3, 0x81, 0x94, 0xe0, 0xc0,
301
            0x4,  0x5c, 0xc6, 0xe8, 0x5f, 0x4b, 0x70, 0x38, 0x9f, 0x82, 0x80, 0x51, 0x2b, 0xc5, 0x45, 0x49,
302
            0x9b, 0x21, 0x52, 0x53, 0x54, 0x85, 0xb,  0x5d, 0x61, 0xda, 0x7b, 0x55, 0x26, 0x24, 0x7,  0x6e,
303
            0x36, 0x5b, 0x47, 0xb7, 0xd9, 0x4a, 0xa2, 0xdf, 0xbf, 0x12, 0x25, 0xbc, 0x1e, 0x7f, 0x56, 0xea,
304
            0x10, 0xe6, 0xcf, 0x67, 0x4d, 0x3c, 0x91, 0x83, 0xe1, 0x31, 0xb3, 0x6f, 0xf4, 0x5,  0x8a, 0x46,
305
            0xc8, 0x18, 0x76, 0x68, 0xbd, 0xac, 0x92, 0x2a, 0x13, 0xe9, 0xf,  0xa3, 0x7a, 0xdb, 0x3d, 0xd4,
306
            0xe7, 0x3a, 0x1a, 0x57, 0xaf, 0x20, 0x42, 0xb2, 0x9e, 0xc3, 0x8b, 0xf2, 0xd5, 0xd3, 0xa4, 0x7e,
307
            0x1f, 0x98, 0x9c, 0xee, 0x74, 0xa5, 0xa6, 0xa7, 0xd8, 0x5e, 0xb0, 0xb4, 0x34, 0xce, 0xa8, 0x79,
308
            0x77, 0x5a, 0xc1, 0x89, 0xae, 0x9a, 0x11, 0x33, 0x9d, 0xf5, 0x39, 0x19, 0x65, 0x78, 0x16, 0x71,
309
            0xd2, 0xa9, 0x44, 0x63, 0x40, 0x29, 0xba, 0xa0, 0x8f, 0xe4, 0xd6, 0x3b, 0x84, 0xd,  0xc2, 0x4e,
310
            0x58, 0xdd, 0x99, 0x22, 0x6b, 0xc9, 0xbb, 0x17, 0x6,  0xe5, 0x7d, 0x66, 0x43, 0x62, 0xf6, 0xcd,
311
            0x35, 0x90, 0x2e, 0x41, 0x8d, 0x6d, 0xaa, 0x9,  0x73, 0x95, 0xc,  0xf1, 0x1d, 0xde, 0x4c, 0x2f,
312
            0x2d, 0xf7, 0xd1, 0x72, 0xeb, 0xef, 0x48, 0xc7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
313
        };
314
        return table[v];
315
    }
316

  
317
    std::ostream& SonyMakerNote::print0x940e(std::ostream& os, const Value& value, const ExifData*)
318
    {
319
        if (value.count() != 12288)
320
        {
321
            os << "(" << value << ")";
322
        }
323
        else
324
        {
325
            const char* focusMode[] = {
326
                N_("Manual"),
327
                "AF-S",
328
                "AF-C",
329
                "AF-A"
330
            };
331

  
332
//            os << value.toString(0xb);
333
//            os << (long)decipher(value.toLong(0xb));
334

  
335
            os << focusMode[decipher(value.toLong(0xb))];
336

  
337
            int16_t statusActiveSensor = decipher(value.toLong(0x4)) + (decipher(value.toLong(0x5)) << 8);
338
            os << "\nStatus Active Sensor: ";
339
            os << (statusActiveSensor > 0 ? "BF" : "FF");
340
            os << " (" << statusActiveSensor << ")";
341
        }
342
        return os;
343
    }
344

  
291 345
    std::ostream& SonyMakerNote::print0xb000(std::ostream& os, const Value& value, const ExifData*)
292 346
    {
293 347
        if (value.count() != 4)
......
394 451
        TagInfo(0x3000, "ShotInfo", N_("Shot Info"),
395 452
                N_("Shot Information"),
396 453
                sony1Id, makerTags, undefined, -1, printValue),
454
        TagInfo(0x940E, "AFInfo", N_("AF Info"),
455
                N_("AF Information"),
456
                sony1Id, makerTags, unsignedByte, -1, print0x940e),
397 457
        TagInfo(0xB000, "FileFormat", N_("File Format"),
398 458
                N_("File Format"),
399 459
                sony1Id, makerTags, unsignedByte, -1, print0xb000),
400
-- exiv2-0.25.orig/src/sonymn_int.hpp
460
++ exiv2-0.25/src/sonymn_int.hpp
......
65 65
        //@{
66 66
        //! Print Sony Camera Model
67 67
        static std::ostream& print0xb000(std::ostream&, const Value&, const ExifData*);
68
        //! Print Sony AF Info
69
        static std::ostream& print0x940e(std::ostream&, const Value&, const ExifData*);
68 70
        //! Print Full and Preview Image size
69 71
        static std::ostream& printImageSize(std::ostream&, const Value&, const ExifData*);
70 72

  
    (1-1/1)