diff options
Diffstat (limited to 'apps/codecs/wma.c')
-rw-r--r-- | apps/codecs/wma.c | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/apps/codecs/wma.c b/apps/codecs/wma.c index 235f1a38c9..17d2af2e98 100644 --- a/apps/codecs/wma.c +++ b/apps/codecs/wma.c | |||
@@ -34,60 +34,6 @@ static uint32_t decoded[BLOCK_MAX_SIZE * MAX_CHANNELS] IBSS_ATTR; | |||
34 | /* NOTE: WMADecodeContext is 120152 bytes (on x86) */ | 34 | /* NOTE: WMADecodeContext is 120152 bytes (on x86) */ |
35 | static WMADecodeContext wmadec; | 35 | static WMADecodeContext wmadec; |
36 | 36 | ||
37 | /*entry point for seeks*/ | ||
38 | static int seek(int ms, asf_waveformatex_t* wfx) | ||
39 | { | ||
40 | int time, duration, delta, temp, count=0; | ||
41 | |||
42 | /*estimate packet number from bitrate*/ | ||
43 | int initial_packet = ci->curpos/wfx->packet_size; | ||
44 | int packet_num = (((int64_t)ms)*(wfx->bitrate>>3))/wfx->packet_size/1000; | ||
45 | int last_packet = ci->id3->filesize / wfx->packet_size; | ||
46 | |||
47 | if (packet_num > last_packet) { | ||
48 | packet_num = last_packet; | ||
49 | } | ||
50 | |||
51 | /*calculate byte address of the start of that packet*/ | ||
52 | int packet_offset = packet_num*wfx->packet_size; | ||
53 | |||
54 | /*seek to estimated packet*/ | ||
55 | ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); | ||
56 | temp = ms; | ||
57 | while (1) | ||
58 | { | ||
59 | /*for very large files it can be difficult and unimportant to find the exact packet*/ | ||
60 | count++; | ||
61 | |||
62 | /*check the time stamp of our packet*/ | ||
63 | time = asf_get_timestamp(&duration); | ||
64 | DEBUGF("seeked to %d ms with duration %d\n", time, duration); | ||
65 | |||
66 | if (time < 0) { | ||
67 | /*unknown error, try to recover*/ | ||
68 | DEBUGF("UKNOWN SEEK ERROR\n"); | ||
69 | ci->seek_buffer(ci->id3->first_frame_offset+initial_packet*wfx->packet_size); | ||
70 | /*seek failed so return time stamp of the initial packet*/ | ||
71 | return asf_get_timestamp(&duration); | ||
72 | } | ||
73 | |||
74 | if ((time+duration>=ms && time<=ms) || count > 10) { | ||
75 | DEBUGF("Found our packet! Now at %d packet\n", packet_num); | ||
76 | return time; | ||
77 | } else { | ||
78 | /*seek again*/ | ||
79 | delta = ms-time; | ||
80 | /*estimate new packet number from bitrate and our current position*/ | ||
81 | temp += delta; | ||
82 | packet_num = ((temp/1000)*(wfx->bitrate>>3) - (wfx->packet_size>>1))/wfx->packet_size; //round down! | ||
83 | packet_offset = packet_num*wfx->packet_size; | ||
84 | ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | |||
90 | |||
91 | /* this is the codec entry point */ | 37 | /* this is the codec entry point */ |
92 | enum codec_status codec_main(void) | 38 | enum codec_status codec_main(void) |
93 | { | 39 | { |