Permalink
Browse files

Attempt to plug a memory leak in MPEG2 "lossless" transcode

Seems that when we hit the 2000 frames in use (i.e. queued), we very
ungracefully reject more frames, "No more queue slots!", and then we promptly
leak the packet we were going to put in that frame.  Added a few more
av_free_packet() to hopefully plug the leak.

Also, since it seems the HDHR Prime (and perhaps other sources) record MPEG2
that can sometimes have exceedingly large GOP sizes.  This code was mostly
designed for use with ivtv and others with predicably small GOP sizes.  To
try to get the "No more queue slots!" to disappear, I have increased the
max frames from 2000 to 20000.  This could still use a rework, but hopefully
will fix the short-term issue.

Thanks to rkulagow for reporting this mess. :)
  • Loading branch information...
1 parent fc980fa commit 68a6f02fadd8a574f2c39c91fad3f7b544915fc9 @Beirdo Beirdo committed Jul 12, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 mythtv/programs/mythtranscode/mpeg2fix.cpp
@@ -1201,7 +1201,7 @@ int MPEG2fixup::BuildFrame(AVPacket *pkt, QString fname)
return 0;
}
-#define MAX_FRAMES 2000
+#define MAX_FRAMES 20000
MPEG2frame *MPEG2fixup::GetPoolFrame(AVPacket *pkt)
{
MPEG2frame *f;
@@ -1271,12 +1271,16 @@ int MPEG2fixup::GetFrame(AVPacket *pkt)
{
LOG(VB_GENERAL, LOG_ERR,
"Found end of file without finding any frames");
+ av_free_packet(pkt);
return 1;
}
MPEG2frame *tmpFrame = GetPoolFrame(&vFrame.last()->pkt);
if (tmpFrame == NULL)
+ {
+ av_free_packet(pkt);
return 1;
+ }
vFrame.append(tmpFrame);
real_file_end = true;
@@ -1316,7 +1320,10 @@ int MPEG2fixup::GetFrame(AVPacket *pkt)
MPEG2frame *tmpFrame = GetPoolFrame(pkt);
if (tmpFrame == NULL)
+ {
+ av_free_packet(pkt);
return 1;
+ }
switch (inputFC->streams[pkt->stream_index]->codec->codec_type)
{

0 comments on commit 68a6f02

Please sign in to comment.