forked from len0rd/rockbox
More completely flush WMA decoder state on seek to prevent artifact.
Each MDCT depends on the previous frame for reconstruction. Previosly these were not zeroed out when seeking, resulting in a few milliseconds of the previous frame playing with the current one. Fix that. Additionally, since the codec treats seeks to the start of a track as a "reset", flush the entire codec state in this event to ensure that everything is reset. Change-Id: If593621a2922b0bbfa34f926f9bff31bee6b8c6a
This commit is contained in:
parent
905f920dc9
commit
bc41926b8f
1 changed files with 13 additions and 7 deletions
20
apps/codecs/wma.c
Normal file → Executable file
20
apps/codecs/wma.c
Normal file → Executable file
|
|
@ -54,14 +54,15 @@ enum codec_status codec_run(void)
|
|||
int errcount = 0;
|
||||
intptr_t param;
|
||||
|
||||
/* Proper reset of the decoder context. */
|
||||
memset(&wmadec, 0, sizeof(wmadec));
|
||||
|
||||
/* Remember the resume position - when the codec is opened, the
|
||||
playback engine will reset it. */
|
||||
resume_offset = ci->id3->offset;
|
||||
|
||||
restart_track:
|
||||
|
||||
/* Proper reset of the decoder context. */
|
||||
memset(&wmadec, 0, sizeof(wmadec));
|
||||
|
||||
if (codec_init()) {
|
||||
LOGF("WMA: Error initialising codec\n");
|
||||
return CODEC_ERROR;
|
||||
|
|
@ -111,6 +112,15 @@ restart_track:
|
|||
/* Deal with any pending seek requests */
|
||||
if (action == CODEC_ACTION_SEEK_TIME) {
|
||||
|
||||
/*flush the wma decoder state*/
|
||||
wmadec.last_superframe_len = 0;
|
||||
wmadec.last_bitoffset = 0;
|
||||
|
||||
/*zero the frame out buffer so we don't overlap with a
|
||||
stale samples*/
|
||||
memset((*(wmadec.frame_out)), 0,
|
||||
sizeof(fixed32) * MAX_CHANNELS * BLOCK_MAX_SIZE * 2);
|
||||
|
||||
if (param == 0) {
|
||||
ci->set_elapsed(0);
|
||||
ci->seek_complete();
|
||||
|
|
@ -125,10 +135,6 @@ restart_track:
|
|||
}
|
||||
/*DEBUGF("Seek returned %d\n", (int)elapsedtime);*/
|
||||
|
||||
/*flush the wma decoder state*/
|
||||
wmadec.last_superframe_len = 0;
|
||||
wmadec.last_bitoffset = 0;
|
||||
|
||||
ci->set_elapsed(elapsedtime);
|
||||
ci->seek_complete();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue