Hi,
the attached patch should fix this bug.
--
Anton Khirnov
Index: jugglemaster-0.4/src/jmdlx/print.cpp
===================================================================
--- jugglemaster-0.4.orig/src/jmdlx/print.cpp 2014-02-28 22:33:54.000000000 +0000
+++ jugglemaster-0.4/src/jmdlx/print.cpp 2014-03-01 10:38:29.329110616 +0000
@@ -524,9 +524,10 @@
AVCodec *codec;
AVCodecContext *c= NULL;
AVFrame *picture;
+ int ret, got_output;
- int i, out_size, size, outbuf_size;
- uint8_t *outbuf, *picture_buf;
+ int i, out_size, size;
+ uint8_t outbuf[4], *picture_buf;
int x,y;
@@ -546,7 +547,7 @@
avcodec_register_all();
- codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
+ codec = avcodec_find_encoder(AV_CODEC_ID_MPEG1VIDEO);
if (!codec) {
return(1);
}
@@ -568,8 +569,6 @@
return(1);
}
- outbuf_size = 100000;
- outbuf = (uint8_t *)malloc(outbuf_size);
size = c->width * c->height;
picture_buf = (uint8_t *)malloc((size * 3) / 2); /* size for YUV 420 */
@@ -586,6 +585,9 @@
}
while (!done) {
+ AVPacket pkt = { 0 };
+ int ret, got_output;
+
jmlib->doJuggle();
done = 1;
@@ -620,8 +622,11 @@
}
}
- out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
- fwrite(outbuf, 1, out_size, outputfile);
+ ret = avcodec_encode_video2(c, &pkt, picture, &got_output);
+ if (ret >= 0 && got_output) {
+ fwrite(pkt.data, 1, pkt.size, outputfile);
+ av_free_packet(&pkt);
+ }
if(current_frames % 10 == 0) {
if(FALSE == progress.Update(current_frames)) {
@@ -630,10 +635,14 @@
}
}
- for(; out_size; i++) {
- out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
- fwrite(outbuf, 1, out_size, outputfile);
- }
+ do {
+ AVPacket pkt = { 0 };
+ ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
+ if (ret >= 0 && got_output) {
+ fwrite(pkt.data, 1, pkt.size, outputfile);
+ av_free_packet(&pkt);
+ }
+ } while (got_output);
outbuf[0] = 0x00;
outbuf[1] = 0x00;
@@ -641,7 +650,6 @@
outbuf[3] = 0xb7;
fwrite(outbuf, 1, 4, outputfile);
free(picture_buf);
- free(outbuf);
avcodec_close(c);
free(c);