summarylogtreecommitdiffstats
path: root/ffmpeg.patch
diff options
context:
space:
mode:
Diffstat (limited to 'ffmpeg.patch')
-rw-r--r--ffmpeg.patch155
1 files changed, 155 insertions, 0 deletions
diff --git a/ffmpeg.patch b/ffmpeg.patch
new file mode 100644
index 000000000000..82a6ef80c0cd
--- /dev/null
+++ b/ffmpeg.patch
@@ -0,0 +1,155 @@
+diff --git a/gazebo/common/Video.cc b/gazebo/common/Video.cc
+--- a/gazebo/common/Video.cc
++++ b/gazebo/common/Video.cc
+@@ -15,14 +15,18 @@
+ *
+ */
+
+-#include <gazebo/common/Console.hh>
+-#include <gazebo/common/Video.hh>
+-#include <gazebo/gazebo_config.h>
+-#include <gazebo/common/ffmpeg_inc.h>
++#include "gazebo/gazebo_config.h"
++#include "gazebo/common/Console.hh"
++#include "gazebo/common/Video.hh"
++#include "gazebo/common/ffmpeg_inc.h"
+
+ using namespace gazebo;
+ using namespace common;
+
++/// \brief Destination audio video frame
++/// TODO Do not merge forward. Declared here for gazebo7 ABI compatibility
++AVFrame *avFrameDst;
++
+ /////////////////////////////////////////////////
+ // #ifdef HAVE_FFMPEG
+ // static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
+@@ -44,25 +48,17 @@
+ {
+ this->formatCtx = NULL;
+ this->codecCtx = NULL;
+- this->avFrame = NULL;
+ this->swsCtx = NULL;
+ this->avFrame = NULL;
+- this->pic = NULL;
+ this->videoStream = -1;
+
+-#ifdef HAVE_FFMPEG
+- this->pic = new AVPicture;
+-#endif
++ avFrameDst = NULL;
+ }
+
+ /////////////////////////////////////////////////
+ Video::~Video()
+ {
+ this->Cleanup();
+-
+-#ifdef HAVE_FFMPEG
+- delete this->pic;
+-#endif
+ }
+
+ /////////////////////////////////////////////////
+@@ -78,7 +74,7 @@
+ // Close the codec
+ avcodec_close(this->codecCtx);
+
+- avpicture_free(this->pic);
++ av_free(avFrameDst);
+ #endif
+ }
+
+@@ -147,16 +143,13 @@
+ return false;
+ }
+
+- avpicture_alloc(this->pic, PIX_FMT_RGB24, this->codecCtx->width,
+- this->codecCtx->height);
+-
+ this->swsCtx = sws_getContext(
+ this->codecCtx->width,
+ this->codecCtx->height,
+ this->codecCtx->pix_fmt,
+ this->codecCtx->width,
+ this->codecCtx->height,
+- PIX_FMT_RGB24,
++ AV_PIX_FMT_RGB24,
+ SWS_BICUBIC, NULL, NULL, NULL);
+
+ if (this->swsCtx == NULL)
+@@ -165,20 +158,13 @@
+ return false;
+ }
+
+- // DEBUG: Will save all the frames
+- /*Image img;
+- char buf[1024];
+- int frame = 0;
+-
+- // the decoding loop, running until EOF
+- while (this->GetNextFrame(img))
+- {
+- printf("WH[%d %d]\n",this->codecCtx->width, this->codecCtx->height);
+- snprintf(buf, sizeof(buf), "/tmp/test_%3d.png", frame++);
+- img.SavePNG(buf);
+- }
+- printf("Done\n");
+- */
++ avFrameDst = common::AVFrameAlloc();
++ avFrameDst->format = this->codecCtx->pix_fmt;
++ avFrameDst->width = this->codecCtx->width;
++ avFrameDst->height = this->codecCtx->height;
++ av_image_alloc(avFrameDst->data, avFrameDst->linesize,
++ this->codecCtx->width, this->codecCtx->height, this->codecCtx->pix_fmt,
++ 1);
+
+ return true;
+ }
+@@ -226,9 +212,10 @@
+ if (frameAvailable)
+ {
+ sws_scale(swsCtx, this->avFrame->data, this->avFrame->linesize, 0,
+- this->codecCtx->height, this->pic->data, this->pic->linesize);
++ this->codecCtx->height, avFrameDst->data,
++ avFrameDst->linesize);
+
+- memcpy(*_buffer, this->pic->data[0],
++ memcpy(*_buffer, avFrameDst->data[0],
+ this->codecCtx->height * (this->codecCtx->width*3));
+
+ // Debug:
+diff --git a/gazebo/common/Video.hh b/gazebo/common/Video.hh
+--- a/gazebo/common/Video.hh
++++ b/gazebo/common/Video.hh
+@@ -14,8 +14,8 @@
+ * limitations under the License.
+ *
+ */
+-#ifndef _VIDEO_HH_
+-#define _VIDEO_HH_
++#ifndef _GAZEBO_COMMON_VIDEO_HH_
++#define _GAZEBO_COMMON_VIDEO_HH_
+
+ #include <string>
+ #include "gazebo/util/system.hh"
+@@ -74,7 +74,7 @@
+ /// \brief audio video frame
+ private: AVFrame *avFrame;
+
+- /// \brief audi video picture
++ /// \brief audio video picture
+ private: AVPicture *pic;
+
+ /// \brief software scaling context
+diff --git a/gazebo/common/ffmpeg_inc.h b/gazebo/common/ffmpeg_inc.h
+--- a/gazebo/common/ffmpeg_inc.h
++++ b/gazebo/common/ffmpeg_inc.h
+@@ -31,6 +31,7 @@
+ extern "C" {
+ #include <libavcodec/avcodec.h>
+ #include <libavformat/avformat.h>
++#include <libavutil/imgutils.h>
+ #include <libavutil/opt.h>
+ #include <libswscale/swscale.h>
+ }