Commit 85dd1a0b authored by David Flynn's avatar David Flynn Committed by Laurent Aimar

mux/ogg: Don't use granulepos = UINT64_MAX on EOS page

It isn't legal for granulepos to be UINT64_MAX on an EOS page since
this special value indicates that no packets finish on the page, yet
an EOS page signifies that the final packet does finish on the page.

It seems that there is a convention for repeating the last used
granulepos in the EOS page per logical stream.  This then allows
some extra file size hints (duration = last gp - first gp) [1]

[1] This is flawed -- EOS may occur anywhere, however this is what
some people do.
Signed-off-by: default avatarDavid Flynn <davidf@rd.bbc.co.uk>
Signed-off-by: default avatarLaurent Aimar <fenrir@videolan.org>
parent faa5af57
...@@ -184,6 +184,7 @@ typedef struct ...@@ -184,6 +184,7 @@ typedef struct
int i_serial_no; int i_serial_no;
int i_keyframe_granule_shift; /* Theora only */ int i_keyframe_granule_shift; /* Theora only */
int i_last_keyframe; /* dirac and eventually theora */ int i_last_keyframe; /* dirac and eventually theora */
uint64_t u_last_granulepos; /* Used for correct EOS page */
ogg_stream_state os; ogg_stream_state os;
oggds_header_t *p_oggds_header; oggds_header_t *p_oggds_header;
...@@ -851,7 +852,7 @@ static block_t *OggCreateFooter( sout_mux_t *p_mux ) ...@@ -851,7 +852,7 @@ static block_t *OggCreateFooter( sout_mux_t *p_mux )
op.bytes = 0; op.bytes = 0;
op.b_o_s = 0; op.b_o_s = 0;
op.e_o_s = 1; op.e_o_s = 1;
op.granulepos = -1; op.granulepos = p_stream->u_last_granulepos;
op.packetno = p_stream->i_packet_no++; op.packetno = p_stream->i_packet_no++;
ogg_stream_packetin( &p_stream->os, &op ); ogg_stream_packetin( &p_stream->os, &op );
...@@ -866,7 +867,7 @@ static block_t *OggCreateFooter( sout_mux_t *p_mux ) ...@@ -866,7 +867,7 @@ static block_t *OggCreateFooter( sout_mux_t *p_mux )
op.bytes = 0; op.bytes = 0;
op.b_o_s = 0; op.b_o_s = 0;
op.e_o_s = 1; op.e_o_s = 1;
op.granulepos = -1; op.granulepos = p_sys->pp_del_streams[i]->u_last_granulepos;
op.packetno = p_sys->pp_del_streams[i]->i_packet_no++; op.packetno = p_sys->pp_del_streams[i]->i_packet_no++;
ogg_stream_packetin( &p_sys->pp_del_streams[i]->os, &op ); ogg_stream_packetin( &p_sys->pp_del_streams[i]->os, &op );
...@@ -1039,6 +1040,7 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -1039,6 +1040,7 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
op.granulepos = ( p_data->i_dts - p_sys->i_start_dts ) / 1000; op.granulepos = ( p_data->i_dts - p_sys->i_start_dts ) / 1000;
} }
p_stream->u_last_granulepos = op.granulepos;
ogg_stream_packetin( &p_stream->os, &op ); ogg_stream_packetin( &p_stream->os, &op );
if( p_stream->i_cat == SPU_ES || if( p_stream->i_cat == SPU_ES ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment