git subrepo pull (merge) --force deps/libchdr
[pcsx_rearmed.git] / deps / libchdr / deps / zstd-1.5.5 / lib / deprecated / zbuff_decompress.c
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under both the BSD-style license (found in the
6  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7  * in the COPYING file in the root directory of this source tree).
8  * You may select, at your option, one of the above-listed licenses.
9  */
10
11
12
13 /* *************************************
14 *  Dependencies
15 ***************************************/
16 #define ZSTD_DISABLE_DEPRECATE_WARNINGS  /* suppress warning on ZSTD_initDStream_usingDict */
17 #include "../zstd.h"        /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
18 #define ZBUFF_STATIC_LINKING_ONLY
19 #include "zbuff.h"
20
21
22 ZBUFF_DCtx* ZBUFF_createDCtx(void)
23 {
24     return ZSTD_createDStream();
25 }
26
27 ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
28 {
29     return ZSTD_createDStream_advanced(customMem);
30 }
31
32 size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
33 {
34     return ZSTD_freeDStream(zbd);
35 }
36
37
38 /* *** Initialization *** */
39
40 size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
41 {
42     return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
43 }
44
45 size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
46 {
47     return ZSTD_initDStream(zbd);
48 }
49
50
51 /* *** Decompression *** */
52
53 size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
54                                 void* dst, size_t* dstCapacityPtr,
55                           const void* src, size_t* srcSizePtr)
56 {
57     ZSTD_outBuffer outBuff;
58     ZSTD_inBuffer inBuff;
59     size_t result;
60     outBuff.dst  = dst;
61     outBuff.pos  = 0;
62     outBuff.size = *dstCapacityPtr;
63     inBuff.src  = src;
64     inBuff.pos  = 0;
65     inBuff.size = *srcSizePtr;
66     result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);
67     *dstCapacityPtr = outBuff.pos;
68     *srcSizePtr = inBuff.pos;
69     return result;
70 }
71
72
73 /* *************************************
74 *  Tool functions
75 ***************************************/
76 size_t ZBUFF_recommendedDInSize(void)  { return ZSTD_DStreamInSize(); }
77 size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }