This is an automated email from the git hooks/post-receive script.

jcowgill-guest pushed a commit to branch master
in repository dolphin-emu.

commit 2f12221725dfc9fafa3fc377a744a7e226e14b91
Author: James Cowgill <[email protected]>
Date:   Tue Nov 11 15:17:23 2014 +0000

    Refresh libav patch
---
 debian/patches/02_fixes-for-libav-10.patch | 220 ++++++-----------------------
 1 file changed, 46 insertions(+), 174 deletions(-)

diff --git a/debian/patches/02_fixes-for-libav-10.patch 
b/debian/patches/02_fixes-for-libav-10.patch
index e2c50c2..b9742a8 100644
--- a/debian/patches/02_fixes-for-libav-10.patch
+++ b/debian/patches/02_fixes-for-libav-10.patch
@@ -1,181 +1,53 @@
-From c2c46d75738624b7afa4a522db8d2b029a95acb5 Mon Sep 17 00:00:00 2001
-From: Tillmann Karras <[email protected]>
-Date: Sun, 15 Jun 2014 05:16:58 +0200
-Subject: [PATCH] AVIDump: update ffmpeg/libav API usage
+Description: Copy avcodec_encode_video from libav so it compiles
+ with newer versions.
+Author: Brandon Barnes <[email protected]>
+Forwarded: not-needed
 
-libav 10 was released on May 10th, 2014 and it drops support for some
-long-deprecated stuff like avcodec_encode_video().
----
- Source/Core/VideoCommon/AVIDump.cpp | 93 +++++++++++++++++++------------------
- 1 file changed, 49 insertions(+), 44 deletions(-)
-
-diff --git a/Source/Core/VideoCommon/AVIDump.cpp 
b/Source/Core/VideoCommon/AVIDump.cpp
-index b53340f..a287056 100644
---- a/Source/Core/VideoCommon/AVIDump.cpp
-+++ b/Source/Core/VideoCommon/AVIDump.cpp
-@@ -220,7 +220,7 @@ static AVStream* s_stream = nullptr;
- static AVFrame* s_bgr_frame = nullptr;
- static AVFrame* s_yuv_frame = nullptr;
- static uint8_t* s_yuv_buffer = nullptr;
--static uint8_t* s_out_buffer = nullptr;
-+static SwsContext* s_sws_context = nullptr;
- static int s_width;
- static int s_height;
- static int s_size;
-@@ -262,14 +262,15 @@ bool AVIDump::CreateFile()
-               return false;
-       }
- 
--      s_stream->codec->codec_id = g_Config.bUseFFV1 ? CODEC_ID_FFV1 : 
s_format_context->oformat->video_codec;
-+      s_stream->codec->codec_id = g_Config.bUseFFV1 ? AV_CODEC_ID_FFV1
-+                                                    : 
s_format_context->oformat->video_codec;
-       s_stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-       s_stream->codec->bit_rate = 400000;
-       s_stream->codec->width = s_width;
-       s_stream->codec->height = s_height;
-       s_stream->codec->time_base = (AVRational){1, 
static_cast<int>(VideoInterface::TargetRefreshRate)};
-       s_stream->codec->gop_size = 12;
--      s_stream->codec->pix_fmt = g_Config.bUseFFV1 ? PIX_FMT_BGRA : 
PIX_FMT_YUV420P;
-+      s_stream->codec->pix_fmt = g_Config.bUseFFV1 ? AV_PIX_FMT_BGRA : 
AV_PIX_FMT_YUV420P;
- 
-       if (!(codec = avcodec_find_encoder(s_stream->codec->codec_id)) ||
-           (avcodec_open2(s_stream->codec, codec, nullptr) < 0))
-@@ -277,16 +278,14 @@ bool AVIDump::CreateFile()
-               return false;
-       }
- 
--      s_bgr_frame = avcodec_alloc_frame();
--      s_yuv_frame = avcodec_alloc_frame();
-+      s_bgr_frame = av_frame_alloc();
-+      s_yuv_frame = av_frame_alloc();
- 
-       s_size = avpicture_get_size(s_stream->codec->pix_fmt, s_width, 
s_height);
- 
-       s_yuv_buffer = new uint8_t[s_size];
-       avpicture_fill((AVPicture*)s_yuv_frame, s_yuv_buffer, 
s_stream->codec->pix_fmt, s_width, s_height);
- 
--      s_out_buffer = new uint8_t[s_size];
--
-       NOTICE_LOG(VIDEO, "Opening file %s for dumping", 
s_format_context->filename);
-       if (avio_open(&s_format_context->pb, s_format_context->filename, 
AVIO_FLAG_WRITE) < 0)
-       {
-@@ -299,45 +298,52 @@ bool AVIDump::CreateFile()
-       return true;
+--- a/Source/Core/VideoCommon/Src/AVIDump.cpp
++++ b/Source/Core/VideoCommon/Src/AVIDump.cpp
+@@ -243,6 +243,45 @@ bool AVIDump::Start(int w, int h)
+       return CreateFile();
  }
  
-+static void PreparePacket(AVPacket* pkt)
++#if (LIBAVCODEC_VERSION_MAJOR >= 55)
++
++#define CODEC_ID_FFV1 AV_CODEC_ID_FFV1
++
++// Shamelessly copied from libav-9.13 utils.c
++int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
++                                             const AVFrame *pict)
 +{
-+      av_init_packet(pkt);
-+      pkt->data = nullptr;
-+      pkt->size = 0;
-+      if (s_stream->codec->coded_frame->pts != AV_NOPTS_VALUE)
-+      {
-+              pkt->pts = av_rescale_q(s_stream->codec->coded_frame->pts,
-+                                      s_stream->codec->time_base, 
s_stream->time_base);
-+      }
-+      if (s_stream->codec->coded_frame->key_frame)
-+              pkt->flags |= AV_PKT_FLAG_KEY;
-+      pkt->stream_index = s_stream->index;
++    AVPacket pkt;
++    int ret, got_packet = 0;
++
++    if (buf_size < FF_MIN_BUFFER_SIZE) {
++        av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
++        return -1;
++    }
++
++    av_init_packet(&pkt);
++    pkt.data = buf;
++    pkt.size = buf_size;
++
++    ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet);
++    if (!ret && got_packet && avctx->coded_frame) {
++        avctx->coded_frame->pts       = pkt.pts;
++        avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
++    }
++
++    /* free any side data since we cannot return it */
++    if (pkt.side_data_elems > 0) {
++        int i;
++        for (i = 0; i < pkt.side_data_elems; i++)
++            av_free(pkt.side_data[i].data);
++        av_freep(&pkt.side_data);
++        pkt.side_data_elems = 0;
++    }
++
++    return ret ? ret : pkt.size;
 +}
++#endif
 +
- void AVIDump::AddFrame(const u8* data, int width, int height)
+ bool AVIDump::CreateFile()
  {
--      avpicture_fill((AVPicture*)s_bgr_frame, const_cast<u8*>(data), 
PIX_FMT_BGR24, width, height);
-+      avpicture_fill((AVPicture*)s_bgr_frame, const_cast<u8*>(data), 
AV_PIX_FMT_BGR24, width, height);
- 
-       // Convert image from BGR24 to desired pixel format, and scale to 
initial
-       // width and height
--      struct SwsContext* s_sws_context;
--      if ((s_sws_context = sws_getContext(width, height, PIX_FMT_BGR24, 
s_width, s_height,
--                                          s_stream->codec->pix_fmt, 
SWS_BICUBIC, nullptr, nullptr, nullptr)))
-+      if ((s_sws_context = sws_getCachedContext(s_sws_context,
-+                                                width, height, 
AV_PIX_FMT_BGR24,
-+                                                s_width, s_height, 
s_stream->codec->pix_fmt,
-+                                                SWS_BICUBIC, nullptr, 
nullptr, nullptr)))
-       {
-               sws_scale(s_sws_context, s_bgr_frame->data, 
s_bgr_frame->linesize, 0,
-                         height, s_yuv_frame->data, s_yuv_frame->linesize);
--              sws_freeContext(s_sws_context);
-       }
- 
--      // Encode and write the image
--      int outsize = avcodec_encode_video(s_stream->codec, s_out_buffer, 
s_size, s_yuv_frame);
--      while (outsize > 0)
-+      // Encode and write the image.
-+      AVPacket pkt;
-+      PreparePacket(&pkt);
-+      int got_packet;
-+      int error = avcodec_encode_video2(s_stream->codec, &pkt, s_yuv_frame, 
&got_packet);
-+      while (!error && got_packet)
-       {
--              AVPacket pkt;
--              av_init_packet(&pkt);
--
--              if (s_stream->codec->coded_frame->pts != (unsigned 
int)AV_NOPTS_VALUE)
--              {
--                      pkt.pts = 
av_rescale_q(s_stream->codec->coded_frame->pts,
--                                             s_stream->codec->time_base, 
s_stream->time_base);
--              }
--              if (s_stream->codec->coded_frame->key_frame)
--                      pkt.flags |= AV_PKT_FLAG_KEY;
--              pkt.stream_index = s_stream->index;
--              pkt.data = s_out_buffer;
--              pkt.size = outsize;
--
--              // Write the compressed frame in the media file
-+              // Write the compressed frame in the media file.
-               av_interleaved_write_frame(s_format_context, &pkt);
- 
--              // Encode delayed frames
--              outsize = avcodec_encode_video(s_stream->codec, s_out_buffer, 
s_size, nullptr);
-+              // Handle delayed frames.
-+              PreparePacket(&pkt);
-+              error = avcodec_encode_video2(s_stream->codec, &pkt, nullptr, 
&got_packet);
-       }
-+      if (error)
-+              ERROR_LOG(VIDEO, "Error while encoding video: %d", error);
- }
- 
- void AVIDump::Stop()
-@@ -358,20 +364,13 @@ void AVIDump::CloseFile()
-       }
- 
-       if (s_yuv_buffer)
-+      {
-               delete[] s_yuv_buffer;
--      s_yuv_buffer = nullptr;
--
--      if (s_out_buffer)
--              delete[] s_out_buffer;
--      s_out_buffer = nullptr;
--
--      if (s_bgr_frame)
--              av_free(s_bgr_frame);
--      s_bgr_frame = nullptr;
-+              s_yuv_buffer = nullptr;
-+      }
- 
--      if (s_yuv_frame)
--              av_free(s_yuv_frame);
--      s_yuv_frame = nullptr;
-+      av_frame_free(&s_bgr_frame);
-+      av_frame_free(&s_yuv_frame);
- 
-       if (s_format_context)
-       {
-@@ -380,6 +379,12 @@ void AVIDump::CloseFile()
-               av_free(s_format_context);
-               s_format_context = nullptr;
-       }
-+
-+      if (s_sws_context)
-+      {
-+              sws_freeContext(s_sws_context);
-+              s_sws_context = nullptr;
-+      }
- }
- 
- #endif
--- 
-2.1.3
-
+       AVCodec *codec = NULL;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/dolphin-emu.git

_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to