MCPcopy Create free account
hub / github.com/ImpulseAdventure/JPEGsnoop / DecodeScanCompPrint

Method DecodeScanCompPrint

ImgDecode.cpp:1859–2094  ·  view source on GitHub ↗

Decode a single component for one block of an MCU with printing used for the Detailed Decode functionality - Same as DecodeScanComp() but adds reporting of variable length codes (VLC) INPUT: - nTblDhtDc = DHT table ID for DC component - nTblDhtAc = DHT talbe ID for AC component - nMcuX = Current MCU X coordinate (for reporting only) - nMcuY = Current MCU Y coordinate (for report

Source from the content-addressed store, hash-verified

1857// FIXME: Consider adding checks for DHT table like in ReadScanVal()
1858//
1859bool CimgDecode::DecodeScanCompPrint(unsigned nTblDhtDc,unsigned nTblDhtAc,unsigned nTblDqt,unsigned nMcuX,unsigned nMcuY)
1860{
1861 bool bPrint = true;
1862 teRsvRet eRsvRet;
1863 CString strTmp;
1864 CString strTbl;
1865 CString strSpecial;
1866 CString strPos;
1867 unsigned nZrl;
1868 signed nVal;
1869 bool bDone = false;
1870
1871 bool bDC = true; // Start with DC component
1872
1873 if (bPrint) {
1874 switch(nTblDqt) {
1875 case 0:
1876 strTbl = _T("Lum");
1877 break;
1878 case 1:
1879 strTbl = _T("Chr(0)"); // Usually Cb
1880 break;
1881 case 2:
1882 strTbl = _T("Chr(1)"); // Usually Cr
1883 break;
1884 default:
1885 strTbl = _T("???");
1886 break;
1887 }
1888 strTmp.Format(_T(" %s (Tbl #%u), MCU=[%u,%u]"),(LPCTSTR)strTbl,nTblDqt,nMcuX,nMcuY);
1889 m_pLog->AddLine(strTmp);
1890 }
1891
1892 unsigned nNumCoeffs = 0;
1893 unsigned nSavedBufPos = 0;
1894 unsigned nSavedBufErr = SCANBUF_OK;
1895 unsigned nSavedBufAlign = 0;
1896
1897 DecodeIdctClear();
1898
1899 while (!bDone) {
1900 BuffTopup();
1901
1902 // Note that once we perform ReadScanVal(), then GetScanBufPos() will be
1903 // after the decoded VLC
1904
1905 // Save old file position info in case we want accurate error positioning
1906 nSavedBufPos = m_anScanBuffPtr_pos[0];
1907 nSavedBufErr = m_nScanBuffLatchErr;
1908 nSavedBufAlign = m_nScanBuffPtr_align;
1909
1910 // Return values:
1911 // 0 - OK
1912 // 1 - EOB
1913 // 2 - Overread error
1914 // 3 - No huffman code found, but restart marker seen
1915 eRsvRet = ReadScanVal(bDC?0:1,bDC?nTblDhtDc:nTblDhtAc,nZrl,nVal);
1916

Callers

nothing calls this directly

Calls 2

AddLineMethod · 0.80
AddLineErrMethod · 0.80

Tested by

no test coverage detected