Opened 4 years ago

Closed 2 years ago

#2016 closed enhancement (fixed)

Support libopenjpeg 2.0.0

Reported by: KSHawkEye Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords: libopenjpeg
Cc: hussam@visp.net.lb, mcirsta Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I'm trying to compile the latest FFmpeg git with openjpeg 2.0.0 but keep getting an undefined reference to opj_version.

I have already asked for help with this issue here: http://code.google.com/p/openjpeg/issues/detail?id=200
Here: http://sourceforge.net/mailarchive/message.php?msg_id=30209438

And one of my users on my forum posted about it here: http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=5&t=674&hilit=opj_version

I think openjpeg is failing to compile in static and is searching for some .dll file when FFmpeg tries to link to it.

Some code that does compile with opj_version is:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <openjpeg.h>

int main(void)
{
    printf("OPJ2 version is %s\n",opj_version());

    return 0;
}

Though I have no idea why that succeeds, and FFmpeg's test code:

extern int opj_version();
int main(void){ opj_version(); }

fails.

This command: $ i686-w64-mingw32-nm ./libopenjp2.a | grep opj_version

Returns:
00000228 T _opj_version@0

So it looks like it is in the lib, but just keeps failing.

Openjpeg 2.0.0 compiled without error.

It also looks like FFmpeg is trying to test the lib with:

BEGIN /tmp/ffconf.ns4yWT3Y.c
    1	extern int opj_version();
    2	int main(void){ opj_version(); }
END /tmp/ffconf.ns4yWT3Y.c
i686-w64-mingw32-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -std=c99 -fomit-frame-pointer -c -o /tmp/ffconf.ohUKczd4.o /tmp/ffconf.ns4yWT3Y.c
i686-w64-mingw32-gcc -Wl,--as-needed -o /tmp/ffconf.hJciF3wT.exe /tmp/ffconf.ohUKczd4.o -lopenjpeg -lm -lz
/tmp/ffconf.ohUKczd4.o:ffconf.ns4yWT3Y.c:(.text+0xc): undefined reference to `opj_version'
collect2: error: ld returned 1 exit status
ERROR: libopenjpeg not found

I'm happy to provide any further needed information to help get this fixed.

Attachments (4)

config.log (229.0 KB) - added by spookybathtub 3 years ago.
configure.patch (2.5 KB) - added by muffins 3 years ago.
configure ffmpeg for openjpeg 2.0
ffmpeg.log (16.5 KB) - added by muffins 3 years ago.
errors in unpatched libopenjpeg{de,en}c.c using openjpeg 2.0
openjpeg2.patch (1.9 KB) - added by mcirsta 3 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 follow-up: Changed 4 years ago by cehoyos

  • Keywords libopenjpeg added; openjpeg removed
  • Priority changed from important to wish
  • Status changed from new to open
  • Summary changed from undefined reference to `opj_version' to Support libopenjpeg 2.0.0
  • Type changed from defect to enhancement

openjpeg 1.5.1 is expected to work fine, please open an independent ticket if there are any problems with it.

comment:2 in reply to: ↑ 1 Changed 4 years ago by KSHawkEye

Replying to cehoyos:

openjpeg 1.5.1 is expected to work fine, please open an independent ticket if there are any problems with it.

So your saying that FFmpeg doesn't support 2.0.0? There is no reason why the new version should fail and the outdated to succeed.

comment:3 Changed 4 years ago by cehoyos

I am not sure I understand you: Do you mean that when openjpeg support was implemented in 2009, the FFmpeg developers should have foreseen that the libopenjpeg developers will decide to change the name of the libopenjpeg library in 2012 from openjpeg.dll to libopenjp2.dll?
(Note that I am not claiming the name change would be the only change from 1.5 to 2.0, I am just trying to explain that if an external library decides to change its API, there is generally no way to already support the new api when it gets released, so claiming that "there is no reason why the new version should fail and the outdated to succeed" seems like an overreaction to me given that the new version was released three weeks ago and to the best of my knowledge you are the first one to report that there is a new version.)

Last edited 4 years ago by cehoyos (previous) (diff)

comment:4 Changed 4 years ago by rogerdpack

for me, after renaming libopenjp2.a to libopenjpeg.a (to try and fake out ffmpeg), I get this:

libavcodec/libavcodec.a(libopenjpegenc.o): In function `libopenjpeg_encode_frame’:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegenc.c:421: undefined reference to `opj_cio_open’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegenc.c:433: undefined reference to `cio_tell’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegenc.c:442: undefined reference to `opj_cio_close’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegenc.c:435: undefined reference to `opj_cio_close’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegenc.c:428: undefined reference to `opj_cio_close’
libavcodec/libavcodec.a(libopenjpegenc.o): In function `libopenjpeg_encode_close’:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegenc.c:450: undefined reference to `opj_destroy_compress’
libavcodec/libavcodec.a(libopenjpegenc.o): In function `libopenjpeg_encode_init’:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegenc.c:203: undefined reference to `opj_set_event_mgr’
libavcodec/libavcodec.a(libopenjpegdec.o): In function `libopenjpeg_decode_frame’:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:268: undefined reference to `opj_set_event_mgr’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:273: undefined reference to `opj_cio_open’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:283: undefined reference to `opj_decode_with_info’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:284: undefined reference to `opj_cio_close’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:330: undefined reference to `opj_cio_open’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:339: undefined reference to `opj_decode_with_info’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:340: undefined reference to `opj_cio_close’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:389: undefined reference to `opj_destroy_decompress’
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/win32/ffmpeg_git/libavcodec/libopenjpegdec.c:288: undefined reference to `opj_destroy_decompress’
collect2: error: ld returned 1 exit status

Which I assume means that openjpeg has changed their internal api, with version 2, perhaps? (though I might be cross compiling libopenjpeg 2.0.0 wrong as well).

Version 0, edited 4 years ago by rogerdpack (next)

comment:5 Changed 4 years ago by richardpl

  • Component changed from undetermined to avcodec

comment:6 Changed 3 years ago by spookybathtub

Here we are 11 months later. Are there any plans to support openjpeg 2.0? I have it installed via MacPorts?, so I have these files in /opt/local/include/openjpeg-2.0

openjpeg.h
opj_config.h
opj_stdint.h

Changed 3 years ago by spookybathtub

comment:7 Changed 3 years ago by llogan

You could supply a patch or offer a bounty/sponsor this feature request. We are volunteers. Features requests are limited mostly by manpower and developer interest, but maybe an offer of support will generate some more interest.

Changed 3 years ago by muffins

configure ffmpeg for openjpeg 2.0

Changed 3 years ago by muffins

errors in unpatched libopenjpeg{de,en}c.c using openjpeg 2.0

comment:8 Changed 3 years ago by muffins

I added a patch to configure so ffmpeg uses the openjpeg 2.0 lib, and the tail of a build log showing the errors resulting. I can see at some things are just name changes, but hopefully someone more familiar with the lib can help.
(Edit: What have I done. ಠ_ಠ *jumps off a cliff*)

Last edited 3 years ago by muffins (previous) (diff)

comment:9 Changed 3 years ago by hussam

  • Cc hussam@visp.net.lb added

Changed 3 years ago by mcirsta

comment:10 follow-up: Changed 3 years ago by mcirsta

I've added a patch to compile ffmpeg with openjpeg2. You also need to pass:

--extra-cflags="-DHAVE_OPENJPEG_2_0_OPENJPEG_H"

to configure.
Also from openjpeg2 you need to copy the openjpeg.h from src/lib/openmj2 to openjpeg-2.0/openmj2.h.

You probably have to modify the #ifdef at the beginning of your openmj2.h file.

Good new is there seem to not have been any API changes so after compiling all works fine.


comment:11 in reply to: ↑ 10 ; follow-up: Changed 3 years ago by cehoyos

  • Cc mcirsta added

Replying to mcirsta:

I've added a patch to compile ffmpeg with openjpeg2. You also need to pass:

--extra-cflags="-DHAVE_OPENJPEG_2_0_OPENJPEG_H"

to configure.

The configure check should set this define.

Also from openjpeg2 you need to copy the openjpeg.h from src/lib/openmj2 to openjpeg-2.0/openmj2.h.

The header is not installed?

Please send patches to the ffmpeg-devel mailing list, they receive more attention there.

comment:12 in reply to: ↑ 11 Changed 3 years ago by mcirsta

Replying to cehoyos:

Replying to mcirsta:

I've added a patch to compile ffmpeg with openjpeg2. You also need to pass:

--extra-cflags="-DHAVE_OPENJPEG_2_0_OPENJPEG_H"

to configure.

The configure check should set this define.

Agreed but this was just a quick hack so this was fine for me.

Also from openjpeg2 you need to copy the openjpeg.h from src/lib/openmj2 to openjpeg-2.0/openmj2.h.

The header is not installed?

Unfortunately,no , by default openjpeg2 doesn't expose this header for some reason. I've tried contacting them but didn't get any solution to this.

Please send patches to the ffmpeg-devel mailing list, they receive more attention there.

I'm afraid without that header exposed there's no real easy way to do this sending a patch is not an option till openjpeg solves this.

comment:13 Changed 2 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed

Should be fixed in 475e3799

Note: See TracTickets for help on using tickets.