@@ -1520,31 +1520,31 @@ ptp_pack_EOS_ImageFormat (PTPParams* params, unsigned char* data, uint16_t value
1520
1520
htod32a (data += 4 , (value >> 0 ) & 0x7 );
1521
1521
}
1522
1522
1523
- #undef PACK_5DM3_SMALL_JPEG_SIZE
1523
+ #undef PACK_EOS_S123_JPEG_SIZE
1524
1524
1525
1525
return s ;
1526
1526
}
1527
1527
1528
- /* 00: 32 bit size
1529
- * 04: 16 bit subsize
1530
- * 08: 16 bit version (?)
1531
- * 0c: 16 bit focus_points_in_struct
1532
- * 10: 16 bit focus_points_in_use
1533
- * 14: variable arrays:
1528
+ /* 32 bit size
1529
+ * 16 bit subsize
1530
+ * 16 bit version (?)
1531
+ * 16 bit focus_points_in_struct
1532
+ * 16 bit focus_points_in_use
1533
+ * variable arrays:
1534
1534
* 16 bit sizex, 16 bit sizey
1535
1535
* 16 bit othersizex, 16 bit othersizey
1536
1536
* 16 bit array height[focus_points_in_struct]
1537
1537
* 16 bit array width[focus_points_in_struct]
1538
1538
* 16 bit array offsetheight[focus_points_in_struct] middle is 0
1539
1539
* 16 bit array offsetwidth[focus_points_in_struct] middle is ?
1540
1540
* bitfield of selected focus points, starting with 0 [size focus_points_in_struct in bits]
1541
- * unknown stuff , likely which are active
1541
+ * unknown stuff, likely which are active
1542
1542
* 16 bit 0xffff
1543
1543
*
1544
1544
* size=NxN,size2=NxN,points={NxNxNxN,NxNxNxN,...},selected={0,1,2}
1545
1545
*/
1546
1546
static inline char *
1547
- ptp_unpack_EOS_FocusInfoEx (PTPParams * params , const unsigned char * * data , uint32_t datasize )
1547
+ ptp_unpack_EOS_FocusInfoEx (PTPParams * params , const unsigned char * * data , uint32_t datasize )
1548
1548
{
1549
1549
uint32_t size = dtoh32a ( * data );
1550
1550
uint32_t halfsize = dtoh16a ( (* data ) + 4 );
@@ -1569,11 +1569,6 @@ ptp_unpack_EOS_FocusInfoEx (PTPParams* params, const unsigned char** data, uint3
1569
1569
ptp_debug (params , "skipped FocusInfoEx data (zero filled)" );
1570
1570
return strdup ("no focus points returned by camera" );
1571
1571
}
1572
-
1573
- /* every focuspoint gets 4 (16 bit number possible "-" sign and a x) and a ,*/
1574
- /* initial things around lets say 100 chars at most.
1575
- * FIXME: check selected when we decode it
1576
- */
1577
1572
if (size < focus_points_in_struct * 8 ) {
1578
1573
ptp_error (params , "focus_points_in_struct %d is too large vs size %d" , focus_points_in_struct , size );
1579
1574
return strdup ("bad size 2" );
@@ -1582,54 +1577,48 @@ ptp_unpack_EOS_FocusInfoEx (PTPParams* params, const unsigned char** data, uint3
1582
1577
ptp_error (params , "focus_points_in_use %d is larger than focus_points_in_struct %d" , focus_points_in_use , focus_points_in_struct );
1583
1578
return strdup ("bad size 3" );
1584
1579
}
1585
-
1586
- maxlen = focus_points_in_use * 32 + 100 + (size - focus_points_in_struct * 8 )* 2 ;
1587
1580
if (halfsize != size - 4 ) {
1588
- ptp_error (params , "halfsize %d is not expected %d" , halfsize , size - 4 );
1589
- return strdup ("bad size 4" );
1581
+ ptp_debug (params , "halfsize %d is not expected %d" , halfsize , size - 4 );
1590
1582
}
1583
+
1591
1584
if (20 + focus_points_in_struct * 8 + (focus_points_in_struct + 7 )/8 > size ) {
1592
1585
ptp_error (params , "size %d is too large for fp in struct %d" , focus_points_in_struct * 8 + 20 + (focus_points_in_struct + 7 )/8 , size );
1593
1586
return strdup ("bad size 5" );
1594
1587
}
1588
+
1589
+ ptp_debug (params ," prop d1d3 version is %d with %d focus points in struct and %d in use, size=%ux%u, size2=%ux%u" ,
1590
+ version , focus_points_in_struct , focus_points_in_use , sizeX , sizeY , size2X , size2Y );
1595
1591
#if 0
1596
- ptp_debug (params ,"d1d3 content:" );
1597
- for (i = 0 ;i < size ;i += 2 )
1598
- ptp_debug (params ,"%d: %02x %02x" , i , (* data )[i ], (* data )[i + 1 ]);
1592
+ ptp_debug_data (params , * data , datasize );
1599
1593
#endif
1600
- ptp_debug (params ," version of d1d3 is %d with %d focus points in struct and %d in use" ,
1601
- version , focus_points_in_struct , focus_points_in_use );
1602
1594
1595
+ /* every selected focus_point gets an entry like "{N,N,N,N}," where N can be 5 chars long */
1596
+ maxlen = 1 + focus_points_in_use * 26 + 2 ;
1603
1597
str = (char * )malloc ( maxlen );
1604
1598
if (!str )
1605
1599
return NULL ;
1606
1600
p = str ;
1607
1601
1608
- p += sprintf (p ,"eosversion=%u,size=%ux%u,size2=%ux%u,points={" , version , sizeX , sizeY , size2X , size2Y );
1602
+ /* output only the selected AF-points, so no AF means you get an empty list: "{}" */
1603
+ p += sprintf (p ,"{" );
1609
1604
for (i = 0 ;i < focus_points_in_use ;i ++ ) {
1605
+ if (((1 <<(i %8 )) & (* data )[focus_points_in_struct * 8 + 20 + i /8 ]) == 0 )
1606
+ continue ;
1610
1607
int16_t x = dtoh16a ((* data ) + focus_points_in_struct * 4 + 20 + 2 * i );
1611
1608
int16_t y = dtoh16a ((* data ) + focus_points_in_struct * 6 + 20 + 2 * i );
1612
1609
int16_t w = dtoh16a ((* data ) + focus_points_in_struct * 2 + 20 + 2 * i );
1613
1610
int16_t h = dtoh16a ((* data ) + focus_points_in_struct * 0 + 20 + 2 * i );
1614
1611
1615
- p += sprintf (p ,"{%d,%d,%d,%d}" ,x ,y ,w ,h );
1616
-
1617
- if (i < focus_points_in_use - 1 )
1618
- p += sprintf (p ,"," );
1619
- }
1620
- p += sprintf (p ,"},select={" );
1621
- for (i = 0 ;i < focus_points_in_use ;i ++ ) {
1622
- if ((1 <<(i %8 )) & ((* data )[focus_points_in_struct * 8 + 20 + i /8 ]))
1623
- p += sprintf (p ,"%u," , i );
1624
- }
1625
-
1626
- p += sprintf (p ,"},unknown={" );
1627
- for (i = focus_points_in_struct * 8 + (focus_points_in_struct + 7 )/8 + 20 ;i < size ;i ++ ) {
1628
- if ((p - str ) > maxlen - 4 )
1612
+ int n = snprintf (p , maxlen - (p - str ), "{%d,%d,%d,%d}," , x , y , w , h );
1613
+ if (n < 0 || n > maxlen - (p - str )) {
1614
+ ptp_error (params , "snprintf buffer overflow in %s" , __func__ );
1629
1615
break ;
1630
- p += sprintf (p ,"%02x" , (* data )[i ]);
1616
+ }
1617
+ p += n ;
1631
1618
}
1632
- p += sprintf (p ,"}" );
1619
+ if (p [-1 ] == ',' )
1620
+ p -- ;
1621
+ p += sprintf (p , "}" );
1633
1622
return str ;
1634
1623
}
1635
1624
@@ -2408,6 +2397,16 @@ static unsigned int olcsizes[0x15][13] = {
2408
2397
case 0x0100 : /* Focus Info */
2409
2398
/* mask 0x0100: 6 bytes, 00 00 00 00 00 00 (before focus) and
2410
2399
* 00 00 00 00 01 00 (on focus) observed */
2400
+ /* a full trigger capture cycle on the 5Ds with enabled and acting auto-focus looks like this
2401
+ 0.098949 6 bytes: 00 00 00 00 00 00 (first GetEvent)
2402
+ 0.705762 6 bytes: 00 00 00 00 00 01 (first GetEvent after half-press-on, together with FocusInfoEx == {})
2403
+ 0.758275 6 bytes: 00 00 00 00 01 01 (second GetEvent after half-press-on, together with FocusInfoEx == {...})
2404
+ 0.962160 6 bytes: 00 00 00 00 01 00 (couple GetEvents later, together with 3x FocusInfoEx == {} and next line)
2405
+ 0.962300 6 bytes: 00 00 00 00 00 00
2406
+ On AF-failure, the 5Ds sequence is 0-1, 2-2, 2-0, 0-0.
2407
+ The R8 looks similar except another 00 byte is appended and on sucess it jumps directly from 1-1 to 0-0.
2408
+ On an AF-failure, it jumps from 0-1 to 0-0. The R5m2 has seen to fail with 0-1, 2-1, 2-0, 0-0.
2409
+ */
2411
2410
e [i ].type = PTP_EOSEvent_FocusInfo ;
2412
2411
PTP_CANON_SET_INFO (e [i ], "%s" , ptp_bytes2str (curdata + curoff , olcsizes [olcver ][j ], "%02x" ));
2413
2412
break ;
0 commit comments