summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_film.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_film.c')
-rw-r--r--src/demuxers/demux_film.c97
1 files changed, 29 insertions, 68 deletions
diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c
index d3cedc0e1..cc9e90d66 100644
--- a/src/demuxers/demux_film.c
+++ b/src/demuxers/demux_film.c
@@ -15,13 +15,11 @@
*
* 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
*
* FILM (CPK) File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information on the FILM file format, visit:
* http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: demux_film.c,v 1.82 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -49,10 +47,10 @@
* demuxer is dispatching to the engine */
#define DEBUG_FILM_DEMUX 0
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -143,7 +141,7 @@ static int open_film_file(demux_film_t *film) {
return 0;
/* FILM signature correct? */
- if (strncmp(scratch, "FILM", 4)) {
+ if (memcmp(scratch, "FILM", 4)) {
return 0;
}
llprintf(DEBUG_FILM_LOAD, "found 'FILM' signature\n");
@@ -152,11 +150,11 @@ static int open_film_file(demux_film_t *film) {
film->input->seek(film->input, 16, SEEK_SET);
/* header size = header size - 16-byte FILM signature */
- film_header_size = BE_32(&scratch[4]) - 16;
+ film_header_size = _X_BE_32(&scratch[4]) - 16;
film_header = xine_xmalloc(film_header_size);
if (!film_header)
return 0;
- strncpy(film->version, &scratch[8], 4);
+ memcpy(film->version, &scratch[8], 4);
llprintf(DEBUG_FILM_LOAD, "0x%X header bytes, version %c%c%c%c\n",
film_header_size,
film->version[0],
@@ -180,8 +178,8 @@ static int open_film_file(demux_film_t *film) {
/* traverse the FILM header */
i = 0;
while (i < film_header_size) {
- chunk_type = BE_32(&film_header[i]);
- chunk_size = BE_32(&film_header[i + 4]);
+ chunk_type = _X_BE_32(&film_header[i]);
+ chunk_size = _X_BE_32(&film_header[i + 4]);
/* sanity check the chunk size */
if (i + chunk_size > film_header_size) {
@@ -197,8 +195,8 @@ static int open_film_file(demux_film_t *film) {
llprintf(DEBUG_FILM_LOAD, "parsing FDSC chunk\n");
/* always fetch the video information */
- film->bih.biWidth = BE_32(&film_header[i + 16]);
- film->bih.biHeight = BE_32(&film_header[i + 12]);
+ film->bih.biWidth = _X_BE_32(&film_header[i + 16]);
+ film->bih.biHeight = _X_BE_32(&film_header[i + 12]);
film->video_codec = *(uint32_t *)&film_header[i + 8];
film->video_type = _x_fourcc_to_buf_video(*(uint32_t *)&film_header[i + 8]);
@@ -209,7 +207,7 @@ static int open_film_file(demux_film_t *film) {
if (chunk_size == 32) {
film->audio_channels = film_header[21];
film->audio_bits = film_header[22];
- film->sample_rate = BE_16(&film_header[24]);
+ film->sample_rate = _X_BE_16(&film_header[24]);
} else {
/* If the FDSC chunk is not 32 bytes long, this is an early FILM
* file. Make a few assumptions about the audio parms based on the
@@ -253,23 +251,22 @@ static int open_film_file(demux_film_t *film) {
llprintf(DEBUG_FILM_LOAD, "parsing STAB chunk\n");
/* load the sample table */
- if (film->sample_table)
- free(film->sample_table);
- film->frequency = BE_32(&film_header[i + 8]);
- film->sample_count = BE_32(&film_header[i + 12]);
+ free(film->sample_table);
+ film->frequency = _X_BE_32(&film_header[i + 8]);
+ film->sample_count = _X_BE_32(&film_header[i + 12]);
film->sample_table =
- xine_xmalloc(film->sample_count * sizeof(film_sample_t));
+ xine_xcalloc(film->sample_count, sizeof(film_sample_t));
for (j = 0; j < film->sample_count; j++) {
film->sample_table[j].sample_offset =
- BE_32(&film_header[(i + 16) + j * 16 + 0])
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 0])
+ film_header_size + 16;
film->sample_table[j].sample_size =
- BE_32(&film_header[(i + 16) + j * 16 + 4]);
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 4]);
pts =
- BE_32(&film_header[(i + 16) + j * 16 + 8]);
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 8]);
film->sample_table[j].duration =
- BE_32(&film_header[(i + 16) + j * 16 + 12]);
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 12]);
if (pts == 0xFFFFFFFF) {
@@ -331,8 +328,7 @@ static int open_film_file(demux_film_t *film) {
/* allocate enough space in the interleave preload buffer for the
* first chunk (which will be more than enough for successive chunks) */
if (film->audio_type) {
- if (film->interleave_buffer)
- free(film->interleave_buffer);
+ free(film->interleave_buffer);
film->interleave_buffer =
xine_xmalloc(film->sample_table[0].sample_size);
}
@@ -823,8 +819,7 @@ static int demux_film_seek (demux_plugin_t *this_gen, off_t start_pos, int start
static void demux_film_dispose (demux_plugin_t *this_gen) {
demux_film_t *this = (demux_film_t *) this_gen;
- if (this->sample_table)
- free(this->sample_table);
+ free(this->sample_table);
free(this->interleave_buffer);
free(this);
}
@@ -873,19 +868,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:
@@ -904,39 +887,17 @@ 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 "FILM (CPK) demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "FILM (CPK)";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "cpk cak film";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_film_class_t *this = (demux_film_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_film_init_plugin (xine_t *xine, void *data) {
demux_film_class_t *this;
this = xine_xmalloc (sizeof (demux_film_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_("FILM (CPK) demux plugin");
+ this->demux_class.identifier = "FILM (CPK)";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "cpk cak film";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}