Cidu
Cidu

Reputation: 21

libvpx "Codec does not implement requested capability" (decoder)

I'm currently facing an issue on a project using libvpx v1.10.0 ( https://github.com/webmproject/libvpx/releases ).

I have successfully built the library for Visual Studio 16 on Windows 10 (PC x64).
[I must build libvpx by my own since I need it to run on a Windows 10 ARM64 / VS16 as well (Hololens 2) and a such build is not officially provided]

I've made a C++ DLL that uses the static libs from libvpx (to be used as a native plugin in Unity). While the VP9 encoding part seems to work correctly in a sample app using my DLL, I cannot initialize the VP9 decoder. Maybe I am missing something in the configuration step of libvpx?

To build the libvpx static libraries, I have launched MSYS2 from the x64 Native Tools Command Prompt of Visual Studio 2019. Then, I have set the configuration as follows, inspired by what we can find in an ArchLinux AUR package ( https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=libvpx-git ):

./configure --target=x86_64-win64-vs16 --enable-libyuv \
--enable-vp8 --enable-vp9 --enable-postproc --enable-vp9-postproc \
--enable-vp9-highbitdepth --enable-vp9-temporal-denoising
make -j

At the end of the compilation, the build succeeds with 0 error but 2 warnings. The --help of the configure scripts indicates that the --enable-vp9 option enables both the VP9 encoder and decoder.

Then, when I run my app using the C++ DLL that performs the encoding and decoding stuff, I get this error message from libvpx: Codec does not implement requested capability .

It occurs when I call the vpx_codec_dec_init() function. I don't understand why it cannot be initialized as I think that the VP9 codec is fully built. The error appears as well when I add the --enable-vp9-encoder and --enable-vp9-decoder` options and all other VP9 related options to the configuration.

Is there something to do in the code itself before initializing the VP9 decoder? I have not seen a such thing in the samples of code. Notice that the problem occurs if I use VP8 as well (encoding OK / decoding KO, same error).

Here is the beginning of my function for decoding a frame:

vpx_codec_err_t resultError;
vpx_codec_ctx_t codec;
const vpx_codec_iface_t* decoderInterface = vpx_codec_vp9_cx(); // >>> OK!

if (!decoderInterface)
{
    return "libvpx: unsupported codec (decoder)";
}

resultError = vpx_codec_dec_init(&codec, decoderInterface, nullptr, 0); // >>> KO...
if (resultError)
{
    std::cout << vpx_codec_error(&codec) << std::endl; // outputs "Codec does not implement requested capability"
    return "libvpx: failed to initialize decoder";
}

vpx_codec_iter_t iter = nullptr;
vpx_image_t* yuvFrame = nullptr;

resultError = vpx_codec_decode(&codec, compressedFrame, (unsigned int)compressedFrameSize, nullptr, 0);

if (resultError)
{
    return "libvpx: failed to decode frame";
}

// ....

Any help would be great! Thank you. :)

Upvotes: 1

Views: 888

Answers (1)

Cidu
Cidu

Reputation: 21

OK, I've figured it out! :)

The line:
const vpx_codec_iface_t* decoderInterface = vpx_codec_vp9_cx();

must be replaced by (+ #include <vpx/vp8dx.h>):
const vpx_codec_iface_t* decoderInterface = vpx_codec_vp9_dx();

The reason I have made this error is due to a previous experience in encoding/decoding videos. I've developed a webcam streaming app using the H.264 codec, which needs a set up "context" structure. So, because of the name of the vpx_codec_vp9_cx() function, I've thought it was creating a such context for VP9. In fact, cx matches for encoding and dx for decoding... Not really obvious though. I don't like this kind of function names.

Anyway, I hope it will help anybody in a same situation. ;)

Upvotes: 1

Related Questions