Pekka Lampila
2007-Nov-18 17:42 UTC
[Swfdec] 3 commits - libswfdec/swfdec_audio_event.c libswfdec/swfdec_sound.c
libswfdec/swfdec_audio_event.c | 24 ++++++++++++------------ libswfdec/swfdec_sound.c | 4 ++++ 2 files changed, 16 insertions(+), 12 deletions(-) New commits: commit 18c5498527fafbd536c1ba79117f2983469e5cc7 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Nov 18 19:42:39 2007 +0200 Don't return double from swfdec_audio_event_get_envelop_volume diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c index 3c3b603..13fb588 100644 --- a/libswfdec/swfdec_audio_event.c +++ b/libswfdec/swfdec_audio_event.c @@ -50,32 +50,32 @@ swfdec_audio_event_iterate (SwfdecAudio *audio, guint remove) return 0; } -static double +static guint16 swfdec_audio_event_get_envelop_volume (SwfdecAudioEvent *event, guint pos, guint offset, guint channel) { double distance; - g_return_val_if_fail (SWFDEC_IS_AUDIO_EVENT (event), 1); - g_return_val_if_fail (pos <= event->n_envelopes, 1); - g_return_val_if_fail (channel == 0 || channel == 1, 1); + g_return_val_if_fail (SWFDEC_IS_AUDIO_EVENT (event), 32768); + g_return_val_if_fail (pos <= event->n_envelopes, 32768); + g_return_val_if_fail (channel == 0 || channel == 1, 32768); if (event->n_envelopes == 0) - return 1; + return 32768; if (pos == 0) - return event->envelope[pos].volume[channel] / 32768.0; + return event->envelope[pos].volume[channel]; if (pos == event->n_envelopes) - return event->envelope[pos - 1].volume[channel] / 32768.0; + return event->envelope[pos - 1].volume[channel]; distance = event->envelope[pos].offset - event->envelope[pos - 1].offset; g_return_val_if_fail (offset >= event->envelope[pos - 1].offset, 1); offset -= event->envelope[pos - 1].offset; g_return_val_if_fail (offset < distance, 1); - return (event->envelope[pos - 1].volume[channel] * (1 - offset / distance) + - event->envelope[pos].volume[channel] * (offset / distance)) / 32768.0; + return event->envelope[pos - 1].volume[channel] * (1 - offset / distance) + + event->envelope[pos].volume[channel] * (offset / distance); } static void @@ -119,13 +119,13 @@ swfdec_audio_event_render (SwfdecAudio *audio, gint16* dest, guint start, event->envelope[pos].offset <= global_offset + (i / 2)) pos++; if (channels == 1) { - dest[i] *= swfdec_audio_event_get_envelop_volume (event, pos, + dest[i] *= (swfdec_audio_event_get_envelop_volume (event, pos, global_offset + (i / 2), 0) * 0.5 + swfdec_audio_event_get_envelop_volume (event, pos, - global_offset + (i / 2), 1) * 0.5; + global_offset + (i / 2), 1) * 0.5) / 32768.0; } else { dest[i] *= swfdec_audio_event_get_envelop_volume (event, pos, - global_offset + (i / 2), i % 2); + global_offset + (i / 2), i % 2) / 32768.0; } } } commit c0dcf0bbf9feb29c792e5791595e235210f4261e Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Nov 18 18:08:45 2007 +0200 Fix yet another oops in the sound envelope code diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c index a0d1581..3c3b603 100644 --- a/libswfdec/swfdec_audio_event.c +++ b/libswfdec/swfdec_audio_event.c @@ -122,7 +122,7 @@ swfdec_audio_event_render (SwfdecAudio *audio, gint16* dest, guint start, dest[i] *= swfdec_audio_event_get_envelop_volume (event, pos, global_offset + (i / 2), 0) * 0.5 + swfdec_audio_event_get_envelop_volume (event, pos, - global_offset + (i / 2), 1); + global_offset + (i / 2), 1) * 0.5; } else { dest[i] *= swfdec_audio_event_get_envelop_volume (event, pos, global_offset + (i / 2), i % 2); commit b1b1e84b689c361b69147adc523a50ebc58aeb5a Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Sun Nov 18 18:01:53 2007 +0200 In StartSound tag loop_count 0 means 1 diff --git a/libswfdec/swfdec_sound.c b/libswfdec/swfdec_sound.c index 4b97df5..dffe212 100644 --- a/libswfdec/swfdec_sound.c +++ b/libswfdec/swfdec_sound.c @@ -348,6 +348,10 @@ swfdec_sound_parse_chunk (SwfdecSwfDecoder *s, SwfdecBits *b, int id) } if (has_loops) { chunk->loop_count = swfdec_bits_get_u16 (b); + if (chunk->loop_count == 0) { + SWFDEC_ERROR ("loop_count 0 not allowed, setting to 1"); + chunk->loop_count = 1; + } SWFDEC_LOG (" loop_count = %u", chunk->loop_count); } else { chunk->loop_count = 1;
Seemingly Similar Threads
- 12 commits - configure.ac doc/Makefile.am libswfdec/swfdec_as_frame.c libswfdec/swfdec_audio.c libswfdec/swfdec_audio_event.c libswfdec/swfdec_audio_event.h libswfdec/swfdec_shape_parser.c libswfdec/swfdec_sound.c test/sound
- 5 commits - libswfdec/swfdec_as_object.c libswfdec/swfdec_audio.c libswfdec/swfdec_sound.c libswfdec/swfdec_xml.c
- 2 commits - libswfdec/swfdec_sound.c libswfdec/swfdec_text_field_movie.c
- libswfdec/swfdec_audio_event.c libswfdec/swfdec_bits.c libswfdec/swfdec_sound.c libswfdec/swfdec_sprite.c libswfdec/swfdec_swf_decoder.c
- libswfdec/swfdec_audio_event.c