Skip to content

Commit

Permalink
fix pack size calculation
Browse files Browse the repository at this point in the history
git-svn-id: https://dvbcut.svn.sourceforge.net/svnroot/dvbcut/trunk@38 36490176-9c1c-0410-b649-dbf2af5787bf
  • Loading branch information
too-tired committed Jun 3, 2007
1 parent 5c6cca7 commit a54d977
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2007-06-03 Michael Riepe <[email protected]>

* src/mpegmuxer.cpp: fix size calculation.

2007-05-30 Michael Riepe <[email protected]>

* src/streamdata.cpp: add missing #include <assert.h>
Expand Down
15 changes: 8 additions & 7 deletions src/mpegmuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,16 +422,16 @@ void mpegmuxer::packetizer(int str,pts_t maxdts)
headerlen+=3;
int len=9+headerlen+a->getsize();
if (pespacket_setlength)
len+=9*((len-6)/65536);
len+=9*((len-10)/65532);

if (!video || packsize) {
int maxsize=9+headerlen+s->getbufsize()*3/4;
if (pespacket_setlength)
maxsize+=9*((maxsize-6)/65536);
maxsize+=9*((maxsize-10)/65532);
if (packsize && maxsize>pack::maxpayload(packsize))
maxsize=pack::maxpayload(packsize);
if (pespacket_setlength && (maxsize-6)>65535 && ((maxsize-6)%65541)<=9)
maxsize-=((maxsize-6)%65541);
if (pespacket_setlength && maxsize>65541 && maxsize%65541<=9)
maxsize-=maxsize%65541;

std::list<au*>::iterator it=s->aulist.begin();
++it;
Expand All @@ -447,8 +447,8 @@ void mpegmuxer::packetizer(int str,pts_t maxdts)
break;
int newlen;
if (pespacket_setlength) {
newlen=len-9*((len-6)/65545)+aa->getsize();
newlen+=9*((newlen-6)/65536);
newlen=len-9*((len-10)/65541)+aa->getsize();
newlen+=9*((newlen-10)/65532);
} else
newlen=len+aa->getsize();
if (s->type==streamtype::mpegaudio && (newlen>maxsize) && (len>maxsize-50))
Expand Down Expand Up @@ -621,7 +621,8 @@ void mpegmuxer::packetizer(int str,pts_t maxdts)
}

if (len) {
fprintf(stderr,"str=%d len=%d aulist.size=%d packlist.size=%d\n",str,len,s->aulist.size(),s->packlist.size());
fprintf(stderr,"str=%d len=%d aulist.size=%d packlist.size=%d\n",
str,len,s->aulist.size(),s->packlist.size());
assert(len==0);
}
}
Expand Down

0 comments on commit a54d977

Please sign in to comment.