Commit 3b00aed7 authored by Laurent Aimar's avatar Laurent Aimar

* mp4 : use same endian for fourcc than one used in vlc (video.h if I'm

right).
 * cinepak : take care of grayscale option.
parent 670718e9
......@@ -2,7 +2,7 @@
* cinepak.c: cinepak video decoder
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: cinepak.c,v 1.1 2002/07/21 15:11:55 fenrir Exp $
* $Id: cinepak.c,v 1.2 2002/07/21 18:47:22 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -342,7 +342,7 @@ static vout_thread_t *cinepak_CreateVout( videodec_thread_t *p_vdec,
void cinepak_LoadCodebook( cinepak_codebook_t *p_codebook,
u8 *p_data,
int b_12bits )
int b_grayscale )
{
int i, i_y[4], i_u, i_v, i_Cb, i_Cr;
int i_uv;
......@@ -353,7 +353,7 @@ void cinepak_LoadCodebook( cinepak_codebook_t *p_codebook,
{
i_y[i] = (u8)( *(p_data++) );
}
if( b_12bits )
if( b_grayscale )
{
i_u = (s8)( *(p_data++) );
i_v = (s8)( *(p_data++) );
......@@ -632,7 +632,8 @@ int cinepak_decode_frame( cinepak_context_t *p_context,
for( i = 0; i < i_count; i++ )
{
cinepak_LoadCodebook( &((*p_codebook)[i_strip][i]),
p_data, i_mode );
p_data,
i_mode&~p_context->b_grayscale );
p_data += i_mode ? 6 : 4;
i_chunk_size -= i_mode ? 6 : 4;
}
......@@ -661,7 +662,9 @@ int cinepak_decode_frame( cinepak_context_t *p_context,
if( i_vector_flags&0x80000000UL )
{
cinepak_LoadCodebook( &((*p_codebook)[i_strip][i_index]),
p_data, i_mode );
p_data,
i_mode&~p_context->b_grayscale );
p_data += i_mode ? 6 : 4;
i_chunk_size -= i_mode ? 6 : 4;
}
......@@ -843,6 +846,15 @@ static int InitThread( videodec_thread_t *p_vdec )
}
memset( p_vdec->p_context, 0, sizeof( cinepak_context_t ) );
if( config_GetInt( p_vdec->p_fifo, "grayscale" ) )
{
p_vdec->p_context->b_grayscale = 1;
}
else
{
p_vdec->p_context->b_grayscale = 0;
}
p_vdec->p_vout = NULL;
msg_Dbg( p_vdec->p_fifo, "cinepak decoder started" );
return( 0 );
......
......@@ -2,7 +2,7 @@
* cinepak.h: Cinepak video decoder
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: cinepak.h,v 1.1 2002/07/21 15:11:55 fenrir Exp $
* $Id: cinepak.h,v 1.2 2002/07/21 18:47:22 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -33,6 +33,8 @@ typedef struct cinepak_codebook_s
typedef struct cinepak_context_s
{
int b_grayscale; /* force to grayscale */
int i_width;
int i_height;
......
......@@ -2,7 +2,7 @@
* libmp4.c : LibMP4 library for mp4 module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: libmp4.c,v 1.2 2002/07/21 15:13:19 fenrir Exp $
* $Id: libmp4.c,v 1.3 2002/07/21 18:47:22 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -55,6 +55,9 @@
#define MP4_GET4BYTES( dst ) \
dst = GetDWBE( p_peek ); p_peek += 4; i_read -= 4
#define MP4_GETFOURCC( dst ) \
dst = GetDWLE( p_peek ); p_peek += 4; i_read -= 4
#define MP4_GET8BYTES( dst ) \
dst = GetQWBE( p_peek ); p_peek += 8; i_read -= 8
......@@ -435,7 +438,7 @@ int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
p_box->p_next = NULL;
MP4_GET4BYTES( p_box->i_shortsize );
MP4_GET4BYTES( p_box->i_type );
MP4_GETFOURCC( p_box->i_type );
/* Now special case */
......@@ -465,8 +468,8 @@ int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if( p_box->i_size )
{
msg_Dbg( p_stream->p_input, "Found Box: %c%c%c%c size %d",
(p_box->i_type>>24)&0xff, (p_box->i_type>>16)&0xff,
(p_box->i_type>>8)&0xff, (p_box->i_type)&0xff,
(p_box->i_type)&0xff, (p_box->i_type>>8)&0xff,
(p_box->i_type>>16)&0xff, (p_box->i_type>>24)&0xff,
(u32)p_box->i_size );
}
#endif
......@@ -589,10 +592,10 @@ int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
/* Nothing to do */
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Skip box: \"%c%c%c%c\"",
(p_box->i_type>>24)&0xff,
(p_box->i_type>>16)&0xff,
(p_box->i_type>>8)&0xff,
(p_box->i_type)&0xff );
(p_box->i_type)&0xff,
(p_box->i_type>>8)&0xff,
(p_box->i_type>>16)&0xff,
(p_box->i_type>>24)&0xff );
#endif
return( 1 );
}
......@@ -601,7 +604,7 @@ int MP4_ReadBox_ftyp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_ftyp_t );
MP4_GET4BYTES( p_box->data.p_ftyp->i_major_brand );
MP4_GETFOURCC( p_box->data.p_ftyp->i_major_brand );
MP4_GET4BYTES( p_box->data.p_ftyp->i_minor_version );
if( ( p_box->data.p_ftyp->i_compatible_brands_count = i_read / 4 ) )
......@@ -612,7 +615,7 @@ int MP4_ReadBox_ftyp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
for( i =0; i < p_box->data.p_ftyp->i_compatible_brands_count; i++ )
{
MP4_GET4BYTES( p_box->data.p_ftyp->i_compatible_brands[i] );
MP4_GETFOURCC( p_box->data.p_ftyp->i_compatible_brands[i] );
}
}
else
......@@ -849,17 +852,17 @@ int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GETVERSIONFLAGS( p_box->data.p_hdlr );
MP4_GET4BYTES( p_box->data.p_hdlr->i_predefined );
MP4_GET4BYTES( p_box->data.p_hdlr->i_handler_type );
MP4_GETFOURCC( p_box->data.p_hdlr->i_handler_type );
p_box->data.p_hdlr->psz_name = calloc( sizeof( char ), i_read + 1 );
memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_read );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"hdlr\" hanler type %c%c%c%c name %s",
( p_box->data.p_hdlr->i_handler_type >> 24 )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 16 )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 8 )&0xff,
( p_box->data.p_hdlr->i_handler_type )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 8 )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 16 )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 24 )&0xff,
p_box->data.p_hdlr->psz_name );
#endif
......@@ -1291,7 +1294,9 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES( p_box->data.p_sample_vide->i_depth );
MP4_GET2BYTES( p_box->data.p_sample_vide->i_predefined4 );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 78);
MP4_ReadBoxContainerRaw( p_stream, p_box );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"vide\" in stsd %dx%d depth %d",
p_box->data.p_sample_vide->i_width,
......@@ -1302,6 +1307,7 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_EXIT( 1 );
}
#if 0
int MP4_ReadBox_sample_mp4v( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
int i;
......@@ -1353,7 +1359,7 @@ int MP4_ReadBox_sample_mp4v( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
#endif
MP4_READBOX_EXIT( 1 );
}
#endif
int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
......@@ -1745,14 +1751,14 @@ int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_dcom_t );
MP4_GET4BYTES( p_box->data.p_dcom->i_algorithm );
MP4_GETFOURCC( p_box->data.p_dcom->i_algorithm );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input,
"Read Box: \"dcom\" compression algorithm : %c%c%c%c",
( p_box->data.p_dcom->i_algorithm >> 24 )&0xff,
( p_box->data.p_dcom->i_algorithm )&0xff,
( p_box->data.p_dcom->i_algorithm >> 8 )&0xff,
( p_box->data.p_dcom->i_algorithm >> 16 )&0xff,
( p_box->data.p_dcom->i_algorithm >> 8 )&0xff,
( p_box->data.p_dcom->i_algorithm )&0xff );
( p_box->data.p_dcom->i_algorithm >> 24 )&0xff );
#endif
MP4_READBOX_EXIT( 1 );
......@@ -1834,10 +1840,10 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if( p_dcom->data.p_dcom->i_algorithm != FOURCC_zlib )
{
msg_Dbg( p_stream->p_input, "Read Box: \"cmov\" compression algorithm : %c%c%c%c not supported",
( p_dcom->data.p_dcom->i_algorithm >> 24 )&0xff,
( p_dcom->data.p_dcom->i_algorithm )&0xff,
( p_dcom->data.p_dcom->i_algorithm >> 8 )&0xff,
( p_dcom->data.p_dcom->i_algorithm >> 16 )&0xff,
( p_dcom->data.p_dcom->i_algorithm >> 8 )&0xff,
( p_dcom->data.p_dcom->i_algorithm )&0xff );
( p_dcom->data.p_dcom->i_algorithm >> 24 )&0xff );
return( 1 );
}
......@@ -1988,12 +1994,18 @@ static struct
{ FOURCC_mp4a, MP4_ReadBox_sample_mp4a, MP4_FreeBox_Common },
{ FOURCC_vide, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_mp4v, MP4_ReadBox_sample_mp4v, MP4_FreeBox_Common },
{ FOURCC_mp4v, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_SVQ1, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_DIVX, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_h263, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_cvid, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_3IV1, NULL, MP4_FreeBox_Common },
{ FOURCC_3IV1, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_mjpa, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_mjpb, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_mjqt, NULL, NULL }, /* found in mjpa/b */
{ FOURCC_mjht, NULL, NULL },
{ FOURCC_jpeg, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_mp4s, NULL, MP4_FreeBox_Common },
......@@ -2049,10 +2061,10 @@ int MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box, MP4_Box_t *p_father )
{
msg_Warn( p_stream->p_input,
"Unknown box type %c%c%c%c (uncompletetly loaded)",
(p_box->i_type>>24)&0xff,
(p_box->i_type>>16)&0xff,
(p_box->i_type)&0xff,
(p_box->i_type>>8)&0xff,
(p_box->i_type)&0xff );
(p_box->i_type>>16)&0xff,
(p_box->i_type>>24)&0xff );
return( 1 );
}
else
......@@ -2109,10 +2121,10 @@ void MP4_FreeBox( input_thread_t *p_input, MP4_Box_t *p_box )
/* Should not happen */
msg_Warn( p_input,
"cannot free box %c%c%c%c, type unknown",
(p_box->i_type >> 24)&0xff,
(p_box->i_type)&0xff,
(p_box->i_type >> 8)&0xff,
(p_box->i_type >> 16)&0xff,
(p_box->i_type >> 8)&0xff,
(p_box->i_type )&0xff );
(p_box->i_type >> 24)&0xff );
}
else
{
......@@ -2197,10 +2209,10 @@ static void __MP4_DumpBoxStructure( input_thread_t *p_input,
if( !i_level )
{
msg_Dbg( p_input, "Dumping root Box \"%c%c%c%c \"",
(p_box->i_type>>24 ) &0xff,
(p_box->i_type>>16 ) &0xff,
(p_box->i_type>> 8 ) &0xff,
(p_box->i_type ) &0xff );
(p_box->i_type ) &0xff,
(p_box->i_type >>8 ) &0xff,
(p_box->i_type >>16 ) &0xff,
(p_box->i_type >>24) &0xff );
}
else
{
......@@ -2212,10 +2224,10 @@ static void __MP4_DumpBoxStructure( input_thread_t *p_input,
str[i*5] = '|';
}
sprintf( str + i_level * 5, "+ %c%c%c%c size %d",
(p_box->i_type>>24 ) &0xff,
(p_box->i_type>>16 ) &0xff,
(p_box->i_type>> 8 ) &0xff,
(p_box->i_type ) &0xff,
(p_box->i_type>>8 ) &0xff,
(p_box->i_type>>16 ) &0xff,
(p_box->i_type>>24 ) &0xff,
(u32)p_box->i_size );
msg_Dbg( p_input, "%s", str );
......
......@@ -2,7 +2,7 @@
* libmp4.h : LibMP4 library for mp4 module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: libmp4.h,v 1.2 2002/07/21 15:13:19 fenrir Exp $
* $Id: libmp4.h,v 1.3 2002/07/21 18:47:22 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -23,10 +23,14 @@
/* XXX It's not the same than VLC_FOURCC */
#if 0
#define MP4_FOURCC( a, b, c, d ) \
( ((u32)d) | ( ((u32)c) << 8 ) | ( ((u32)b) << 16 ) | ( ((u32)a) << 24 ) )
#endif
#define MP4_FOURCC( a, b, c, d ) \
( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
#define FOURCC_uuid MP4_FOURCC( 'u', 'u', 'i', 'd' )
#define FOURCC_ftyp MP4_FOURCC( 'f', 't', 'y', 'p' )
......@@ -106,8 +110,13 @@
#define FOURCC_h263 MP4_FOURCC( 'h', '2', '6', '3' )
#define FOURCC_DIVX MP4_FOURCC( 'D', 'I', 'V', 'X' )
#define FOURCC_cvid MP4_FOURCC( 'c', 'v', 'i', 'd' )
#define FOURCC_mjpa MP4_FOURCC( 'm', 'j', 'p', 'a' )
#define FOURCC_mjpb MP4_FOURCC( 'm', 'j', 'q', 't' )
#define FOURCC_mjqt MP4_FOURCC( 'm', 'j', 'h', 't' )
#define FOURCC_mjht MP4_FOURCC( 'm', 'j', 'p', 'b' )
#define FOURCC_jpeg MP4_FOURCC( 'j', 'p', 'e', 'g' )
/*
#define FOURCC_ MP4_FOURCC( '', '', '', '' )
*/
......@@ -367,6 +376,7 @@ typedef struct MP4_Box_data_sample_vide_s
} MP4_Box_data_sample_vide_t;
/*
typedef struct MP4_Box_data_sample_mp4v_s
{
u8 i_reserved1[6];
......@@ -392,7 +402,7 @@ typedef struct MP4_Box_data_sample_mp4v_s
} MP4_Box_data_sample_mp4v_t;
*/
typedef struct MP4_Box_data_sample_hint_s
{
......
......@@ -2,7 +2,7 @@
* mp4.c : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mp4.c,v 1.1 2002/07/17 21:37:27 fenrir Exp $
* $Id: mp4.c,v 1.2 2002/07/21 18:47:22 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -137,8 +137,8 @@ static int MP4Init( input_thread_t *p_input )
msg_Warn( p_input, "MP4 plugin discarded (cannot peek)" );
return( -1 );
}
i_type = ( p_peek[4] << 24 ) + ( p_peek[5] << 16 ) +
( p_peek[6] << 8 ) + ( p_peek[7] );
i_type = ( p_peek[4] ) + ( p_peek[5] << 8 ) +
( p_peek[6] << 16 ) + ( p_peek[7] << 24);
switch( i_type )
{
case( FOURCC_ftyp ):
......@@ -809,10 +809,10 @@ static void MP4_StartDecoder( input_thread_t *p_input,
{
msg_Warn( p_input, "%s (%c%c%c%c) unsupported",
psz_name,
(p_sample->i_type >> 24)&0xff,
(p_sample->i_type >> 16)&0xff,
(p_sample->i_type )&0xff,
(p_sample->i_type >> 8)&0xff,
(p_sample->i_type )&0xff);
(p_sample->i_type >> 16)&0xff,
(p_sample->i_type >> 24)&0xff);
p_demux_track->b_ok = 0;
return;
}
......
......@@ -2,7 +2,7 @@
* mp4.h : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mp4.h,v 1.2 2002/07/21 15:13:19 fenrir Exp $
* $Id: mp4.h,v 1.3 2002/07/21 18:47:22 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -214,6 +214,9 @@ static struct
{ FOURCC_mp4v, MPEG4_VIDEO_ES, "MP4VisualSampleEntry (MPEG-4)" },
{ FOURCC_3IV1, UNKNOWN_ES, "3IV1 SampleEntry" },
{ FOURCC_cvid, CINEPAK_VIDEO_ES,"cvid SampleEntry (Cinepak Video Codec)" },
{ FOURCC_mjpa, UNKNOWN_ES, "MJPEG-A SampleEntry (Motion JPEG)" },
{ FOURCC_mjpb, UNKNOWN_ES, "MJPEG-A SampleEntry (Motion JPEG)" },
{ FOURCC_jpeg, UNKNOWN_ES, "JPEG (ISO) SampleEntry" },
/* Audio codec */
{ FOURCC_soun, UNKNOWN_ES, "Generic AudioSampleEntry" },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment