.osr 文件格式解析(一) - 官方格式说明

先上官网原文: Osr (file format) - osu!wiki

.osr is a file format containing information about an osu! replay. To use it, the beatmap specified by the file is required in “Songs” folder.

#Data Types

NameBytesDescription
Byte1A single 8 bit value.
Short2A 2-byte little endian value.
Integer4A 4-byte little endian value.
Long8A 8-byte little endian value.
ULEB128VariableA variable length integer. See wikipedia:ULEB128.
StringVariableHas three parts; a single byte which will be either 0x00, indicating that the next two parts are not present, or 0x0b (decimal 11), indicating that the next two parts are present. If it is 0x0b, there will then be a ULEB128, representing the byte length of the following string, and then the string itself, encoded in UTF-8. See wikipedia:UTF-8

#Format

Byte offsets are not included in this table due to variable length values.

Data TypeDescription
ByteGame mode of the replay (0 = osu! Standard, 1 = Taiko, 2 = Catch the Beat, 3 = osu!mania)
IntegerVersion of the game when the replay was created (ex. 20131216)
Stringosu! beatmap MD5 hash
StringPlayer name
Stringosu! replay MD5 hash (includes certain properties of the replay)
ShortNumber of 300s
ShortNumber of 100s in standard, 150s in Taiko, 100s in CTB, 200s in mania
ShortNumber of 50s in standard, small fruit in CTB, 50s in mania
ShortNumber of Gekis in standard, Max 300s in mania
ShortNumber of Katus in standard, 100s in mania
ShortNumber of misses
IntegerTotal score displayed on the score report
ShortGreatest combo displayed on the score report
BytePerfect/full combo (1 = no misses and no slider breaks and no early finished sliders)
IntegerMods used. See below for list of mod values.
StringLife bar graph: comma separated pairs u┃v, where u is the time in milliseconds into the song and v is a floating point value from 0 - 1 that represents the amount of life you have at the given time (0 = life bar is empty, 1= life bar is full).
LongTime stamp Windows ticks
IntegerLength in bytes of compressed replay data
Byte ArrayCompressed replay data

The remaining data contains information about mouse movement and key presses in an wikipedia:LZMA stream.
When decompressed, the text contains data separated by commas. Each piece denotes an action, represented by 4 numbers in the form: w | x | y | z.

PartData TypeDescription
wLongTime in milliseconds since the previous action
xFloatx-coordinate of the cursor from 0 - 512
yFloaty-coordinate of the cursor from 0 - 384
zIntegerBitwise combination of keys/mouse buttons pressed (M1 = 1, M2 = 2, K1 = 5, K2 = 10)

##Mods
As seen on the osu! API.

ModValue (BitOffset)Comment
None0
NoFail1 (0)
Easy2 (1)
NoVideo4 (2)this isn’t really a mod anymore.
Hidden8 (3)
HardRock16 (4)
SuddenDeath32 (5)
DoubleTime64 (6)
Relax128 (7)
HalfTime256 (8)
Nightcore512 (9)always used with DT : 512 + 64 = 576
Flashlight1024 (10)
Autoplay2048 (11)
SpunOut4096 (12)
Relax28192 (13)Autopilot
Perfect16384 (14)
Key432768 (15)
Key565536 (16)
Key6131072 (17
Key7262144 (18)
Key8524288 (19)
keyMod1015808k4+k5+k6+k7+k8
FadeIn1048576 (20)
Random2097152 (21)
LastMod4194304 (22)Cinema
TargetPractice8388608 (23)osu!cuttingedge only
Key916777216 (24)
Coop33554432 (25)
Key167108864 (26)
Key3134217728 (27)
Key2268435456 (28)

ppy在官网上直接开源了文件格式,极大的方便了文件格式的解析(至少不用自己耗脑子去破解了),下一篇再开始讲如何解析

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将 NetCDF 或 R-NC 格式的数据转换为 GeoTIFF 格式,可以使用 Java 或 R 中的 GDAL 库。下面是一个 Java 示例代码,可以将 NetCDF 文件转换为 GeoTIFF 文件: ```java import org.gdal.gdal.gdal; import org.gdal.gdalconst.gdalconst; import org.gdal.osr.SpatialReference; import org.gdal.osr.osr; public class NetcdfToGeoTiff { public static void main(String[] args) { // Register GDAL drivers gdal.AllRegister(); // Open NetCDF file String inputFilePath = "path/to/netcdf/file.nc"; gdal.Dataset netcdfDataset = gdal.Open(inputFilePath, gdalconst.GA_ReadOnly); // Get number of bands and dimensions int numBands = netcdfDataset.getRasterCount(); int numDims = netcdfDataset.getRasterXSize() * netcdfDataset.getRasterYSize(); // Read data from NetCDF file float[] data = new float[numDims * numBands]; netcdfDataset.readRaster(0, 0, netcdfDataset.getRasterXSize(), netcdfDataset.getRasterYSize(), data); // Create output GeoTIFF file String outputFilePath = "path/to/geotiff/file.tiff"; gdal.Driver driver = gdal.GetDriverByName("GTiff"); gdal.Dataset geotiffDataset = driver.Create(outputFilePath, netcdfDataset.getRasterXSize(), netcdfDataset.getRasterYSize(), numBands, gdalconst.GDT_Float32); // Set projection and geotransform SpatialReference srs = new SpatialReference(netcdfDataset.GetProjectionRef()); geotiffDataset.SetProjection(srs.ExportToWkt()); double[] geoTransform = new double[6]; netcdfDataset.GetGeoTransform(geoTransform); geotiffDataset.SetGeoTransform(geoTransform); // Write data to GeoTIFF file for (int i = 0; i < numBands; i++) { gdal.Band band = geotiffDataset.GetRasterBand(i + 1); band.WriteRaster(0, 0, netcdfDataset.getRasterXSize(), netcdfDataset.getRasterYSize(), data, netcdfDataset.getRasterXSize(), netcdfDataset.getRasterYSize(), gdalconst.GDT_Float32, 0, 0); band.FlushCache(); } // Close datasets geotiffDataset.delete(); netcdfDataset.delete(); } } ``` 请注意,此示例代码需要 GDAL 和 JavaGDAL 库。你需要将这些库添加到你的项目中。 同样,你也可以使用 R 中的 GDAL 包来转换 R-NC 数据。下面是一个简单的 R 示例代码: ```R library(gdal) # Open R-NC file inputFilePath <- "path/to/r-nc/file.nc" rncDataset <- gdalUtils::gdal_open(inputFilePath) # Get number of bands and dimensions numBands <- rncDataset@nbands numDims <- rncDataset@nrows * rncDataset@ncols # Read data from R-NC file data <- gdalUtils::gdal_read(rncDataset) # Create output GeoTIFF file outputFilePath <- "path/to/geotiff/file.tiff" geotiffDataset <- gdalUtils::gdal_translate(data, dst_dataset=outputFilePath, format="GTiff") # Set projection and geotransform geotiffDataset@proj4string <- rncDataset@proj4string geotiffDataset@extent <- rncDataset@extent # Close datasets gdalUtils::gdal_close(rncDataset) gdalUtils::gdal_close(geotiffDataset) ``` 请注意,此示例代码需要 GDAL 和 gdalUtils 包。你需要将这些库添加到你的 R 环境中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值