Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkclean: fix regression checks #175

Merged
merged 9 commits into from
Dec 28, 2024
2 changes: 1 addition & 1 deletion corec/corec/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
#define LOAD32LE(ptr) ((LOAD8(ptr,3)<<24)|(LOAD8(ptr,2)<<16)|(LOAD8(ptr,1)<<8)|LOAD8(ptr,0))
#define LOAD32BE(ptr) ((LOAD8(ptr,0)<<24)|(LOAD8(ptr,1)<<16)|(LOAD8(ptr,2)<<8)|LOAD8(ptr,3))
#define LOAD64BE(ptr) ((((uint64_t)LOAD8(ptr,0))<<56)|(((uint64_t)LOAD8(ptr,1))<<48)|(((uint64_t)LOAD8(ptr,2))<<40)|(((uint64_t)LOAD8(ptr,3))<<32)| \
(((uint64_t)LOAD8(ptr,4))<<24)|(((uint64_t)LOAD8(ptr,5))<<16)|(((uint64_t)LOAD8(ptr,6))<< 8)|(((uint64_t)LOAD8(ptr,0)) ))
(((uint64_t)LOAD8(ptr,4))<<24)|(((uint64_t)LOAD8(ptr,5))<<16)|(((uint64_t)LOAD8(ptr,6))<< 8)|(((uint64_t)LOAD8(ptr,7)) ))


#define STORE8(p, o, i) ((uint8_t *) (p))[o] = (uint8_t) ((i) & 0xFF)
Expand Down
2 changes: 1 addition & 1 deletion libmatroska2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (CONFIG_ZLIB)
)

FetchContent_MakeAvailable(zlib)
target_compile_definitions("zlib" PRIVATE NO_GZIP)
target_compile_definitions("zlibstatic" PRIVATE NO_GZIP)
endif()
endif()

Expand Down
34 changes: 17 additions & 17 deletions libmatroska2/matroskamain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,17 +1224,18 @@ err_t MATROSKA_BlockReadData(matroska_block *Element, stream *Input, int ForProf
ArrayClear(&TmpBuf);
goto failed;
}
size_t Offset = 0;
for (NumFrame=0;Err==ERR_NONE && NumFrame<ARRAYCOUNT(Element->SizeList,int32_t);++NumFrame)
{
#if defined(CONFIG_ZLIB)
if (EBML_IntegerValue((ebml_integer*)Header)==MATROSKA_TRACK_ENCODING_COMP_ZLIB)
{
size_t UncompressedSize;
size_t Offset = 0;
Err = UnCompressFrameZLib(InBuf, ARRAYBEGIN(Element->SizeList,int32_t)[NumFrame], &Element->Data, &UncompressedSize, &Offset);
FrameSize = ARRAYBEGIN(Element->SizeList,int32_t)[NumFrame];
Err = UnCompressFrameZLib(InBuf, FrameSize, &Element->Data, &UncompressedSize, &Offset);
if (Err == ERR_NONE)
{
ArrayResize(&Element->Data, UncompressedSize, 0);
OutSize += UncompressedSize;
ARRAYBEGIN(Element->SizeList,int32_t)[NumFrame] = UncompressedSize;
}
}
Expand Down Expand Up @@ -1611,24 +1612,23 @@ static filepos_t GetBlockFrameSize(const matroska_block *Element, size_t Frame,
return ARRAYBEGIN(Element->SizeList,int32_t)[Frame];
if (Header->Context==MATROSKA_getContextContentCompAlgo())
{
// handle zlib
size_t OutSize;
const int32_t *Size = ARRAYBEGIN(Element->SizeList,int32_t);
const uint8_t *Data = ARRAYBEGIN(Element->Data,uint8_t);
while (Frame)
{
Data += *Size;
++Size;
--Frame;
}
OutSize = *Size;
assert(Element->Base.Base.bValueIsSet);
if (!Element->Base.Base.bValueIsSet)
return *Size; // we can't tell the final size without decoding the data
return ARRAYBEGIN(Element->SizeList,int32_t)[Frame]; // we can't tell the final size without decoding the data

// skip previous frames data
size_t PrevFramesSize = 0;
for (size_t FrameNum=0; FrameNum<Frame; FrameNum++)
PrevFramesSize += ARRAYBEGIN(Element->SizeList,int32_t)[FrameNum];

// handle zlib
size_t OutSize = ARRAYBEGIN(Element->SizeList,int32_t)[Frame];
assert((PrevFramesSize + OutSize) <= ARRAYCOUNT(Element->Data,uint8_t));
const uint8_t *Data = ARRAYBEGIN(Element->Data,uint8_t) + PrevFramesSize;
#if defined(CONFIG_EBML_WRITING)
#if defined(CONFIG_ZLIB)
if (CompAlgo == MATROSKA_TRACK_ENCODING_COMP_ZLIB && CompressFrameZLib(Data,*Size,NULL,&OutSize)!=ERR_NONE)
return *Size; // we can't tell the final size without decoding the data
if (CompAlgo == MATROSKA_TRACK_ENCODING_COMP_ZLIB && CompressFrameZLib(Data,ARRAYBEGIN(Element->SizeList,int32_t)[Frame],NULL,&OutSize)!=ERR_NONE)
return ARRAYBEGIN(Element->SizeList,int32_t)[Frame]; // we can't tell the final size without decoding the data
#endif
#endif
return OutSize;
Expand Down
4 changes: 4 additions & 0 deletions mkclean/regression/mkcleanreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def testFile(cli, line_num, src_file, mkclean_options, filesize, hash):
print(f"\"{src_file}\" \"{mkclean_options}\" {outsize} {filemd5}", file=sys.stderr)
elif not filemd5 == hash:
print(f"Fail:8:{line_num}: bad MD5 {filemd5} for {outputfile}", file=sys.stderr)
return

if not cli.keep:
os.remove(outputfile)
Expand All @@ -116,6 +117,9 @@ def main():
for line in args.regression_file:
if not line.startswith('#') and not line.strip() == '':
regression = line.split('\"')
if len(regression) == 1:
print(regression[0])
continue
src_file = regression[1]
mkclean_options = regression[3].strip()
values = regression[4].strip().split()
Expand Down
Loading
Loading