Skip to content

Commit 29f6f4f

Browse files
HookedBehemothfincs
authored andcommitted
update capsdc for 18.0.0
1 parent b88afc5 commit 29f6f4f

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

nx/include/switch/services/capsdc.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,31 @@ Result capsdcDecodeJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption
3333

3434
/**
3535
* @brief Shrinks a jpeg's dimensions by 2.
36+
* @note Tries to compress with jpeg quality in this order: 98, 95, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0.
37+
* @note Only available on [17.0.0+].
38+
* @param[in] width Input image width.
39+
* @param[in] height Input image width.
40+
* @param[in] opts \ref CapsScreenShotDecodeOption.
41+
* @param[in] jpeg Jpeg image input buffer.
42+
* @param[in] jpeg_size Input image buffer size.
43+
* @param[out] out_jpeg Jpeg image output buffer
44+
* @param[in] out_jpeg_size Output image buffer size.
45+
* @param[out] out_result_size size of the resulting JPEG.
3646
*/
3747
Result capsdcShrinkJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size);
48+
49+
/**
50+
* @brief Shrinks a jpeg.
51+
* @note Fails if the scaled size is larger than the original or the output buffer isn't large enough.
52+
* @note Only available on [19.0.0+].
53+
* @param[in] scaled_width Wanted image width.
54+
* @param[in] scaled_height Wanted image width.
55+
* @param[in] jpeg_quality has to be in range 0-100.
56+
* @param[in] opts \ref CapsScreenShotDecodeOption.
57+
* @param[in] jpeg Jpeg image input buffer.
58+
* @param[in] jpeg_size Input image buffer size.
59+
* @param[out] out_jpeg Jpeg image output buffer
60+
* @param[in] out_jpeg_size Output image buffer size.
61+
* @param[out] out_result_size size of the resulting jpeg.
62+
*/
63+
Result capsdcShrinkJpegEx(u32 scaled_width, u32 scaled_height, u32 jpeg_quality, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size);

nx/source/services/capsdc.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Result capsdcDecodeJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption
4141
}
4242

4343
Result capsdcShrinkJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size) {
44+
if (hosversionBefore(17,0,0))
45+
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
46+
4447
const struct {
4548
u32 width;
4649
u32 height;
@@ -57,3 +60,26 @@ Result capsdcShrinkJpeg(u32 width, u32 height, const CapsScreenShotDecodeOption
5760
}
5861
);
5962
}
63+
64+
Result capsdcShrinkJpegEx(u32 scaled_width, u32 scaled_height, u32 jpeg_quality, const CapsScreenShotDecodeOption *opts, const void* jpeg, size_t jpeg_size, void* out_jpeg, size_t out_jpeg_size, u64 *out_result_size) {
65+
if (hosversionBefore(18,0,0))
66+
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
67+
68+
const struct {
69+
u32 scaled_width;
70+
u32 scaled_height;
71+
u32 jpeg_quality;
72+
u8 pad[4];
73+
CapsScreenShotDecodeOption opts;
74+
} in = { scaled_width, scaled_height, jpeg_quality, {}, *opts };
75+
return serviceDispatchInOut(&g_capsdcSrv, 4002, in, *out_result_size,
76+
.buffer_attrs = {
77+
SfBufferAttr_In | SfBufferAttr_HipcMapAlias,
78+
SfBufferAttr_Out | SfBufferAttr_HipcMapAlias | SfBufferAttr_HipcMapTransferAllowsNonSecure,
79+
},
80+
.buffers = {
81+
{ jpeg, jpeg_size },
82+
{ out_jpeg, out_jpeg_size },
83+
}
84+
);
85+
}

0 commit comments

Comments
 (0)