[FFmpeg-devel] [PATCH v7] - Added Turing codec interface for ffmpeg

Mark Thompson sw at jkqxz.net
Thu Feb 23 22:47:07 EET 2017


On 21/02/17 17:15, Saverio Blasi wrote:
> Hi all,
> 
> We have recently circulated this new iteration (see below) of our work towards integrating our HEVC Turing codec within FFMpeg. Assuming that there are no more requests for changes, we would like to understand what is the timeline for integration within the project.
> 
> Thanks a lot,
> 
> All the best,
> ----------------------------------------------------
> Saverio Blasi, PhD
> Senior Research Engineer 
> BBC Research & Development
> Centre House|56 Wood Lane|London|W12 7SB
> 
> 
> 
> 
> -----Original Message-----
> From: Saverio Blasi [mailto:saverio.blasi at bbc.co.uk] 
> Sent: 13 February 2017 13:37
> To: ffmpeg-devel at ffmpeg.org
> Cc: Saverio Blasi <Saverio.Blasi at bbc.co.uk>
> Subject: [PATCH v7] - Added Turing codec interface for ffmpeg
> 
> - This patch contains the changes to interface the Turing codec (http://turingcodec.org/) with ffmpeg. The patch was modified to address the comments in the review as follows:
>   - Added a pkg-config file to list all dependencies required by libturing. This should address the issue pointed out by Hendrik Leppkes on Fri 18/11/2016
>   - As per suggestions of wm4, two functions (add_option and finalise_options) have been created. The former appends new options while the latter sets up the argv array of pointers to char* accordingly. add_option re-allocates the buffer for options using av_realloc
>   - Additionally, both these functions handle the errors in case the memory wasn't allocated correctly
>   - malloc|free|realloc have been substituted with their corresponding av_{malloc|free|realloc} version
>   - Check on bit-depth has been removed since the ffmpeg already casts the right pix_fmt and bit depth
>   - pix_fmts is now set in ff_libturing_encoder as in h264dec.c.
>   - Changed usage of av_free with av_freep and fixed calls to free arrays
>   - Added brackets to all if and for statements
>   - Avoid repetition of code to free arrays in case of failure to initialise the libturing encoder
>   - Some fixes to address the review from wm4 and Mark Thompson received on Wed 08/02/2017
>   - Fixed indentation
> ---
>  LICENSE.md             |   1 +
>  configure              |   5 +
>  libavcodec/Makefile    |   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/libturing.c | 320 +++++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 328 insertions(+)
>  create mode 100644 libavcodec/libturing.c
> 
> diff --git a/LICENSE.md b/LICENSE.md
> index 640633c..86e5371 100644
> --- a/LICENSE.md
> +++ b/LICENSE.md
> @@ -85,6 +85,7 @@ The following libraries are under GPL:
>  - frei0r
>  - libcdio
>  - librubberband
> +- libturing
>  - libvidstab
>  - libx264
>  - libx265
> diff --git a/configure b/configure
> index 7154142..a27cb8b 100755
> --- a/configure
> +++ b/configure
> @@ -255,6 +255,7 @@ External library support:
>    --enable-libssh          enable SFTP protocol via libssh [no]
>    --enable-libtesseract    enable Tesseract, needed for ocr filter [no]
>    --enable-libtheora       enable Theora encoding via libtheora [no]
> +  --enable-libturing       enable H.265/HEVC encoding via libturing [no]
>    --enable-libtwolame      enable MP2 encoding via libtwolame [no]
>    --enable-libv4l2         enable libv4l2/v4l-utils [no]
>    --enable-libvidstab      enable video stabilization using vid.stab [no]
> @@ -1562,6 +1563,7 @@ EXTERNAL_LIBRARY_LIST="
>      libssh
>      libtesseract
>      libtheora
> +    libturing
>      libtwolame
>      libv4l2
>      libvidstab
> @@ -2858,6 +2860,7 @@ libspeex_decoder_deps="libspeex"
>  libspeex_encoder_deps="libspeex"
>  libspeex_encoder_select="audio_frame_queue"
>  libtheora_encoder_deps="libtheora"
> +libturing_encoder_deps="libturing"
>  libtwolame_encoder_deps="libtwolame"
>  libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
>  libvorbis_decoder_deps="libvorbis"
> @@ -5131,6 +5134,7 @@ die_license_disabled gpl frei0r  die_license_disabled gpl libcdio  die_license_disabled gpl librubberband  die_license_disabled gpl libsmbclient
> +die_license_disabled gpl libturing
>  die_license_disabled gpl libvidstab
>  die_license_disabled gpl libx264
>  die_license_disabled gpl libx265
> @@ -5789,6 +5793,7 @@ enabled libssh            && require_pkg_config libssh libssh/sftp.h sftp_init
>  enabled libspeex          && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex
>  enabled libtesseract      && require_pkg_config tesseract tesseract/capi.h TessBaseAPICreate
>  enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
> +enabled libturing         && require_pkg_config libturing turing.h turing_version
>  enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame &&
>                               { check_lib twolame.h twolame_encode_buffer_float32_interleaved -ltwolame ||
>                                 die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 43a6add..de5af1d 100644

Are you missing some link options?

I was wanting to test this, so I installed from your git (stable branch).  Trying to configure gives me:

 11608  check_pkg_config libturing turing.h turing_version
 11609  pkg-config --exists --print-errors libturing
 11610  check_func_headers turing.h turing_version -I/usr/local/include -L/usr/local/lib -lturing -lhavoc
 11611  check_ld cc -I/usr/local/include -L/usr/local/lib -lturing -lhavoc
 11612  check_cc -I/usr/local/include -L/usr/local/lib
 11613  BEGIN /tmp/ffconf.V1e5ldp7.c
 11614      1   #include <turing.h>
 11615      2   #include <stdint.h>
 11616      3   long check_turing_version(void) { return (long) turing_version; }
 11617      4   int main(void) { int ret = 0;
 11618      5    ret |= ((intptr_t)check_turing_version) & 0xFFFF;
 11619      6   return ret; }
 11620  END /tmp/ffconf.V1e5ldp7.c
 11621  gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -std=c11 -fPIC -pthread -I/usr/local/include -L/usr/local/lib -c -o /tmp/ffconf.i9eT8703.o /tmp/ffconf.V1e5ldp7.c
 11622  gcc -Wl,--as-needed -Wl,-z,noexecstack -I/usr/local/include -L/usr/local/lib -o /tmp/ffconf.oWzD6Ewr /tmp/ffconf.i9eT8703.o -lturing -lhavoc -lm -lz -pthread
 11623  /usr/local/lib/libturing.a(Encoder.cpp.o): In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.390]':
 11624  Encoder.cpp:(.text+0x50): undefined reference to `std::__throw_logic_error(char const*)'
 11625  Encoder.cpp:(.text+0x9b): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
 11626  /usr/local/lib/libturing.a(Encoder.cpp.o): In function `hashToString(std::vector<int, std::allocator<int> >, int)':
... over nine thousand lines deleted ...
 21104  ThreadPool.cpp:(.text._ZNSt5dequeIPN10ThreadPool4TaskESaIS2_EE17_M_reallocate_mapEmb[_ZNSt5dequeIPN10ThreadPool4TaskESaIS2_EE17_M_reallocate_mapEmb]+0x19e): undefined reference to `std::__throw_bad_alloc()'
 21105  /usr/local/lib/libturing.a(ThreadPool.cpp.o):(.data.rel.ro._ZTINSt6thread11_State_implISt12_Bind_simpleIFSt7_Mem_fnIM10ThreadPoolFvvEEPS3_EEEE[_ZTINSt6thread11_State_implISt12_Bind_simpleIFSt7_Mem_fnIM10ThreadPoolFvvEEPS3_EEEE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
 21106  /usr/local/lib/libturing.a(ThreadPool.cpp.o):(.data.rel.ro._ZTINSt6thread11_State_implISt12_Bind_simpleIFSt7_Mem_fnIM10ThreadPoolFvvEEPS3_EEEE[_ZTINSt6thread11_State_implISt12_Bind_simpleIFSt7_Mem_fnIM10ThreadPoolFvvEEPS3_EEEE]+0x10): undefined reference to `typeinfo for std::thread::_State'
 21107  collect2: error: ld returned 1 exit status
 21108  ERROR: libturing not found using pkg-config

That is, the static libraries contain references to a load of symbols which haven't been pulled in anywhere.  Adding --extra-libs='-lstdc++' removed a few thousand of the errors, but it clearly needs some other stuff as well.

Modulo being unable to test it this looks ok, so if you would explain how I've messed up so that I can test it then I would be happy to commit in a day or two if noone else objects.

Thanks,

- Mark


More information about the ffmpeg-devel mailing list