Benjamin Otte
2007-Oct-15 19:12 UTC
[Swfdec] 3 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_codec_audio.h test/swfdec-extract.c
libswfdec/swfdec_as_interpret.c | 1 libswfdec/swfdec_codec_audio.h | 2 - test/swfdec-extract.c | 43 ++++++++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 16 deletions(-) New commits: commit e1267777e2a617fcafb578fa411a5c739ef51253 Author: Benjamin Otte <otte at gnome.org> Date: Mon Oct 15 21:11:57 2007 +0200 indent diff --git a/libswfdec/swfdec_codec_audio.h b/libswfdec/swfdec_codec_audio.h index 157eadf..8a0f4f1 100644 --- a/libswfdec/swfdec_codec_audio.h +++ b/libswfdec/swfdec_codec_audio.h @@ -49,7 +49,7 @@ struct _SwfdecAudioDecoder { SwfdecAudioDecoder * swfdec_audio_decoder_new (SwfdecAudioCodec codec, SwfdecAudioFormat format); void swfdec_audio_decoder_free (SwfdecAudioDecoder * decoder); -SwfdecAudioFormat swfdec_audio_decoder_get_format (SwfdecAudioDecoder * decoder); +SwfdecAudioFormat swfdec_audio_decoder_get_format (SwfdecAudioDecoder * decoder); void swfdec_audio_decoder_push (SwfdecAudioDecoder * decoder, SwfdecBuffer * buffer); SwfdecBuffer * swfdec_audio_decoder_pull (SwfdecAudioDecoder * decoder); commit 2fad068e134ad983a46a46725dc2a449b178d6ce Author: Benjamin Otte <otte at gnome.org> Date: Mon Oct 15 21:11:46 2007 +0200 fix to work with new audio stuff diff --git a/test/swfdec-extract.c b/test/swfdec-extract.c index 1466de6..07dce11 100644 --- a/test/swfdec-extract.c +++ b/test/swfdec-extract.c @@ -44,20 +44,36 @@ #include <libswfdec/swfdec_swf_instance.h> static SwfdecBuffer * -encode_wav (SwfdecBuffer *buffer) +encode_wav (SwfdecBuffer *buffer, SwfdecAudioFormat format) { SwfdecBuffer *wav = swfdec_buffer_new_and_alloc (buffer->length + 44); unsigned char *data; guint i; data = wav->data; + /* FIXME: too much magic in this memmove */ memmove (data, "RIFF----WAVEfmt \020\0\0\0" - "\001\0\002\0D\254\0\0\020\261\002\0\004\0\020\0data", 40); - *(gint32 *) &data[4] = GUINT32_TO_LE (buffer->length + 36); - *(gint32 *) &data[40] = GUINT32_TO_LE (buffer->length); + "\001\0ccRRRRbbbbAAbbdata", 40); + *(guint32 *) &data[4] = GUINT32_TO_LE (buffer->length + 36); + *(guint16 *) &data[22] = GUINT16_TO_LE (swfdec_audio_format_get_channels (format)); + *(guint32 *) &data[24] = GUINT32_TO_LE (swfdec_audio_format_get_rate (format)); + /* bits per sample */ + i = swfdec_audio_format_is_16bit (format) ? 2 : 1; + *(guint16 *) &data[34] = GUINT16_TO_LE (i * 8); + /* block align */ + i *= swfdec_audio_format_get_channels (format); + *(guint16 *) &data[32] = GUINT16_TO_LE (i); + /* bytes per second */ + i *= swfdec_audio_format_get_rate (format); + *(guint32 *) &data[28] = GUINT32_TO_LE (i); + *(guint32 *) &data[40] = GUINT32_TO_LE (buffer->length); data += 44; - for (i = 0; i < buffer->length; i += 2) { - *(gint16 *) (data + i) = GINT16_TO_LE (*(gint16* )(buffer->data + i)); + if (swfdec_audio_format_is_16bit (format)) { + for (i = 0; i < buffer->length; i += 2) { + *(gint16 *) (data + i) = GINT16_TO_LE (*(gint16* )(buffer->data + i)); + } + } else { + memcpy (data, buffer->data, buffer->length); } return wav; } @@ -66,17 +82,16 @@ static gboolean export_sound (SwfdecSound *sound, const char *filename) { GError *error = NULL; - SwfdecBuffer *wav; - gint16 tmp[2]; + SwfdecBuffer *wav, *buffer; + SwfdecAudioFormat format; /* try to render the sound, that should decode it. */ - swfdec_sound_render (sound, tmp, 0, 1); - - if (sound->decoded == NULL) { - g_printerr ("not a sound event. For extraction of streams extract the sprite.\n"); + buffer = swfdec_sound_get_decoded (sound, &format); + if (buffer == NULL) { + g_printerr ("Couldn't decode sound. For extraction of streams extract the sprite.\n"); return FALSE; } - wav = encode_wav (sound->decoded); + wav = encode_wav (buffer, format); if (!g_file_set_contents (filename, (char *) wav->data, wav->length, &error)) { g_printerr ("Couldn't save sound to file \"%s\": %s\n", filename, error->message); @@ -133,7 +148,7 @@ export_sprite_sound (SwfdecSprite *sprite, const char *filename) } buffer = swfdec_buffer_queue_pull (queue, depth); swfdec_buffer_queue_unref (queue); - wav = encode_wav (buffer); + wav = encode_wav (buffer, swfdec_audio_format_new (44100, 2, TRUE)); swfdec_buffer_unref (buffer); if (!g_file_set_contents (filename, (char *) wav->data, wav->length, &error)) { commit 7477b57ae166cf3a1f08550637c20d4215fe3341 Author: Benjamin Otte <otte at gnome.org> Date: Mon Oct 15 20:00:42 2007 +0200 Pop ction appeared twice in list diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c index f2022b4..e11397f 100644 --- a/libswfdec/swfdec_as_interpret.c +++ b/libswfdec/swfdec_as_interpret.c @@ -2795,7 +2795,6 @@ const SwfdecActionSpec swfdec_as_actions[256] = { [SWFDEC_AS_ACTION_ASCII_TO_CHAR] = { "AsciiToChar", NULL, 1, 1, { NULL, swfdec_action_ascii_to_char_5, swfdec_action_ascii_to_char_5, swfdec_action_ascii_to_char, swfdec_action_ascii_to_char } }, [SWFDEC_AS_ACTION_GET_TIME] = { "GetTime", NULL, 0, 1, { NULL, swfdec_action_get_time, swfdec_action_get_time, swfdec_action_get_time, swfdec_action_get_time } }, [SWFDEC_AS_ACTION_MB_STRING_EXTRACT] = { "MBStringExtract", NULL, 3, 1, { NULL, swfdec_action_string_extract, swfdec_action_string_extract, swfdec_action_string_extract, swfdec_action_string_extract } }, - [SWFDEC_AS_ACTION_POP] = { "Pop", NULL, 1, 0, { NULL, swfdec_action_pop, swfdec_action_pop, swfdec_action_pop, swfdec_action_pop } }, [SWFDEC_AS_ACTION_MB_CHAR_TO_ASCII] = { "MBCharToAscii", NULL }, [SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR] = { "MBAsciiToChar", NULL, 1, 1, { NULL, swfdec_action_mb_ascii_to_char_5, swfdec_action_mb_ascii_to_char_5, swfdec_action_ascii_to_char, swfdec_action_ascii_to_char } }, /* version 5 */
Seemingly Similar Threads
- 14 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_interpret.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_script.c libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_tag.c libswfdec/swfdec_text_field_movie.c
- 6 commits - libswfdec/Makefile.am libswfdec/swfdec_audio_flv.c libswfdec/swfdec_audio_flv.h libswfdec/swfdec_audio_stream.c libswfdec/swfdec_audio_stream.h libswfdec/swfdec_buffer.c libswfdec/swfdec_codec_adpcm.c libswfdec/swfdec_codec_audio.c
- 9 commits - configure.ac libswfdec/swfdec_as_context.c libswfdec/swfdec_audio_internal.h libswfdec/swfdec_codec_audio.c libswfdec/swfdec_codec_gst.c libswfdec/swfdec_sound.c
- 4 commits - libswfdec/swfdec_codec_audio.c libswfdec/swfdec_codec_gst.c libswfdec/swfdec_codec_video.c libswfdec/swfdec_sound.c
- libswfdec/swfdec_codec_audio.c libswfdec/swfdec_codec_gst.c