forked from len0rd/rockbox
FS#12161: Correct the gapless processing for AAC, so that it doesn't remove too much from the start of a track. Also simplify the logic a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30012 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
21685577c7
commit
6c8ef19dfd
1 changed files with 28 additions and 7 deletions
|
@ -72,6 +72,7 @@ enum codec_status codec_run(void)
|
||||||
unsigned char c = 0;
|
unsigned char c = 0;
|
||||||
void *ret;
|
void *ret;
|
||||||
intptr_t param;
|
intptr_t param;
|
||||||
|
bool empty_first_frame = false;
|
||||||
|
|
||||||
/* Clean and initialize decoder structures */
|
/* Clean and initialize decoder structures */
|
||||||
memset(&demux_res , 0, sizeof(demux_res));
|
memset(&demux_res , 0, sizeof(demux_res));
|
||||||
|
@ -213,10 +214,24 @@ enum codec_status codec_run(void)
|
||||||
/* Output the audio */
|
/* Output the audio */
|
||||||
ci->yield();
|
ci->yield();
|
||||||
|
|
||||||
|
if (empty_first_frame)
|
||||||
|
{
|
||||||
|
/* Remove the first frame from lead_trim, under the assumption
|
||||||
|
* that it had the same size as this frame
|
||||||
|
*/
|
||||||
|
empty_first_frame = false;
|
||||||
|
lead_trim -= (frame_info.samples >> 1);
|
||||||
|
|
||||||
|
if (lead_trim < 0)
|
||||||
|
{
|
||||||
|
lead_trim = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Gather number of samples for the decoded frame. */
|
/* Gather number of samples for the decoded frame. */
|
||||||
framelength = (frame_info.samples >> 1) - lead_trim;
|
framelength = (frame_info.samples >> 1) - lead_trim;
|
||||||
|
|
||||||
if (i == demux_res.num_sample_byte_sizes - 1 && framelength > 0)
|
if (i == demux_res.num_sample_byte_sizes - 1)
|
||||||
{
|
{
|
||||||
framelength -= ci->id3->tail_trim;
|
framelength -= ci->id3->tail_trim;
|
||||||
}
|
}
|
||||||
|
@ -226,15 +241,21 @@ enum codec_status codec_run(void)
|
||||||
ci->pcmbuf_insert(&decoder->time_out[0][lead_trim],
|
ci->pcmbuf_insert(&decoder->time_out[0][lead_trim],
|
||||||
&decoder->time_out[1][lead_trim],
|
&decoder->time_out[1][lead_trim],
|
||||||
framelength);
|
framelength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lead_trim > 0)
|
if (lead_trim > 0)
|
||||||
{
|
{
|
||||||
/* frame_info.samples can be 0 for the first frame */
|
/* frame_info.samples can be 0 for frame 0. We still want to
|
||||||
lead_trim -= (i > 0 || frame_info.samples)
|
* remove it from lead_trim, so do that during frame 1.
|
||||||
? (frame_info.samples >> 1) : (uint32_t)framelength;
|
*/
|
||||||
|
if (0 == i && 0 == frame_info.samples)
|
||||||
|
{
|
||||||
|
empty_first_frame = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (lead_trim < 0 || ci->id3->lead_trim == 0)
|
lead_trim -= (frame_info.samples >> 1);
|
||||||
|
|
||||||
|
if (lead_trim < 0)
|
||||||
{
|
{
|
||||||
lead_trim = 0;
|
lead_trim = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue