@@ -691,17 +691,15 @@ namespace Exiv2 {
691691
692692 std::ostream& PanasonicMakerNote::printAccelerometer (std::ostream& os, const Value& value, const ExifData*)
693693 {
694- // value is stored as unsigned int, but should be readed as signed int, so manually convert it
695- int i = value.toLong ();
696- i = i - ((i & 0x8000 ) >> 15 ) * 0xffff ;
694+ // value is stored as unsigned int, but should be read as int16_t.
695+ const int16_t i = static_cast <int16_t >(value.toLong ());
697696 return os << i;
698697 } // PanasonicMakerNote::printAccelerometer
699698
700699 std::ostream& PanasonicMakerNote::printRollAngle (std::ostream& os, const Value& value, const ExifData*)
701700 {
702- // roll angle is stored as signed int, but tag states to be unsigned int
703- int i = value.toLong ();
704- i = i - ((i & 0x8000 ) >> 15 ) * 0xffff ;
701+ // value is stored as unsigned int, but should be read as int16_t.
702+ const int16_t i = static_cast <int16_t >(value.toLong ());
705703 std::ostringstream oss;
706704 oss.copyfmt (os);
707705 os << std::fixed << std::setprecision (1 ) << i / 10.0 ;
@@ -712,10 +710,8 @@ namespace Exiv2 {
712710
713711 std::ostream& PanasonicMakerNote::printPitchAngle (std::ostream& os, const Value& value, const ExifData*)
714712 {
715- // pitch angle is stored as signed int, but tag states to be unsigned int
716- // change sign to be compatible with ExifTool: positive is upwards
717- int i = value.toLong ();
718- i = i - ((i & 0x8000 ) >> 15 ) * 0xffff ;
713+ // value is stored as unsigned int, but should be read as int16_t.
714+ const int16_t i = static_cast <int16_t >(value.toLong ());
719715 std::ostringstream oss;
720716 oss.copyfmt (os);
721717 os << std::fixed << std::setprecision (1 ) << -i / 10.0 ;
0 commit comments