klange / toaruos

A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
https://toaruos.org/
University of Illinois/NCSA Open Source License
6.03k stars 475 forks source link

Is it possible to port FFmpeg to toaruos? #259

Open Vir-BryanQ opened 1 year ago

Vir-BryanQ commented 1 year ago

It seems that there are few tools to deal with multimedia content and I didn't find a way to play a video on toaruos.
I wonder if it is possible to port FFmpeg to toaruos so that toaruos will be more powerful to deal with multimedia content. If possible, how difficult will it be? By the way, are there any video players on toaruos?

klange commented 1 year ago

FFmpeg was ported many years ago, before the switch to an in-house libc. I have not revisited that port, though the “minimp3” library available from the package manager is derived from (very slimmed down) FFmpeg sources. I seem to recall FFmpeg relying on some libc/libm math functions, which may be missing or stubbed, so some more work may be necessary to get it building again.

klange commented 1 year ago

A comment was posted here but deleted by its author, asking about alternative libms.

I don't intend to import any third-party code to support the in-house libm, but I have considered making musl's libm available from the package manager to support ports. The libm implementation in musl, much like others, is largely derivative of an old Sun libm.

This will require some work in the ld.so to fix up the incorrect, naive implementation of symbol resolution. Thankfully, libm implementations do not tend to rely much, if at all, on the internal details of the libc they are shipped with, so an external libm should be able to co-exist with our own in-house libc.

mxlgv commented 1 year ago

I wasn't really talking about making a port of musl, but rather about taking the missing math from there and mixing it into your libc. Mathematics in different libc looks about the same, as it is written in assembler. You will not get something fundamentally different if you want to implement it yourself. And yes, I'm talking about what should be in the C standard math module in libc.

klange commented 1 year ago

as it is written in assembler

There's actually lots of bit twiddling in C to implement the majority of floating point math functions. Even when a platform has an FPU that supports a function directly, a libm implementation may avoid using the hardware instruction if it's known to be slow or inaccurate.

And yes, I'm talking about what should be in the C standard math module in libc.

Again, I don't intend to import any third-party code - even if my own implementations would be necessarily identical. I think the path forward for math function support is to clean up the implementations of functions we do have - the ones needed to power the core OS - and then defer other functions to a third-party package, installable from the repository. Musl is a good candidate for that (I think even mlibc just uses muls's libm!)