mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-06-06 08:15:00 -06:00
Cleaner fix
This commit is contained in:
parent
f450405f35
commit
693e17b56c
@ -203,36 +203,23 @@ s32 PS4_SYSV_ABI sceVideodec2GetPictureInfo(const OrbisVideodec2OutputInfo* outp
|
|||||||
LOG_ERROR(Lib_Vdec2, "No picture info available");
|
LOG_ERROR(Lib_Vdec2, "No picture info available");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
if (gPictureInfos.empty()) {
|
||||||
|
LOG_ERROR(Lib_Vdec2, "No picture info available");
|
||||||
|
return ORBIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// If the game uses the older Videodec2 structs, we need to accomodate that.
|
if (p1stPictureInfoOut) {
|
||||||
if (outputInfo->thisSize != sizeof(OrbisVideodec2OutputInfo)) {
|
// Copy enough data to check thisSize.
|
||||||
if (gLegacyPictureInfos.empty()) {
|
u64 picture_size = 0;
|
||||||
LOG_ERROR(Lib_Vdec2, "No picture info available");
|
memcpy(&picture_size, p1stPictureInfoOut, sizeof(u64));
|
||||||
return ORBIS_OK;
|
if ((picture_size | 0x10) != sizeof(OrbisVideodec2AvcPictureInfo)) {
|
||||||
}
|
LOG_ERROR(Lib_Vdec2, "Invalid struct size");
|
||||||
if (p1stPictureInfoOut) {
|
return ORBIS_VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||||
OrbisVideodec2LegacyAvcPictureInfo* picInfo =
|
|
||||||
static_cast<OrbisVideodec2LegacyAvcPictureInfo*>(p1stPictureInfoOut);
|
|
||||||
if (picInfo->thisSize != sizeof(OrbisVideodec2LegacyAvcPictureInfo)) {
|
|
||||||
LOG_ERROR(Lib_Vdec2, "Invalid struct size");
|
|
||||||
return ORBIS_VIDEODEC2_ERROR_STRUCT_SIZE;
|
|
||||||
}
|
|
||||||
*picInfo = gLegacyPictureInfos.back();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (gPictureInfos.empty()) {
|
|
||||||
LOG_ERROR(Lib_Vdec2, "No picture info available");
|
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
|
||||||
if (p1stPictureInfoOut) {
|
|
||||||
OrbisVideodec2AvcPictureInfo* picInfo =
|
|
||||||
static_cast<OrbisVideodec2AvcPictureInfo*>(p1stPictureInfoOut);
|
|
||||||
if (picInfo->thisSize != sizeof(OrbisVideodec2AvcPictureInfo)) {
|
|
||||||
LOG_ERROR(Lib_Vdec2, "Invalid struct size");
|
|
||||||
return ORBIS_VIDEODEC2_ERROR_STRUCT_SIZE;
|
|
||||||
}
|
|
||||||
*picInfo = gPictureInfos.back();
|
|
||||||
}
|
}
|
||||||
|
// Copy the requested picture data to the output.
|
||||||
|
memcpy(p1stPictureInfoOut, &gPictureInfos.back(), picture_size);
|
||||||
|
// Correct the outputted picture struct size.
|
||||||
|
memcpy(p1stPictureInfoOut, &picture_size, sizeof(u64));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputInfo->pictureCount > 1) {
|
if (outputInfo->pictureCount > 1) {
|
||||||
|
|||||||
@ -74,57 +74,4 @@ struct OrbisVideodec2AvcPictureInfo {
|
|||||||
};
|
};
|
||||||
static_assert(sizeof(OrbisVideodec2AvcPictureInfo) == 0x78);
|
static_assert(sizeof(OrbisVideodec2AvcPictureInfo) == 0x78);
|
||||||
|
|
||||||
// An older version of the OrbisVideodec2AvcPictureInfo struct
|
|
||||||
// Keeping this is needed for compatiblity with older games.
|
|
||||||
struct OrbisVideodec2LegacyAvcPictureInfo {
|
|
||||||
u64 thisSize;
|
|
||||||
|
|
||||||
bool isValid;
|
|
||||||
|
|
||||||
u64 ptsData;
|
|
||||||
u64 dtsData;
|
|
||||||
u64 attachedData;
|
|
||||||
|
|
||||||
u8 idrPictureflag;
|
|
||||||
|
|
||||||
u8 profile_idc;
|
|
||||||
u8 level_idc;
|
|
||||||
u32 pic_width_in_mbs_minus1;
|
|
||||||
u32 pic_height_in_map_units_minus1;
|
|
||||||
u8 frame_mbs_only_flag;
|
|
||||||
|
|
||||||
u8 frame_cropping_flag;
|
|
||||||
u32 frameCropLeftOffset;
|
|
||||||
u32 frameCropRightOffset;
|
|
||||||
u32 frameCropTopOffset;
|
|
||||||
u32 frameCropBottomOffset;
|
|
||||||
|
|
||||||
u8 aspect_ratio_info_present_flag;
|
|
||||||
u8 aspect_ratio_idc;
|
|
||||||
u16 sar_width;
|
|
||||||
u16 sar_height;
|
|
||||||
|
|
||||||
u8 video_signal_type_present_flag;
|
|
||||||
u8 video_format;
|
|
||||||
u8 video_full_range_flag;
|
|
||||||
u8 colour_description_present_flag;
|
|
||||||
u8 colour_primaries;
|
|
||||||
u8 transfer_characteristics;
|
|
||||||
u8 matrix_coefficients;
|
|
||||||
|
|
||||||
u8 timing_info_present_flag;
|
|
||||||
u32 num_units_in_tick;
|
|
||||||
u32 time_scale;
|
|
||||||
u8 fixed_frame_rate_flag;
|
|
||||||
|
|
||||||
u8 bitstream_restriction_flag;
|
|
||||||
u8 max_dec_frame_buffering;
|
|
||||||
|
|
||||||
u8 pic_struct_present_flag;
|
|
||||||
u8 pic_struct;
|
|
||||||
u8 field_pic_flag;
|
|
||||||
u8 bottom_field_flag;
|
|
||||||
};
|
|
||||||
static_assert(sizeof(OrbisVideodec2LegacyAvcPictureInfo) == 0x68);
|
|
||||||
|
|
||||||
} // namespace Libraries::Videodec2
|
} // namespace Libraries::Videodec2
|
||||||
@ -12,7 +12,6 @@
|
|||||||
namespace Libraries::Videodec2 {
|
namespace Libraries::Videodec2 {
|
||||||
|
|
||||||
std::vector<OrbisVideodec2AvcPictureInfo> gPictureInfos;
|
std::vector<OrbisVideodec2AvcPictureInfo> gPictureInfos;
|
||||||
std::vector<OrbisVideodec2LegacyAvcPictureInfo> gLegacyPictureInfos;
|
|
||||||
|
|
||||||
static inline void CopyNV12Data(u8* dst, const AVFrame& src) {
|
static inline void CopyNV12Data(u8* dst, const AVFrame& src) {
|
||||||
if (src.width == src.linesize[0]) {
|
if (src.width == src.linesize[0]) {
|
||||||
@ -132,46 +131,27 @@ s32 VdecDecoder::Decode(const OrbisVideodec2InputData& inputData,
|
|||||||
outputInfo.isErrorFrame = false;
|
outputInfo.isErrorFrame = false;
|
||||||
outputInfo.pictureCount = 1; // TODO: 2 pictures for interlaced video
|
outputInfo.pictureCount = 1; // TODO: 2 pictures for interlaced video
|
||||||
|
|
||||||
// For proper compatibility with older games, check the inputted OutputInfo struct size.
|
// Only set framePitchInBytes if the game uses the newer struct version.
|
||||||
if (outputInfo.thisSize == sizeof(OrbisVideodec2OutputInfo)) {
|
if (outputInfo.thisSize == sizeof(OrbisVideodec2OutputInfo)) {
|
||||||
// framePitchInBytes only exists in the newer struct.
|
outputInfo.framePitchInBytes = frame->linesize[0];
|
||||||
outputInfo.framePitchInBytes = frame->width;
|
}
|
||||||
if (outputInfo.isValid) {
|
|
||||||
OrbisVideodec2AvcPictureInfo pictureInfo = {};
|
|
||||||
|
|
||||||
pictureInfo.thisSize = sizeof(OrbisVideodec2AvcPictureInfo);
|
if (outputInfo.isValid) {
|
||||||
pictureInfo.isValid = true;
|
OrbisVideodec2AvcPictureInfo pictureInfo = {};
|
||||||
|
|
||||||
pictureInfo.ptsData = inputData.ptsData;
|
pictureInfo.thisSize = sizeof(OrbisVideodec2AvcPictureInfo);
|
||||||
pictureInfo.dtsData = inputData.dtsData;
|
pictureInfo.isValid = true;
|
||||||
pictureInfo.attachedData = inputData.attachedData;
|
|
||||||
|
|
||||||
pictureInfo.frameCropLeftOffset = frame->crop_left;
|
pictureInfo.ptsData = inputData.ptsData;
|
||||||
pictureInfo.frameCropRightOffset = frame->crop_right;
|
pictureInfo.dtsData = inputData.dtsData;
|
||||||
pictureInfo.frameCropTopOffset = frame->crop_top;
|
pictureInfo.attachedData = inputData.attachedData;
|
||||||
pictureInfo.frameCropBottomOffset = frame->crop_bottom;
|
|
||||||
|
|
||||||
gPictureInfos.push_back(pictureInfo);
|
pictureInfo.frameCropLeftOffset = frame->crop_left;
|
||||||
}
|
pictureInfo.frameCropRightOffset = frame->crop_right;
|
||||||
} else {
|
pictureInfo.frameCropTopOffset = frame->crop_top;
|
||||||
if (outputInfo.isValid) {
|
pictureInfo.frameCropBottomOffset = frame->crop_bottom;
|
||||||
// If the game uses the older struct versions, we need to use it too.
|
|
||||||
OrbisVideodec2LegacyAvcPictureInfo pictureInfo = {};
|
|
||||||
|
|
||||||
pictureInfo.thisSize = sizeof(OrbisVideodec2LegacyAvcPictureInfo);
|
gPictureInfos.push_back(pictureInfo);
|
||||||
pictureInfo.isValid = true;
|
|
||||||
|
|
||||||
pictureInfo.ptsData = inputData.ptsData;
|
|
||||||
pictureInfo.dtsData = inputData.dtsData;
|
|
||||||
pictureInfo.attachedData = inputData.attachedData;
|
|
||||||
|
|
||||||
pictureInfo.frameCropLeftOffset = frame->crop_left;
|
|
||||||
pictureInfo.frameCropRightOffset = frame->crop_right;
|
|
||||||
pictureInfo.frameCropTopOffset = frame->crop_top;
|
|
||||||
pictureInfo.frameCropBottomOffset = frame->crop_bottom;
|
|
||||||
|
|
||||||
gLegacyPictureInfos.push_back(pictureInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,6 @@ extern "C" {
|
|||||||
namespace Libraries::Videodec2 {
|
namespace Libraries::Videodec2 {
|
||||||
|
|
||||||
extern std::vector<OrbisVideodec2AvcPictureInfo> gPictureInfos;
|
extern std::vector<OrbisVideodec2AvcPictureInfo> gPictureInfos;
|
||||||
extern std::vector<OrbisVideodec2LegacyAvcPictureInfo> gLegacyPictureInfos;
|
|
||||||
|
|
||||||
class VdecDecoder {
|
class VdecDecoder {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user