unpaper/unpaper-6.1-fix-ffmpeg-inco...

56 lines
1.5 KiB
Diff

From 89bce4417c35a8cbaa35f5a7451abca3d1c95adc Mon Sep 17 00:00:00 2001
From: Thomas Koch <thomas@koch.ro>
Date: Mon, 28 Sep 2015 07:39:30 +0200
Subject: [PATCH] fix ffmpeg incompatibility
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Thanks to Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> for the patch.
Received 2015-09-28 via debian bug
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800312
with the following comment:
Not really. unpaper just doesn't use the API correctly.
More specifically, it doesn't make sure it actually got a frame.
The following change makes it work:
Closes: #39
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
file.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/file.c b/file.c
index c92994d..3989447 100644
--- a/file.c
+++ b/file.c
@@ -93,12 +93,23 @@ void loadImage(const char *filename, AVFrame **image) {
if (pkt.stream_index != 0)
errOutput("unable to open file %s: invalid stream.", filename);
+ while (!got_frame && pkt.data) {
+
+ if (pkt.size <= 0) {
+ pkt.data = NULL;
+ pkt.size = 0;
+ }
+
ret = avcodec_decode_video2(avctx, frame, &got_frame, &pkt);
if (ret < 0) {
av_strerror(ret, errbuff, sizeof(errbuff));
errOutput("unable to open file %s: %s", filename, errbuff);
}
+ pkt.data += ret;
+ pkt.size -= ret;
+ }
+
switch(frame->format) {
case AV_PIX_FMT_Y400A: // 8-bit grayscale PNG
case AV_PIX_FMT_GRAY8:
--
2.5.5