[vlc-commits] [Git][videolan/vlc][master] 4 commits: cdda: cddb: compute the track offset once
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Sep 4 07:57:05 UTC 2021
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
3e8b98b8 by Steve Lhomme at 2021-09-04T07:41:41+00:00
cdda: cddb: compute the track offset once
The LBAPregap() function transforms the gap in seconds to frames/LBA. It avoids
using magic number in the code.
The CDDB hash assumes the first track starts at 2s (which is not always true)
so we add the offset to each track.
- - - - -
0901a5a3 by Steve Lhomme at 2021-09-04T07:41:41+00:00
cdda: cddb: compute the total track frames once
i_size was accumulating the p_sectors[track+1].i_lba - p_sectors[track].i_lba
difference for each track with a factor. It's equivalent to
p_sectors[p_toc->i_tracks].i_lba - p_sectors[0].i_lba
- - - - -
294346b1 by Steve Lhomme at 2021-09-04T07:41:41+00:00
cdda: cddb: don't multiply the size/length by 1000000
- - - - -
8e127ccd by Steve Lhomme at 2021-09-04T07:41:41+00:00
cdda: cddb: compute the length in seconds once
Do the cast to integers onces
- - - - -
1 changed file:
- modules/access/cdda.c
Changes:
=====================================
modules/access/cdda.c
=====================================
@@ -554,22 +554,21 @@ static cddb_disc_t *GetCDDBInfo( vlc_object_t *obj, const vcddev_toc_t *p_toc )
goto error;
}
- int64_t i_length = 2000000; /* PreGap */
for( int i = 0; i < p_toc->i_tracks; i++ )
{
+ int cddb_offset = LBAPregap(p_toc->p_sectors[i].i_lba); // 2s Pregap offset
cddb_track_t *t = cddb_track_new();
- cddb_track_set_frame_offset( t, p_toc->p_sectors[i].i_lba + 150 ); /* Pregap offset */
+ cddb_track_set_frame_offset( t, cddb_offset );
cddb_disc_add_track( p_disc, t );
- const int64_t i_size = ( p_toc->p_sectors[i+1].i_lba - p_toc->p_sectors[i].i_lba ) *
- (int64_t)CDDA_DATA_SIZE;
- i_length += INT64_C(1000000) * i_size / 44100 / 4 ;
- msg_Dbg( obj, "Track %i offset: %i", i, p_toc->p_sectors[i].i_lba + 150 );
+ msg_Dbg( obj, "Track %i offset: %i", i, cddb_offset );
}
+ const int64_t i_size = p_toc->p_sectors[p_toc->i_tracks].i_lba - p_toc->p_sectors[0].i_lba;
+ int i_length = (int)(i_size * CDDA_DATA_SIZE / 4 / 44100) + 2 ; // 2s Pregap
- msg_Dbg( obj, "Total length: %i", (int)(i_length/1000000) );
- cddb_disc_set_length( p_disc, (int)(i_length/1000000) );
+ msg_Dbg( obj, "Total length: %i", i_length );
+ cddb_disc_set_length( p_disc, i_length );
if( !cddb_disc_calc_discid( p_disc ) )
{
@@ -678,10 +677,10 @@ static int ReadDir(stream_t *access, input_item_node_t *node)
const vcddev_toc_t *p_toc = sys->p_toc;
/* Build title table */
- const int i_start_track_offset = sys->i_cdda_first - sys->p_toc->i_first_track;
+ const int i_start_cddb_offset = sys->i_cdda_first - sys->p_toc->i_first_track;
for (int i = 0; i < sys->i_cdda_tracks; i++)
{
- if(i < i_start_track_offset)
+ if(i < i_start_cddb_offset)
continue;
msg_Dbg(access, "track[%d] start=%d", i, p_toc->p_sectors[i].i_lba);
@@ -690,7 +689,7 @@ static int ReadDir(stream_t *access, input_item_node_t *node)
char *name;
if (unlikely(asprintf(&name, _("Audio CD - Track %02i"),
- i - i_start_track_offset + 1 ) == -1))
+ i - i_start_cddb_offset + 1 ) == -1))
name = NULL;
/* Create playlist items */
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a09a78748a879eb4ee8bcfe9f3bc71e1817b9c0c...8e127ccd62339971f0e476db067d7c345d1e3f56
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a09a78748a879eb4ee8bcfe9f3bc71e1817b9c0c...8e127ccd62339971f0e476db067d7c345d1e3f56
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list