Subversion Repositories Kolibri OS

Rev

Rev 4995 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. format MS COFF
  2. public EXPORTS
  3. section '.flat' code readable align 16
  4.  
  5. include '../../../../macros.inc'
  6. include '../../../../proc32.inc'
  7.  
  8.  
  9.  
  10. ;---------
  11. offs_m_or_i    equ 8 ;ᬥ饭¨¥ ¯ à ¬¥âà  'MM' ¨«¨ 'II' (Motorola, Intel)
  12. offs_tag_count equ 16 ;ᬥ饭¨¥ ª®«¨ç¥á⢠ ⥣®¢
  13. offs_tag_0     equ 18 ;ᬥ饭¨¥ 0-£® ⥣ 
  14. tag_size       equ 12 ;à §¬¥à áâàãªâãàë ⥣ 
  15. ;ä®à¬ âë ¤ ­­ëå
  16. tag_format_ui1b  equ  1 ;unsigned integer 1 byte
  17. tag_format_text  equ  2 ;ascii string
  18. tag_format_ui2b  equ  3 ;unsigned integer 2 byte
  19. tag_format_ui4b  equ  4 ;unsigned integer 4 byte
  20. tag_format_ui8b  equ  5 ;unsigned integer 8 byte
  21. tag_format_si1b  equ  6 ;signed integer 1 byte
  22. tag_format_undef equ  7 ;undefined
  23. tag_format_si2b  equ  8 ;signed integer 2 byte
  24. tag_format_si4b  equ  9 ;signed integer 4 byte
  25. tag_format_si8b  equ 10 ;signed integer 8 byte
  26. tag_format_f4b   equ 11 ;float 4 byte
  27. tag_format_f8b   equ 12 ;float 8 byte
  28.  
  29. align 4
  30. txt_dp db ': ',0
  31.  
  32. ;
  33. align 4
  34. exif_tag_numbers:
  35.  
  36. db 0x01,0x0e,'Image description',0
  37. db 0x01,0x0f,'Manufacturer of digicam',0
  38. db 0x01,0x10,'Model',0
  39. db 0x01,0x12,'Orientation',0
  40. db 0x01,0x1a,'X resolution',0
  41. db 0x01,0x1b,'Y resolution',0
  42. db 0x01,0x28,'Resolution unit',0
  43. db 0x01,0x31,'Software',0
  44. db 0x01,0x32,'Date time',0
  45. db 0x01,0x3e,'White point',0
  46. db 0x01,0x3f,'Primary chromaticities',0
  47. db 0x02,0x11,'YCbCrCoefficients',0
  48. db 0x02,0x13,'YCbCrPositioning',0
  49. db 0x02,0x14,'Reference black white',0
  50. db 0x82,0x98,'Copyright',0
  51. db 0x87,0x69,'Exif offset',0
  52.  
  53. db 0x88,0x25,'GPS Info',0
  54.  
  55. dw 0
  56.  
  57.  
  58. ;input:
  59. ; bof - 㪠§ â¥«ì ­  ­ ç «® ä ©« 
  60. ; app1 - 㪠§ â¥«ì ¤«ï § ¯®«­¥­¨ï exif.app1
  61. ;output:
  62. ; app1 - 㪠§ â¥«ì ­  ­ ç «® exif.app1 (¨«¨ 0 ¥á«¨ ­¥ ­ ©¤¥­® ¨«¨ ä®à¬ â ä ©«  ­¥ ¯®¤¤¥à¦¨¢ ¥âáï)
  63. align 4
  64. proc exif_get_app1 uses eax ebx edi, bof:dword, app1:dword
  65.         mov eax,[bof]
  66.         mov edi,[app1]
  67.  
  68.         ;ä ©« ¢ ä®à¬ â¥ jpg?
  69.         cmp word[eax],0xd8ff
  70.         jne .no_exif
  71.         add eax,2
  72.  
  73.         ;ä ©« ᮤ¥à¦¨â exif.app0?
  74.         cmp word[eax],0xe0ff
  75.         jne @f
  76.                 add eax,2
  77.                 movzx ebx,word[eax]
  78.                 ror bx,8 ;¢á¥£¤  «¨ â ª ­ ¤®?
  79.                 add eax,ebx
  80.         @@:
  81.  
  82.         ;ä ©« ᮤ¥à¦¨â exif.app1?
  83.         cmp word[eax],0xe1ff
  84.         jne .no_exif
  85.  
  86.         add eax,2
  87.         mov [edi],eax
  88.  
  89.         jmp @f
  90.         .no_exif:
  91.                 mov dword[edi],0
  92.         @@:
  93.         ret
  94. endp
  95.  
  96. ;input:
  97. ; app1 - 㪠§ â¥«ì ­  ­ ç «® exif.app1
  98. ; num - ¯®à浪®¢ë© ­®¬¥à ⥣  (­ ç¨­ ¥âáï á 1)
  99. ; txt - 㪠§ â¥«ì ­  ⥪áâ, ªã¤  ¡ã¤¥â § ¯¨á ­® §­ ç¥­¨¥
  100. ; t_max - ¬ ªá¨¬ «ì­ë© à §¬¥à ⥪áâ 
  101. align 4
  102. proc exif_get_app1_tag, app1:dword, num:dword, txt:dword, t_max:dword
  103. pushad
  104.         mov eax,[app1]
  105.         mov edi,[txt]
  106.         mov ecx,[num]
  107.  
  108.         xor edx,edx
  109.         cmp eax,edx
  110.         je .end_f ;¥á«¨ ­¥ ­ ©¤¥­ 㪠§ â¥«ì ­  ­ ç «® exif.app1
  111.         cmp ecx,edx
  112.         jle .end_f ;¥á«¨ ¯®à浪®¢ë© ­®¬¥à ⥣  <= 0
  113.  
  114.         mov byte[edi],0
  115.         cmp word[eax+offs_m_or_i],'II'
  116.         je @f
  117.                 inc edx ;if 'MM' edx=1
  118.         @@:
  119.  
  120.         ;¯à®¢¥à塞 ç¨á«® ⥣®¢
  121.         movzx ebx,word[eax+offs_tag_count]
  122.         bt edx,0
  123.         jnc @f
  124.                 ror bx,8
  125.         @@:
  126.         cmp ecx,ebx
  127.         jg .end_f ;¥á«¨ ­®¬¥à ⥣  ¡®«ìè¥ ç¥¬ ¨å ¥áâì ¢ ä ©«¥
  128.  
  129.         ;¯¥à¥å®¤¨¬ ­  § ¤ ­­ë© ⥣
  130.         dec ecx
  131.         imul ecx,tag_size
  132.         add eax,offs_tag_0
  133.         add eax,ecx
  134.  
  135.         ;ç¨â ¥¬ ­ §­ ç¥­¨¥ ⥣ 
  136.         push exif_tag_numbers
  137.         pop esi
  138.         .next_tag:
  139.         mov bx,word[esi]
  140.         cmp bx,0
  141.         je .tag_unknown ;⥣ ­¥ ®¯®§­ ­
  142.         bt edx,0
  143.         jc @f
  144.                 ror bx,8
  145.         @@:
  146.         cmp word[eax],bx
  147.         je .found
  148.         inc esi
  149.         @@:
  150.                 inc esi
  151.                 cmp byte[esi],0
  152.                 jne @b
  153.         inc esi
  154.         jmp .next_tag
  155.         .found:
  156.  
  157.         ;ª®¯¨à㥬 áâபã
  158.         add esi,2
  159.         stdcall str_n_cat,edi,esi,[t_max]
  160.  
  161.         ;ç¨â ¥¬ ¨­ä®à¬ æ¨î ¢ ⥣¥
  162.         mov bx,tag_format_text
  163.         bt edx,0
  164.         jnc @f
  165.                 ror bx,8
  166.         @@:
  167.         cmp word[eax+2],bx
  168.         jne .tag_02
  169.                 stdcall str_n_cat,edi,txt_dp,[t_max]
  170.                 ;¯à®¢¥à塞 ¤«¨­­ã áâப¨
  171.                 mov ebx,dword[eax+4]
  172.                 bt edx,0
  173.                 jnc @f
  174.                         ror bx,8
  175.                         ror ebx,16
  176.                         ror bx,8
  177.                 @@:
  178.                 cmp ebx,4
  179.                 jg @f
  180.                         ;¥á«¨ áâப  ¯®¬¥é ¥âáï ¢ 4 ᨬ¢®« 
  181.                         mov esi,eax
  182.                         add esi,8
  183.                         stdcall str_n_cat,edi,esi,[t_max]
  184.                         jmp .end_f
  185.                 ;¥á«¨ áâப  ­¥ ¯®¬¥é ¥âáï ¢ 4 ᨬ¢®« 
  186.                 @@:
  187.                 mov esi,dword[eax+8]
  188.                 bt edx,0
  189.                 jnc @f
  190.                         ror si,8
  191.                         ror esi,16
  192.                         ror si,8
  193.                 @@:
  194.                 add esi,offs_m_or_i
  195.                 add esi,[app1]
  196.                 stdcall str_n_cat,edi,esi,[t_max]
  197.                 ;;;jmp .end_f
  198.         .tag_02:
  199.  
  200.         jmp .end_f
  201.         .tag_unknown:
  202.                 mov dword[edi],'???'
  203.                 mov byte[edi+3],0
  204.         .end_f:
  205. popad
  206.         ret
  207. endp
  208.  
  209. align 4
  210. proc exif_get_image_160_120 uses edi, app1:dword
  211.         mov edi,[app1]
  212.  
  213.         ret
  214. endp
  215.  
  216. align 4
  217. proc str_n_cat uses eax ecx edi esi, str1:dword, str2:dword, n:dword
  218.         mov esi,dword[str2]
  219.         mov ecx,dword[n]
  220.         mov edi,dword[str1]
  221.         stdcall str_len,edi
  222.         add edi,eax
  223.         cld
  224.         repne movsb
  225.         mov byte[edi],0
  226.         ret
  227. endp
  228.  
  229. ;output:
  230. ; eax = strlen
  231. align 4
  232. proc str_len, str1:dword
  233.         mov eax,[str1]
  234.         @@:
  235.                 cmp byte[eax],0
  236.                 je @f
  237.                 inc eax
  238.                 jmp @b
  239.         @@:
  240.         sub eax,[str1]
  241.         ret
  242. endp
  243.  
  244. align 16
  245. EXPORTS:
  246.         dd sz_exif_get_app1, exif_get_app1
  247.         dd sz_exif_get_app1_tag, exif_get_app1_tag
  248.         ;dd sz_exif_get_image_160_120, exif_get_image_160_120
  249.         dd 0,0
  250.         sz_exif_get_app1 db 'exif_get_app1',0
  251.         sz_exif_get_app1_tag db 'exif_get_app1_tag',0
  252.         ;sz_exif_get_image_160_120 db 'exif_get_image_160_120',0
  253.        
  254.