From ed270a0cd386a3a258e847e333f5196ba22b49c6 Mon Sep 17 00:00:00 2001 From: wep21 Date: Thu, 30 Jan 2025 00:32:21 +0900 Subject: [PATCH] feat: add some image transport Signed-off-by: wep21 --- patch/ros-humble-ffmpeg-encoder-decoder.patch | 54 +++++++++++++++++++ vinca_linux_64.yaml | 4 ++ vinca_linux_aarch64.yaml | 4 ++ vinca_osx.yaml | 4 ++ vinca_osx_arm64.yaml | 4 ++ 5 files changed, 70 insertions(+) create mode 100644 patch/ros-humble-ffmpeg-encoder-decoder.patch diff --git a/patch/ros-humble-ffmpeg-encoder-decoder.patch b/patch/ros-humble-ffmpeg-encoder-decoder.patch new file mode 100644 index 00000000..07fa9f5f --- /dev/null +++ b/patch/ros-humble-ffmpeg-encoder-decoder.patch @@ -0,0 +1,54 @@ +diff --git a/src/decoder.cpp b/src/decoder.cpp +index 0a12d25..10834e3 100644 +--- a/src/decoder.cpp ++++ b/src/decoder.cpp +@@ -38,7 +38,11 @@ Decoder::~Decoder() { reset(); } + void Decoder::reset() + { + if (codecContext_) { ++#if LIBAVFORMAT_VERSION_MAJOR < 59 + avcodec_close(codecContext_); ++#else ++ avcodec_free_context(&codecContext_); ++#endif + av_free(codecContext_); + codecContext_ = NULL; + } +diff --git a/src/encoder.cpp b/src/encoder.cpp +index a4b6de6..2e1d4a2 100644 +--- a/src/encoder.cpp ++++ b/src/encoder.cpp +@@ -54,7 +54,11 @@ static void free_frame(AVFrame ** frame) + void Encoder::closeCodec() + { + if (codecContext_) { ++#if LIBAVFORMAT_VERSION_MAJOR < 59 + avcodec_close(codecContext_); ++#else ++ avcodec_free_context(&codecContext_); ++#endif + codecContext_ = nullptr; + } + free_frame(&frame_); +diff --git a/src/utils.cpp b/src/utils.cpp +index da089e4..01e8eea 100644 +--- a/src/utils.cpp ++++ b/src/utils.cpp +@@ -104,8 +104,15 @@ enum AVPixelFormat get_preferred_pixel_format( + std::vector get_encoder_formats(const AVCodec * c) + { + std::vector formats; +- if (c && c->pix_fmts) { +- for (const auto * p = c->pix_fmts; *p != AV_PIX_FMT_NONE; ++p) { ++#if LIBAVUTIL_VERSION_MAJOR > 59 || (LIBAVUTIL_VERSION_MAJOR == 59 && LIBAVUTIL_VERSION_MINOR >= 39) ++ const enum AVPixelFormat *pix_fmts = NULL; ++ avcodec_get_supported_config(NULL, c, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void **) &pix_fmts, NULL); ++ if (c && pix_fmts) { ++#else ++ const enum AVPixelFormat *pix_fmts = c->pix_fmts; ++ if (c && pix_fmts) { ++#endif ++ for (const auto * p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) { + formats.push_back(*p); + } + } diff --git a/vinca_linux_64.yaml b/vinca_linux_64.yaml index 2355a923..432ad528 100644 --- a/vinca_linux_64.yaml +++ b/vinca_linux_64.yaml @@ -189,6 +189,10 @@ packages_select_by_deps: - open3d_conversions + - ffmpeg_image_transport + + - foxglove_compressed_image_transport + # ----- end of package support ----- # - rtabmap diff --git a/vinca_linux_aarch64.yaml b/vinca_linux_aarch64.yaml index 65f2b5f7..1df5053d 100644 --- a/vinca_linux_aarch64.yaml +++ b/vinca_linux_aarch64.yaml @@ -118,6 +118,10 @@ packages_select_by_deps: - open3d_conversions + - ffmpeg_image_transport + + - foxglove_compressed_image_transport + # Used to work, now needs fixes # - rtabmap # - webots-ros2 diff --git a/vinca_osx.yaml b/vinca_osx.yaml index de8b353d..29a734e0 100644 --- a/vinca_osx.yaml +++ b/vinca_osx.yaml @@ -140,5 +140,9 @@ packages_select_by_deps: - open3d_conversions + - ffmpeg_image_transport + + - foxglove_compressed_image_transport + patch_dir: patch rosdistro_snapshot: rosdistro_snapshot.yaml diff --git a/vinca_osx_arm64.yaml b/vinca_osx_arm64.yaml index 8f0c36ea..e28c4068 100644 --- a/vinca_osx_arm64.yaml +++ b/vinca_osx_arm64.yaml @@ -130,5 +130,9 @@ packages_select_by_deps: - open3d_conversions + - ffmpeg_image_transport + + - foxglove_compressed_image_transport + patch_dir: patch rosdistro_snapshot: rosdistro_snapshot.yaml