@ -192,7 +192,8 @@ static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
}
}
static int ogg_buffer_data ( AVFormatContext * s , AVStream * st ,
static int ogg_buffer_data ( AVFormatContext * s , AVStream * st ,
uint8_t * data , unsigned size , int64_t granule )
uint8_t * data , unsigned size , int64_t granule ,
int header )
{
{
OGGStreamContext * oggstream = st - > priv_data ;
OGGStreamContext * oggstream = st - > priv_data ;
OGGContext * ogg = s - > priv_data ;
OGGContext * ogg = s - > priv_data ;
@ -201,7 +202,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
int i , segments , len , flush = 0 ;
int i , segments , len , flush = 0 ;
// Handles VFR by flushing page because this frame needs to have a timestamp
// Handles VFR by flushing page because this frame needs to have a timestamp
if ( st - > codec - > codec_id = = CODEC_ID_THEORA & &
if ( st - > codec - > codec_id = = CODEC_ID_THEORA & & ! header & &
ogg_granule_to_timestamp ( oggstream , granule ) >
ogg_granule_to_timestamp ( oggstream , granule ) >
ogg_granule_to_timestamp ( oggstream , oggstream - > last_granule ) + 1 ) {
ogg_granule_to_timestamp ( oggstream , oggstream - > last_granule ) + 1 ) {
if ( oggstream - > page . granule ! = - 1 )
if ( oggstream - > page . granule ! = - 1 )
@ -231,8 +232,8 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
if ( i = = total_segments )
if ( i = = total_segments )
page - > granule = granule ;
page - > granule = granule ;
if ( page - > segments_count = = 255 | |
if ( ! header & & ( page - > segments_count = = 255 | |
( ogg - > pref_size > 0 & & page - > size > = ogg - > pref_size ) ) {
( ogg - > pref_size > 0 & & page - > size > = ogg - > pref_size ) ) ) {
ogg_buffer_page ( s , oggstream ) ;
ogg_buffer_page ( s , oggstream ) ;
}
}
}
}
@ -431,7 +432,7 @@ static int ogg_write_header(AVFormatContext *s)
for ( j = 0 ; j < s - > nb_streams ; j + + ) {
for ( j = 0 ; j < s - > nb_streams ; j + + ) {
OGGStreamContext * oggstream = s - > streams [ j ] - > priv_data ;
OGGStreamContext * oggstream = s - > streams [ j ] - > priv_data ;
ogg_buffer_data ( s , s - > streams [ j ] , oggstream - > header [ 0 ] ,
ogg_buffer_data ( s , s - > streams [ j ] , oggstream - > header [ 0 ] ,
oggstream - > header_len [ 0 ] , 0 ) ;
oggstream - > header_len [ 0 ] , 0 , 1 ) ;
oggstream - > page . flags | = 2 ; // bos
oggstream - > page . flags | = 2 ; // bos
ogg_buffer_page ( s , oggstream ) ;
ogg_buffer_page ( s , oggstream ) ;
}
}
@ -441,7 +442,7 @@ static int ogg_write_header(AVFormatContext *s)
for ( i = 1 ; i < 3 ; i + + ) {
for ( i = 1 ; i < 3 ; i + + ) {
if ( oggstream & & oggstream - > header_len [ i ] )
if ( oggstream & & oggstream - > header_len [ i ] )
ogg_buffer_data ( s , st , oggstream - > header [ i ] ,
ogg_buffer_data ( s , st , oggstream - > header [ i ] ,
oggstream - > header_len [ i ] , 0 ) ;
oggstream - > header_len [ i ] , 0 , 1 ) ;
}
}
ogg_buffer_page ( s , oggstream ) ;
ogg_buffer_page ( s , oggstream ) ;
}
}
@ -492,7 +493,7 @@ static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt)
} else
} else
granule = pkt - > pts + pkt - > duration ;
granule = pkt - > pts + pkt - > duration ;
ret = ogg_buffer_data ( s , st , pkt - > data , pkt - > size , granule ) ;
ret = ogg_buffer_data ( s , st , pkt - > data , pkt - > size , granule , 0 ) ;
if ( ret < 0 )
if ( ret < 0 )
return ret ;
return ret ;