⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exifhdr.c

📁 台湾凌阳方案300万数码相机源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*++

Copyright (c) 2001 Sunplus Technology Co., Ltd.

Module Name:

        exifhdr.c

Abstract:

        Module related to chip initialization

Environment:

        Keil C51 Compiler

Revision History:

        02/22/2001      Leeada    created

--*/

//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "impt533.h"
#include "main.h"
#include "sdramhw.h"
#include "image.h"
#include "libfunc.h"
#include "initio.h"
#include "exifhdr.h"
#include "exiffunc.h"
#include "exifvar.h"
#include "exifcon.h"
#include "doslink.h"
#include "uiflow.h"

//=============================================================================
//Symbol
//=============================================================================


//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
xdata     USHORT G_ucThumbnailWidth;
xdata     USHORT G_ucThumbnailHeight;
xdata     UCHAR Text_NowDateTime[20];

//patch3.2@ada@0401 For EXIF
xdata     USHORT ByteOrder;
xdata     ULONG ByteOrderOffset;
xdata     ULONG IFD_ThumbnaiFrameOffset;
xdata     ULONG IFD_ThumbnaiFrameLength;
xdata     USHORT Tiff_ID;
xdata     ULONG Tiff_IFDOffset;
xdata     ULONG NextIFDOffset;
xdata     USHORT IFD_Number;
xdata     ULONG IFD_DateTime_Offset;
xdata     UCHAR Jpeg_Exif_Format;
xdata     ULONG ExifTmpDramAddr;
xdata     UCHAR Extract_Finished;
xdata     UCHAR Extract_Thumbnail;
xdata     ULONG HeaderLength;
xdata     UCHAR Parsing_Marker;
xdata     USHORT APP0Length;
xdata     USHORT APP1Length;
xdata     USHORT APPnLength;
xdata     USHORT ThumbAPPnLength;
xdata     USHORT TotalThumbAPPnLength;
xdata     USHORT TotalAPPnLength;
xdata     USHORT COMLength;
xdata     USHORT DQTLength;
xdata     USHORT DHTLength;
xdata     USHORT SOFLength;
xdata     USHORT SOSLength;
xdata     USHORT DRILength;
xdata     USHORT DRI_MCU_Num;
xdata     UCHAR NeedReadMoreHeader;

//Joe@2003.3.24 20:09 add begin
extern unsigned long Shutter;
extern int Tidx;
extern bit STROBE;  //andrew
//Joe@2003.3.24 20:09 add end
//=============================================================================
//Program
//=============================================================================

//-----------------------------------------------------------------------------
//EXIFHDR_Initialize_AllExifHeader
//-----------------------------------------------------------------------------
void EXIFHDR_Initialize_AllExifHeader(void) USING_0
{
	 //patch5.0@richie@sdram mapping begin
     ULONG InitialDramHeaderAddr = K_SDRAM_ThumbBufAddr + K_SDRAM_ThumbBufSize;//K_SDRAM_EXIF_BufAddr;
	 //patch5.0@richie@sdram mapping end
     DbgPrint("EXIFHDR_Initialize_AllExifHeader\n");

     EXIFHDR_Initialize_ExifHeader0(&InitialDramHeaderAddr);
     EXIFHDR_Initialize_ExifHeader1(&InitialDramHeaderAddr);
     EXIFHDR_Initialize_ExifHeader2(&InitialDramHeaderAddr);
     EXIFHDR_Initialize_ExifHeader3(&InitialDramHeaderAddr);
}
//-----------------------------------------------------------------------------
//EXIFHDR_Initialize_ExifHeader0
//-----------------------------------------------------------------------------
void EXIFHDR_Initialize_ExifHeader0(PULONG pDramHdrAddr) USING_0
{
     struct Exif_Header0 Header0;

//----- Header 0 -----

//EXIF SOI
     Header0.SOI.Marker[0] = 0xff;
     Header0.SOI.Marker[1] = 0xd8;

//EXIF APP1
     Header0.APP1.Marker[0] = 0xff;
     Header0.APP1.Marker[1] = 0xe1;

     Header0.APP1.Length = 0x0000;

     EXIFHDR_Fill_Text(Text_Exif,Header0.APP1.ExifString,5);

     Header0.APP1.Pad = 0x00;

	//patch4.5@ada@improve power to shot performance begin
     Header0.APP1.Tiff_ByteOrder = 0x4949;    //little endian
     //Header0.APP1.Tiff_ByteOrder = EXIFHDR_ByteSwapOfUSHORT(0x4949);    //little endian

     Header0.APP1.Tiff_ID = 0x2a00;
     //Header0.APP1.Tiff_ID = EXIFHDR_ByteSwapOfUSHORT(0x002a);

     Header0.APP1.Tiff_IFD0Offset = 0x08000000;
     //Header0.APP1.Tiff_IFD0Offset = EXIFHDR_ByteSwapOfULONG(0x00000008);

     Header0.APP1.IFD0_NumberOfInteroperability = 0x0a00;
     //Header0.APP1.IFD0_NumberOfInteroperability = M_ByteSwapOfWord(0x000a);

     Header0.APP1.IFD0_ImageDescriptionTag.tag = 0x0e01;
     //Header0.APP1.IFD0_ImageDescriptionTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x010e);

     Header0.APP1.IFD0_ImageDescriptionTag.type = 0x0200;    //ASCII
     //Header0.APP1.IFD0_ImageDescriptionTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0002);    //ASCII

     Header0.APP1.IFD0_ImageDescriptionTag.count = M_ByteSwapOfDword(Length_Text_ImageDescription);
     //Header0.APP1.IFD0_ImageDescriptionTag.count = EXIFHDR_ByteSwapOfULONG(Length_Text_ImageDescription);

     Header0.APP1.IFD0_ImageDescriptionTag.valueoffset = //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) Header0.APP1.IFD0_ImageDescriptionValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_ImageDescriptionTag.valueoffset = //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) Header0.APP1.IFD0_ImageDescriptionValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));

     Header0.APP1.IFD0_MakeTag.tag = 0x0f01;
     //Header0.APP1.IFD0_MakeTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x010f);

     Header0.APP1.IFD0_MakeTag.type = 0x0200; //ASCII
     //Header0.APP1.IFD0_MakeTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0002); //ASCII

     Header0.APP1.IFD0_MakeTag.count = M_ByteSwapOfDword(Length_Text_Make);
     //Header0.APP1.IFD0_MakeTag.count = EXIFHDR_ByteSwapOfULONG(Length_Text_Make);

     Header0.APP1.IFD0_MakeTag.valueoffset = //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) Header0.APP1.IFD0_MakeValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_MakeTag.valueoffset = //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) Header0.APP1.IFD0_MakeValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));

     Header0.APP1.IFD0_ModelTag.tag = 0x1001;
     //Header0.APP1.IFD0_ModelTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x0110);

     Header0.APP1.IFD0_ModelTag.type = 0x0200;     //ASCII
     //Header0.APP1.IFD0_ModelTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0002);     //ASCII

     Header0.APP1.IFD0_ModelTag.count = M_ByteSwapOfDword(Length_Text_Model);
     //Header0.APP1.IFD0_ModelTag.count = EXIFHDR_ByteSwapOfULONG(Length_Text_Model);

     Header0.APP1.IFD0_ModelTag.valueoffset = //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) Header0.APP1.IFD0_ModelValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_ModelTag.valueoffset = //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) Header0.APP1.IFD0_ModelValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));

     Header0.APP1.IFD0_OrientationTag.tag = 0x1201;
     //Header0.APP1.IFD0_OrientationTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x0112);

     Header0.APP1.IFD0_OrientationTag.type = 0x0300;    //short
     //Header0.APP1.IFD0_OrientationTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0003);    //short

     Header0.APP1.IFD0_OrientationTag.count = 0x01000000;
     //Header0.APP1.IFD0_OrientationTag.count = EXIFHDR_ByteSwapOfULONG(0x00000001);

     Header0.APP1.IFD0_OrientationTag.valueoffset = 0x01000000;   //value
     //Header0.APP1.IFD0_OrientationTag.valueoffset = EXIFHDR_ByteSwapOfULONG(0x00000001);   //value

     Header0.APP1.IFD0_XResolutionTag.tag = 0x1a01;
     //Header0.APP1.IFD0_XResolutionTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x011a);

     Header0.APP1.IFD0_XResolutionTag.type = 0x0500;    //rational
     //Header0.APP1.IFD0_XResolutionTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0005);    //rational

     Header0.APP1.IFD0_XResolutionTag.count = 0x01000000;
     //Header0.APP1.IFD0_XResolutionTag.count = EXIFHDR_ByteSwapOfULONG(0x00000001);

     Header0.APP1.IFD0_XResolutionTag.valueoffset = //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) Header0.APP1.IFD0_XResolutionValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_XResolutionTag.valueoffset = //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) Header0.APP1.IFD0_XResolutionValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));

     Header0.APP1.IFD0_YResolutionTag.tag = 0x1b01;
     //Header0.APP1.IFD0_YResolutionTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x011b);

     Header0.APP1.IFD0_YResolutionTag.type = 0x0500;    //rational
     //Header0.APP1.IFD0_YResolutionTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0005);    //rational

     Header0.APP1.IFD0_YResolutionTag.count = 0x01000000;
     //Header0.APP1.IFD0_YResolutionTag.count = EXIFHDR_ByteSwapOfULONG(0x00000001);

     Header0.APP1.IFD0_YResolutionTag.valueoffset = //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) Header0.APP1.IFD0_YResolutionValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_YResolutionTag.valueoffset = //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) Header0.APP1.IFD0_YResolutionValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));


     Header0.APP1.IFD0_ResolutionUnitTag.tag = 0x2801;
     //Header0.APP1.IFD0_ResolutionUnitTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x0128);

     Header0.APP1.IFD0_ResolutionUnitTag.type = 0x0300; //short
     //Header0.APP1.IFD0_ResolutionUnitTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0003); //short

     Header0.APP1.IFD0_ResolutionUnitTag.count = 0x01000000;
     //Header0.APP1.IFD0_ResolutionUnitTag.count = EXIFHDR_ByteSwapOfULONG(0x00000001);

     Header0.APP1.IFD0_ResolutionUnitTag.valueoffset = 0x02000000;    //value
     //Header0.APP1.IFD0_ResolutionUnitTag.valueoffset = EXIFHDR_ByteSwapOfULONG(0x00000002);    //value

     Header0.APP1.IFD0_DateTimeTag.tag = 0x3201;
     //Header0.APP1.IFD0_DateTimeTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x0132);

     Header0.APP1.IFD0_DateTimeTag.type = 0x0200;  //ASCII
     //Header0.APP1.IFD0_DateTimeTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0002);  //ASCII

     Header0.APP1.IFD0_DateTimeTag.count = 0x14000000;
     //Header0.APP1.IFD0_DateTimeTag.count = EXIFHDR_ByteSwapOfULONG(0x00000014);

     Header0.APP1.IFD0_DateTimeTag.valueoffset =   //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) Header0.APP1.IFD0_DateTimeValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_DateTimeTag.valueoffset =   //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) Header0.APP1.IFD0_DateTimeValue - (USHORT) &Header0.APP1.Tiff_ByteOrder));

     Header0.APP1.IFD0_YCbCrPositionTag.tag = 0x1302;
     //Header0.APP1.IFD0_YCbCrPositionTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x0213);

     Header0.APP1.IFD0_YCbCrPositionTag.type = 0x0300;  //short
     //Header0.APP1.IFD0_YCbCrPositionTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0003);  //short

     Header0.APP1.IFD0_YCbCrPositionTag.count = 0x01000000;
     //Header0.APP1.IFD0_YCbCrPositionTag.count = EXIFHDR_ByteSwapOfULONG(0x00000001);

     Header0.APP1.IFD0_YCbCrPositionTag.valueoffset = 0x02000000;    //value
     //Header0.APP1.IFD0_YCbCrPositionTag.valueoffset = EXIFHDR_ByteSwapOfULONG(0x00000002);    //value

     Header0.APP1.IFD0_ExifIFDPointerTag.tag = 0x6987;
     //Header0.APP1.IFD0_ExifIFDPointerTag.tag = EXIFHDR_ByteSwapOfUSHORT(0x8769);

     Header0.APP1.IFD0_ExifIFDPointerTag.type = 0x0400; //long
     //Header0.APP1.IFD0_ExifIFDPointerTag.type = EXIFHDR_ByteSwapOfUSHORT(0x0004); //long

     Header0.APP1.IFD0_ExifIFDPointerTag.count = 0x01000000;
     //Header0.APP1.IFD0_ExifIFDPointerTag.count = EXIFHDR_ByteSwapOfULONG(0x00000001);

     Header0.APP1.IFD0_ExifIFDPointerTag.valueoffset =    //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) &Header0.APP1.Exif_IFDNumber - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_ExifIFDPointerTag.valueoffset =    //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) &Header0.APP1.Exif_IFDNumber - (USHORT) &Header0.APP1.Tiff_ByteOrder));

     Header0.APP1.IFD0_NextIFDOffset =  //offset
          M_ByteSwapOfDword((ULONG) ((USHORT) &Header0.APP1.IFD1_NumberOfInteroperability - (USHORT) &Header0.APP1.Tiff_ByteOrder));
     //Header0.APP1.IFD0_NextIFDOffset =  //offset
     //     EXIFHDR_ByteSwapOfULONG((ULONG) ((USHORT) &Header0.APP1.IFD1_NumberOfInteroperability - (USHORT) &Header0.APP1.Tiff_ByteOrder));
	//patch4.5@ada@improve power to shot performance end

     EXIFHDR_Fill_Text(Text_ImageDescription,Header0.APP1.IFD0_ImageDescriptionValue,Length_Text_ImageDescription);

     EXIFHDR_Fill_Text(Text_Make,Header0.APP1.IFD0_MakeValue,Length_Text_Make);

     EXIFHDR_Fill_Text(Text_Model,Header0.APP1.IFD0_ModelValue,Length_Text_Model);

	//patch4.5@ada@improve power to shot performance begin
     Header0.APP1.IFD0_XResolutionValue[0] = 0x48000000;     //72 dpi
     //Header0.APP1.IFD0_XResolutionValue[0] = EXIFHDR_ByteSwapOfULONG(0x00000048);     //72 dpi

     Header0.APP1.IFD0_XResolutionValue[1] = 0x01000000;
     //Header0.APP1.IFD0_XResolutionValue[1] = EXIFHDR_ByteSwapOfULONG(0x00000001);

     Header0.APP1.IFD0_YResolutionValue[0] = 0x48000000;     //72 dpi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -