diff --git a/src/Audio.c b/src/Audio.c index b09e511bd..e814655ef 100644 --- a/src/Audio.c +++ b/src/Audio.c @@ -761,17 +761,17 @@ static ReturnCode Music_PlayOgg(struct Stream* source) { ReturnCode res; Ogg_MakeStream(&stream, buffer, source); - vorbis.Source = &stream; + vorbis.source = &stream; if ((res = Vorbis_DecodeHeaders(&vorbis))) goto cleanup; - fmt.Channels = vorbis.Channels; - fmt.SampleRate = vorbis.SampleRate; + fmt.Channels = vorbis.channels; + fmt.SampleRate = vorbis.sampleRate; fmt.BitsPerSample = 16; if ((res = Audio_SetFormat(music_out, &fmt))) goto cleanup; /* largest possible vorbis frame decodes to blocksize1 * channels samples */ /* so we may end up decoding slightly over a second of audio */ - chunkSize = fmt.Channels * (fmt.SampleRate + vorbis.BlockSizes[1]); + chunkSize = fmt.Channels * (fmt.SampleRate + vorbis.blockSizes[1]); samplesPerSecond = fmt.Channels * fmt.SampleRate; data = (int16_t*)Mem_Alloc(chunkSize * AUDIO_MAX_BUFFERS, 2, "Ogg final output"); diff --git a/src/AxisLinesRenderer.c b/src/AxisLinesRenderer.c index 5dc9297ec..07c22bdcc 100644 --- a/src/AxisLinesRenderer.c +++ b/src/AxisLinesRenderer.c @@ -38,7 +38,7 @@ void AxisLinesRenderer_Render(double delta) { Gfx_SetTexturing(false); pos = LocalPlayer_Instance.Base.Position; pos.Y += 0.05f; - count = Camera.Active->IsThirdPerson ? 12 : 8; + count = Camera.Active->isThirdPerson ? 12 : 8; Vector3_Add1(&coords[0], &pos, -AXISLINES_LENGTH); Vector3_Add1(&coords[1], &pos, -AXISLINES_THICKNESS); diff --git a/src/Camera.c b/src/Camera.c index d15888377..17df95f71 100644 --- a/src/Camera.c +++ b/src/Camera.c @@ -80,7 +80,7 @@ static void PerspectiveCamera_UpdateMouseRotation(double delta) { float headY, headX; Vector2 rot = PerspectiveCamera_GetMouseDelta(delta); - if (Key_IsAltPressed() && Camera.Active->IsThirdPerson) { + if (Key_IsAltPressed() && Camera.Active->isThirdPerson) { cam_rotOffset.X += rot.X; cam_rotOffset.Y += rot.Y; return; } @@ -251,7 +251,7 @@ void Camera_Init(void) { void Camera_CycleActive(void) { struct LocalPlayer* p = &LocalPlayer_Instance; if (Game_ClassicMode) return; - Camera.Active = Camera.Active->Next; + Camera.Active = Camera.Active->next; if (!p->Hacks.CanUseThirdPersonCamera || !p->Hacks.Enabled) { Camera.Active = &cam_FirstPerson; @@ -268,7 +268,7 @@ static struct Camera* cams_tail; void Camera_Register(struct Camera* cam) { LinkedList_Add(cam, cams_head, cams_tail); /* want a circular linked list */ - cam->Next = cams_head; + cam->next = cams_head; } static bool cam_focussed; diff --git a/src/Camera.h b/src/Camera.h index b5c313303..45f7aaa8e 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -32,7 +32,7 @@ extern struct _CameraData { struct Camera { /* Whether this camera is third person. (i.e. not allowed when -thirdperson in MOTD) */ - bool IsThirdPerson; + bool isThirdPerson; /* Calculates the current projection matrix of this camera. */ void (*GetProjection)(struct Matrix* proj); @@ -60,7 +60,7 @@ struct Camera { bool (*Zoom)(float amount); /* Next camera in linked list of cameras. */ - struct Camera* Next; + struct Camera* next; }; /* Initialises the default cameras. */ diff --git a/src/Chat.c b/src/Chat.c index 78134e4b3..e4b2200e0 100644 --- a/src/Chat.c +++ b/src/Chat.c @@ -239,7 +239,7 @@ static struct ChatCommand* Commands_GetMatch(const String* cmdName) { String name; struct ChatCommand* match = NULL; - for (cmd = cmds_head; cmd; cmd = cmd->Next) { + for (cmd = cmds_head; cmd; cmd = cmd->next) { name = String_FromReadonly(cmd->Name); if (!String_CaselessStarts(&name, cmdName)) continue; @@ -270,7 +270,7 @@ static void Commands_PrintDefault(void) { Chat_AddRaw("&eList of client commands:"); String_InitArray(str, strBuffer); - for (cmd = cmds_head; cmd; cmd = cmd->Next) { + for (cmd = cmds_head; cmd; cmd = cmd->next) { name = String_FromReadonly(cmd->Name); if ((str.length + name.length + 2) > str.capacity) { diff --git a/src/Chat.h b/src/Chat.h index 3096273e3..440a05ade 100644 --- a/src/Chat.h +++ b/src/Chat.h @@ -40,7 +40,7 @@ struct ChatCommand { void (*Execute)(const String* args, int argsCount); bool SingleplayerOnly; /* Whether this command is only usable in singleplayer */ const char* Help[5]; /* Messages to show when a player uses /help on this command */ - struct ChatCommand* Next; /* Next command in linked-list of client commands */ + struct ChatCommand* next; /* Next command in linked-list of client commands */ }; /* Registers a client-side command, allowing it to be used with /client [cmd name] */ CC_API void Commands_Register(struct ChatCommand* cmd); diff --git a/src/Entity.c b/src/Entity.c index d382f543d..7fadb906b 100644 --- a/src/Entity.c +++ b/src/Entity.c @@ -873,12 +873,12 @@ static void LocalPlayer_RenderModel(struct Entity* e, double deltaTime, float t) AnimatedComp_GetCurrent(e, t); TiltComp_GetCurrent(&p->Tilt, t); - if (!Camera.Active->IsThirdPerson) return; + if (!Camera.Active->isThirdPerson) return; Model_Render(e->Model, e); } static void LocalPlayer_RenderName(struct Entity* e) { - if (!Camera.Active->IsThirdPerson) return; + if (!Camera.Active->isThirdPerson) return; Player_DrawName((struct Player*)e); } diff --git a/src/EntityComponents.c b/src/EntityComponents.c index 627d0243e..2b6f31aad 100644 --- a/src/EntityComponents.c +++ b/src/EntityComponents.c @@ -1300,7 +1300,7 @@ static bool SoundComp_ShouldPlay(struct LocalPlayer* p, Vector3 soundPos) { if (p->Base.Anim.Swing < 0.999f) return distSq > 1.75f * 1.75f; /* have our legs just crossed over the '0' point? */ - if (Camera.Active->IsThirdPerson) { + if (Camera.Active->isThirdPerson) { oldLegRot = (float)Math_Cos(p->Base.Anim.WalkTimeO); newLegRot = (float)Math_Cos(p->Base.Anim.WalkTimeN); } else { diff --git a/src/Funcs.h b/src/Funcs.h index 1f42eb243..04d7929c3 100644 --- a/src/Funcs.h +++ b/src/Funcs.h @@ -34,8 +34,8 @@ if (j - left <= right - i) {\ } #define LinkedList_Add(item, head, tail)\ -if (!head) { head = item; } else { tail->Next = item; }\ +if (!head) { head = item; } else { tail->next = item; }\ tail = item;\ -item->Next = NULL; +item->next = NULL; #endif diff --git a/src/Game.c b/src/Game.c index 5feb1dea9..d3f3e837f 100644 --- a/src/Game.c +++ b/src/Game.c @@ -196,7 +196,7 @@ void Game_Reset(void) { World_TextureUrl.length = 0; } - for (comp = comps_head; comp; comp = comp->Next) { + for (comp = comps_head; comp; comp = comp->next) { if (comp->Reset) comp->Reset(); } } @@ -288,14 +288,14 @@ static void Game_OnResize(void* obj) { static void Game_OnNewMapCore(void* obj) { struct IGameComponent* comp; - for (comp = comps_head; comp; comp = comp->Next) { + for (comp = comps_head; comp; comp = comp->next) { if (comp->OnNewMap) comp->OnNewMap(); } } static void Game_OnNewMapLoadedCore(void* obj) { struct IGameComponent* comp; - for (comp = comps_head; comp; comp = comp->Next) { + for (comp = comps_head; comp; comp = comp->next) { if (comp->OnNewMapLoaded) comp->OnNewMapLoaded(); } } @@ -498,7 +498,7 @@ static void Game_Load(void) { Game_AddComponent(&AxisLinesRenderer_Component); Game_LoadPlugins(); - for (comp = comps_head; comp; comp = comp->Next) { + for (comp = comps_head; comp; comp = comp->next) { if (comp->Init) comp->Init(); } @@ -684,7 +684,7 @@ void Game_Free(void* obj) { Event_UnregisterVoid(&WindowEvents.Resized, NULL, Game_OnResize); Event_UnregisterVoid(&WindowEvents.Closing, NULL, Game_Free); - for (comp = comps_head; comp; comp = comp->Next) { + for (comp = comps_head; comp; comp = comp->next) { if (comp->Free) comp->Free(); } diff --git a/src/GameStructs.h b/src/GameStructs.h index 585b2fb93..0af241ed7 100644 --- a/src/GameStructs.h +++ b/src/GameStructs.h @@ -19,7 +19,7 @@ struct IGameComponent { /* Called to update the component's state when the user has finished loading a new map. */ void (*OnNewMapLoaded)(void); /* Next component in linked list of components. */ - struct IGameComponent* Next; + struct IGameComponent* next; }; /* Adds a component to linked list of components. (always at end) */ CC_NOINLINE void Game_AddComponent(struct IGameComponent* comp); diff --git a/src/HeldBlockRenderer.c b/src/HeldBlockRenderer.c index 34b59a771..deb2459be 100644 --- a/src/HeldBlockRenderer.c +++ b/src/HeldBlockRenderer.c @@ -223,7 +223,7 @@ void HeldBlockRenderer_Render(double delta) { HeldBlockRenderer_ResetHeldState(); HeldBlockRenderer_DoAnimation(delta, lastSwingY); HeldBlockRenderer_SetBaseOffset(); - if (!Camera.Active->IsThirdPerson) HeldBlockRenderer_RenderModel(); + if (!Camera.Active->isThirdPerson) HeldBlockRenderer_RenderModel(); Gfx.View = view; Gfx_LoadMatrix(MATRIX_PROJECTION, &Gfx.Projection); diff --git a/src/Model.c b/src/Model.c index 044c297cb..6907613be 100644 --- a/src/Model.c +++ b/src/Model.c @@ -392,7 +392,7 @@ static void Model_Make(struct Model* model) { struct Model* Model_Get(const String* name) { struct Model* model; - for (model = models_head; model; model = model->Next) { + for (model = models_head; model; model = model->next) { if (!String_CaselessEqualsConst(name, model->Name)) continue; if (!model->initalised) Model_Make(model); @@ -404,7 +404,7 @@ struct Model* Model_Get(const String* name) { struct ModelTex* Model_GetTexture(const String* name) { struct ModelTex* tex; - for (tex = textures_head; tex; tex = tex->Next) { + for (tex = textures_head; tex; tex = tex->next) { if (String_CaselessEqualsConst(name, tex->Name)) return tex; } return NULL; @@ -421,7 +421,7 @@ void Model_RegisterTexture(struct ModelTex* tex) { static void Models_TextureChanged(void* obj, struct Stream* stream, const String* name) { struct ModelTex* tex; - for (tex = textures_head; tex; tex = tex->Next) { + for (tex = textures_head; tex; tex = tex->next) { if (!String_CaselessEqualsConst(name, tex->Name)) continue; Game_UpdateTexture(&tex->TexID, stream, name, &tex->SkinType); @@ -1703,7 +1703,7 @@ static void Models_Init(void) { static void Models_Free(void) { struct ModelTex* tex; - for (tex = textures_head; tex; tex = tex->Next) { + for (tex = textures_head; tex; tex = tex->next) { Gfx_DeleteTexture(&tex->TexID); } Models_ContextLost(NULL); diff --git a/src/Model.h b/src/Model.h index ac200d7f0..f5536beb7 100644 --- a/src/Model.h +++ b/src/Model.h @@ -34,7 +34,7 @@ static CC_INLINE void ModelPart_Init(struct ModelPart* part, int offset, int cou struct ModelTex; /* Contains information about a texture used for models. */ -struct ModelTex { const char* Name; uint8_t SkinType; GfxResourceID TexID; struct ModelTex* Next; }; +struct ModelTex { const char* Name; uint8_t SkinType; GfxResourceID TexID; struct ModelTex* next; }; struct Model; /* Contains a set of quads and/or boxes that describe a 3D object as well as @@ -80,7 +80,7 @@ struct Model { void (*DrawArm)(struct Entity* entity); float MaxScale, ShadowScale, NameScale; - struct Model* Next; + struct Model* next; }; #if 0 public CustomModel[] CustomModels = new CustomModel[256]; diff --git a/src/Particle.c b/src/Particle.c index 0f23c6470..3303e3445 100644 --- a/src/Particle.c +++ b/src/Particle.c @@ -49,9 +49,9 @@ void Particle_DoRender(Vector2* size, Vector3* pos, TextureRec* rec, PackedCol c } static void Particle_Reset(struct Particle* p, Vector3 pos, Vector3 velocity, float lifetime) { - p->LastPos = pos; p->NextPos = pos; - p->Velocity = velocity; - p->Lifetime = lifetime; + p->lastPos = pos; p->nextPos = pos; + p->velocity = velocity; + p->lifetime = lifetime; } static bool Particle_CanPass(BlockID block, bool throughLiquids) { @@ -82,24 +82,24 @@ static bool Particle_TestY(struct Particle* p, int y, bool topFace, bool through bool collideVer; if (y < 0) { - p->NextPos.Y = ENTITY_ADJUSTMENT; p->LastPos.Y = ENTITY_ADJUSTMENT; - p->Velocity = Vector3_Zero(); + p->nextPos.Y = ENTITY_ADJUSTMENT; p->lastPos.Y = ENTITY_ADJUSTMENT; + p->velocity = Vector3_Zero(); particle_hitTerrain = true; return false; } - block = Particle_GetBlock((int)p->NextPos.X, y, (int)p->NextPos.Z); + block = Particle_GetBlock((int)p->nextPos.X, y, (int)p->nextPos.Z); if (Particle_CanPass(block, throughLiquids)) return true; minBB = Blocks.MinBB[block]; maxBB = Blocks.MaxBB[block]; collideY = y + (topFace ? maxBB.Y : minBB.Y); - collideVer = topFace ? (p->NextPos.Y < collideY) : (p->NextPos.Y > collideY); + collideVer = topFace ? (p->nextPos.Y < collideY) : (p->nextPos.Y > collideY); - if (collideVer && Particle_CollideHor(&p->NextPos, block)) { + if (collideVer && Particle_CollideHor(&p->nextPos, block)) { float adjust = topFace ? ENTITY_ADJUSTMENT : -ENTITY_ADJUSTMENT; - p->LastPos.Y = collideY + adjust; - p->NextPos.Y = p->LastPos.Y; - p->Velocity = Vector3_Zero(); + p->lastPos.Y = collideY + adjust; + p->nextPos.Y = p->lastPos.Y; + p->velocity = Vector3_Zero(); particle_hitTerrain = true; return false; } @@ -112,39 +112,39 @@ static bool Particle_PhysicsTick(struct Particle* p, float gravity, bool through Vector3 velocity; int y, begY, endY; - p->LastPos = p->NextPos; - cur = Particle_GetBlock((int)p->NextPos.X, (int)p->NextPos.Y, (int)p->NextPos.Z); - minY = Math_Floor(p->NextPos.Y) + Blocks.MinBB[cur].Y; - maxY = Math_Floor(p->NextPos.Y) + Blocks.MaxBB[cur].Y; + p->lastPos = p->nextPos; + cur = Particle_GetBlock((int)p->nextPos.X, (int)p->nextPos.Y, (int)p->nextPos.Z); + minY = Math_Floor(p->nextPos.Y) + Blocks.MinBB[cur].Y; + maxY = Math_Floor(p->nextPos.Y) + Blocks.MaxBB[cur].Y; - if (!Particle_CanPass(cur, throughLiquids) && p->NextPos.Y >= minY - && p->NextPos.Y < maxY && Particle_CollideHor(&p->NextPos, cur)) { + if (!Particle_CanPass(cur, throughLiquids) && p->nextPos.Y >= minY + && p->nextPos.Y < maxY && Particle_CollideHor(&p->nextPos, cur)) { return true; } - p->Velocity.Y -= gravity * (float)delta; - begY = Math_Floor(p->NextPos.Y); + p->velocity.Y -= gravity * (float)delta; + begY = Math_Floor(p->nextPos.Y); - Vector3_Mul1(&velocity, &p->Velocity, (float)delta * 3.0f); - Vector3_Add(&p->NextPos, &p->NextPos, &velocity); - endY = Math_Floor(p->NextPos.Y); + Vector3_Mul1(&velocity, &p->velocity, (float)delta * 3.0f); + Vector3_Add(&p->nextPos, &p->nextPos, &velocity); + endY = Math_Floor(p->nextPos.Y); - if (p->Velocity.Y > 0.0f) { + if (p->velocity.Y > 0.0f) { /* don't test block we are already in */ for (y = begY + 1; y <= endY && Particle_TestY(p, y, false, throughLiquids); y++) {} } else { for (y = begY; y >= endY && Particle_TestY(p, y, true, throughLiquids); y--) {} } - p->Lifetime -= (float)delta; - return p->Lifetime < 0.0f; + p->lifetime -= (float)delta; + return p->lifetime < 0.0f; } /*########################################################################################################################* *-------------------------------------------------------Rain particle-----------------------------------------------------* *#########################################################################################################################*/ -struct RainParticle { struct Particle Base; }; +struct RainParticle { struct Particle base; }; static struct RainParticle rain_Particles[PARTICLES_MAX]; static int rain_count; @@ -152,7 +152,7 @@ static TextureRec rain_rec = { 2.0f/128.0f, 14.0f/128.0f, 5.0f/128.0f, 16.0f/128 static bool RainParticle_Tick(struct RainParticle* p, double delta) { particle_hitTerrain = false; - return Particle_PhysicsTick(&p->Base, 3.5f, false, delta) || particle_hitTerrain; + return Particle_PhysicsTick(&p->base, 3.5f, false, delta) || particle_hitTerrain; } static void RainParticle_Render(struct RainParticle* p, float t, VertexP3fT2fC4b* vertices) { @@ -161,8 +161,8 @@ static void RainParticle_Render(struct RainParticle* p, float t, VertexP3fT2fC4b PackedCol col; int x, y, z; - Vector3_Lerp(&pos, &p->Base.LastPos, &p->Base.NextPos, t); - size.X = (float)p->Base.Size * 0.015625f; size.Y = size.X; + Vector3_Lerp(&pos, &p->base.lastPos, &p->base.nextPos, t); + size.X = (float)p->base.size * 0.015625f; size.Y = size.X; x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z); col = World_Contains(x, y, z) ? Lighting_Col(x, y, z) : Env.SunCol; @@ -210,10 +210,10 @@ static void Rain_Tick(double delta) { *------------------------------------------------------Terrain particle---------------------------------------------------* *#########################################################################################################################*/ struct TerrainParticle { - struct Particle Base; - TextureRec Rec; - TextureLoc TexLoc; - BlockID Block; + struct Particle base; + TextureRec rec; + TextureLoc texLoc; + BlockID block; }; static struct TerrainParticle terrain_particles[PARTICLES_MAX]; @@ -222,7 +222,7 @@ static uint16_t terrain_1DCount[ATLAS1D_MAX_ATLASES]; static uint16_t terrain_1DIndices[ATLAS1D_MAX_ATLASES]; static bool TerrainParticle_Tick(struct TerrainParticle* p, double delta) { - return Particle_PhysicsTick(&p->Base, 5.4f, true, delta); + return Particle_PhysicsTick(&p->base, 5.4f, true, delta); } static void TerrainParticle_Render(struct TerrainParticle* p, float t, VertexP3fT2fC4b* vertices) { @@ -231,21 +231,21 @@ static void TerrainParticle_Render(struct TerrainParticle* p, float t, VertexP3f Vector2 size; int x, y, z; - Vector3_Lerp(&pos, &p->Base.LastPos, &p->Base.NextPos, t); - size.X = (float)p->Base.Size * 0.015625f; size.Y = size.X; + Vector3_Lerp(&pos, &p->base.lastPos, &p->base.nextPos, t); + size.X = (float)p->base.size * 0.015625f; size.Y = size.X; - if (!Blocks.FullBright[p->Block]) { + if (!Blocks.FullBright[p->block]) { x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z); col = World_Contains(x, y, z) ? Lighting_Col_XSide(x, y, z) : Env.SunXSide; } - if (Blocks.Tinted[p->Block]) { - PackedCol tintCol = Blocks.FogCol[p->Block]; + if (Blocks.Tinted[p->block]) { + PackedCol tintCol = Blocks.FogCol[p->block]; col.R = (uint8_t)(col.R * tintCol.R / 255); col.G = (uint8_t)(col.G * tintCol.G / 255); col.B = (uint8_t)(col.B * tintCol.B / 255); } - Particle_DoRender(&size, &pos, &p->Rec, col, vertices); + Particle_DoRender(&size, &pos, &p->rec, col, vertices); } static void Terrain_Update1DCounts(void) { @@ -256,7 +256,7 @@ static void Terrain_Update1DCounts(void) { terrain_1DIndices[i] = 0; } for (i = 0; i < terrain_count; i++) { - index = Atlas1D_Index(terrain_particles[i].TexLoc); + index = Atlas1D_Index(terrain_particles[i].texLoc); terrain_1DCount[index] += 4; } for (i = 1; i < Atlas1D.Count; i++) { @@ -273,7 +273,7 @@ static void Terrain_Render(float t) { Terrain_Update1DCounts(); for (i = 0; i < terrain_count; i++) { - index = Atlas1D_Index(terrain_particles[i].TexLoc); + index = Atlas1D_Index(terrain_particles[i].texLoc); ptr = &vertices[terrain_1DIndices[index]]; TerrainParticle_Render(&terrain_particles[i], t, ptr); @@ -414,13 +414,13 @@ void Particles_BreakBlockEffect(Vector3I coords, BlockID old, BlockID now) { life = 0.3f + Random_Float(&rnd) * 1.2f; Vector3_Add(&pos, &origin, &cell); - Particle_Reset(&p->Base, pos, velocity, life); + Particle_Reset(&p->base, pos, velocity, life); - p->Rec = rec; - p->TexLoc = loc; - p->Block = old; + p->rec = rec; + p->texLoc = loc; + p->block = old; type = Random_Range(&rnd, 0, 30); - p->Base.Size = (uint8_t)(type >= 28 ? 12 : (type >= 25 ? 10 : 8)); + p->base.size = (uint8_t)(type >= 28 ? 12 : (type >= 25 ? 10 : 8)); } } } @@ -445,10 +445,10 @@ void Particles_RainSnowEffect(Vector3 pos) { p = &rain_Particles[rain_count++]; Vector3_Add(&pos, &origin, &offset); - Particle_Reset(&p->Base, pos, velocity, 40.0f); + Particle_Reset(&p->base, pos, velocity, 40.0f); type = Random_Range(&rnd, 0, 30); - p->Base.Size = (uint8_t)(type >= 28 ? 2 : (type >= 25 ? 4 : 3)); + p->base.size = (uint8_t)(type >= 28 ? 2 : (type >= 25 ? 4 : 3)); } } diff --git a/src/Particle.h b/src/Particle.h index d0b0039f1..36079d543 100644 --- a/src/Particle.h +++ b/src/Particle.h @@ -11,10 +11,10 @@ struct ScheduledTask; extern struct IGameComponent Particles_Component; struct Particle { - Vector3 Velocity; - float Lifetime; - Vector3 LastPos, NextPos; - uint8_t Size; + Vector3 velocity; + float lifetime; + Vector3 lastPos, nextPos; + uint8_t size; }; /* http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/ */ diff --git a/src/Resources.c b/src/Resources.c index 9375e28aa..c37acb52d 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -596,11 +596,11 @@ static void SoundPatcher_FixupHeader(struct Stream* s, struct VorbisState* ctx) Stream_SetU32_BE(&header[12], WAV_FourCC('f','m','t',' ')); Stream_SetU32_LE(&header[16], 16); /* fmt chunk size */ Stream_SetU16_LE(&header[20], 1); /* PCM audio format */ - Stream_SetU16_LE(&header[22], ctx->Channels); - Stream_SetU32_LE(&header[24], ctx->SampleRate); + Stream_SetU16_LE(&header[22], ctx->channels); + Stream_SetU32_LE(&header[24], ctx->sampleRate); - Stream_SetU32_LE(&header[28], ctx->SampleRate * ctx->Channels * 2); /* byte rate */ - Stream_SetU16_LE(&header[32], ctx->Channels * 2); /* block align */ + Stream_SetU32_LE(&header[28], ctx->sampleRate * ctx->channels * 2); /* byte rate */ + Stream_SetU16_LE(&header[32], ctx->channels * 2); /* block align */ Stream_SetU16_LE(&header[34], 16); /* bits per sample */ Stream_SetU32_BE(&header[36], WAV_FourCC('d','a','t','a')); Stream_SetU32_LE(&header[40], length - sizeof(header)); @@ -621,7 +621,7 @@ static void SoundPatcher_DecodeAudio(struct Stream* s, struct VorbisState* ctx) res = Vorbis_DecodeHeaders(ctx); if (res) { Logger_Warn(res, "decoding .ogg header"); return; } - samples = (int16_t*)Mem_Alloc(ctx->BlockSizes[1] * ctx->Channels, 2, ".ogg samples"); + samples = (int16_t*)Mem_Alloc(ctx->blockSizes[1] * ctx->channels, 2, ".ogg samples"); for (;;) { res = Vorbis_DecodeFrame(ctx); @@ -651,7 +651,7 @@ static void SoundPatcher_Save(struct ResourceSound* sound, struct HttpRequest* r if (res) { Logger_Warn(res, "creating .wav file"); return; } Ogg_MakeStream(&ogg, buffer, &src); - ctx.Source = &ogg; + ctx.source = &ogg; SoundPatcher_DecodeAudio(&dst, &ctx); SoundPatcher_FixupHeader(&dst, &ctx); diff --git a/src/Vorbis.c b/src/Vorbis.c index 14056eeb8..b1a6678af 100644 --- a/src/Vorbis.c +++ b/src/Vorbis.c @@ -109,7 +109,7 @@ static uint32_t Vorbis_ReadBits(struct VorbisState* ctx, uint32_t bitsCount) { ReturnCode res; while (ctx->NumBits < bitsCount) { - res = ctx->Source->ReadU8(ctx->Source, &portion); + res = ctx->source->ReadU8(ctx->source, &portion); if (res) { Logger_Abort2(res, "Failed to read byte for vorbis"); } Vorbis_PushByte(ctx, portion); } @@ -123,7 +123,7 @@ static ReturnCode Vorbis_TryReadBits(struct VorbisState* ctx, uint32_t bitsCount ReturnCode res; while (ctx->NumBits < bitsCount) { - res = ctx->Source->ReadU8(ctx->Source, &portion); + res = ctx->source->ReadU8(ctx->source, &portion); if (res) return res; Vorbis_PushByte(ctx, portion); } @@ -138,7 +138,7 @@ static uint32_t Vorbis_ReadBit(struct VorbisState* ctx) { ReturnCode res; if (!ctx->NumBits) { - res = ctx->Source->ReadU8(ctx->Source, &portion); + res = ctx->source->ReadU8(ctx->source, &portion); if (res) { Logger_Abort2(res, "Failed to read byte for vorbis"); } Vorbis_PushByte(ctx, portion); } @@ -552,7 +552,7 @@ static bool Floor_DecodeFrame(struct VorbisState* ctx, struct Floor* f, int ch) cval = 0; if (cbits) { bookNum = f->ClassMasterbooks[klass]; - cval = Codebook_DecodeScalar(ctx, &ctx->Codebooks[bookNum]); + cval = Codebook_DecodeScalar(ctx, &ctx->codebooks[bookNum]); } for (j = 0; j < cdim; j++) { @@ -560,7 +560,7 @@ static bool Floor_DecodeFrame(struct VorbisState* ctx, struct Floor* f, int ch) cval >>= cbits; if (bookNum >= 0) { - yList[idx + j] = Codebook_DecodeScalar(ctx, &ctx->Codebooks[bookNum]); + yList[idx + j] = Codebook_DecodeScalar(ctx, &ctx->codebooks[bookNum]); } else { yList[idx + j] = 0; } @@ -643,7 +643,7 @@ static void Floor_Synthesis(struct VorbisState* ctx, struct Floor* f, int ch) { /* amplitude value synthesis */ yList = f->YList[ch]; - data = ctx->CurOutput[ch]; + data = ctx->curOutput[ch]; Step2[0] = true; Step2[1] = true; @@ -700,15 +700,15 @@ static void Floor_Synthesis(struct VorbisState* ctx, struct Floor* f, int ch) { hx = f->XList[i]; hy = YFinal[i] * f->Multiplier; if (lx < hx) { - Floor_RenderLine(lx, ly, min(hx, ctx->DataSize), hy, data); + Floor_RenderLine(lx, ly, min(hx, ctx->dataSize), hy, data); } lx = hx; ly = hy; } /* fill remainder of floor with a flat line */ /* TODO: Is this right? should hy be 0, if Step2 is false for all */ - if (hx >= ctx->DataSize) return; - lx = hx; hx = ctx->DataSize; + if (hx >= ctx->dataSize) return; + lx = hx; hx = ctx->dataSize; value = floor1_inverse_dB_table[hy]; for (; lx < hx; lx++) { data[lx] *= value; } @@ -778,14 +778,14 @@ static void Residue_DecodeCore(struct VorbisState* ctx, struct Residue* r, uint3 /* per spec, ensure decoded bounds are actually in size */ residueBeg = min(r->Begin, size); residueEnd = min(r->End, size); - classbook = &ctx->Codebooks[r->Classbook]; + classbook = &ctx->codebooks[r->Classbook]; classwordsPerCodeword = classbook->Dimensions; nToRead = residueEnd - residueBeg; partitionsToRead = nToRead / r->PartitionSize; /* first half of temp array is used by residue type 2 for storing temp interleaved data */ - classifications_raw = ((uint8_t*)ctx->Temp) + (ctx->DataSize * ctx->Channels * 5); + classifications_raw = ((uint8_t*)ctx->temp) + (ctx->dataSize * ctx->channels * 5); for (i = 0; i < ch; i++) { /* add a bit of space in case classwordsPerCodeword is > partitionsToRead*/ classifications[i] = classifications_raw + i * (partitionsToRead + 64); @@ -819,7 +819,7 @@ static void Residue_DecodeCore(struct VorbisState* ctx, struct Residue* r, uint3 offset = residueBeg + partitionCount * r->PartitionSize; v = data[j] + offset; - c = &ctx->Codebooks[book]; + c = &ctx->codebooks[book]; if (r->Type == 0) { int step = r->PartitionSize / c->Dimensions; @@ -839,7 +839,7 @@ static void Residue_DecodeCore(struct VorbisState* ctx, struct Residue* r, uint3 } static void Residue_DecodeFrame(struct VorbisState* ctx, struct Residue* r, int ch, bool* doNotDecode, float** data) { - uint32_t size = ctx->DataSize; + uint32_t size = ctx->dataSize; float* interleaved; int i, j; @@ -853,10 +853,10 @@ static void Residue_DecodeFrame(struct VorbisState* ctx, struct Residue* r, int if (!decodeAny) return; decodeAny = false; /* because DecodeCore expects this to be 'false' for 'do not decode' */ - interleaved = ctx->Temp; + interleaved = ctx->temp; /* TODO: avoid using ctx->temp and deinterleaving at all */ /* TODO: avoid setting memory to 0 here */ - Mem_Set(interleaved, 0, ctx->DataSize * ctx->Channels * sizeof(float)); + Mem_Set(interleaved, 0, ctx->dataSize * ctx->channels * sizeof(float)); Residue_DecodeCore(ctx, r, size * ch, 1, &decodeAny, &interleaved); /* deinterleave type 2 output */ @@ -898,7 +898,7 @@ static ReturnCode Mapping_DecodeSetup(struct VorbisState* ctx, struct Mapping* m if (Vorbis_ReadBit(ctx)) { couplingSteps = Vorbis_ReadBits(ctx, 8) + 1; /* TODO: How big can couplingSteps ever really get in practice? */ - couplingBits = iLog(ctx->Channels - 1); + couplingBits = iLog(ctx->channels - 1); for (i = 0; i < couplingSteps; i++) { m->Magnitude[i] = Vorbis_ReadBits(ctx, couplingBits); @@ -913,11 +913,11 @@ static ReturnCode Mapping_DecodeSetup(struct VorbisState* ctx, struct Mapping* m m->CouplingSteps = couplingSteps; if (submaps > 1) { - for (i = 0; i < ctx->Channels; i++) { + for (i = 0; i < ctx->channels; i++) { m->Mux[i] = Vorbis_ReadBits(ctx, 4); } } else { - for (i = 0; i < ctx->Channels; i++) { + for (i = 0; i < ctx->channels; i++) { m->Mux[i] = 0; } } @@ -959,11 +959,11 @@ static uint32_t Vorbis_ReverseBits(uint32_t v) { void imdct_init(struct imdct_state* state, int n) { int k, k2, n4 = n >> 2, n8 = n >> 3, log2_n; - float *A = state->A, *B = state->B, *C = state->C; + float *A = state->a, *B = state->b, *C = state->c; uint32_t* reversed; log2_n = Math_Log2(n); - reversed = state->Reversed; + reversed = state->reversed; state->n = n; state->log2_n = log2_n; /* setup twiddle factors */ @@ -991,7 +991,7 @@ void imdct_calc(float* in, float* out, struct imdct_state* state) { /* Optimised algorithm from "The use of multirate filter banks for coding of high quality digital audio" */ /* Uses a few fixes for the paper noted at http://www.nothings.org/stb_vorbis/mdct_01.txt */ - float *A = state->A, *B = state->B, *C = state->C; + float *A = state->a, *B = state->b, *C = state->c; float u[VORBIS_MAX_BLOCK_SIZE]; float w[VORBIS_MAX_BLOCK_SIZE]; @@ -1043,7 +1043,7 @@ void imdct_calc(float* in, float* out, struct imdct_state* state) { } /* step 4, step 5, step 6, step 7, step 8, output */ - reversed = state->Reversed; + reversed = state->reversed; for (k = 0, k2 = 0, k8 = 0; k < n8; k++, k2 += 2, k8 += 8) { uint32_t j = reversed[k], j8 = j << 3; e_1 = u[n-j8-1]; e_2 = u[n-j8-3]; @@ -1109,17 +1109,17 @@ static void Vorbis_CalcWindow(struct VorbisWindow* window, int blockSize) { void Vorbis_Free(struct VorbisState* ctx) { int i; - for (i = 0; i < ctx->NumCodebooks; i++) { - Codebook_Free(&ctx->Codebooks[i]); + for (i = 0; i < ctx->numCodebooks; i++) { + Codebook_Free(&ctx->codebooks[i]); } - Mem_Free(ctx->Codebooks); - Mem_Free(ctx->Floors); - Mem_Free(ctx->Residues); - Mem_Free(ctx->Mappings); - Mem_Free(ctx->Modes); - Mem_Free(ctx->WindowRaw); - Mem_Free(ctx->Temp); + Mem_Free(ctx->codebooks); + Mem_Free(ctx->floors); + Mem_Free(ctx->residues); + Mem_Free(ctx->mappings); + Mem_Free(ctx->modes); + Mem_Free(ctx->windowRaw); + Mem_Free(ctx->temp); } static bool Vorbis_ValidBlockSize(uint32_t size) { @@ -1131,7 +1131,7 @@ static ReturnCode Vorbis_CheckHeader(struct VorbisState* ctx, uint8_t type) { bool OK; ReturnCode res; - if ((res = Stream_Read(ctx->Source, header, sizeof(header)))) return res; + if ((res = Stream_Read(ctx->source, header, sizeof(header)))) return res; if (header[0] != type) return VORBIS_ERR_WRONG_HEADER; OK = @@ -1145,21 +1145,21 @@ static ReturnCode Vorbis_DecodeIdentifier(struct VorbisState* ctx) { uint32_t version; ReturnCode res; - if ((res = Stream_Read(ctx->Source, header, sizeof(header)))) return res; + if ((res = Stream_Read(ctx->source, header, sizeof(header)))) return res; version = Stream_GetU32_LE(&header[0]); if (version != 0) return VORBIS_ERR_VERSION; - ctx->Channels = header[4]; - ctx->SampleRate = Stream_GetU32_LE(&header[5]); + ctx->channels = header[4]; + ctx->sampleRate = Stream_GetU32_LE(&header[5]); /* (12) bitrate_maximum, nominal, minimum */ - ctx->BlockSizes[0] = 1 << (header[21] & 0xF); - ctx->BlockSizes[1] = 1 << (header[21] >> 4); + ctx->blockSizes[0] = 1 << (header[21] & 0xF); + ctx->blockSizes[1] = 1 << (header[21] >> 4); - if (!Vorbis_ValidBlockSize(ctx->BlockSizes[0])) return VORBIS_ERR_BLOCKSIZE; - if (!Vorbis_ValidBlockSize(ctx->BlockSizes[1])) return VORBIS_ERR_BLOCKSIZE; - if (ctx->BlockSizes[0] > ctx->BlockSizes[1]) return VORBIS_ERR_BLOCKSIZE; + if (!Vorbis_ValidBlockSize(ctx->blockSizes[0])) return VORBIS_ERR_BLOCKSIZE; + if (!Vorbis_ValidBlockSize(ctx->blockSizes[1])) return VORBIS_ERR_BLOCKSIZE; + if (ctx->blockSizes[0] > ctx->blockSizes[1]) return VORBIS_ERR_BLOCKSIZE; - if (ctx->Channels == 0 || ctx->Channels > VORBIS_MAX_CHANS) return VORBIS_ERR_CHANS; + if (ctx->channels == 0 || ctx->channels > VORBIS_MAX_CHANS) return VORBIS_ERR_CHANS; /* check framing flag */ return (header[22] & 1) ? 0 : VORBIS_ERR_FRAMING; } @@ -1168,7 +1168,7 @@ static ReturnCode Vorbis_DecodeComments(struct VorbisState* ctx) { uint32_t i, len, comments; uint8_t flag; ReturnCode res; - struct Stream* stream = ctx->Source; + struct Stream* stream = ctx->source; /* vendor name, followed by comments */ if ((res = Stream_ReadU32_LE(stream, &len))) return res; @@ -1192,12 +1192,12 @@ static ReturnCode Vorbis_DecodeSetup(struct VorbisState* ctx) { ReturnCode res; count = Vorbis_ReadBits(ctx, 8) + 1; - ctx->Codebooks = (struct Codebook*)Mem_Alloc(count, sizeof(struct Codebook), "vorbis codebooks"); + ctx->codebooks = (struct Codebook*)Mem_Alloc(count, sizeof(struct Codebook), "vorbis codebooks"); for (i = 0; i < count; i++) { - res = Codebook_DecodeSetup(ctx, &ctx->Codebooks[i]); + res = Codebook_DecodeSetup(ctx, &ctx->codebooks[i]); if (res) return res; } - ctx->NumCodebooks = count; + ctx->numCodebooks = count; count = Vorbis_ReadBits(ctx, 6) + 1; for (i = 0; i < count; i++) { @@ -1206,40 +1206,40 @@ static ReturnCode Vorbis_DecodeSetup(struct VorbisState* ctx) { } count = Vorbis_ReadBits(ctx, 6) + 1; - ctx->Floors = (struct Floor*)Mem_Alloc(count, sizeof(struct Floor), "vorbis floors"); + ctx->floors = (struct Floor*)Mem_Alloc(count, sizeof(struct Floor), "vorbis floors"); for (i = 0; i < count; i++) { int floor = Vorbis_ReadBits(ctx, 16); if (floor != 1) return VORBIS_ERR_FLOOR_TYPE; - res = Floor_DecodeSetup(ctx, &ctx->Floors[i]); + res = Floor_DecodeSetup(ctx, &ctx->floors[i]); if (res) return res; } count = Vorbis_ReadBits(ctx, 6) + 1; - ctx->Residues = (struct Residue*)Mem_Alloc(count, sizeof(struct Residue), "vorbis residues"); + ctx->residues = (struct Residue*)Mem_Alloc(count, sizeof(struct Residue), "vorbis residues"); for (i = 0; i < count; i++) { int residue = Vorbis_ReadBits(ctx, 16); if (residue > 2) return VORBIS_ERR_FLOOR_TYPE; - res = Residue_DecodeSetup(ctx, &ctx->Residues[i], residue); + res = Residue_DecodeSetup(ctx, &ctx->residues[i], residue); if (res) return res; } count = Vorbis_ReadBits(ctx, 6) + 1; - ctx->Mappings = (struct Mapping*)Mem_Alloc(count, sizeof(struct Mapping), "vorbis mappings"); + ctx->mappings = (struct Mapping*)Mem_Alloc(count, sizeof(struct Mapping), "vorbis mappings"); for (i = 0; i < count; i++) { int mapping = Vorbis_ReadBits(ctx, 16); if (mapping != 0) return VORBIS_ERR_MAPPING_TYPE; - res = Mapping_DecodeSetup(ctx, &ctx->Mappings[i]); + res = Mapping_DecodeSetup(ctx, &ctx->mappings[i]); if (res) return res; } count = Vorbis_ReadBits(ctx, 6) + 1; - ctx->Modes = (struct Mode*)Mem_Alloc(count, sizeof(struct Mode), "vorbis modes"); + ctx->modes = (struct Mode*)Mem_Alloc(count, sizeof(struct Mode), "vorbis modes"); for (i = 0; i < count; i++) { - res = Mode_DecodeSetup(ctx, &ctx->Modes[i]); + res = Mode_DecodeSetup(ctx, &ctx->modes[i]); if (res) return res; } - ctx->ModeNumBits = iLog(count - 1); /* ilog([vorbis_mode_count]-1) bits */ + ctx->modeNumBits = iLog(count - 1); /* ilog([vorbis_mode_count]-1) bits */ framing = Vorbis_ReadBit(ctx); Vorbis_AlignBits(ctx); /* check framing flag */ @@ -1258,21 +1258,21 @@ ReturnCode Vorbis_DecodeHeaders(struct VorbisState* ctx) { if ((res = Vorbis_DecodeSetup(ctx))) return res; /* window calculations can be pre-computed here */ - count = ctx->BlockSizes[0] + ctx->BlockSizes[1]; - ctx->WindowRaw = (float*)Mem_Alloc(count, sizeof(float), "Vorbis windows"); - ctx->Windows[0].Prev = ctx->WindowRaw; - ctx->Windows[1].Prev = ctx->WindowRaw + ctx->BlockSizes[0]; + count = ctx->blockSizes[0] + ctx->blockSizes[1]; + ctx->windowRaw = (float*)Mem_Alloc(count, sizeof(float), "Vorbis windows"); + ctx->windows[0].Prev = ctx->windowRaw; + ctx->windows[1].Prev = ctx->windowRaw + ctx->blockSizes[0]; - Vorbis_CalcWindow(&ctx->Windows[0], ctx->BlockSizes[0]); - Vorbis_CalcWindow(&ctx->Windows[1], ctx->BlockSizes[1]); + Vorbis_CalcWindow(&ctx->windows[0], ctx->blockSizes[0]); + Vorbis_CalcWindow(&ctx->windows[1], ctx->blockSizes[1]); - count = ctx->Channels * ctx->BlockSizes[1]; - ctx->Temp = (float*)Mem_AllocCleared(count * 3, sizeof(float), "Vorbis values"); - ctx->Values[0] = ctx->Temp + count; - ctx->Values[1] = ctx->Temp + count * 2; + count = ctx->channels * ctx->blockSizes[1]; + ctx->temp = (float*)Mem_AllocCleared(count * 3, sizeof(float), "Vorbis values"); + ctx->values[0] = ctx->temp + count; + ctx->values[1] = ctx->temp + count * 2; - imdct_init(&ctx->imdct[0], ctx->BlockSizes[0]); - imdct_init(&ctx->imdct[1], ctx->BlockSizes[1]); + imdct_init(&ctx->imdct[0], ctx->blockSizes[0]); + imdct_init(&ctx->imdct[1], ctx->blockSizes[1]); return 0; } @@ -1310,30 +1310,30 @@ ReturnCode Vorbis_DecodeFrame(struct VorbisState* ctx) { if (res) return res; if (packetType) return VORBIS_ERR_FRAME_TYPE; - modeIdx = Vorbis_ReadBits(ctx, ctx->ModeNumBits); - mode = &ctx->Modes[modeIdx]; - mapping = &ctx->Mappings[mode->MappingIdx]; + modeIdx = Vorbis_ReadBits(ctx, ctx->modeNumBits); + mode = &ctx->modes[modeIdx]; + mapping = &ctx->mappings[mode->MappingIdx]; /* decode window shape */ - ctx->CurBlockSize = ctx->BlockSizes[mode->BlockSizeFlag]; - ctx->DataSize = ctx->CurBlockSize / 2; + ctx->curBlockSize = ctx->blockSizes[mode->BlockSizeFlag]; + ctx->dataSize = ctx->curBlockSize / 2; /* long window lapping flags - we don't care about them though */ if (mode->BlockSizeFlag) { Vorbis_ReadBits(ctx, 2); } /* TODO: do we just SkipBits here */ /* swap prev and cur outputs around */ - tmp = ctx->Values[1]; ctx->Values[1] = ctx->Values[0]; ctx->Values[0] = tmp; - Mem_Set(ctx->Values[0], 0, ctx->Channels * ctx->CurBlockSize); + tmp = ctx->values[1]; ctx->values[1] = ctx->values[0]; ctx->values[0] = tmp; + Mem_Set(ctx->values[0], 0, ctx->channels * ctx->curBlockSize); - for (i = 0; i < ctx->Channels; i++) { - ctx->CurOutput[i] = ctx->Values[0] + i * ctx->CurBlockSize; - ctx->PrevOutput[i] = ctx->Values[1] + i * ctx->PrevBlockSize; + for (i = 0; i < ctx->channels; i++) { + ctx->curOutput[i] = ctx->values[0] + i * ctx->curBlockSize; + ctx->prevOutput[i] = ctx->values[1] + i * ctx->prevBlockSize; } /* decode floor */ - for (i = 0; i < ctx->Channels; i++) { + for (i = 0; i < ctx->channels; i++) { submap = mapping->Mux[i]; floorIdx = mapping->FloorIdx[submap]; - hasFloor[i] = Floor_DecodeFrame(ctx, &ctx->Floors[floorIdx], i); + hasFloor[i] = Floor_DecodeFrame(ctx, &ctx->floors[floorIdx], i); hasResidue[i] = hasFloor[i]; } @@ -1351,24 +1351,24 @@ ReturnCode Vorbis_DecodeFrame(struct VorbisState* ctx) { for (i = 0; i < mapping->Submaps; i++) { ch = 0; /* map residue data to actual channel data */ - for (j = 0; j < ctx->Channels; j++) { + for (j = 0; j < ctx->channels; j++) { if (mapping->Mux[j] != i) continue; doNotDecode[ch] = !hasResidue[j]; - data[ch] = ctx->CurOutput[j]; + data[ch] = ctx->curOutput[j]; ch++; } residueIdx = mapping->FloorIdx[i]; - Residue_DecodeFrame(ctx, &ctx->Residues[residueIdx], ch, doNotDecode, data); + Residue_DecodeFrame(ctx, &ctx->residues[residueIdx], ch, doNotDecode, data); } /* inverse coupling */ for (i = mapping->CouplingSteps - 1; i >= 0; i--) { - magValues = ctx->CurOutput[mapping->Magnitude[i]]; - angValues = ctx->CurOutput[mapping->Angle[i]]; + magValues = ctx->curOutput[mapping->Magnitude[i]]; + angValues = ctx->curOutput[mapping->Angle[i]]; - for (j = 0; j < ctx->DataSize; j++) { + for (j = 0; j < ctx->dataSize; j++) { m = magValues[j]; a = angValues[j]; if (m > 0.0f) { @@ -1388,21 +1388,21 @@ ReturnCode Vorbis_DecodeFrame(struct VorbisState* ctx) { } /* compute dot product of floor and residue, producing audio spectrum vector */ - for (i = 0; i < ctx->Channels; i++) { + for (i = 0; i < ctx->channels; i++) { if (!hasFloor[i]) continue; submap = mapping->Mux[i]; floorIdx = mapping->FloorIdx[submap]; - Floor_Synthesis(ctx, &ctx->Floors[floorIdx], i); + Floor_Synthesis(ctx, &ctx->floors[floorIdx], i); } /* inverse monolithic transform of audio spectrum vector */ - for (i = 0; i < ctx->Channels; i++) { - tmp = ctx->CurOutput[i]; + for (i = 0; i < ctx->channels; i++) { + tmp = ctx->curOutput[i]; if (!hasFloor[i]) { /* TODO: Do we actually need to zero data here (residue type 2 maybe) */ - Mem_Set(tmp, 0, ctx->CurBlockSize * sizeof(float)); + Mem_Set(tmp, 0, ctx->curBlockSize * sizeof(float)); } else { imdct_calc(tmp, tmp, &ctx->imdct[mode->BlockSizeFlag]); /* defer windowing until output */ @@ -1425,15 +1425,15 @@ int Vorbis_OutputFrame(struct VorbisState* ctx, int16_t* data) { int i, ch; /* first frame decoded has no data */ - if (ctx->PrevBlockSize == 0) { - ctx->PrevBlockSize = ctx->CurBlockSize; + if (ctx->prevBlockSize == 0) { + ctx->prevBlockSize = ctx->curBlockSize; return 0; } /* data returned is from centre of previous block to centre of current block */ /* data is aligned, such that 3/4 of prev block is aligned to 1/4 of cur block */ - curQrtr = ctx->CurBlockSize / 4; - prevQrtr = ctx->PrevBlockSize / 4; + curQrtr = ctx->curBlockSize / 4; + prevQrtr = ctx->prevBlockSize / 4; overlapQtr = min(curQrtr, prevQrtr); /* So for example, consider a short block overlapping with a long block @@ -1448,14 +1448,14 @@ int Vorbis_OutputFrame(struct VorbisState* ctx, int16_t* data) { curOffset = curQrtr - overlapQtr; prevOffset = prevQrtr - overlapQtr; - for (i = 0; i < ctx->Channels; i++) { - prev[i] = ctx->PrevOutput[i] + (prevQrtr * 2); - cur[i] = ctx->CurOutput[i]; + for (i = 0; i < ctx->channels; i++) { + prev[i] = ctx->prevOutput[i] + (prevQrtr * 2); + cur[i] = ctx->curOutput[i]; } /* for long prev and short cur block, there will be non-overlapped data before */ for (i = 0; i < prevOffset; i++) { - for (ch = 0; ch < ctx->Channels; ch++) { + for (ch = 0; ch < ctx->channels; ch++) { sample = prev[ch][i]; Math_Clamp(sample, -1.0f, 1.0f); *data++ = (int16_t)(sample * 32767); @@ -1463,17 +1463,17 @@ int Vorbis_OutputFrame(struct VorbisState* ctx, int16_t* data) { } /* adjust pointers to start at 0 for overlapping */ - for (i = 0; i < ctx->Channels; i++) { + for (i = 0; i < ctx->channels; i++) { prev[i] += prevOffset; cur[i] += curOffset; } overlapSize = overlapQtr * 2; - window = ctx->Windows[(overlapQtr * 4) == ctx->BlockSizes[1]]; + window = ctx->windows[(overlapQtr * 4) == ctx->blockSizes[1]]; /* overlap and add data */ /* also perform windowing here */ for (i = 0; i < overlapSize; i++) { - for (ch = 0; ch < ctx->Channels; ch++) { + for (ch = 0; ch < ctx->channels; ch++) { sample = prev[ch][i] * window.Prev[i] + cur[ch][i] * window.Cur[i]; Math_Clamp(sample, -1.0f, 1.0f); *data++ = (int16_t)(sample * 32767); @@ -1481,15 +1481,15 @@ int Vorbis_OutputFrame(struct VorbisState* ctx, int16_t* data) { } /* for long cur and short prev block, there will be non-overlapped data after */ - for (i = 0; i < ctx->Channels; i++) { cur[i] += overlapSize; } + for (i = 0; i < ctx->channels; i++) { cur[i] += overlapSize; } for (i = 0; i < curOffset; i++) { - for (ch = 0; ch < ctx->Channels; ch++) { + for (ch = 0; ch < ctx->channels; ch++) { sample = cur[ch][i]; Math_Clamp(sample, -1.0f, 1.0f); *data++ = (int16_t)(sample * 32767); } } - ctx->PrevBlockSize = ctx->CurBlockSize; - return (prevQrtr + curQrtr) * ctx->Channels; + ctx->prevBlockSize = ctx->curBlockSize; + return (prevQrtr + curQrtr) * ctx->channels; } diff --git a/src/Vorbis.h b/src/Vorbis.h index bad74ae9b..745ea8a58 100644 --- a/src/Vorbis.h +++ b/src/Vorbis.h @@ -15,34 +15,34 @@ struct Codebook; struct Floor; struct Residue; struct Mapping; struct Mode; struct imdct_state { int n, log2_n; - float A[VORBIS_MAX_BLOCK_SIZE / 2]; - float B[VORBIS_MAX_BLOCK_SIZE / 2]; - float C[VORBIS_MAX_BLOCK_SIZE / 4]; - uint32_t Reversed[VORBIS_MAX_BLOCK_SIZE / 8]; + float a[VORBIS_MAX_BLOCK_SIZE / 2]; + float b[VORBIS_MAX_BLOCK_SIZE / 2]; + float c[VORBIS_MAX_BLOCK_SIZE / 4]; + uint32_t reversed[VORBIS_MAX_BLOCK_SIZE / 8]; }; struct VorbisWindow { float* Prev; float* Cur; }; struct VorbisState { uint32_t Bits; /* Holds bits across byte boundaries*/ uint32_t NumBits; /* Number of bits in Bits buffer*/ - struct Stream* Source; /* Source for filling Input buffer */ + struct Stream* source; /* Source for filling Input buffer */ - uint8_t Channels, ModeNumBits; - uint16_t CurBlockSize, PrevBlockSize, DataSize, NumCodebooks; - int SampleRate; int BlockSizes[2]; - float* Temp; /* temp array reused in places */ - float* Values[2]; /* swapped each frame */ - float* PrevOutput[VORBIS_MAX_CHANS]; - float* CurOutput[VORBIS_MAX_CHANS]; + uint8_t channels, modeNumBits; + uint16_t curBlockSize, prevBlockSize, dataSize, numCodebooks; + int sampleRate; int blockSizes[2]; + float* temp; /* temp array reused in places */ + float* values[2]; /* swapped each frame */ + float* prevOutput[VORBIS_MAX_CHANS]; + float* curOutput[VORBIS_MAX_CHANS]; - struct Codebook* Codebooks; - struct Floor* Floors; - struct Residue* Residues; - struct Mapping* Mappings; - struct Mode* Modes; + struct Codebook* codebooks; + struct Floor* floors; + struct Residue* residues; + struct Mapping* mappings; + struct Mode* modes; - float* WindowRaw; - struct VorbisWindow Windows[2]; + float* windowRaw; + struct VorbisWindow windows[2]; struct imdct_state imdct[2]; };