diff options
author | saintdev <[email protected]> | 2007-07-13 06:28:48 +0000 |
---|---|---|
committer | saintdev <[email protected]> | 2007-07-13 06:28:48 +0000 |
commit | 0afde9331de7d41babe11e7d76ed76c691c84ecb (patch) | |
tree | 9c20b00084aa8c7d7143d616c4e78ce86217b867 /libhb/encvorbis.c | |
parent | 639d590f4463da1cc1a6e5e0d6db0da4a58dbeb7 (diff) |
More accurate frame start/stop times for vorbis. This is needed for the upcoming Matroska muxer.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@674 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/encvorbis.c')
-rw-r--r-- | libhb/encvorbis.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libhb/encvorbis.c b/libhb/encvorbis.c index fa35de376..cfe506fdd 100644 --- a/libhb/encvorbis.c +++ b/libhb/encvorbis.c @@ -39,6 +39,7 @@ struct hb_work_private_s hb_list_t * list; int out_discrete_channels; int channel_map[6]; + int64_t prev_blocksize; }; int encvorbisInit( hb_work_object_t * w, hb_job_t * job ) @@ -160,6 +161,7 @@ static hb_buffer_t * Flush( hb_work_object_t * w ) { hb_work_private_t * pv = w->private_data; hb_buffer_t * buf; + int64_t blocksize = 0; if( vorbis_analysis_blockout( &pv->vd, &pv->vb ) == 1 ) { @@ -174,12 +176,12 @@ static hb_buffer_t * Flush( hb_work_object_t * w ) memcpy( buf->data, &op, sizeof( ogg_packet ) ); memcpy( buf->data + sizeof( ogg_packet ), op.packet, op.bytes ); + blocksize = vorbis_packet_blocksize(&pv->vi, &op); buf->frametype = HB_FRAME_AUDIO; - buf->start = pv->pts; /* No exact, but who cares - the OGM - muxer doesn't use it */ - buf->stop = buf->start + - 90000 * OGGVORBIS_FRAME_SIZE + pv->job->arate; - + buf->start = (int64_t)(vorbis_granule_time(&pv->vd, op.granulepos) * 90000); + buf->stop = (int64_t)(vorbis_granule_time(&pv->vd, (pv->prev_blocksize + blocksize)/4 + op.granulepos) * 90000); + /* The stop time isn't accurate for the first ~3 packets, as the actual blocksize depends on the previous _and_ current packets. */ + pv->prev_blocksize = blocksize; return buf; } } |