forked from ImpulseAdventure/JPEGsnoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JPEGsnoopCore.h
166 lines (137 loc) · 6.51 KB
/
JPEGsnoopCore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// JPEGsnoop - JPEG Image Decoder & Analysis Utility
// Copyright (C) 2017 - Calvin Hass
// http://www.impulseadventure.com/photo/jpeg-snoop.html
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ==========================================================================
// CLASS DESCRIPTION:
// - This module performs all of the main decoding and processing functions
// - It contains the major context (m_pWBuf, m_pImgDec, m_pJfifDec)
//
// ==========================================================================
#pragma once
#include "JfifDecode.h"
#include "ImgDecode.h"
#include "WindowBuf.h"
#include "SnoopConfig.h"
class CJPEGsnoopCore
{
public:
CJPEGsnoopCore(void);
~CJPEGsnoopCore(void);
void Reset();
void SetStatusBar(CStatusBar* pStatBar);
BOOL AnalyzeFile(CString strFname);
void AnalyzeFileDo();
BOOL AnalyzeOpen();
void AnalyzeClose();
BOOL IsAnalyzed();
BOOL DoAnalyzeOffset(CString strFname);
void DoLogSave(CString strLogName);
void GenBatchFileList(CString strDirSrc,CString strDirDst,bool bRecSubdir,bool bExtractAll);
unsigned GetBatchFileCount();
void DoBatchFileProcess(unsigned nFileInd,bool bWriteLog,bool bExtractAll);
CString GetBatchFileInfo(unsigned nFileInd);
void BuildDirPath(CString strPath);
void DoExtractEmbeddedJPEG(CString strInputFname,CString strOutputFname,
bool bOverlayEn,bool bForceSoi,bool bForceEoi,bool bIgnoreEoi,bool bExtractAllEn,bool bDhtAviInsert,
CString strOutPath);
// Accessor wrappers for CjfifDecode
void J_GetAviMode(bool &bIsAvi,bool &bIsMjpeg);
void J_SetAviMode(bool bIsAvi,bool bIsMjpeg);
void J_ImgSrcChanged();
unsigned long J_GetPosEmbedStart();
unsigned long J_GetPosEmbedEnd();
void J_GetDecodeSummary(CString &strHash,CString &strHashRot,CString &strImgExifMake,CString &strImgExifModel,
CString &strImgQualExif,CString &strSoftware,teDbAdd &eDbReqSuggest);
unsigned J_GetDqtZigZagIndex(unsigned nInd,bool bZigZag);
unsigned J_GetDqtQuantStd(unsigned nInd);
void J_SetStatusBar(CStatusBar* pStatBar);
void J_ProcessFile(CFile* inFile);
void J_PrepareSendSubmit(CString strQual,teSource eUserSource,CString strUserSoftware,CString strUserNotes);
// Accessor wrappers for CImgDec
void I_SetStatusBar(CStatusBar* pStatBar);
unsigned I_GetDqtEntry(unsigned nTblDestId, unsigned nCoeffInd);
void I_SetPreviewMode(unsigned nMode);
unsigned I_GetPreviewMode();
void I_SetPreviewYccOffset(unsigned nMcuX,unsigned nMcuY,int nY,int nCb,int nCr);
void I_GetPreviewYccOffset(unsigned &nMcuX,unsigned &nMcuY,int &nY,int &nCb,int &nCr);
void I_SetPreviewMcuInsert(unsigned nMcuX,unsigned nMcuY,int nLen);
void I_GetPreviewMcuInsert(unsigned &nMcuX,unsigned &nMcuY,unsigned &nLen);
void I_SetPreviewZoom(bool bInc,bool bDec,bool bSet,unsigned nVal);
unsigned I_GetPreviewZoomMode();
float I_GetPreviewZoom();
bool I_GetPreviewOverlayMcuGrid();
void I_SetPreviewOverlayMcuGridToggle();
CPoint I_PixelToMcu(CPoint ptPix);
CPoint I_PixelToBlk(CPoint ptPix);
unsigned I_McuXyToLinear(CPoint ptMcu);
void I_GetImageSize(unsigned &nX,unsigned &nY);
void I_GetPixMapPtrs(short* &pMapY,short* &pMapCb,short* &pMapCr);
void I_GetDetailVlc(bool &bDetail,unsigned &nX,unsigned &nY,unsigned &nLen);
void I_SetDetailVlc(bool bDetail,unsigned nX,unsigned nY,unsigned nLen);
unsigned I_GetMarkerCount();
void I_SetMarkerBlk(unsigned nBlkX,unsigned nBlkY);
CPoint I_GetMarkerBlk(unsigned nInd);
void I_SetStatusText(CString strText);
CString I_GetStatusYccText();
void I_SetStatusYccText(CString strText);
CString I_GetStatusMcuText();
void I_SetStatusMcuText(CString strText);
CString I_GetStatusFilePosText();
void I_SetStatusFilePosText(CString strText);
void I_GetBitmapPtr(unsigned char* &pBitmap);
void I_LookupFilePosMcu(unsigned nMcuX,unsigned nMcuY, unsigned &nByte, unsigned &nBit);
void I_LookupFilePosPix(unsigned nPixX,unsigned nPixY, unsigned &nByte, unsigned &nBit);
void I_LookupBlkYCC(unsigned nBlkX,unsigned nBlkY,int &nY,int &nCb,int &nCr);
void I_ViewOnDraw(CDC* pDC,CRect rectClient,CPoint ptScrolledPos,CFont* pFont, CSize &szNewScrollSize);
void I_GetPreviewPos(unsigned &nX,unsigned &nY);
void I_GetPreviewSize(unsigned &nX,unsigned &nY);
bool I_IsPreviewReady();
// Accessor wrappers for CwindowBuf
void B_SetStatusBar(CStatusBar* pStatBar);
void B_BufLoadWindow(unsigned long nPosition);
void B_BufFileSet(CFile* inFile);
void B_BufFileUnset();
BYTE B_Buf(unsigned long nOffset,bool bClean=false);
bool B_BufSearch(unsigned long nStartPos, unsigned nSearchVal, unsigned nSearchLen,
bool bDirFwd, unsigned long &nFoundPos);
bool B_OverlayInstall(unsigned nOvrInd, BYTE* pOverlay,unsigned nLen,unsigned nBegin,
unsigned nMcuX,unsigned nMcuY,unsigned nMcuLen,unsigned nMcuLenIns,
int nAdjY,int nAdjCb,int nAdjCr);
void B_OverlayRemoveAll();
bool B_OverlayGet(unsigned nOvrInd, BYTE* &pOverlay,unsigned &nLen,unsigned &nBegin);
private:
// Batch processing
void GenBatchFileListRecurse(CString strSrcRootName,CString strDstRootName,CString strPathName,bool bSubdirs,bool bExtractAll);
void GenBatchFileListSingle(CString strSrcRootName,CString strDstRootName,CString strPathName,bool bExtractAll);
private:
// Config
CSnoopConfig* m_pAppConfig; // Pointer to application config
// Input JPEG file
CFile* m_pFile;
ULONGLONG m_lFileSize;
CString m_strPathName;
BOOL m_bFileAnalyzed; // Have we opened and analyzed a file?
BOOL m_bFileOpened; // Is a file currently opened?
// Decoders and Buffers
CjfifDecode* m_pJfifDec;
CimgDecode* m_pImgDec;
CwindowBuf* m_pWBuf;
// Batch processing
CStringArray m_asBatchFiles;
CStringArray m_asBatchDest;
CStringArray m_asBatchOutputs;
};