Bug#800312: RFH: unpaper -- post-processing tool for scanned pages
Hi Thomas,
On 27.09.2015 18:52, Thomas Koch wrote:
> I request assistance with maintaining the unpaper package in Debian.
>
> When the unpaper 6.1 is built in Debian unstable against ffmpeg it fails
> to load the png files from its own tests folder. I already filled an
> upstream bug about this:
> https://github.com/Flameeyes/unpaper/issues/39
>
> Upstream however seems to be unresponsive ATM and my C skills are very
> rusty. :-(
>
> I suspect that there's some incompatibility between ffmpeg and libav.
> Upstream builds against libav and in Debian we use ffmpeg.
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:
--- 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:
Best regards,
Andreas
Reply to: