Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing own MVE library #289

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

winterheart
Copy link
Collaborator

Pull Request Type

  • GitHub Workflow changes
  • Documentation or Wiki changes
  • Build and Dependency changes
  • Runtime changes
    • Render changes
    • Audio changes
    • Input changes
    • Network changes
    • Other changes

Description

Implementing own MVE library under GPLv3+ license based on D2X work. Currently works video with audio and framed playback (for main menu) on Linux and probably macOS. Windows build is expected to fail as need to adapt DirectSound PCM playback, and there I can use some help with experience of DirectX 6 programming.

Old MVE implementation still here in codebase, we need to decide what to do with it.

Related Issues

Fixes #253.

Screenshots (if applicable)

Checklist

  • I have tested my changes locally and verified that they work as intended.
  • I have documented any new or modified functionality.
  • I have reviewed the changes to ensure they do not introduce any unnecessary complexity or duplicate code.
  • I understand that by submitting this pull request, I am agreeing to license my contributions under the project's license.

Additional Comments

@@ -0,0 +1,63 @@
# Third party components

This file contains information about third party components, required for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move third parties to a separate directory ? It would make sense in terms of licensing. This way we could internalize again zlib and spdlog easily if we want to

Copy link
Collaborator

@JeodC JeodC May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a personal preference so feel free to ignore me; I like single-word names like externals whenever possible. If not possible, underscores over spaces. +1 to separate directory for included externals like zlib.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about thirdparty/libmve?

#define LNXSND_VOLUME_MIN -10000
#define LNXSND_PAN_LEFT -10000
#define LNXSND_VOLUME_MIN (-10000)
#define LNXSND_PAN_LEFT (-10000)
#define LNXSND_PAN_RIGHT 10000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

()

mveasm.cpp
mvelibl.cpp
platform.cpp)
# mveasm.cpp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -596,7 +588,7 @@ int NextPow2(int n) {
void BlitToMovieBitmap(unsigned char *buf, unsigned int bufw, unsigned int bufh, unsigned int hicolor,
bool usePow2Texture, int &texW, int &texH) {
// get some sizes
int drawWidth = hicolor ? (bufw >> 1) : bufw;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is hicolor doing ? l. 612/620 still tests for it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hicolor is indicator that MVE is 16-bit color (there two types of MVEs - 8bit paletted - Dolby Sound intro, and hicolor/truecolor - other intros and videos).
Regarding to changes - there was unnecessary doubling and halving back size of width in old libmve and movie callbacks.

@Lgt2x
Copy link
Collaborator

Lgt2x commented May 6, 2024

I think you're aware but video sound cuts on playback when I tested.

@winterheart
Copy link
Collaborator Author

I think you're aware but video sound cuts on playback when I tested.

Well, surprisingly, I don't have any issues with new mve playback. Maybe there sound buffer too short...

@Lgt2x
Copy link
Collaborator

Lgt2x commented May 7, 2024

I think you're aware but video sound cuts on playback when I tested.

Well, surprisingly, I don't have any issues with new mve playback. Maybe there sound buffer too short...

Sound works for a couple seconds, stops and starts again 2 seconds later. I can provide a recording if needed

@winterheart
Copy link
Collaborator Author

Probably here issue:

  SDL_AudioSpec spec {
      .freq = sample_rate,
      .format = (unsigned short)format,
      .channels = (unsigned char)(stereo ? 2 : 1),
      .size = (unsigned int)desired_buffer,
      .callback = mve_audio_callback,
  };

Can you please try set size with 4096 or more on spec in mveplay.c for testing?

@Lgt2x
Copy link
Collaborator

Lgt2x commented May 7, 2024

It works without a problem with hardcoded size=4096

@winterheart
Copy link
Collaborator Author

Probably I should move it out into configuration with default value 4096.

@winterheart
Copy link
Collaborator Author

I decided to make a hybrid build with SDL2 backend for MVE sound playback and DSound for the rest. Still, I need some testing on real Windows platform.

Copy link
Collaborator

@Lgt2x Lgt2x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice, thank you for taking care of that. I'll test on Windows before merging. libmve should go in the thirdparty dir that did not exist when you first started this, but it can be moved later.

@Lgt2x
Copy link
Collaborator

Lgt2x commented May 22, 2024

And you have some conflict resolution to do :)

@JeodC
Copy link
Collaborator

JeodC commented May 22, 2024

Really nice, thank you for taking care of that. I'll test on Windows before merging. libmve should go in the thirdparty dir that did not exist when you first started this, but it can be moved later.

Windows sound is not working yet. You approved before testing.

@Lgt2x Lgt2x mentioned this pull request May 22, 2024
13 tasks
@bryanperris bryanperris added enhancement Something to modernize things needs testing Needs testing to confirm issue or resolution labels May 23, 2024
@winterheart winterheart marked this pull request as draft May 25, 2024 22:22
Adapting movie and mve interfaces each other.
Converted open() to fopen() et al. calls.
movie expected image as RGB565 from old mve, but now it's RGB555, so there no need additional conversion. Fixed hicolor related conversion of width in movie's callbacks. Headers cleanup in both subsystems.

Sound and frame callbacks are still unavailable.
Merge libmve.h into mvelib.h
Reorganized MVE to use own MVESTREAM pointer for each opened MVE file.
Sound supported by SDL backend.
Replaced SDL 1.2 legacy calls to SDL2 equivalents.
Changed spec.size to fixed value 4096 as values obtained from file can produce sound stuttering.
Replacing circular ring implementation with queue that keeps decoded data between SDL audio callbacks.
Implemented abstraction layer and SDL backend.
@winterheart
Copy link
Collaborator Author

I've reimplemented initial DSound support on Windows, but unfortunately there some regressions: sound crackling and stutters on playback in Windows. There need some synchronization between frames and audio playback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something to modernize things needs testing Needs testing to confirm issue or resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementing own version of MVE library
4 participants