diff options
Diffstat (limited to 'src/demuxers/demux_iff.c')
-rw-r--r-- | src/demuxers/demux_iff.c | 284 |
1 files changed, 93 insertions, 191 deletions
diff --git a/src/demuxers/demux_iff.c b/src/demuxers/demux_iff.c index cc4df0c85..665d29cd2 100644 --- a/src/demuxers/demux_iff.c +++ b/src/demuxers/demux_iff.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ /* @@ -35,8 +35,6 @@ * - simple pictures work, nothing more (most work is done in bitmap-decoder) * * ANIM (Animations) * - Animation works fine, without seeking. - * - * $Id: demux_iff.c,v 1.19 2007/01/19 00:26:40 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -49,10 +47,10 @@ #include <string.h> #include <stdlib.h> -#include "xine_internal.h" -#include "xineutils.h" -#include "demux.h" -#include "buffer.h" +#include <xine/xine_internal.h> +#include <xine/xineutils.h> +#include <xine/demux.h> +#include <xine/buffer.h> #include "bswap.h" #include "iff.h" @@ -148,7 +146,7 @@ typedef struct { * different decoding deltas */ -static int8_t delta_decode_block(int8_t *source, int32_t n, int8_t *dest, int8_t x, int8_t *table) { +static int8_t delta_decode_block(const int8_t *source, int32_t n, int8_t *dest, int8_t x, const int8_t *table) { int32_t i; int lim = n * 2; @@ -163,7 +161,7 @@ static int8_t delta_decode_block(int8_t *source, int32_t n, int8_t *dest, int8_t } /* Decode a complete delta encoded array */ -static void delta_decode(int8_t *dest, int8_t *source, int32_t n, int8_t *table){ +static void delta_decode(int8_t *dest, const int8_t *source, int32_t n, const int8_t *table){ delta_decode_block(&source[2], n-2, dest, source[1], table); } @@ -187,8 +185,8 @@ static int read_iff_chunk(demux_iff_t *this) { if (this->input->read(this->input, &signature[7], 1) != 1) return 0; } - junk_size = BE_32(&signature[4]); - switch( BE_32(&signature[0]) ) { + junk_size = _X_BE_32(&signature[4]); + switch( _X_BE_32(&signature[0]) ) { case IFF_CMAP_CHUNK: case IFF_BODY_CHUNK: case IFF_DLTA_CHUNK: @@ -206,19 +204,19 @@ static int read_iff_chunk(demux_iff_t *this) { break; } - switch( BE_32(&signature[0]) ) { + switch( _X_BE_32(&signature[0]) ) { case IFF_FORM_CHUNK: if (this->input->read(this->input, buffer, 4) != 4) return 0; - this->iff_sub_type = BE_32(&buffer[0]); + this->iff_sub_type = _X_BE_32(&buffer[0]); break; case IFF_VHDR_CHUNK: if( this->vhdr == NULL ) this->vhdr = (Voice8Header *)xine_xmalloc(sizeof(Voice8Header)); - this->vhdr->oneShotHiSamples = BE_32(&buffer[0]); - this->vhdr->repeatHiSamples = BE_32(&buffer[4]); - this->vhdr->samplesPerHiCycle = BE_32(&buffer[8]); - this->vhdr->samplesPerSec = BE_16(&buffer[12]); + this->vhdr->oneShotHiSamples = _X_BE_32(&buffer[0]); + this->vhdr->repeatHiSamples = _X_BE_32(&buffer[4]); + this->vhdr->samplesPerHiCycle = _X_BE_32(&buffer[8]); + this->vhdr->samplesPerSec = _X_BE_16(&buffer[12]); this->vhdr->ctOctave = buffer[14]; this->vhdr->sCompression = buffer[15]; this->audio_channels = 1; @@ -237,7 +235,7 @@ static int read_iff_chunk(demux_iff_t *this) { return 0; break; } - this->vhdr->volume = BE_32(&buffer[16]); + this->vhdr->volume = _X_BE_32(&buffer[16]); if (this->vhdr->volume > max_volume) this->vhdr->volume = max_volume; xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->oneShotHiSamples %d\n", @@ -300,7 +298,7 @@ static int read_iff_chunk(demux_iff_t *this) { /* not yet implemented */ break; case IFF_CHAN_CHUNK: - this->chan_settings = BE_32(&buffer[0]); + this->chan_settings = _X_BE_32(&buffer[0]); switch( this->chan_settings ) { case STEREO: this->audio_volume_left = this->vhdr->volume; @@ -325,7 +323,7 @@ static int read_iff_chunk(demux_iff_t *this) { break; case IFF_PAN_CHUNK: this->chan_settings = PAN; - this->pan_sposition = BE_32(&buffer[0]); + this->pan_sposition = _X_BE_32(&buffer[0]); this->audio_channels = 2; this->audio_volume_left = this->vhdr->volume / (max_volume / this->pan_sposition); this->audio_volume_right = this->vhdr->volume - this->audio_volume_left; @@ -333,19 +331,19 @@ static int read_iff_chunk(demux_iff_t *this) { case IFF_BMHD_CHUNK: if( this->bmhd == NULL ) this->bmhd = (BitMapHeader *)xine_xmalloc(sizeof(BitMapHeader)); - this->bmhd->w = BE_16(&buffer[0]); - this->bmhd->h = BE_16(&buffer[2]); - this->bmhd->x = BE_16(&buffer[4]); - this->bmhd->y = BE_16(&buffer[6]); + this->bmhd->w = _X_BE_16(&buffer[0]); + this->bmhd->h = _X_BE_16(&buffer[2]); + this->bmhd->x = _X_BE_16(&buffer[4]); + this->bmhd->y = _X_BE_16(&buffer[6]); this->bmhd->nplanes = buffer[8]; this->bmhd->masking = buffer[9]; this->bmhd->compression = buffer[10]; this->bmhd->pad1 = buffer[11]; - this->bmhd->transparentColor = BE_16(&buffer[12]); + this->bmhd->transparentColor = _X_BE_16(&buffer[12]); this->bmhd->xaspect = buffer[14]; this->bmhd->yaspect = buffer[15]; - this->bmhd->pagewidth = BE_16(&buffer[16]); - this->bmhd->pageheight = BE_16(&buffer[18]); + this->bmhd->pagewidth = _X_BE_16(&buffer[16]); + this->bmhd->pageheight = _X_BE_16(&buffer[18]); if (this->bmhd->w > 0) this->bih.biWidth = this->bmhd->w; @@ -409,25 +407,25 @@ static int read_iff_chunk(demux_iff_t *this) { case IFF_GRAB_CHUNK: if( this->grab == NULL ) this->grab = (Point2D *)xine_xmalloc(sizeof(Point2D)); - this->grab->x = BE_16(&buffer[0]); - this->grab->y = BE_16(&buffer[2]); + this->grab->x = _X_BE_16(&buffer[0]); + this->grab->y = _X_BE_16(&buffer[2]); break; case IFF_DEST_CHUNK: if( this->dest == NULL ) this->dest = (DestMerge *)xine_xmalloc(sizeof(DestMerge)); this->dest->depth = buffer[0]; this->dest->pad1 = buffer[1]; - this->dest->plane_pick = BE_16(&buffer[2]); - this->dest->plane_onoff = BE_16(&buffer[4]); - this->dest->plane_mask = BE_16(&buffer[6]); + this->dest->plane_pick = _X_BE_16(&buffer[2]); + this->dest->plane_onoff = _X_BE_16(&buffer[4]); + this->dest->plane_mask = _X_BE_16(&buffer[6]); break; case IFF_SPRT_CHUNK: - this->sprt = BE_16(&buffer[0]); + this->sprt = _X_BE_16(&buffer[0]); break; case IFF_CAMG_CHUNK: if( this->camg == NULL ) this->camg = (CamgChunk *)xine_xmalloc(sizeof(CamgChunk)); - this->camg->view_modes = BE_32(&buffer[0]); + this->camg->view_modes = _X_BE_32(&buffer[0]); this->bih.biCompression = this->camg->view_modes; if( this->camg->view_modes & CAMG_PAL && this->video_pts_inc == 4500 ) @@ -435,9 +433,9 @@ static int read_iff_chunk(demux_iff_t *this) { break; case IFF_CRNG_CHUNK: if (this->crng_used < 256) { - this->crng[this->crng_used].pad1 = BE_16(&buffer[0]); - this->crng[this->crng_used].rate = BE_16(&buffer[2]); - this->crng[this->crng_used].active = BE_16(&buffer[4]); + this->crng[this->crng_used].pad1 = _X_BE_16(&buffer[0]); + this->crng[this->crng_used].rate = _X_BE_16(&buffer[2]); + this->crng[this->crng_used].active = _X_BE_16(&buffer[4]); this->crng[this->crng_used].low = buffer[6]; this->crng[this->crng_used].high = buffer[7]; this->crng_used++; @@ -446,33 +444,33 @@ static int read_iff_chunk(demux_iff_t *this) { case IFF_CCRT_CHUNK: if( this->ccrt == NULL ) this->ccrt = (CcrtChunk *)xine_xmalloc(sizeof(CcrtChunk)); - this->ccrt->direction = BE_16(&buffer[0]); + this->ccrt->direction = _X_BE_16(&buffer[0]); this->ccrt->start = buffer[2]; this->ccrt->end = buffer[3]; - this->ccrt->seconds = BE_32(&buffer[4]); - this->ccrt->microseconds = BE_32(&buffer[8]); - this->ccrt->pad = BE_16(&buffer[12]); + this->ccrt->seconds = _X_BE_32(&buffer[4]); + this->ccrt->microseconds = _X_BE_32(&buffer[8]); + this->ccrt->pad = _X_BE_16(&buffer[12]); break; case IFF_DPI_CHUNK: if( this->dpi == NULL ) this->dpi = (DPIHeader *)xine_xmalloc(sizeof(DPIHeader)); - this->dpi->x = BE_16(&buffer[0]); - this->dpi->y = BE_16(&buffer[0]); + this->dpi->x = _X_BE_16(&buffer[0]); + this->dpi->y = _X_BE_16(&buffer[0]); break; case IFF_ANHD_CHUNK: if( this->anhd == NULL ) this->anhd = (AnimHeader *)xine_xmalloc(sizeof(AnimHeader)); this->anhd->operation = buffer[0]; this->anhd->mask = buffer[1]; - this->anhd->w = BE_16(&buffer[2]); - this->anhd->h = BE_16(&buffer[4]); - this->anhd->x = BE_16(&buffer[6]); - this->anhd->y = BE_16(&buffer[8]); - this->anhd->abs_time = BE_32(&buffer[10]); - this->anhd->rel_time = BE_32(&buffer[14]); + this->anhd->w = _X_BE_16(&buffer[2]); + this->anhd->h = _X_BE_16(&buffer[4]); + this->anhd->x = _X_BE_16(&buffer[6]); + this->anhd->y = _X_BE_16(&buffer[8]); + this->anhd->abs_time = _X_BE_32(&buffer[10]); + this->anhd->rel_time = _X_BE_32(&buffer[14]); this->anhd->interleave = buffer[18]; this->anhd->pad0 = buffer[19]; - this->anhd->bits = BE_32(&buffer[20]); + this->anhd->bits = _X_BE_32(&buffer[20]); /* Using rel_time deaktivated, seems to be broken in most animations */ /*if( this->dpan == NULL ) this->video_pts += this->video_pts_inc * @@ -503,8 +501,8 @@ static int read_iff_chunk(demux_iff_t *this) { case IFF_DPAN_CHUNK: if( this->dpan == NULL ) this->dpan = (DPAnimChunk *)xine_xmalloc(sizeof(DPAnimChunk)); - this->dpan->version = BE_16(&buffer[0]); - this->dpan->nframes = BE_16(&buffer[2]); + this->dpan->version = _X_BE_16(&buffer[0]); + this->dpan->nframes = _X_BE_16(&buffer[2]); this->dpan->fps = buffer[4]; this->dpan->unused1 = buffer[5]; this->dpan->unused2 = buffer[6]; @@ -626,7 +624,7 @@ static int open_iff_file(demux_iff_t *this) { this->anhd = NULL; this->dpan = NULL; - this->iff_type = BE_32(&signature[8]); + this->iff_type = _X_BE_32(&signature[8]); this->iff_sub_type = this->iff_type; this->video_type = 0; @@ -647,7 +645,7 @@ static int open_iff_file(demux_iff_t *this) { this->bih.biClrImportant = 0; /* check the signature */ - if (BE_32(&signature[0]) == IFF_FORM_CHUNK) + if (_X_BE_32(&signature[0]) == IFF_FORM_CHUNK) { switch( this->iff_type ) { @@ -827,13 +825,13 @@ static int demux_iff_send_chunk(demux_plugin_t *this_gen) { } } else { for (j = 0, k = (interleave_index / 2); j < (buf->size / 2); j += this->audio_channels) { - zw_16 = BE_16(&pointer16_from[k]); + zw_16 = _X_BE_16(&pointer16_from[k]); k++; zw_rescale = zw_16; zw_rescale *= this->audio_volume_left; zw_rescale /= max_volume; zw_16 = (zw_rescale>32767) ? 32767 : ((zw_rescale<-32768) ? -32768 : zw_rescale); - pointer16_to[j] = BE_16(&zw_16); + pointer16_to[j] = _X_BE_16(&zw_16); } } } else { @@ -857,13 +855,13 @@ static int demux_iff_send_chunk(demux_plugin_t *this_gen) { } } else { for (j = 1; j < (buf->size / 2); j += this->audio_channels) { - zw_16 = BE_16(&pointer16_from[k]); + zw_16 = _X_BE_16(&pointer16_from[k]); k++; zw_rescale = zw_16; zw_rescale *= this->audio_volume_left; zw_rescale /= max_volume; zw_16 = (zw_rescale>32767) ? 32767 : ((zw_rescale<-32768) ? -32768 : zw_rescale); - pointer16_to[j] = BE_16(&zw_16); + pointer16_to[j] = _X_BE_16(&zw_16); } } } else if (this->chan_settings == LEFT) { @@ -1118,92 +1116,29 @@ static int demux_iff_seek (demux_plugin_t *this_gen, static void demux_iff_dispose (demux_plugin_t *this_gen) { demux_iff_t *this = (demux_iff_t *) this_gen; - if( this->bmhd ) { - free(this->bmhd); - this->bmhd = NULL; - } - if( this->cmap ) { - free( this->cmap ); - this->cmap = NULL; - } - if( this->grab ) { - free(this->grab); - this->grab = NULL; - } - if( this->dest ) { - free(this->dest); - this->dest = NULL; - } - if( this->camg ) { - free(this->camg); - this->camg = NULL; - } - if( this->ccrt ) { - free(this->ccrt); - this->ccrt = NULL; - } - if( this->dpi ) { - free(this->dpi); - this->dpi = NULL; - } - - if( this->vhdr ) { - free(this->vhdr); - this->vhdr = NULL; - } - if( this->atak ) - { - free( this->atak ); - this->atak = NULL; - } - if( this->rlse ) { - free( this->rlse ); - this->rlse = NULL; - } - - if( this->anhd ) { - free( this->anhd ); - this->anhd = NULL; - } - - if( this->dpan ) { - free( this->dpan ); - this->dpan = NULL; - } - - if( this->title ) { - free (this->title); - this->title = NULL; - } - if( this->copyright ) { - free (this->copyright); - this->copyright = NULL; - } - if( this->author ) { - free (this->author); - this->author = NULL; - } - if( this->annotations ) { - free (this->annotations); - this->annotations = NULL; - } - if( this->version ) { - free (this->version); - this->version = NULL; - } - if( this->text ) { - free (this->text); - this->text = NULL; - } + free(this->bmhd); + free(this->cmap); + free(this->grab); + free(this->dest); + free(this->camg); + free(this->ccrt); + free(this->dpi); + free(this->vhdr); + free(this->atak); + free(this->rlse); + free(this->anhd); + free(this->dpan); + + free(this->title); + free(this->copyright); + free(this->author); + free(this->annotations); + free(this->version); + free(this->text); + + free (this->audio_interleave_buffer); + free (this->audio_read_buffer); - if( this->audio_interleave_buffer ) { - free (this->audio_interleave_buffer); - this->audio_interleave_buffer = NULL; - } - if( this->audio_read_buffer ) { - free (this->audio_read_buffer); - this->audio_read_buffer = NULL; - } this->audio_buffer_filled = 0; free(this); @@ -1254,19 +1189,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str switch (stream->content_detection_method) { - case METHOD_BY_EXTENSION: { - const char *extensions, *mrl; - - mrl = input->get_mrl (input); - extensions = class_gen->get_extensions (class_gen); - - if (!_x_demux_check_extension (mrl, extensions)) { - free (this); - return NULL; - } - } - /* falling through is intended */ - + case METHOD_BY_MRL: case METHOD_BY_CONTENT: case METHOD_EXPLICIT: @@ -1285,46 +1208,25 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str return &this->demux_plugin; } -static const char *get_description (demux_class_t *this_gen) { - return "IFF demux plugin"; -} - -static const char *get_identifier (demux_class_t *this_gen) { - return "IFF"; -} - -static const char *get_extensions (demux_class_t *this_gen) { - return "iff svx 8svx 16sv ilbm ham ham6 ham8 anim anim3 anim5 anim7 anim8"; -} - -static const char *get_mimetypes (demux_class_t *this_gen) { - return "audio/x-8svx: 8svx: IFF-8SVX Audio;" - "audio/8svx: 8svx: IFF-8SVX Audio;" - "audio/x-16sv: 16sv: IFF-16SV Audio;" - "audio/168sv: 16sv: IFF-16SV Audio;" - "image/x-ilbm: ilbm: IFF-ILBM Picture;" - "image/ilbm: ilbm: IFF-ILBM Picture;" - "video/x-anim: anim: IFF-ANIM Video;" - "video/anim: anim: IFF-ANIM Video;"; -} - -static void class_dispose (demux_class_t *this_gen) { - demux_iff_class_t *this = (demux_iff_class_t *) this_gen; - - free (this); -} - static void *init_plugin (xine_t *xine, void *data) { demux_iff_class_t *this; this = xine_xmalloc (sizeof (demux_iff_class_t)); this->demux_class.open_plugin = open_plugin; - this->demux_class.get_description = get_description; - this->demux_class.get_identifier = get_identifier; - this->demux_class.get_mimetypes = get_mimetypes; - this->demux_class.get_extensions = get_extensions; - this->demux_class.dispose = class_dispose; + this->demux_class.description = N_("IFF demux plugin"); + this->demux_class.identifier = "IFF"; + this->demux_class.mimetypes = + "audio/x-8svx: 8svx: IFF-8SVX Audio;" + "audio/8svx: 8svx: IFF-8SVX Audio;" + "audio/x-16sv: 16sv: IFF-16SV Audio;" + "audio/168sv: 16sv: IFF-16SV Audio;" + "image/x-ilbm: ilbm: IFF-ILBM Picture;" + "image/ilbm: ilbm: IFF-ILBM Picture;" + "video/x-anim: anim: IFF-ANIM Video;" + "video/anim: anim: IFF-ANIM Video;"; + this->demux_class.extensions = "iff svx 8svx 16sv ilbm ham ham6 ham8 anim anim3 anim5 anim7 anim8"; + this->demux_class.dispose = default_demux_class_dispose; return this; } @@ -1338,7 +1240,7 @@ static const demuxer_info_t demux_info_iff = { const plugin_info_t xine_plugin_info[] EXPORTED = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_DEMUX, 26, "iff", XINE_VERSION_CODE, &demux_info_iff, init_plugin }, + { PLUGIN_DEMUX, 27, "iff", XINE_VERSION_CODE, &demux_info_iff, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |