mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 10:32:15 +02:00
add jpegdec/caps:dc
This commit is contained in:
parent
c28d736ff0
commit
6ed58e3601
@ -93,6 +93,7 @@ extern "C" {
|
|||||||
#include "switch/services/psc.h"
|
#include "switch/services/psc.h"
|
||||||
#include "switch/services/caps.h"
|
#include "switch/services/caps.h"
|
||||||
#include "switch/services/capsa.h"
|
#include "switch/services/capsa.h"
|
||||||
|
#include "switch/services/capsdc.h"
|
||||||
#include "switch/services/capsu.h"
|
#include "switch/services/capsu.h"
|
||||||
#include "switch/services/capssc.h"
|
#include "switch/services/capssc.h"
|
||||||
#include "switch/services/capssu.h"
|
#include "switch/services/capssu.h"
|
||||||
|
@ -65,7 +65,10 @@ typedef struct {
|
|||||||
|
|
||||||
/// ScreenShotDecodeOption
|
/// ScreenShotDecodeOption
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 unk_x0[0x20]; ///< Unknown. Set to all-zero by official sw.
|
bool fancy_upsampling;
|
||||||
|
bool block_smoothing;
|
||||||
|
u8 unk_x2[0x6]; ///< Padding.
|
||||||
|
u64 unk_x8[3]; ///< Unknown. Ignored by official sw.
|
||||||
} CapsScreenShotDecodeOption;
|
} CapsScreenShotDecodeOption;
|
||||||
|
|
||||||
/// AlbumFileDateTime. This corresponds to each field in the Album entry filename, prior to the "-": "YYYYMMDDHHMMSSII".
|
/// AlbumFileDateTime. This corresponds to each field in the Album entry filename, prior to the "-": "YYYYMMDDHHMMSSII".
|
||||||
|
32
nx/include/switch/services/capsdc.h
Normal file
32
nx/include/switch/services/capsdc.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* @file capsdc.h
|
||||||
|
* @brief Jpeg Decoder (caps:dc) service IPC wrapper. Only Available on 4.0.0+.
|
||||||
|
* @note Only holds one session that is occupied by capsrv.
|
||||||
|
* @author Behemoth
|
||||||
|
* @copyright libnx Authors
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#include "../types.h"
|
||||||
|
#include "../sf/service.h"
|
||||||
|
#include "../services/caps.h"
|
||||||
|
|
||||||
|
/// Initialize caps:dc
|
||||||
|
Result capsdcInitialize(void);
|
||||||
|
|
||||||
|
/// Exit caps:dc.
|
||||||
|
void capsdcExit(void);
|
||||||
|
|
||||||
|
/// Gets the Service for caps:dc.
|
||||||
|
Service* capsdcGetServiceSession(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decodes a jpeg buffer into RGBX.
|
||||||
|
* @param[in] width Image width.
|
||||||
|
* @param[in] height Image height.
|
||||||
|
* @param[in] opts CapsScreenShotDecodeOption decode options.
|
||||||
|
* @param[in] jpeg Jpeg image input buffer.
|
||||||
|
* @param[in] jpeg_size Input image buffer size.
|
||||||
|
* @param[out] image RGBA8 image output buffer.
|
||||||
|
* @param[in] image_size Output image buffer size, should be at least large enough for RGBA8 width x height.
|
||||||
|
*/
|
||||||
|
Result capsdcDecodeJpeg(const u32 width, const u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, const u64 jpeg_size, void* image, const u64 image_size);
|
37
nx/source/services/capsdc.c
Normal file
37
nx/source/services/capsdc.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||||
|
#include "service_guard.h"
|
||||||
|
#include "services/capsdc.h"
|
||||||
|
|
||||||
|
static Service g_capsdcSrv;
|
||||||
|
|
||||||
|
NX_GENERATE_SERVICE_GUARD(capsdc);
|
||||||
|
|
||||||
|
Result _capsdcInitialize(void) {
|
||||||
|
return smGetService(&g_capsdcSrv, "caps:dc");
|
||||||
|
}
|
||||||
|
|
||||||
|
void _capsdcCleanup(void) {
|
||||||
|
serviceClose(&g_capsdcSrv);
|
||||||
|
}
|
||||||
|
|
||||||
|
Service* capsdcGetServiceSession(void) {
|
||||||
|
return &g_capsdcSrv;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result capsdcDecodeJpeg(const u32 width, const u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, const u64 jpeg_size, void* image, const u64 image_size) {
|
||||||
|
const struct {
|
||||||
|
u32 width;
|
||||||
|
u32 height;
|
||||||
|
CapsScreenShotDecodeOption opts;
|
||||||
|
} in = { width, height, *opts };
|
||||||
|
return serviceDispatchIn(&g_capsdcSrv, 3001, in,
|
||||||
|
.buffer_attrs = {
|
||||||
|
SfBufferAttr_In | SfBufferAttr_HipcMapAlias,
|
||||||
|
SfBufferAttr_Out | SfBufferAttr_HipcMapAlias | SfBufferAttr_HipcMapTransferAllowsNonSecure,
|
||||||
|
},
|
||||||
|
.buffers = {
|
||||||
|
{ jpeg, jpeg_size },
|
||||||
|
{ image, image_size },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user