summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2012-04-03 20:15:16 -0400
committerMichael Giacomelli <giac2000@hotmail.com>2012-04-03 20:15:16 -0400
commitbc41926b8f1b77127dd471fc530e9990624d0e36 (patch)
tree6f54d3d1aab602d24ec70bd49ff000073e87c7ea
parent905f920dc9aaed5ad64e2472d080ce1182b980d9 (diff)
downloadrockbox-bc41926b8f1b77127dd471fc530e9990624d0e36.tar.gz
rockbox-bc41926b8f1b77127dd471fc530e9990624d0e36.zip
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
-rwxr-xr-x[-rw-r--r--]apps/codecs/wma.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/codecs/wma.c b/apps/codecs/wma.c
index 361fee6175..f9501ffad3 100644..100755
--- a/apps/codecs/wma.c
+++ b/apps/codecs/wma.c
@@ -54,14 +54,15 @@ enum codec_status codec_run(void)
54 int errcount = 0; 54 int errcount = 0;
55 intptr_t param; 55 intptr_t param;
56 56
57 /* Proper reset of the decoder context. */
58 memset(&wmadec, 0, sizeof(wmadec));
59
60 /* Remember the resume position - when the codec is opened, the 57 /* Remember the resume position - when the codec is opened, the
61 playback engine will reset it. */ 58 playback engine will reset it. */
62 resume_offset = ci->id3->offset; 59 resume_offset = ci->id3->offset;
63 60
64restart_track: 61restart_track:
62
63 /* Proper reset of the decoder context. */
64 memset(&wmadec, 0, sizeof(wmadec));
65
65 if (codec_init()) { 66 if (codec_init()) {
66 LOGF("WMA: Error initialising codec\n"); 67 LOGF("WMA: Error initialising codec\n");
67 return CODEC_ERROR; 68 return CODEC_ERROR;
@@ -111,6 +112,15 @@ restart_track:
111 /* Deal with any pending seek requests */ 112 /* Deal with any pending seek requests */
112 if (action == CODEC_ACTION_SEEK_TIME) { 113 if (action == CODEC_ACTION_SEEK_TIME) {
113 114
115 /*flush the wma decoder state*/
116 wmadec.last_superframe_len = 0;
117 wmadec.last_bitoffset = 0;
118
119 /*zero the frame out buffer so we don't overlap with a
120 stale samples*/
121 memset((*(wmadec.frame_out)), 0,
122 sizeof(fixed32) * MAX_CHANNELS * BLOCK_MAX_SIZE * 2);
123
114 if (param == 0) { 124 if (param == 0) {
115 ci->set_elapsed(0); 125 ci->set_elapsed(0);
116 ci->seek_complete(); 126 ci->seek_complete();
@@ -125,10 +135,6 @@ restart_track:
125 } 135 }
126 /*DEBUGF("Seek returned %d\n", (int)elapsedtime);*/ 136 /*DEBUGF("Seek returned %d\n", (int)elapsedtime);*/
127 137
128 /*flush the wma decoder state*/
129 wmadec.last_superframe_len = 0;
130 wmadec.last_bitoffset = 0;
131
132 ci->set_elapsed(elapsedtime); 138 ci->set_elapsed(elapsedtime);
133 ci->seek_complete(); 139 ci->seek_complete();
134 } 140 }