Opened 12 years ago

Closed 10 years ago

#2016 closed enhancement (fixed)

Support libopenjpeg 2.0.0

Reported by: Kyle Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords: libopenjpeg
Cc: hussam@visp.net.lb, Marius Cirsta 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 Elliott 11 years ago.
configure.patch (2.5 KB ) - added by muffins 11 years ago.
configure ffmpeg for openjpeg 2.0
ffmpeg.log (16.5 KB ) - added by muffins 11 years ago.
errors in unpatched libopenjpeg{de,en}c.c using openjpeg 2.0
openjpeg2.patch (1.9 KB ) - added by Marius Cirsta 11 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 by Carl Eugen Hoyos, 12 years ago

Keywords: libopenjpeg added; openjpeg removed
Priority: importantwish
Status: newopen
Summary: undefined reference to `opj_version'Support libopenjpeg 2.0.0
Type: defectenhancement

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

in reply to:  1 comment:2 by Kyle, 12 years ago

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 by Carl Eugen Hoyos, 12 years ago

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 12 years ago by Carl Eugen Hoyos (previous) (diff)

comment:4 by Roger Pack, 12 years ago

for me, after copying the include files to the "openjpeg 1.x" location, and renaming libopenjp2.a to libopenjpeg.a (to try and fake out ffmpeg), configure passes, and then I get this:

CC	libavcodec/libopenjpegenc.o
In file included from libavcodec/libopenjpegdec.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1052:75: error: unknown type name 'FILE'
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1060:67: error: unknown type name 'FILE'
In file included from libavcodec/libopenjpegdec.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1367:12: error: unknown type name 'FILE'
In file included from libavcodec/libopenjpegenc.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1052:75: error: unknown type name 'FILE'
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1060:67: error: unknown type name 'FILE'
In file included from libavcodec/libopenjpegenc.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1367:12: error: unknown type name 'FILE'
libavcodec/libopenjpegdec.c: In function 'libopenjpeg_guess_pix_fmt':
libavcodec/libopenjpegdec.c:104:10: error: 'CLRSPC_SRGB' undeclared (first use in this function)
libavcodec/libopenjpegdec.c:104:10: note: each undeclared identifier is reported only once for each function it appears in
libavcodec/libopenjpegdec.c:108:10: error: 'CLRSPC_GRAY' undeclared (first use in this function)
libavcodec/libopenjpegdec.c:112:10: error: 'CLRSPC_SYCC' undeclared (first use in this function)
libavcodec/libopenjpegdec.c: In function 'libopenjpeg_decode_frame':
libavcodec/libopenjpegdec.c:241:5: error: unknown type name 'opj_dinfo_t'
libavcodec/libopenjpegdec.c:242:5: error: unknown type name 'opj_cio_t'
libavcodec/libopenjpegdec.c:255:37: error: 'CODEC_JP2' undeclared (first use in this function)
libavcodec/libopenjpegdec.c:261:37: error: 'CODEC_J2K' undeclared (first use in this function)
libavcodec/libopenjpegdec.c:268:5: error: implicit declaration of function 'opj_set_event_mgr' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegdec.c:268:24: error: 'opj_common_ptr' undeclared (first use in this function)
libavcodec/libopenjpegdec.c:268:39: error: expected ')' before 'dec'
libavcodec/libopenjpegdec.c:269:20: error: 'opj_dparameters_t' has no member named 'cp_limit_decoding'
libavcodec/libopenjpegdec.c:269:41: error: 'LIMIT_TO_MAIN_HEADER' undeclared (first use in this function)
libavcodec/libopenjpegdec.c:272:5: warning: passing argument 1 of 'opj_setup_decoder' from incompatible pointer type [enabled by default]
In file included from libavcodec/libopenjpegdec.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1140:31: note: expected 'void **' but argument is of type 'int *'
libavcodec/libopenjpegdec.c:273:5: error: implicit declaration of function 'opj_cio_open' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegdec.c:273:43: error: expected ')' before 'dec'
libavcodec/libopenjpegdec.c:278:9: error: implicit declaration of function 'opj_destroy_decompress' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegdec.c:283:5: error: implicit declaration of function 'opj_decode_with_info' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegdec.c:283:11: warning: assignment makes pointer from integer without a cast [enabled by default]
libavcodec/libopenjpegdec.c:284:5: error: implicit declaration of function 'opj_cio_close' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegdec.c:326:20: error: 'opj_dparameters_t' has no member named 'cp_limit_decoding'
libavcodec/libopenjpegdec.c:326:41: error: 'NO_LIMITATION' undeclared (first use in this function)
libavcodec/libopenjpegdec.c:329:5: warning: passing argument 1 of 'opj_setup_decoder' from incompatible pointer type [enabled by default]
In file included from libavcodec/libopenjpegdec.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1140:31: note: expected 'void **' but argument is of type 'int *'
libavcodec/libopenjpegdec.c:330:43: error: expected ')' before 'dec'
libavcodec/libopenjpegdec.c:339:11: warning: assignment makes pointer from integer without a cast [enabled by default]
cc1: some warnings being treated as errors
make: *** [libavcodec/libopenjpegdec.o] Error 1
make: *** Waiting for unfinished jobs....
libavcodec/libopenjpegenc.c:42:5: error: unknown type name 'opj_cinfo_t'
libavcodec/libopenjpegenc.c:43:5: error: unknown type name 'opj_event_mgr_t'
libavcodec/libopenjpegenc.c: In function 'mj2_create_image':
libavcodec/libopenjpegenc.c:79:35: error: 'CLRSPC_UNKNOWN' undeclared (first use in this function)
libavcodec/libopenjpegenc.c:79:35: note: each undeclared identifier is reported only once for each function it appears in
libavcodec/libopenjpegenc.c:92:23: error: 'CLRSPC_GRAY' undeclared (first use in this function)
libavcodec/libopenjpegenc.c:98:23: error: 'CLRSPC_SRGB' undeclared (first use in this function)
libavcodec/libopenjpegenc.c:133:23: error: 'CLRSPC_SYCC' undeclared (first use in this function)
libavcodec/libopenjpegenc.c: In function 'libopenjpeg_encode_init':
libavcodec/libopenjpegenc.c:180:19: warning: assignment from incompatible pointer type [enabled by default]
libavcodec/libopenjpegenc.c:199:39: error: 'opj_event_mgr_t' undeclared (first use in this function)
libavcodec/libopenjpegenc.c:200:19: error: request for member 'info_handler' in something not a structure or union
libavcodec/libopenjpegenc.c:201:19: error: request for member 'error_handler' in something not a structure or union
libavcodec/libopenjpegenc.c:202:19: error: request for member 'warning_handler' in something not a structure or union
libavcodec/libopenjpegenc.c:203:5: error: implicit declaration of function 'opj_set_event_mgr' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegenc.c:203:24: error: 'opj_common_ptr' undeclared (first use in this function)
libavcodec/libopenjpegenc.c:203:39: error: expected ')' before 'ctx'
libavcodec/libopenjpegenc.c: In function 'libopenjpeg_encode_frame':
libavcodec/libopenjpegenc.c:344:5: error: unknown type name 'opj_cinfo_t'
libavcodec/libopenjpegenc.c:346:5: error: unknown type name 'opj_cio_t'
libavcodec/libopenjpegenc.c:420:5: warning: passing argument 1 of 'opj_setup_encoder' from incompatible pointer type [enabled by default]
In file included from libavcodec/libopenjpegenc.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1312:31: note: expected 'void **' but argument is of type 'int *'
libavcodec/libopenjpegenc.c:421:5: error: implicit declaration of function 'opj_cio_open' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegenc.c:421:28: error: 'opj_common_ptr' undeclared (first use in this function)
libavcodec/libopenjpegenc.c:421:43: error: expected ')' before 'compress'
libavcodec/libopenjpegenc.c:427:5: warning: passing argument 1 of 'opj_encode' from incompatible pointer type [enabled by default]
In file included from libavcodec/libopenjpegenc.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1341:31: note: expected 'void **' but argument is of type 'int *'
libavcodec/libopenjpegenc.c:427:5: warning: passing argument 2 of 'opj_encode' from incompatible pointer type [enabled by default]
In file included from libavcodec/libopenjpegenc.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1341:31: note: expected 'void **' but argument is of type 'int *'
libavcodec/libopenjpegenc.c:427:5: error: too many arguments to function 'opj_encode'
In file included from libavcodec/libopenjpegenc.c:28:0:
/home/rdp/dev/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/openjpeg.h:1341:31: note: declared here
libavcodec/libopenjpegenc.c:428:9: error: implicit declaration of function 'opj_cio_close' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegenc.c:433:5: error: implicit declaration of function 'cio_tell' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegenc.c:439:29: error: request for member 'buffer' in something not a structure or union
libavcodec/libopenjpegenc.c: In function 'libopenjpeg_encode_close':
libavcodec/libopenjpegenc.c:450:5: error: implicit declaration of function 'opj_destroy_compress' [-Werror=implicit-function-declaration]
libavcodec/libopenjpegenc.c: At top level:
libavcodec/libopenjpegenc.c:459:96: error: 'CODEC_JP2' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:459:111: error: 'CODEC_J2K' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:462:96: error: 'STD_RSIZ' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:462:122: error: 'CINEMA4K' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:464:96: error: 'CINEMA2K' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:466:96: error: 'OFF' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:466:122: error: 'CINEMA4K_24' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:468:96: error: 'CINEMA2K_24' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:469:96: error: 'CINEMA2K_48' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:471:96: error: 'LRCP' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:471:122: error: 'CPRL' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:473:96: error: 'RLCP' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:474:96: error: 'RPCL' undeclared here (not in a function)
libavcodec/libopenjpegenc.c:475:96: error: 'PCRL' undeclared here (not in a function)
cc1: some warnings being treated as errors
make: *** [libavcodec/libopenjpegenc.o] Error 1

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).

Last edited 12 years ago by Roger Pack (previous) (diff)

comment:5 by Elon Musk, 12 years ago

Component: undeterminedavcodec

comment:6 by Elliott, 11 years ago

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

by Elliott, 11 years ago

Attachment: config.log added

comment:7 by llogan, 11 years ago

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.

by muffins, 11 years ago

Attachment: configure.patch added

configure ffmpeg for openjpeg 2.0

by muffins, 11 years ago

Attachment: ffmpeg.log added

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

comment:8 by muffins, 11 years ago

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 11 years ago by muffins (previous) (diff)

comment:9 by hussam Al-Tayeb, 11 years ago

Cc: hussam@visp.net.lb added

by Marius Cirsta, 11 years ago

Attachment: openjpeg2.patch added

comment:10 by Marius Cirsta, 11 years ago

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.


in reply to:  10 ; comment:11 by Carl Eugen Hoyos, 11 years ago

Cc: Marius Cirsta 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.

in reply to:  11 comment:12 by Marius Cirsta, 11 years ago

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 by Carl Eugen Hoyos, 10 years ago

Resolution: fixed
Status: openclosed

Should be fixed in 475e3799

Note: See TracTickets for help on using tickets.