Skip to content

Commit

Permalink
[coreMuxer,coreUtils,coreVideoEncoder] Try to avoid accumulation of r…
Browse files Browse the repository at this point in the history
…ounding errors in time increment to frame rate conversion for standard fps values, add 60 and 59.94 fps to known standard frame rates, ensure that codec time base denominator is within the given limit

Some Roku and LG devices reject videos with fps > 60 even just in codec parameters alone. This patch fixes the issue of videos resampled to 60 fps with Avidemux not playable on devices specified to support 60 fps video.
  • Loading branch information
eumagga0x2a committed Jul 1, 2020
1 parent 0ed244e commit e4872e6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions avidemux_core/ADM_coreMuxer/src/ADM_muxerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ void rescaleFps(uint32_t fps1000, AVRational *rational)
rational->den=30000;
break;
}
case 59940 :
{
rational->num=1001;
rational->den=60000;
break;
}
default:
rational->num=1000;
rational->den=fps1000;
Expand Down
7 changes: 7 additions & 0 deletions avidemux_core/ADM_coreUtils/src/avidemutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ double f;
uint32_t ADM_Fps1000FromUs(uint64_t us)
{
if(us<1000) return 1000;
// Avoid accumulation of rounding errors for std fps
#define KNOW(x,y,z) if(us>=x && us<=y) return z;
KNOW(16666,16667,60000)
KNOW(16683,16684,59940)
KNOW(33333,33334,30000)
KNOW(33366,33367,29970)
#undef KNOW
double f;
f=us;
f=1000000./f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ TimeIncrementType fpsTable[]=
{
{ 40000,40000,1000,25000},
{ 20000,20000,1000,50000},
{ 16661,16671,1000,60000},
{ 16678,16688,1001,60000},
{ 33360,33371,1001,30000},
{ 41700,41710,1001,24000},
};
Expand All @@ -85,6 +87,13 @@ bool usSecondsToFrac(uint64_t useconds, int *n, int *d, int limit)
TimeIncrementType *t=fpsTable+i;
if( useconds>=t->mn && useconds<=t->mx)
{
if(t->d>limit)
{
if(t->d%t->n) break;
*n=1;
*d=t->d/t->n;
return true;
}
*n=t->n;
*d=t->d;
return true;
Expand Down

0 comments on commit e4872e6

Please sign in to comment.