[Swfdec-commits] 13 commits - swfdec/swfdec_audio_decoder_adpcm.c swfdec/swfdec_audio_decoder.c swfdec/swfdec_audio_decoder_gst.c swfdec/swfdec_audio_decoder.h swfdec/swfdec_audio_decoder_uncompressed.c swfdec/swfdec_audio_flv.c swfdec/swfdec_audio_stream.c swfdec/swfdec_codec_gst.c swfdec/swfdec_codec_gst.h swfdec/swfdec_net_stream.c swfdec/swfdec_sound.c swfdec/swfdec_video_decoder.c swfdec/swfdec_video_decoder_gst.c swfdec/swfdec_video_decoder.h swfdec/swfdec_video_decoder_screen.c swfdec/swfdec_video_decoder_vp6_alpha.c swfdec/swfdec_video_video_provider.c
Benjamin Otte
company at kemper.freedesktop.org
Tue Dec 16 12:40:55 PST 2008
swfdec/swfdec_audio_decoder.c | 37 ++++++++++++++--
swfdec/swfdec_audio_decoder.h | 12 +++--
swfdec/swfdec_audio_decoder_adpcm.c | 2
swfdec/swfdec_audio_decoder_gst.c | 20 ++++++++
swfdec/swfdec_audio_decoder_uncompressed.c | 2
swfdec/swfdec_audio_flv.c | 45 ++++++++++++++++++-
swfdec/swfdec_audio_stream.c | 2
swfdec/swfdec_codec_gst.c | 18 +++++++
swfdec/swfdec_codec_gst.h | 3 +
swfdec/swfdec_net_stream.c | 66 ++++++-----------------------
swfdec/swfdec_sound.c | 2
swfdec/swfdec_video_decoder.c | 37 ++++++++++++++--
swfdec/swfdec_video_decoder.h | 12 +++--
swfdec/swfdec_video_decoder_gst.c | 32 ++++++++------
swfdec/swfdec_video_decoder_screen.c | 2
swfdec/swfdec_video_decoder_vp6_alpha.c | 6 +-
swfdec/swfdec_video_video_provider.c | 2
17 files changed, 209 insertions(+), 91 deletions(-)
New commits:
commit f82ce694440e90e783af8f90e8e3f8bb9382bf66
Merge: 6438ee5... 08ed13b...
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 15:11:33 2008 +0100
Merge branch '0.8'
commit 6438ee54032919a9c7789881604a0bb2739a688c
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 15:11:20 2008 +0100
Revert "add support for H264 video"
This reverts commit cc5ad40ffad9d6b7f4d66363bb84f9e4668e6daa.
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
index 11d1ac5..7472b56 100644
--- a/swfdec/swfdec_net_stream.c
+++ b/swfdec/swfdec_net_stream.c
@@ -103,62 +103,11 @@ swfdec_net_stream_decode_video (SwfdecVideoDecoder *decoder, SwfdecBuffer *buffe
decoder->width -= wsub;
decoder->height -= hsub;
}
- } else if (decoder->codec == SWFDEC_VIDEO_CODEC_H264) {
- SwfdecBits bits;
- guint type;
- SwfdecBuffer *data;
- swfdec_bits_init (&bits, buffer);
- type = swfdec_bits_get_u8 (&bits);
- /* composition_time_offset = */ swfdec_bits_get_bu24 (&bits);
- switch (type) {
- case 0:
- SWFDEC_ERROR ("new data stream?!");
- break;
- case 1:
- data = swfdec_bits_get_buffer (&bits, -1);
- if (data) {
- swfdec_video_decoder_decode (decoder, data);
- } else {
- SWFDEC_ERROR ("no data in H264 buffer?");
- }
- break;
- case 2:
- break;
- default:
- SWFDEC_ERROR ("H264 data type %u not supported", type);
- break;
- }
} else {
swfdec_video_decoder_decode (decoder, buffer);
}
}
-/* returns TRUE if the buffer was consumed */
-static gboolean
-swfdec_net_stream_new_video_decoder (SwfdecNetStream *stream, guint format, SwfdecBuffer *buffer)
-{
- if (format == SWFDEC_VIDEO_CODEC_H264) {
- SwfdecBits bits;
-
- swfdec_bits_init (&bits, buffer);
- if (swfdec_bits_get_u8 (&bits) == 0) {
- SwfdecBuffer *data;
- /* composition_time_offset = */ swfdec_bits_get_bu24 (&bits);
- data = swfdec_bits_get_buffer (&bits, -1);
- stream->decoder = swfdec_video_decoder_new (format, data);
- if (data)
- swfdec_buffer_unref (data);
- return TRUE;
- } else {
- stream->decoder = swfdec_video_decoder_new (format, NULL);
- return FALSE;
- }
- } else {
- stream->decoder = swfdec_video_decoder_new (format, NULL);
- return FALSE;
- }
-}
-
static void swfdec_net_stream_update_playing (SwfdecNetStream *stream);
static void
swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
@@ -166,7 +115,7 @@ swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
SwfdecBuffer *buffer;
guint format;
cairo_surface_t *old;
- gboolean process_events, skip;
+ gboolean process_events;
guint process_events_from;
SWFDEC_LOG ("goto %ums", timestamp);
@@ -200,14 +149,12 @@ swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
stream->decoder = NULL;
}
- skip = FALSE;
if (stream->decoder == NULL) {
buffer = swfdec_flv_decoder_get_video (stream->flvdecoder,
stream->current_time, TRUE, &format, &stream->decoder_time,
&next);
- skip = !swfdec_net_stream_new_video_decoder (stream, format, buffer);
- }
- if (!skip) {
+ stream->decoder = swfdec_video_decoder_new (format);
+ } else {
swfdec_flv_decoder_get_video (stream->flvdecoder,
stream->decoder_time, FALSE, NULL, NULL, &next);
if (next != stream->current_time) {
@@ -238,10 +185,9 @@ swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
for (;;) {
if (format != swfdec_video_decoder_get_codec (stream->decoder)) {
g_object_unref (stream->decoder);
- skip = swfdec_net_stream_new_video_decoder (stream, format, buffer);
+ stream->decoder = swfdec_video_decoder_new (format);
}
- if (!skip)
- swfdec_net_stream_decode_video (stream->decoder, buffer);
+ swfdec_net_stream_decode_video (stream->decoder, buffer);
if (stream->decoder_time >= stream->current_time)
break;
diff --git a/swfdec/swfdec_video_decoder.c b/swfdec/swfdec_video_decoder.c
index 43ddb98..c09a293 100644
--- a/swfdec/swfdec_video_decoder.c
+++ b/swfdec/swfdec_video_decoder.c
@@ -65,7 +65,6 @@ swfdec_video_codec_get_format (guint codec)
case SWFDEC_VIDEO_CODEC_H263:
case SWFDEC_VIDEO_CODEC_VP6:
case SWFDEC_VIDEO_CODEC_VP6_ALPHA:
- case SWFDEC_VIDEO_CODEC_H264:
return SWFDEC_VIDEO_FORMAT_I420;
case SWFDEC_VIDEO_CODEC_UNDEFINED:
case SWFDEC_VIDEO_CODEC_SCREEN:
@@ -112,8 +111,6 @@ swfdec_video_decoder_prepare (guint codec, char **missing)
/**
* swfdec_video_decoder_new:
* @codec: codec id
- * @data: initialization data for the video codec or %NULL if none. Currently
- * only used for H264
*
* Creates a decoder suitable for decoding @format. If no decoder is available
* for the given for mat, %NULL is returned.
@@ -121,14 +118,14 @@ swfdec_video_decoder_prepare (guint codec, char **missing)
* Returns: a new decoder or %NULL
**/
SwfdecVideoDecoder *
-swfdec_video_decoder_new (guint codec, SwfdecBuffer *buffer)
+swfdec_video_decoder_new (guint codec)
{
SwfdecVideoDecoder *ret = NULL;
GSList *walk;
for (walk = video_codecs; walk; walk = walk->next) {
SwfdecVideoDecoderClass *klass = g_type_class_ref (GPOINTER_TO_SIZE (walk->data));
- ret = klass->create (codec, buffer);
+ ret = klass->create (codec);
g_type_class_unref (klass);
if (ret)
break;
diff --git a/swfdec/swfdec_video_decoder.h b/swfdec/swfdec_video_decoder.h
index 091c42c..2b1b663 100644
--- a/swfdec/swfdec_video_decoder.h
+++ b/swfdec/swfdec_video_decoder.h
@@ -32,7 +32,6 @@ G_BEGIN_DECLS
#define SWFDEC_VIDEO_CODEC_VP6 4
#define SWFDEC_VIDEO_CODEC_VP6_ALPHA 5
#define SWFDEC_VIDEO_CODEC_SCREEN2 6
-#define SWFDEC_VIDEO_CODEC_H264 7
typedef enum {
SWFDEC_VIDEO_FORMAT_RGBA,
@@ -74,8 +73,7 @@ struct _SwfdecVideoDecoderClass
/*< public >*/
gboolean (* prepare) (guint codec,
char ** missing);
- SwfdecVideoDecoder * (* create) (guint codec,
- SwfdecBuffer * data);
+ SwfdecVideoDecoder * (* create) (guint codec);
void (* decode) (SwfdecVideoDecoder * decoder,
SwfdecBuffer * buffer);
@@ -90,8 +88,7 @@ void swfdec_video_decoder_register (GType type);
gboolean swfdec_video_decoder_prepare (guint codec,
char ** missing);
-SwfdecVideoDecoder * swfdec_video_decoder_new (guint codec,
- SwfdecBuffer * buffer);
+SwfdecVideoDecoder * swfdec_video_decoder_new (guint codec);
void swfdec_video_decoder_decode (SwfdecVideoDecoder * decoder,
SwfdecBuffer * buffer);
diff --git a/swfdec/swfdec_video_decoder_gst.c b/swfdec/swfdec_video_decoder_gst.c
index 38f393d..893fc45 100644
--- a/swfdec/swfdec_video_decoder_gst.c
+++ b/swfdec/swfdec_video_decoder_gst.c
@@ -29,7 +29,7 @@
#include "swfdec_debug.h"
static GstCaps *
-swfdec_video_decoder_get_caps (guint codec, SwfdecBuffer *buffer)
+swfdec_video_decoder_get_caps (guint codec)
{
GstCaps *caps;
@@ -40,17 +40,6 @@ swfdec_video_decoder_get_caps (guint codec, SwfdecBuffer *buffer)
case SWFDEC_VIDEO_CODEC_VP6:
caps = gst_caps_from_string ("video/x-vp6-flash");
break;
- case SWFDEC_VIDEO_CODEC_H264:
- caps = gst_caps_from_string ("video/x-h264");
- if (buffer) {
- GstBuffer *gstbuf;
-
- swfdec_buffer_ref (buffer);
- gstbuf = swfdec_gst_buffer_new (buffer);
- gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, gstbuf, NULL);
- gst_buffer_unref (gstbuf);
- }
- break;
default:
return NULL;
}
@@ -86,7 +75,7 @@ swfdec_video_decoder_gst_prepare (guint codec, char **missing)
GstCaps *caps;
/* Check if we can handle the format at all. If not, no plugin will help us. */
- caps = swfdec_video_decoder_get_caps (codec, NULL);
+ caps = swfdec_video_decoder_get_caps (codec);
if (caps == NULL)
return FALSE;
@@ -105,12 +94,12 @@ swfdec_video_decoder_gst_prepare (guint codec, char **missing)
}
static SwfdecVideoDecoder *
-swfdec_video_decoder_gst_create (guint codec, SwfdecBuffer *buffer)
+swfdec_video_decoder_gst_create (guint codec)
{
SwfdecVideoDecoderGst *player;
GstCaps *srccaps, *sinkcaps;
- srccaps = swfdec_video_decoder_get_caps (codec, buffer);
+ srccaps = swfdec_video_decoder_get_caps (codec);
if (srccaps == NULL)
return NULL;
sinkcaps = swfdec_video_decoder_get_sink_caps (codec);
diff --git a/swfdec/swfdec_video_decoder_screen.c b/swfdec/swfdec_video_decoder_screen.c
index c4c8be3..42504b5 100644
--- a/swfdec/swfdec_video_decoder_screen.c
+++ b/swfdec/swfdec_video_decoder_screen.c
@@ -34,7 +34,7 @@ swfdec_video_decoder_screen_prepare (guint codec, char **missing)
}
static SwfdecVideoDecoder *
-swfdec_video_decoder_screen_create (guint codec, SwfdecBuffer *buffer)
+swfdec_video_decoder_screen_create (guint codec)
{
if (codec != SWFDEC_VIDEO_CODEC_SCREEN)
return NULL;
diff --git a/swfdec/swfdec_video_decoder_vp6_alpha.c b/swfdec/swfdec_video_decoder_vp6_alpha.c
index e7fba2c..8e443fc 100644
--- a/swfdec/swfdec_video_decoder_vp6_alpha.c
+++ b/swfdec/swfdec_video_decoder_vp6_alpha.c
@@ -38,7 +38,7 @@ swfdec_video_decoder_vp6_alpha_prepare (guint codec, char **missing)
}
static SwfdecVideoDecoder *
-swfdec_video_decoder_vp6_alpha_create (guint codec, SwfdecBuffer *buffer)
+swfdec_video_decoder_vp6_alpha_create (guint codec)
{
if (codec != SWFDEC_VIDEO_CODEC_VP6_ALPHA)
return NULL;
@@ -128,8 +128,8 @@ swfdec_video_decoder_vp6_alpha_class_init (SwfdecVideoDecoderVp6AlphaClass *klas
static void
swfdec_video_decoder_vp6_alpha_init (SwfdecVideoDecoderVp6Alpha *vp6)
{
- vp6->image = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6, NULL);
- vp6->mask = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6, NULL);
+ vp6->image = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6);
+ vp6->mask = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6);
if (swfdec_video_decoder_get_error (vp6->image) ||
swfdec_video_decoder_get_error (vp6->mask)) {
diff --git a/swfdec/swfdec_video_video_provider.c b/swfdec/swfdec_video_video_provider.c
index 7e05d66..74d6bd3 100644
--- a/swfdec/swfdec_video_video_provider.c
+++ b/swfdec/swfdec_video_video_provider.c
@@ -99,7 +99,7 @@ swfdec_video_video_provider_get_image (SwfdecVideoProvider *prov,
if (provider->decoder != NULL) {
g_object_unref (provider->decoder);
}
- provider->decoder = swfdec_video_decoder_new (provider->video->format, NULL);
+ provider->decoder = swfdec_video_decoder_new (provider->video->format);
if (provider->decoder == NULL)
return NULL;
frame = &g_array_index (provider->video->images, SwfdecVideoFrame, 0);
commit cc2ec453cc59269870e41b65c3e89cf392f67a36
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 15:11:13 2008 +0100
Revert "don't create a new VideoDecoder after seeks"
This reverts commit c42092866fb29b4dd2d8ad8850f007990fd69148.
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
index 4a6f6c3..11d1ac5 100644
--- a/swfdec/swfdec_net_stream.c
+++ b/swfdec/swfdec_net_stream.c
@@ -194,13 +194,11 @@ swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
g_object_unref (stream->decoder);
stream->decoder = NULL;
}
-#if 0
if (stream->decoder != NULL &&
(stream->decoder_time >= stream->current_time)) {
g_object_unref (stream->decoder);
stream->decoder = NULL;
}
-#endif
skip = FALSE;
if (stream->decoder == NULL) {
@@ -697,12 +695,10 @@ swfdec_net_stream_seek (SwfdecNetStream *stream, double secs)
SWFDEC_ERROR ("FIXME: implement seeking in audio only NetStream");
return;
}
-#if 0
if (stream->decoder) {
g_object_unref (stream->decoder);
stream->decoder = NULL;
}
-#endif
msecs = secs * 1000;
msecs += first;
if (msecs > last)
commit 9a7bf3f0f7c533e3ecdafdc5c9a3eb210f02dd50
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 15:11:02 2008 +0100
Revert "make creating audio decoders take codec data, too"
This reverts commit 4742a6015fce9f5dc0f61b4399b32d2bc88cefe4.
diff --git a/swfdec/swfdec_audio_decoder.c b/swfdec/swfdec_audio_decoder.c
index c0b666b..72be732 100644
--- a/swfdec/swfdec_audio_decoder.c
+++ b/swfdec/swfdec_audio_decoder.c
@@ -83,8 +83,6 @@ swfdec_audio_decoder_prepare (guint codec, SwfdecAudioFormat format, char **miss
* swfdec_audio_decoder_new:
* @codec: codec id
* @format: #SwfdecAudioCodec to decode
- * @data: setup data for the codec or %NULL for none. Setup data is only
- * required for AAC audio.
*
* Creates a decoder suitable for decoding @format. If no decoder is available
* for the given for mat, %NULL is returned.
@@ -92,7 +90,7 @@ swfdec_audio_decoder_prepare (guint codec, SwfdecAudioFormat format, char **miss
* Returns: a new decoder or %NULL
**/
SwfdecAudioDecoder *
-swfdec_audio_decoder_new (guint codec, SwfdecAudioFormat format, SwfdecBuffer *data)
+swfdec_audio_decoder_new (guint codec, SwfdecAudioFormat format)
{
SwfdecAudioDecoder *ret = NULL;
GSList *walk;
@@ -101,7 +99,7 @@ swfdec_audio_decoder_new (guint codec, SwfdecAudioFormat format, SwfdecBuffer *d
for (walk = audio_codecs; walk; walk = walk->next) {
SwfdecAudioDecoderClass *klass = g_type_class_ref (GPOINTER_TO_SIZE (walk->data));
- ret = klass->create (codec, format, data);
+ ret = klass->create (codec, format);
g_type_class_unref (klass);
if (ret)
break;
diff --git a/swfdec/swfdec_audio_decoder.h b/swfdec/swfdec_audio_decoder.h
index 8c7fb5d..6837a48 100644
--- a/swfdec/swfdec_audio_decoder.h
+++ b/swfdec/swfdec_audio_decoder.h
@@ -70,8 +70,7 @@ struct _SwfdecAudioDecoderClass
SwfdecAudioFormat format,
char ** missing);
SwfdecAudioDecoder * (* create) (guint codec,
- SwfdecAudioFormat format,
- SwfdecBuffer * data);
+ SwfdecAudioFormat format);
void (* push) (SwfdecAudioDecoder * decoder,
SwfdecBuffer * buffer);
@@ -86,8 +85,7 @@ gboolean swfdec_audio_decoder_prepare (guint codec,
SwfdecAudioFormat format,
char ** missing);
SwfdecAudioDecoder * swfdec_audio_decoder_new (guint codec,
- SwfdecAudioFormat format,
- SwfdecBuffer * data);
+ SwfdecAudioFormat format);
void swfdec_audio_decoder_push (SwfdecAudioDecoder * decoder,
SwfdecBuffer * buffer);
diff --git a/swfdec/swfdec_audio_decoder_adpcm.c b/swfdec/swfdec_audio_decoder_adpcm.c
index 255af88..18eaab1 100644
--- a/swfdec/swfdec_audio_decoder_adpcm.c
+++ b/swfdec/swfdec_audio_decoder_adpcm.c
@@ -34,7 +34,7 @@ swfdec_audio_decoder_adpcm_prepare (guint codec, SwfdecAudioFormat format, char
}
static SwfdecAudioDecoder *
-swfdec_audio_decoder_adpcm_create (guint codec, SwfdecAudioFormat format, SwfdecBuffer *data)
+swfdec_audio_decoder_adpcm_create (guint codec, SwfdecAudioFormat format)
{
if (codec != SWFDEC_AUDIO_CODEC_ADPCM)
return NULL;
diff --git a/swfdec/swfdec_audio_decoder_gst.c b/swfdec/swfdec_audio_decoder_gst.c
index e22c05b..9b29957 100644
--- a/swfdec/swfdec_audio_decoder_gst.c
+++ b/swfdec/swfdec_audio_decoder_gst.c
@@ -108,7 +108,7 @@ swfdec_audio_decoder_get_resampler (void)
}
static SwfdecAudioDecoder *
-swfdec_audio_decoder_gst_create (guint type, SwfdecAudioFormat format, SwfdecBuffer *data)
+swfdec_audio_decoder_gst_create (guint type, SwfdecAudioFormat format)
{
SwfdecAudioDecoderGst *player;
GstCaps *srccaps, *sinkcaps;
diff --git a/swfdec/swfdec_audio_decoder_uncompressed.c b/swfdec/swfdec_audio_decoder_uncompressed.c
index e299f72..6a4caf6 100644
--- a/swfdec/swfdec_audio_decoder_uncompressed.c
+++ b/swfdec/swfdec_audio_decoder_uncompressed.c
@@ -35,7 +35,7 @@ swfdec_audio_decoder_uncompressed_prepare (guint codec, SwfdecAudioFormat format
}
static SwfdecAudioDecoder *
-swfdec_audio_decoder_uncompressed_create (guint codec, SwfdecAudioFormat format, SwfdecBuffer *data)
+swfdec_audio_decoder_uncompressed_create (guint codec, SwfdecAudioFormat format)
{
if (codec != SWFDEC_AUDIO_CODEC_UNDEFINED &&
codec != SWFDEC_AUDIO_CODEC_UNCOMPRESSED)
diff --git a/swfdec/swfdec_audio_flv.c b/swfdec/swfdec_audio_flv.c
index e5cd6be..2a49ee6 100644
--- a/swfdec/swfdec_audio_flv.c
+++ b/swfdec/swfdec_audio_flv.c
@@ -92,7 +92,7 @@ swfdec_audio_flv_decode_one (SwfdecAudioFlv *flv)
}
flv->format = format;
flv->in = in;
- flv->decoder = swfdec_audio_decoder_new (flv->format, flv->in, NULL);
+ flv->decoder = swfdec_audio_decoder_new (flv->format, flv->in);
if (flv->decoder == NULL)
return NULL;
} else if (format != flv->format ||
diff --git a/swfdec/swfdec_audio_stream.c b/swfdec/swfdec_audio_stream.c
index 0806350..857fecd 100644
--- a/swfdec/swfdec_audio_stream.c
+++ b/swfdec/swfdec_audio_stream.c
@@ -203,7 +203,7 @@ swfdec_audio_stream_use_decoder (SwfdecAudioStream *stream,
/* FIXME: send NULL buffer */
g_object_unref (stream->decoder);
}
- stream->decoder = swfdec_audio_decoder_new (codec, format, NULL);
+ stream->decoder = swfdec_audio_decoder_new (codec, format);
}
void
diff --git a/swfdec/swfdec_sound.c b/swfdec/swfdec_sound.c
index 75891c6..d228e45 100644
--- a/swfdec/swfdec_sound.c
+++ b/swfdec/swfdec_sound.c
@@ -192,7 +192,7 @@ swfdec_sound_get_decoded (SwfdecSound *sound)
if (sound->encoded == NULL)
return NULL;
- decoder = swfdec_audio_decoder_new (sound->codec, sound->format, NULL);
+ decoder = swfdec_audio_decoder_new (sound->codec, sound->format);
if (decoder == NULL)
return NULL;
commit 08ed13b0f846815735eb6a29af2dc4b6d53bc969
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 13:20:00 2008 +0100
add various hacks so we never remove the video decoder.
Removing the video decoder would put H264 video decoding into FAIL
state.
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
index 9316336..0fea305 100644
--- a/swfdec/swfdec_net_stream.c
+++ b/swfdec/swfdec_net_stream.c
@@ -165,14 +165,11 @@ swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
} else {
guint next;
- if (stream->decoder && swfdec_video_decoder_get_codec (stream->decoder) != format) {
- g_object_unref (stream->decoder);
- stream->decoder = NULL;
- }
if (stream->decoder != NULL &&
- (stream->decoder_time >= stream->current_time)) {
- g_object_unref (stream->decoder);
- stream->decoder = NULL;
+ stream->decoder_time >= stream->current_time) {
+ buffer = swfdec_flv_decoder_get_video (stream->flvdecoder,
+ stream->current_time, TRUE, &format, &stream->decoder_time,
+ &next);
}
if (stream->decoder == NULL) {
@@ -732,10 +729,6 @@ swfdec_net_stream_seek (SwfdecNetStream *stream, double secs)
SWFDEC_ERROR ("FIXME: implement seeking in audio only NetStream");
return;
}
- if (stream->decoder) {
- g_object_unref (stream->decoder);
- stream->decoder = NULL;
- }
msecs = secs * 1000;
msecs += first;
if (msecs > last)
commit c60581f4c20fe566e147e769775551f74a8d251a
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 13:08:55 2008 +0100
add a hack that makes codec setup data survive seeks
diff --git a/swfdec/swfdec_audio_flv.c b/swfdec/swfdec_audio_flv.c
index d3f8dbb..4595f07 100644
--- a/swfdec/swfdec_audio_flv.c
+++ b/swfdec/swfdec_audio_flv.c
@@ -95,6 +95,18 @@ swfdec_audio_flv_decode_one (SwfdecAudioFlv *flv)
flv->decoder = swfdec_audio_decoder_new (flv->format, flv->in);
if (flv->decoder == NULL)
return NULL;
+ /* This is a hack that ensures AAC codec data is always present, even if
+ * the decoder gets initialized in the middle of the stream */
+ if (format == SWFDEC_AUDIO_CODEC_AAC) {
+ SwfdecBuffer *tmp = swfdec_flv_decoder_get_audio (flv->flvdecoder,
+ 0, &format, NULL, NULL, NULL);
+ if (format == SWFDEC_AUDIO_CODEC_AAC && tmp->data[0] == 0 &&
+ tmp->length > 1) {
+ tmp = swfdec_buffer_new_subbuffer (tmp, 1, tmp->length - 1);
+ swfdec_audio_decoder_set_codec_data (flv->decoder, tmp);
+ swfdec_buffer_unref (tmp);
+ }
+ }
} else if (format != flv->format ||
in != flv->in) {
SWFDEC_ERROR ("FIXME: format change not implemented");
commit 8132dc877d46c74c132ad1703ff2df35ee7b6f3e
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 13:00:05 2008 +0100
implement AAC codec-data support
diff --git a/swfdec/swfdec_audio_flv.c b/swfdec/swfdec_audio_flv.c
index 2a49ee6..d3f8dbb 100644
--- a/swfdec/swfdec_audio_flv.c
+++ b/swfdec/swfdec_audio_flv.c
@@ -102,7 +102,36 @@ swfdec_audio_flv_decode_one (SwfdecAudioFlv *flv)
} else if (flv->decoder == NULL) {
return NULL;
}
- swfdec_audio_decoder_push (flv->decoder, buffer);
+ if (format == SWFDEC_AUDIO_CODEC_AAC) {
+ SwfdecBuffer *data;
+ SwfdecBits bits;
+ guint type;
+ swfdec_bits_init (&bits, buffer);
+ type = swfdec_bits_get_u8 (&bits);
+ switch (type) {
+ case 0:
+ data = swfdec_bits_get_buffer (&bits, -1);
+ if (data) {
+ swfdec_audio_decoder_set_codec_data (flv->decoder, data);
+ swfdec_buffer_unref (data);
+ }
+ break;
+ case 1:
+ data = swfdec_bits_get_buffer (&bits, -1);
+ if (data) {
+ swfdec_audio_decoder_push (flv->decoder, data);
+ swfdec_buffer_unref (data);
+ } else {
+ SWFDEC_ERROR ("no data in AAC data buffer?");
+ }
+ break;
+ default:
+ SWFDEC_FIXME ("handle AAC type %u", type);
+ break;
+ }
+ } else {
+ swfdec_audio_decoder_push (flv->decoder, buffer);
+ }
if (flv->next_timestamp == 0)
swfdec_audio_decoder_push (flv->decoder, NULL);
buffer = swfdec_audio_decoder_pull (flv->decoder);
commit 590499c32c60e27f3a84d4bb61e9c79827023ed3
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 12:59:43 2008 +0100
implement AAC support
diff --git a/swfdec/swfdec_audio_decoder_gst.c b/swfdec/swfdec_audio_decoder_gst.c
index 9b29957..7354d72 100644
--- a/swfdec/swfdec_audio_decoder_gst.c
+++ b/swfdec/swfdec_audio_decoder_gst.c
@@ -47,6 +47,9 @@ swfdec_audio_decoder_get_caps (guint codec, SwfdecAudioFormat format)
swfdec_audio_format_get_rate (format),
swfdec_audio_format_get_channels (format));
break;
+ case SWFDEC_AUDIO_CODEC_AAC:
+ s = g_strdup_printf ("audio/mpeg, mpegversion=4");
+ break;
default:
return NULL;
}
@@ -142,6 +145,20 @@ error:
}
static void
+swfdec_audio_decoder_gst_set_codec_data (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
+{
+ SwfdecAudioDecoderGst *player = SWFDEC_AUDIO_DECODER_GST (dec);
+
+ if (buffer) {
+ GstBuffer *buf = swfdec_gst_buffer_new (swfdec_buffer_ref (buffer));
+ swfdec_gst_decoder_set_codec_data (&player->dec, buf);
+ gst_buffer_unref (buf);
+ } else {
+ swfdec_gst_decoder_set_codec_data (&player->dec, NULL);
+ }
+}
+
+static void
swfdec_audio_decoder_gst_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
{
SwfdecAudioDecoderGst *player = SWFDEC_AUDIO_DECODER_GST (dec);
@@ -189,6 +206,7 @@ swfdec_audio_decoder_gst_class_init (SwfdecAudioDecoderGstClass *klass)
decoder_class->prepare = swfdec_audio_decoder_gst_prepare;
decoder_class->create = swfdec_audio_decoder_gst_create;
+ decoder_class->set_codec_data = swfdec_audio_decoder_gst_set_codec_data;
decoder_class->pull = swfdec_audio_decoder_gst_pull;
decoder_class->push = swfdec_audio_decoder_gst_push;
}
commit 07b2fd4007020759e6ff2ad9a0086e245a14e544
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 12:59:13 2008 +0100
add codec data API to the audio decoder, too
diff --git a/swfdec/swfdec_audio_decoder.c b/swfdec/swfdec_audio_decoder.c
index 72be732..c1dbf60 100644
--- a/swfdec/swfdec_audio_decoder.c
+++ b/swfdec/swfdec_audio_decoder.c
@@ -28,8 +28,17 @@
G_DEFINE_TYPE (SwfdecAudioDecoder, swfdec_audio_decoder, G_TYPE_OBJECT)
static void
+swfdec_audio_decoder_do_set_codec_data (SwfdecAudioDecoder *decoder,
+ SwfdecBuffer *buffer)
+{
+ SWFDEC_WARNING ("%s does not implement codec data",
+ G_OBJECT_TYPE_NAME (decoder));
+}
+
+static void
swfdec_audio_decoder_class_init (SwfdecAudioDecoderClass *klass)
{
+ klass->set_codec_data = swfdec_audio_decoder_do_set_codec_data;
}
static void
@@ -117,6 +126,28 @@ swfdec_audio_decoder_new (guint codec, SwfdecAudioFormat format)
}
/**
+ * swfdec_audio_decoder_set_codec_data:
+ * @decoder: an audio decoder
+ * @buffer: setup data for the decoder. May be %NULL
+ *
+ * Provides setup data for the audio decoder. This function is usually called
+ * on initialization, but can be called at any time. Currently this
+ * functionality is only used for AAC audio.
+ **/
+void
+swfdec_audio_decoder_set_codec_data (SwfdecAudioDecoder *decoder, SwfdecBuffer *buffer)
+{
+ SwfdecAudioDecoderClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AUDIO_DECODER (decoder));
+
+ if (decoder->error)
+ return;
+ klass = SWFDEC_AUDIO_DECODER_GET_CLASS (decoder);
+ klass->set_codec_data (decoder, buffer);
+}
+
+/**
* swfdec_audio_decoder_push:
* @decoder: a #SwfdecAudioDecoder
* @buffer: a #SwfdecBuffer to process or %NULL to flush
diff --git a/swfdec/swfdec_audio_decoder.h b/swfdec/swfdec_audio_decoder.h
index e0e2960..ee72d3e 100644
--- a/swfdec/swfdec_audio_decoder.h
+++ b/swfdec/swfdec_audio_decoder.h
@@ -30,8 +30,14 @@ G_BEGIN_DECLS
#define SWFDEC_AUDIO_CODEC_ADPCM 1
#define SWFDEC_AUDIO_CODEC_MP3 2
#define SWFDEC_AUDIO_CODEC_UNCOMPRESSED 3
+#define SWFDEC_AUDIO_CODEC_NELLYMOSER_16KHZ 4
#define SWFDEC_AUDIO_CODEC_NELLYMOSER_8KHZ 5
#define SWFDEC_AUDIO_CODEC_NELLYMOSER 6
+#define SWFDEC_AUDIO_CODEC_ALAW 7
+#define SWFDEC_AUDIO_CODEC_MULAW 8
+#define SWFDEC_AUDIO_CODEC_AAC 10
+#define SWFDEC_AUDIO_CODEC_SPEEX 11
+#define SWFDEC_AUDIO_CODEC_MP3_8KHZ 14
typedef struct _SwfdecAudioDecoder SwfdecAudioDecoder;
@@ -66,6 +72,9 @@ struct _SwfdecAudioDecoderClass
SwfdecAudioDecoder * (* create) (guint codec,
SwfdecAudioFormat format);
+ void (* set_codec_data)
+ (SwfdecAudioDecoder * decoder,
+ SwfdecBuffer * buffer);
void (* push) (SwfdecAudioDecoder * decoder,
SwfdecBuffer * buffer);
SwfdecBuffer * (* pull) (SwfdecAudioDecoder * decoder);
@@ -81,6 +90,9 @@ gboolean swfdec_audio_decoder_prepare (guint codec,
SwfdecAudioDecoder * swfdec_audio_decoder_new (guint codec,
SwfdecAudioFormat format);
+void swfdec_audio_decoder_set_codec_data
+ (SwfdecAudioDecoder * decoder,
+ SwfdecBuffer * buffer);
void swfdec_audio_decoder_push (SwfdecAudioDecoder * decoder,
SwfdecBuffer * buffer);
SwfdecBuffer * swfdec_audio_decoder_pull (SwfdecAudioDecoder * decoder);
commit 65f9f907d95568fe4d2e108b40912d6bed5ee7a9
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 12:58:22 2008 +0100
fix small bugs in the H264 GStreamer implementation
diff --git a/swfdec/swfdec_codec_gst.c b/swfdec/swfdec_codec_gst.c
index c0ad4b0..4eef8d9 100644
--- a/swfdec/swfdec_codec_gst.c
+++ b/swfdec/swfdec_codec_gst.c
@@ -278,6 +278,7 @@ swfdec_gst_decoder_set_codec_data (SwfdecGstDecoder *dec,
GstCaps *caps;
caps = gst_pad_get_caps (dec->src);
+ caps = gst_caps_make_writable (caps);
if (buffer) {
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
} else {
diff --git a/swfdec/swfdec_video_decoder_gst.c b/swfdec/swfdec_video_decoder_gst.c
index 0bd18cf..07f4828 100644
--- a/swfdec/swfdec_video_decoder_gst.c
+++ b/swfdec/swfdec_video_decoder_gst.c
@@ -126,11 +126,14 @@ swfdec_video_decoder_gst_set_codec_data (SwfdecVideoDecoder *dec,
SwfdecBuffer *buffer)
{
SwfdecVideoDecoderGst *player = SWFDEC_VIDEO_DECODER_GST (dec);
- GstBuffer *buf;
- buf = swfdec_gst_buffer_new (swfdec_buffer_ref (buffer));
- swfdec_gst_decoder_set_codec_data (&player->dec, buf);
- gst_buffer_unref (buf);
+ if (buffer) {
+ GstBuffer *buf = swfdec_gst_buffer_new (swfdec_buffer_ref (buffer));
+ swfdec_gst_decoder_set_codec_data (&player->dec, buf);
+ gst_buffer_unref (buf);
+ } else {
+ swfdec_gst_decoder_set_codec_data (&player->dec, NULL);
+ }
}
static void
commit cfdde594b5bbed06a174c49fedce062dfc2fc646
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 12:35:19 2008 +0100
make the GStreamer decoder handle H264
diff --git a/swfdec/swfdec_codec_gst.c b/swfdec/swfdec_codec_gst.c
index 638e8a6..c0ad4b0 100644
--- a/swfdec/swfdec_codec_gst.c
+++ b/swfdec/swfdec_codec_gst.c
@@ -271,6 +271,23 @@ swfdec_gst_decoder_finish (SwfdecGstDecoder *dec)
}
}
+void
+swfdec_gst_decoder_set_codec_data (SwfdecGstDecoder *dec,
+ GstBuffer *buffer)
+{
+ GstCaps *caps;
+
+ caps = gst_pad_get_caps (dec->src);
+ if (buffer) {
+ gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
+ } else {
+ GstStructure *structure = gst_caps_get_structure (caps, 0);
+ gst_structure_remove_field (structure, "codec_data");
+ }
+ gst_pad_set_caps (dec->src, caps);
+ gst_caps_unref (caps);
+}
+
gboolean
swfdec_gst_decoder_push (SwfdecGstDecoder *dec, GstBuffer *buffer)
{
diff --git a/swfdec/swfdec_codec_gst.h b/swfdec/swfdec_codec_gst.h
index 049422d..31e8319 100644
--- a/swfdec/swfdec_codec_gst.h
+++ b/swfdec/swfdec_codec_gst.h
@@ -38,6 +38,9 @@ gboolean swfdec_gst_decoder_init (SwfdecGstDecoder * dec,
GstCaps * srccaps,
GstCaps * sinkcaps,
...) G_GNUC_NULL_TERMINATED;
+void swfdec_gst_decoder_set_codec_data
+ (SwfdecGstDecoder * dec,
+ GstBuffer * buffer);
void swfdec_gst_decoder_push_eos (SwfdecGstDecoder * dec);
GstBuffer * swfdec_gst_decoder_pull (SwfdecGstDecoder * dec);
gboolean swfdec_gst_decoder_push (SwfdecGstDecoder * dec,
diff --git a/swfdec/swfdec_video_decoder_gst.c b/swfdec/swfdec_video_decoder_gst.c
index 893fc45..0bd18cf 100644
--- a/swfdec/swfdec_video_decoder_gst.c
+++ b/swfdec/swfdec_video_decoder_gst.c
@@ -40,6 +40,9 @@ swfdec_video_decoder_get_caps (guint codec)
case SWFDEC_VIDEO_CODEC_VP6:
caps = gst_caps_from_string ("video/x-vp6-flash");
break;
+ case SWFDEC_VIDEO_CODEC_H264:
+ caps = gst_caps_from_string ("video/x-h264");
+ break;
default:
return NULL;
}
@@ -119,6 +122,18 @@ swfdec_video_decoder_gst_create (guint codec)
}
static void
+swfdec_video_decoder_gst_set_codec_data (SwfdecVideoDecoder *dec,
+ SwfdecBuffer *buffer)
+{
+ SwfdecVideoDecoderGst *player = SWFDEC_VIDEO_DECODER_GST (dec);
+ GstBuffer *buf;
+
+ buf = swfdec_gst_buffer_new (swfdec_buffer_ref (buffer));
+ swfdec_gst_decoder_set_codec_data (&player->dec, buf);
+ gst_buffer_unref (buf);
+}
+
+static void
swfdec_video_decoder_gst_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer)
{
SwfdecVideoDecoderGst *player = SWFDEC_VIDEO_DECODER_GST (dec);
@@ -201,6 +216,7 @@ swfdec_video_decoder_gst_class_init (SwfdecVideoDecoderGstClass *klass)
decoder_class->prepare = swfdec_video_decoder_gst_prepare;
decoder_class->create = swfdec_video_decoder_gst_create;
+ decoder_class->set_codec_data = swfdec_video_decoder_gst_set_codec_data;
decoder_class->decode = swfdec_video_decoder_gst_decode;
}
commit 578af79d93d605d973231cea4220d03df54ac2ce
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 12:34:55 2008 +0100
decode H264 using the new API
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
index 601576d..9316336 100644
--- a/swfdec/swfdec_net_stream.c
+++ b/swfdec/swfdec_net_stream.c
@@ -100,6 +100,35 @@ swfdec_net_stream_decode_video (SwfdecVideoDecoder *decoder, SwfdecBuffer *buffe
decoder->width -= wsub;
decoder->height -= hsub;
}
+ } else if (decoder->codec == SWFDEC_VIDEO_CODEC_H264) {
+ SwfdecBits bits;
+ guint type;
+ SwfdecBuffer *data;
+ swfdec_bits_init (&bits, buffer);
+ type = swfdec_bits_get_u8 (&bits);
+ /* composition_time_offset = */ swfdec_bits_get_bu24 (&bits);
+ switch (type) {
+ case 0:
+ data = swfdec_bits_get_buffer (&bits, -1);
+ if (data) {
+ swfdec_video_decoder_set_codec_data (decoder, data);
+ swfdec_buffer_unref (data);
+ }
+ break;
+ case 1:
+ data = swfdec_bits_get_buffer (&bits, -1);
+ if (data) {
+ swfdec_video_decoder_decode (decoder, data);
+ } else {
+ SWFDEC_ERROR ("no data in H264 buffer?");
+ }
+ break;
+ case 2:
+ break;
+ default:
+ SWFDEC_ERROR ("H264 data type %u not supported", type);
+ break;
+ }
} else {
swfdec_video_decoder_decode (decoder, buffer);
}
commit 4e1659795d9a18a9b5a47a4626d89fbb1b2cf9c9
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Dec 16 12:34:26 2008 +0100
add API necessary for H264
diff --git a/swfdec/swfdec_video_decoder.c b/swfdec/swfdec_video_decoder.c
index c09a293..527ac1e 100644
--- a/swfdec/swfdec_video_decoder.c
+++ b/swfdec/swfdec_video_decoder.c
@@ -30,8 +30,17 @@
G_DEFINE_TYPE (SwfdecVideoDecoder, swfdec_video_decoder, G_TYPE_OBJECT)
static void
+swfdec_video_decoder_do_set_codec_data (SwfdecVideoDecoder *decoder,
+ SwfdecBuffer *buffer)
+{
+ SWFDEC_WARNING ("%s does not implement codec data",
+ G_OBJECT_TYPE_NAME (decoder));
+}
+
+static void
swfdec_video_decoder_class_init (SwfdecVideoDecoderClass *klass)
{
+ klass->set_codec_data = swfdec_video_decoder_do_set_codec_data;
}
static void
@@ -65,6 +74,7 @@ swfdec_video_codec_get_format (guint codec)
case SWFDEC_VIDEO_CODEC_H263:
case SWFDEC_VIDEO_CODEC_VP6:
case SWFDEC_VIDEO_CODEC_VP6_ALPHA:
+ case SWFDEC_VIDEO_CODEC_H264:
return SWFDEC_VIDEO_FORMAT_I420;
case SWFDEC_VIDEO_CODEC_UNDEFINED:
case SWFDEC_VIDEO_CODEC_SCREEN:
@@ -142,6 +152,28 @@ swfdec_video_decoder_new (guint codec)
}
/**
+ * swfdec_video_decoder_set_codec_data:
+ * @decoder: a video decoder
+ * @buffer: setup data for the decoder. May be %NULL
+ *
+ * Provides setup data for the video decoder. This function is usually called
+ * on initialization, but can be called at any time. Currently this
+ * functionality is only used for H264.
+ **/
+void
+swfdec_video_decoder_set_codec_data (SwfdecVideoDecoder *decoder, SwfdecBuffer *buffer)
+{
+ SwfdecVideoDecoderClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_VIDEO_DECODER (decoder));
+
+ if (decoder->error)
+ return;
+ klass = SWFDEC_VIDEO_DECODER_GET_CLASS (decoder);
+ klass->set_codec_data (decoder, buffer);
+}
+
+/**
* swfdec_video_decoder_decode:
* @decoder: a #SwfdecVideoDecoder
* @buffer: a #SwfdecBuffer to process
diff --git a/swfdec/swfdec_video_decoder.h b/swfdec/swfdec_video_decoder.h
index 2b1b663..21248fa 100644
--- a/swfdec/swfdec_video_decoder.h
+++ b/swfdec/swfdec_video_decoder.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
#define SWFDEC_VIDEO_CODEC_VP6 4
#define SWFDEC_VIDEO_CODEC_VP6_ALPHA 5
#define SWFDEC_VIDEO_CODEC_SCREEN2 6
+#define SWFDEC_VIDEO_CODEC_H264 7
typedef enum {
SWFDEC_VIDEO_FORMAT_RGBA,
@@ -75,6 +76,9 @@ struct _SwfdecVideoDecoderClass
char ** missing);
SwfdecVideoDecoder * (* create) (guint codec);
+ void (* set_codec_data)
+ (SwfdecVideoDecoder * decoder,
+ SwfdecBuffer * buffer);
void (* decode) (SwfdecVideoDecoder * decoder,
SwfdecBuffer * buffer);
};
@@ -90,6 +94,9 @@ gboolean swfdec_video_decoder_prepare (guint codec,
SwfdecVideoDecoder * swfdec_video_decoder_new (guint codec);
+void swfdec_video_decoder_set_codec_data
+ (SwfdecVideoDecoder * decoder,
+ SwfdecBuffer * buffer);
void swfdec_video_decoder_decode (SwfdecVideoDecoder * decoder,
SwfdecBuffer * buffer);
guint swfdec_video_decoder_get_codec (SwfdecVideoDecoder * decoder);
More information about the Swfdec-commits
mailing list