2002-01-19 14:50:50 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@temple-baptist.com>
|
2001-12-22 23:26:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-22 23:26:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "flx_fmt.h"
|
|
|
|
#include "gstflxdec.h"
|
2003-07-06 20:49:52 +00:00
|
|
|
#include <gst/video/video.h>
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-06-16 21:56:49 +00:00
|
|
|
#define JIFFIE (GST_SECOND/70)
|
2002-01-13 22:27:25 +00:00
|
|
|
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (flxdec_debug);
|
|
|
|
#define GST_CAT_DEFAULT flxdec_debug
|
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
/* flx element information */
|
|
|
|
static GstElementDetails flxdec_details = {
|
|
|
|
"FLX Decoder",
|
2003-11-16 22:02:23 +00:00
|
|
|
"Codec/Decoder/Audio",
|
2001-12-22 23:26:33 +00:00
|
|
|
"FLX decoder",
|
2003-11-02 17:36:30 +00:00
|
|
|
"Sepp Wijnands <mrrazz@garbage-coderz.net>"
|
2001-12-22 23:26:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Flx signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:26:33 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:26:33 +00:00
|
|
|
ARG_0
|
|
|
|
};
|
|
|
|
|
|
|
|
/* input */
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-fli")
|
|
|
|
);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
/* output */
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate src_video_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN)
|
|
|
|
);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_flxdec_class_init (GstFlxDecClass * klass);
|
|
|
|
static void gst_flxdec_base_init (GstFlxDecClass * klass);
|
|
|
|
static void gst_flxdec_init (GstFlxDec * flxdec);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_flxdec_loop (GstElement * element);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstElementStateReturn gst_flxdec_change_state (GstElement * element);
|
2002-01-13 22:27:25 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_flxdec_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_flxdec_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
|
|
|
|
static void flx_decode_brun (GstFlxDec *, guchar *, guchar *);
|
|
|
|
static void flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
|
|
|
|
static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
#define rndalign(off) ((off) + ((off) % 2))
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flxdec_get_type (void)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
static GType flxdec_type = 0;
|
|
|
|
|
|
|
|
if (!flxdec_type) {
|
|
|
|
static const GTypeInfo flxdec_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstFlxDecClass),
|
|
|
|
(GBaseInitFunc) gst_flxdec_base_init,
|
2001-12-22 23:26:33 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_flxdec_class_init,
|
2001-12-22 23:26:33 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstFlxDec),
|
2001-12-22 23:26:33 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_flxdec_init,
|
2001-12-22 23:26:33 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flxdec_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstFlxDec", &flxdec_info, 0);
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
return flxdec_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 17:36:30 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flxdec_base_init (GstFlxDecClass * klass)
|
2003-11-02 17:36:30 +00:00
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-11-02 17:36:30 +00:00
|
|
|
gst_element_class_set_details (gstelement_class, &flxdec_details);
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&sink_factory));
|
2003-11-02 17:36:30 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&src_video_factory));
|
2003-11-02 17:36:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_flxdec_class_init (GstFlxDecClass * klass)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (flxdec_debug, "flxdec", 0, "FLX video decoder");
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class->set_property = gst_flxdec_set_property;
|
2002-02-02 13:56:02 +00:00
|
|
|
gobject_class->get_property = gst_flxdec_get_property;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
gstelement_class->change_state = gst_flxdec_change_state;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flxdec_init (GstFlxDec * flxdec)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
flxdec->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
|
|
|
|
"sink");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->sinkpad);
|
|
|
|
gst_element_set_loop_function (GST_ELEMENT (flxdec), gst_flxdec_loop);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flxdec->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&src_video_factory), "src");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->srcpad);
|
2004-10-06 13:56:07 +00:00
|
|
|
gst_pad_use_explicit_caps (flxdec->srcpad);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
flxdec->bs = NULL;
|
|
|
|
flxdec->frame = NULL;
|
|
|
|
flxdec->delta = NULL;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
flx_decode_chunks (GstFlxDec * flxdec, gulong count, gchar * data, gchar * dest)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
FlxFrameChunk *hdr;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (data != NULL);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
while (count--) {
|
2004-03-14 22:34:33 +00:00
|
|
|
hdr = (FlxFrameChunk *) data;
|
2001-12-22 23:26:33 +00:00
|
|
|
data += FlxFrameChunkSize;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (hdr->id) {
|
2001-12-22 23:26:33 +00:00
|
|
|
case FLX_COLOR64:
|
2004-03-15 19:32:27 +00:00
|
|
|
flx_decode_color (flxdec, data, dest, 2);
|
|
|
|
data += rndalign (hdr->size) - FlxFrameChunkSize;
|
|
|
|
break;
|
2002-01-18 18:41:58 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
case FLX_COLOR256:
|
2004-03-15 19:32:27 +00:00
|
|
|
flx_decode_color (flxdec, data, dest, 0);
|
|
|
|
data += rndalign (hdr->size) - FlxFrameChunkSize;
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
case FLX_BRUN:
|
2004-03-15 19:32:27 +00:00
|
|
|
flx_decode_brun (flxdec, data, dest);
|
|
|
|
data += rndalign (hdr->size) - FlxFrameChunkSize;
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
case FLX_LC:
|
2004-03-15 19:32:27 +00:00
|
|
|
flx_decode_delta_fli (flxdec, data, dest);
|
|
|
|
data += rndalign (hdr->size) - FlxFrameChunkSize;
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
case FLX_SS2:
|
2004-03-15 19:32:27 +00:00
|
|
|
flx_decode_delta_flc (flxdec, data, dest);
|
|
|
|
data += rndalign (hdr->size) - FlxFrameChunkSize;
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
case FLX_BLACK:
|
2004-03-15 19:32:27 +00:00
|
|
|
memset (dest, 0, flxdec->size);
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
case FLX_MINI:
|
2004-03-15 19:32:27 +00:00
|
|
|
data += rndalign (hdr->size) - FlxFrameChunkSize;
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
default:
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_WARNING ("Unimplented chunk type: 0x%02x size: %d - skipping",
|
2004-03-15 19:32:27 +00:00
|
|
|
hdr->id, hdr->size);
|
|
|
|
data += rndalign (hdr->size) - FlxFrameChunkSize;
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
flx_decode_color (GstFlxDec * flxdec, guchar * data, guchar * dest, gint scale)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
guint packs, count, indx;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (flxdec != NULL);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
packs = (data[0] + (data[1] << 8));
|
|
|
|
|
|
|
|
data += 2;
|
2004-03-14 22:34:33 +00:00
|
|
|
indx = 0;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_LOG ("GstFlxDec: cmap packs: %d", packs);
|
2001-12-22 23:26:33 +00:00
|
|
|
while (packs--) {
|
|
|
|
/* color map index + skip count */
|
|
|
|
indx += *data++;
|
|
|
|
|
|
|
|
/* number of rgb triplets */
|
|
|
|
count = *data++ & 0xff;
|
|
|
|
if (count == 0)
|
|
|
|
count = 256;
|
|
|
|
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_LOG ("GstFlxDec: cmap count: %d (indx: %d)\n", count, indx);
|
2004-03-14 22:34:33 +00:00
|
|
|
flx_set_palette_vector (flxdec->converter, indx, count, data, scale);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
data += (count * 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
gulong count, lines, row;
|
|
|
|
guchar x;
|
|
|
|
|
|
|
|
g_return_if_fail (flxdec != NULL);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
lines = flxdec->hdr.height;
|
2004-03-14 22:34:33 +00:00
|
|
|
while (lines--) {
|
2001-12-22 23:26:33 +00:00
|
|
|
/* packet count.
|
|
|
|
* should not be used anymore, since the flc format can
|
|
|
|
* contain more then 255 RLE packets. we use the frame
|
|
|
|
* width instead.
|
|
|
|
*/
|
|
|
|
data++;
|
|
|
|
|
|
|
|
row = flxdec->hdr.width;
|
2004-03-14 22:34:33 +00:00
|
|
|
while (row) {
|
2001-12-22 23:26:33 +00:00
|
|
|
count = *data++;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (count > 0x7f) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* literal run */
|
|
|
|
count = 0x100 - count;
|
|
|
|
row -= count;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
while (count--)
|
|
|
|
*dest++ = *data++;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* replicate run */
|
|
|
|
row -= count;
|
|
|
|
x = *data++;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
while (count--)
|
|
|
|
*dest++ = x;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
gulong count, packets, lines, start_line, start_l;
|
|
|
|
guchar *start_p, x;
|
|
|
|
|
|
|
|
g_return_if_fail (flxdec != NULL);
|
|
|
|
g_return_if_fail (flxdec->delta != NULL);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* use last frame for delta */
|
2004-03-14 22:34:33 +00:00
|
|
|
memcpy (dest, GST_BUFFER_DATA (flxdec->delta),
|
|
|
|
GST_BUFFER_SIZE (flxdec->delta));
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
start_line = (data[0] + (data[1] << 8));
|
2004-03-14 22:34:33 +00:00
|
|
|
lines = (data[2] + (data[3] << 8));
|
|
|
|
data += 4;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
/* start position of delta */
|
|
|
|
dest += (flxdec->hdr.width * start_line);
|
|
|
|
start_p = dest;
|
|
|
|
start_l = lines;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
while (lines--) {
|
2001-12-22 23:26:33 +00:00
|
|
|
/* packet count */
|
|
|
|
packets = *data++;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
while (packets--) {
|
2001-12-22 23:26:33 +00:00
|
|
|
/* skip count */
|
|
|
|
dest += *data++;
|
|
|
|
|
|
|
|
/* RLE count */
|
|
|
|
count = *data++;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (count > 0x7f) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* literal run */
|
|
|
|
count = 0x100 - count;
|
|
|
|
x = *data++;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
while (count--)
|
|
|
|
*dest++ = x;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* replicate run */
|
|
|
|
while (count--)
|
|
|
|
*dest++ = *data++;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-18 19:41:04 +00:00
|
|
|
start_p += flxdec->hdr.width;
|
|
|
|
dest = start_p;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
gulong count, lines, start_l, opcode;
|
|
|
|
guchar *start_p;
|
|
|
|
|
|
|
|
g_return_if_fail (flxdec != NULL);
|
|
|
|
g_return_if_fail (flxdec->delta != NULL);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* use last frame for delta */
|
2004-03-14 22:34:33 +00:00
|
|
|
memcpy (dest, GST_BUFFER_DATA (flxdec->delta),
|
|
|
|
GST_BUFFER_SIZE (flxdec->delta));
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
lines = (data[0] + (data[1] << 8));
|
|
|
|
data += 2;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
start_p = dest;
|
|
|
|
start_l = lines;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-18 19:41:04 +00:00
|
|
|
while (lines) {
|
2001-12-22 23:26:33 +00:00
|
|
|
dest = start_p + (flxdec->hdr.width * (start_l - lines));
|
|
|
|
|
|
|
|
/* process opcode(s) */
|
|
|
|
while ((opcode = (data[0] + (data[1] << 8))) & 0xc000) {
|
|
|
|
data += 2;
|
|
|
|
if ((opcode & 0xc000) == 0xc000) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* skip count */
|
|
|
|
start_l += (0x10000 - opcode);
|
|
|
|
dest += flxdec->hdr.width * (0x10000 - opcode);
|
2001-12-22 23:26:33 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* last pixel */
|
|
|
|
dest += flxdec->hdr.width;
|
|
|
|
*dest++ = (opcode & 0xff);
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
data += 2;
|
|
|
|
|
|
|
|
/* last opcode is the packet count */
|
2004-03-14 22:34:33 +00:00
|
|
|
while (opcode--) {
|
2001-12-22 23:26:33 +00:00
|
|
|
/* skip count */
|
|
|
|
dest += *data++;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
/* RLE count */
|
|
|
|
count = *data++;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
if (count > 0x7f) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* replicate word run */
|
|
|
|
count = 0x100 - count;
|
|
|
|
while (count--) {
|
|
|
|
*dest++ = data[0];
|
|
|
|
*dest++ = data[1];
|
|
|
|
}
|
|
|
|
data += 2;
|
2001-12-22 23:26:33 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* literal word run */
|
|
|
|
while (count--) {
|
|
|
|
*dest++ = *data++;
|
|
|
|
*dest++ = *data++;
|
|
|
|
}
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-18 19:41:04 +00:00
|
|
|
lines--;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
flx_get_data (GstFlxDec * flxdec, gulong size)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GstBuffer *retbuf;
|
2002-05-15 19:08:49 +00:00
|
|
|
guint32 got_bytes;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (flxdec != NULL, NULL);
|
|
|
|
|
2002-05-15 19:08:49 +00:00
|
|
|
got_bytes = gst_bytestream_read (flxdec->bs, &retbuf, size);
|
|
|
|
if (got_bytes < size) {
|
2002-01-13 22:27:25 +00:00
|
|
|
GstEvent *event;
|
|
|
|
guint32 remaining;
|
|
|
|
|
|
|
|
gst_bytestream_get_status (flxdec->bs, &remaining, &event);
|
|
|
|
gst_pad_event_default (flxdec->sinkpad, event);
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_flxdec_loop (GstElement * element)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstBuffer *buf;
|
|
|
|
GstBuffer *databuf;
|
|
|
|
guchar *data, *chunk;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
GstFlxDec *flxdec;
|
|
|
|
FlxHeader *flxh;
|
|
|
|
FlxFrameChunk *flxfh;
|
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
g_return_if_fail (element != NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_FLXDEC (element));
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("entering loop function");
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
flxdec = GST_FLXDEC (element);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
if (flxdec->state == GST_FLXDEC_READ_HEADER) {
|
2004-03-14 22:34:33 +00:00
|
|
|
databuf = flx_get_data (flxdec, FlxHeaderSize);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-19 18:46:23 +00:00
|
|
|
if (!databuf) {
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_LOG ("empty buffer");
|
2002-01-19 18:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
data = GST_BUFFER_DATA (databuf);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
memcpy ((char *) &flxdec->hdr, data, sizeof (FlxHeader));
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
gst_buffer_unref (databuf);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
flxh = &flxdec->hdr;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
/* check header */
|
|
|
|
if (flxh->type != FLX_MAGICHDR_FLI &&
|
2004-03-15 19:32:27 +00:00
|
|
|
flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("not a flx file (type %d)\n", flxh->type));
|
2001-12-22 23:26:33 +00:00
|
|
|
return;
|
2002-01-19 18:46:23 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_LOG ("size : %d\n", flxh->size);
|
|
|
|
GST_LOG ("frames : %d\n", flxh->frames);
|
|
|
|
GST_LOG ("width : %d\n", flxh->width);
|
|
|
|
GST_LOG ("height : %d\n", flxh->height);
|
|
|
|
GST_LOG ("depth : %d\n", flxh->depth);
|
|
|
|
GST_LOG ("speed : %d\n", flxh->speed);
|
2002-01-13 22:27:25 +00:00
|
|
|
|
|
|
|
flxdec->next_time = 0;
|
|
|
|
|
|
|
|
if (flxh->type == FLX_MAGICHDR_FLI) {
|
|
|
|
flxdec->frame_time = JIFFIE * flxh->speed;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2003-01-12 21:28:38 +00:00
|
|
|
flxdec->frame_time = flxh->speed * GST_MSECOND;
|
2002-01-13 22:27:25 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-01-12 02:01:52 +00:00
|
|
|
caps = gst_caps_from_string (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN);
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_caps_set_simple (caps,
|
2004-03-15 19:32:27 +00:00
|
|
|
"width", G_TYPE_INT, flxh->width,
|
|
|
|
"height", G_TYPE_INT, flxh->height,
|
2004-10-06 13:56:07 +00:00
|
|
|
"framerate", G_TYPE_DOUBLE, (gdouble) (GST_SECOND / flxdec->frame_time),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gst_pad_set_explicit_caps (flxdec->srcpad, caps);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flxh->depth <= 8)
|
|
|
|
flxdec->converter =
|
2004-03-15 19:32:27 +00:00
|
|
|
flx_colorspace_converter_new (flxh->width, flxh->height);
|
2002-01-13 22:27:25 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flxh->type == FLX_MAGICHDR_FLC || flxh->type == FLX_MAGICHDR_FLX) {
|
ext/flac/gstflacdec.c: Only return true if we actually filled something in. Prevents player applications from showing...
Original commit message from CVS:
* ext/flac/gstflacdec.c: (gst_flacdec_src_query):
Only return true if we actually filled something in. Prevents
player applications from showing a random length for flac files.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_class_init),
(gst_riff_read_use_event), (gst_riff_read_handle_event),
(gst_riff_read_seek), (gst_riff_read_skip), (gst_riff_read_strh),
(gst_riff_read_strf_vids_with_data),
(gst_riff_read_strf_auds_with_data), (gst_riff_read_strf_iavs):
OK, ok, so I implemented event handling. Apparently it's normal
that we receive random events at random points without asking
for it.
* gst/avi/gstavidemux.c: (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_handle_src_event), (gst_avi_demux_stream_index),
(gst_avi_demux_sync), (gst_avi_demux_stream_scan),
(gst_avi_demux_massage_index), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry),
(gst_avi_demux_stream_data), (gst_avi_demux_loop):
* gst/avi/gstavidemux.h:
Implement non-lineair chunk handling and subchunk processing.
The first solves playback of AVI files where the audio and video
data of individual buffers that we read are not synchronized.
This should not happen according to the wonderful AVI specs, but
of course it does happen in reality. It is also a prerequisite for
the second. Subchunk processing allows us to cut chunks in small
pieces and process each of these pieces separately. This is
required because I've seen several AVI files with incredibly large
audio chunks, even some files with only one audio chunk for the
whole file. This allows for proper playback including seeking.
This patch is supposed to fix all AVI A/V sync issues.
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(flx_decode_chunks), (flx_decode_color), (gst_flxdec_loop):
Work.
* gst/modplug/gstmodplug.cc:
Proper return value setting for the query() function.
* gst/playback/gstplaybasebin.c: (setup_source):
Being in non-playing state (after, e.g., EOS) is not necessarily
a bad thing. Allow for that. This fixes playback of short files.
They don't actually playback fully now, because the clock already
runs. This means that small files (<500kB) with a small length
(<2sec) will still not or barely play. Other files, such as mod
or flx, will work correctly, however.
2004-09-29 09:45:40 +00:00
|
|
|
GST_LOG ("(FLC) aspect_dx : %d\n", flxh->aspect_dx);
|
|
|
|
GST_LOG ("(FLC) aspect_dy : %d\n", flxh->aspect_dy);
|
|
|
|
GST_LOG ("(FLC) oframe1 : 0x%08x\n", flxh->oframe1);
|
|
|
|
GST_LOG ("(FLC) oframe2 : 0x%08x\n", flxh->oframe2);
|
2002-01-13 22:27:25 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
flxdec->size = (flxh->width * flxh->height);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
/* create delta and output frame */
|
2004-03-14 22:34:33 +00:00
|
|
|
flxdec->frame = gst_buffer_new ();
|
|
|
|
flxdec->delta = gst_buffer_new ();
|
|
|
|
GST_BUFFER_DATA (flxdec->frame) = g_malloc (flxdec->size);
|
|
|
|
GST_BUFFER_SIZE (flxdec->frame) = flxdec->size;
|
|
|
|
GST_BUFFER_DATA (flxdec->delta) = g_malloc (flxdec->size);
|
|
|
|
GST_BUFFER_SIZE (flxdec->delta) = flxdec->size;
|
2002-01-13 22:27:25 +00:00
|
|
|
|
|
|
|
flxdec->state = GST_FLXDEC_PLAYING;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (flxdec->state == GST_FLXDEC_PLAYING) {
|
2002-01-19 18:26:20 +00:00
|
|
|
GstBuffer *out;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
databuf = flx_get_data (flxdec, FlxFrameChunkSize);
|
2002-01-19 18:26:20 +00:00
|
|
|
if (!databuf)
|
|
|
|
return;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flxfh = (FlxFrameChunk *) GST_BUFFER_DATA (databuf);
|
|
|
|
|
|
|
|
switch (flxfh->id) {
|
2001-12-22 23:26:33 +00:00
|
|
|
case FLX_FRAME_TYPE:
|
2004-03-15 19:32:27 +00:00
|
|
|
buf = flx_get_data (flxdec, flxfh->size - FlxFrameChunkSize);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
chunk = GST_BUFFER_DATA (buf);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (((FlxFrameType *) chunk)->chunks == 0)
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* create 32 bits output frame */
|
|
|
|
out = gst_buffer_new ();
|
|
|
|
GST_BUFFER_DATA (out) = g_malloc (flxdec->size * 4);
|
|
|
|
GST_BUFFER_SIZE (out) = flxdec->size * 4;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* decode chunks */
|
|
|
|
flx_decode_chunks (flxdec,
|
|
|
|
((FlxFrameType *) chunk)->chunks,
|
|
|
|
GST_BUFFER_DATA (buf) + FlxFrameTypeSize,
|
|
|
|
GST_BUFFER_DATA (flxdec->frame));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* destroy input buffer */
|
|
|
|
gst_buffer_unref (buf);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* save copy of the current frame for possible delta. */
|
|
|
|
memcpy (GST_BUFFER_DATA (flxdec->delta),
|
|
|
|
GST_BUFFER_DATA (flxdec->frame), GST_BUFFER_SIZE (flxdec->delta));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* convert current frame. */
|
|
|
|
flx_colorspace_convert (flxdec->converter,
|
|
|
|
GST_BUFFER_DATA (flxdec->frame), GST_BUFFER_DATA (out));
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (out) = flxdec->next_time;
|
|
|
|
flxdec->next_time += flxdec->frame_time;
|
2002-01-13 22:27:25 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_pad_push (flxdec->srcpad, GST_DATA (out));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
/* destroy header buffer */
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_buffer_unref (databuf);
|
2002-01-13 22:27:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstElementStateReturn
|
|
|
|
gst_flxdec_change_state (GstElement * element)
|
2002-01-13 22:27:25 +00:00
|
|
|
{
|
|
|
|
GstFlxDec *flxdec;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flxdec = GST_FLXDEC (element);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
2002-01-19 18:46:23 +00:00
|
|
|
flxdec->bs = gst_bytestream_new (flxdec->sinkpad);
|
2002-01-13 22:27:25 +00:00
|
|
|
flxdec->state = GST_FLXDEC_READ_HEADER;
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
|
|
|
break;
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
gst_buffer_unref (flxdec->frame);
|
2002-01-19 18:26:20 +00:00
|
|
|
flxdec->frame = NULL;
|
2002-01-13 22:27:25 +00:00
|
|
|
gst_buffer_unref (flxdec->delta);
|
2002-01-19 18:26:20 +00:00
|
|
|
flxdec->delta = NULL;
|
2002-01-19 18:46:23 +00:00
|
|
|
gst_bytestream_destroy (flxdec->bs);
|
2002-01-13 22:27:25 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
parent_class->change_state (element);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
return GST_STATE_SUCCESS;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_flxdec_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GstFlxDec *flxdec;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_FLXDEC (object));
|
|
|
|
flxdec = GST_FLXDEC (object);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_flxdec_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GstFlxDec *flxdec;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_FLXDEC (object));
|
|
|
|
flxdec = GST_FLXDEC (object);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2003-10-28 20:52:41 +00:00
|
|
|
if (!gst_library_load ("gstbytestream"))
|
|
|
|
return FALSE;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-11-02 17:36:30 +00:00
|
|
|
return gst_element_register (plugin, "flxdec",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_RANK_PRIMARY, GST_TYPE_FLXDEC);
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"flxdec",
|
|
|
|
"FLX video decoder",
|
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
|