mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-17 08:20:30 +02:00
The libretro-common submodule pinned the standalone repository at 76a3d54. It is replaced by an in-tree copy of RetroArch master (b655a20) holding only what the core uses: the VFS, file, string, encoding, compat and time sources it already built, the headers they and the core include, the threading set - rthreads, retro_atomic, retro_spsc and retro_waitable_spsc, mpsc_stack, retro_triple_buffer, retro_eventcount, retro_asym_eventcount, retro_procbarrier and tpool, with features_cpu and rstrtod, which they need - and the codecs that replace the bundled zlib, zstd, libchdr, libzip and libpng: rinflate and rdeflate, rzstd, rchd with its LZMA and FLAC decoders, rzip_archive, rpng and crc32. stdstring.c, which nothing calls, is no longer built. The threading sources are always built, by both the static Makefile and CMake; the VFS set stays behind HAVE_LIBRETRO_VFS as before. The codecs are built by the change that switches the core over to them.
105 lines
3.3 KiB
C
105 lines
3.3 KiB
C
/* Copyright (C) 2010-2020 The RetroArch team
|
|
*
|
|
* ---------------------------------------------------------------------------------------
|
|
* The following license statement only applies to this file (trans_stream.c).
|
|
* ---------------------------------------------------------------------------------------
|
|
*
|
|
* Permission is hereby granted, free of charge,
|
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation the rights to
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <streams/trans_stream.h>
|
|
|
|
/**
|
|
* trans_stream_trans_full:
|
|
* @data : (optional) existing stream data, or a target
|
|
* for the new stream data to be saved
|
|
* @in : input data
|
|
* @in_size : input size
|
|
* @s : output data
|
|
* @len : output size
|
|
* @err : (optional) output for error code
|
|
*
|
|
* Perform a full transcoding from a source to a destination.
|
|
*/
|
|
bool trans_stream_trans_full(
|
|
struct trans_stream_backend *backend, void **data,
|
|
const uint8_t *in, uint32_t in_size,
|
|
uint8_t *s, uint32_t len,
|
|
enum trans_stream_error *err)
|
|
{
|
|
void *rdata;
|
|
bool ret;
|
|
uint32_t rd, wn;
|
|
|
|
if (data && *data)
|
|
rdata = *data;
|
|
else
|
|
{
|
|
if (!(rdata = backend->stream_new()))
|
|
{
|
|
if (err)
|
|
*err = TRANS_STREAM_ERROR_ALLOCATION_FAILURE;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
backend->set_in(rdata, in, in_size);
|
|
backend->set_out(rdata, s, len);
|
|
ret = backend->trans(rdata, true, &rd, &wn, err);
|
|
|
|
if (data)
|
|
*data = rdata;
|
|
else
|
|
backend->stream_free(rdata);
|
|
|
|
return ret;
|
|
}
|
|
|
|
const struct trans_stream_backend* trans_stream_get_zlib_deflate_backend(void)
|
|
{
|
|
#if HAVE_ZLIB
|
|
return &zlib_deflate_backend;
|
|
#else
|
|
/* No zlib: use the built-in clean-room DEFLATE backend so compression
|
|
* paths keep working. */
|
|
return &deflate_deflate_backend;
|
|
#endif
|
|
}
|
|
|
|
const struct trans_stream_backend* trans_stream_get_zlib_inflate_backend(void)
|
|
{
|
|
#if HAVE_ZLIB
|
|
return &zlib_inflate_backend;
|
|
#else
|
|
return &deflate_inflate_backend;
|
|
#endif
|
|
}
|
|
|
|
const struct trans_stream_backend* trans_stream_get_deflate_deflate_backend(void)
|
|
{
|
|
return &deflate_deflate_backend;
|
|
}
|
|
|
|
const struct trans_stream_backend* trans_stream_get_deflate_inflate_backend(void)
|
|
{
|
|
return &deflate_inflate_backend;
|
|
}
|
|
|
|
const struct trans_stream_backend* trans_stream_get_pipe_backend(void)
|
|
{
|
|
return &pipe_backend;
|
|
}
|