Kaydet (Commit) 82e5a874 authored tarafından Caolán McNamara's avatar Caolán McNamara

forcepoint #4

Thanks to Antti Levomäki and Christian Jalio from Forcepoint.

Change-Id: I569ca80267ad9b5a21da0029ba903d2a4c45a035
Reviewed-on: https://gerrit.libreoffice.org/50065Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 7bde30fd
...@@ -1560,11 +1560,8 @@ inline bool isSet( const Scanline i_pLine, long i_nIndex ) ...@@ -1560,11 +1560,8 @@ inline bool isSet( const Scanline i_pLine, long i_nIndex )
return (i_pLine[ i_nIndex/8 ] & (0x80 >> (i_nIndex&7))) != 0; return (i_pLine[ i_nIndex/8 ] & (0x80 >> (i_nIndex&7))) != 0;
} }
long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_bSet ) long findBitRunImpl( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_bSet )
{ {
if( i_nStartIndex < 0 )
return i_nW;
long nIndex = i_nStartIndex; long nIndex = i_nStartIndex;
if( nIndex < i_nW ) if( nIndex < i_nW )
{ {
...@@ -1626,6 +1623,24 @@ long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_b ...@@ -1626,6 +1623,24 @@ long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_b
return std::min(nIndex, i_nW); return std::min(nIndex, i_nW);
} }
long findBitRun(const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_bSet)
{
if (i_nStartIndex < 0)
return i_nW;
return findBitRunImpl(i_pLine, i_nStartIndex, i_nW, i_bSet);
}
long findBitRun(const Scanline i_pLine, long i_nStartIndex, long i_nW)
{
if (i_nStartIndex < 0)
return i_nW;
const bool bSet = i_nStartIndex < i_nW && isSet(i_pLine, i_nStartIndex);
return findBitRunImpl(i_pLine, i_nStartIndex, i_nW, bSet);
}
struct BitStreamState struct BitStreamState
{ {
sal_uInt8 mnBuffer; sal_uInt8 mnBuffer;
...@@ -1929,7 +1944,7 @@ void PDFWriterImpl::writeG4Stream( BitmapReadAccess const * i_pBitmap ) ...@@ -1929,7 +1944,7 @@ void PDFWriterImpl::writeG4Stream( BitmapReadAccess const * i_pBitmap )
long nRefIndex1 = bRefSet ? 0 : findBitRun( pRefLine, 0, nW, bRefSet ); long nRefIndex1 = bRefSet ? 0 : findBitRun( pRefLine, 0, nW, bRefSet );
for( ; nLineIndex < nW; ) for( ; nLineIndex < nW; )
{ {
long nRefIndex2 = findBitRun( pRefLine, nRefIndex1, nW, isSet( pRefLine, nRefIndex1 ) ); long nRefIndex2 = findBitRun( pRefLine, nRefIndex1, nW );
if( nRefIndex2 >= nRunIndex1 ) if( nRefIndex2 >= nRunIndex1 )
{ {
long nDiff = nRefIndex1 - nRunIndex1; long nDiff = nRefIndex1 - nRunIndex1;
...@@ -1959,7 +1974,7 @@ void PDFWriterImpl::writeG4Stream( BitmapReadAccess const * i_pBitmap ) ...@@ -1959,7 +1974,7 @@ void PDFWriterImpl::writeG4Stream( BitmapReadAccess const * i_pBitmap )
{ // difference too large, horizontal coding { // difference too large, horizontal coding
// emit horz code 001 // emit horz code 001
putG4Bits( 3, 0x1, aBitState ); putG4Bits( 3, 0x1, aBitState );
long nRunIndex2 = findBitRun( pCurLine, nRunIndex1, nW, isSet( pCurLine, nRunIndex1 ) ); long nRunIndex2 = findBitRun( pCurLine, nRunIndex1, nW );
bool bWhiteFirst = ( nLineIndex + nRunIndex1 == 0 || ! isSet( pCurLine, nLineIndex ) ); bool bWhiteFirst = ( nLineIndex + nRunIndex1 == 0 || ! isSet( pCurLine, nLineIndex ) );
putG4Span( nRunIndex1 - nLineIndex, bWhiteFirst, aBitState ); putG4Span( nRunIndex1 - nLineIndex, bWhiteFirst, aBitState );
putG4Span( nRunIndex2 - nRunIndex1, ! bWhiteFirst, aBitState ); putG4Span( nRunIndex2 - nRunIndex1, ! bWhiteFirst, aBitState );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment