Skip to content

Commit

Permalink
feat: add some image transport
Browse files Browse the repository at this point in the history
Signed-off-by: wep21 <[email protected]>
  • Loading branch information
wep21 committed Jan 29, 2025
1 parent 9d38764 commit ed270a0
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
54 changes: 54 additions & 0 deletions patch/ros-humble-ffmpeg-encoder-decoder.patch
Original file line number Diff line number Diff line change
@@ -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<enum AVPixelFormat> get_encoder_formats(const AVCodec * c)
{
std::vector<enum AVPixelFormat> 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);
}
}
4 changes: 4 additions & 0 deletions vinca_linux_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ packages_select_by_deps:

- open3d_conversions

- ffmpeg_image_transport

- foxglove_compressed_image_transport

# ----- end of package support -----

# - rtabmap
Expand Down
4 changes: 4 additions & 0 deletions vinca_linux_aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions vinca_osx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions vinca_osx_arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ed270a0

Please sign in to comment.