Commit 6f67ff83 authored by Laurent Aimar's avatar Laurent Aimar

* cinepak: add a new fourcc

 * ffmpeg and mp4: some clean up and change the way ffmpeg is
initialised.
parent d5eeda89
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* cinepak.c: cinepak video decoder * cinepak.c: cinepak video decoder
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: cinepak.c,v 1.3 2002/07/23 00:39:16 sam Exp $ * $Id: cinepak.c,v 1.4 2002/07/23 17:19:02 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -92,7 +92,14 @@ MODULE_DEACTIVATE_STOP ...@@ -92,7 +92,14 @@ MODULE_DEACTIVATE_STOP
*****************************************************************************/ *****************************************************************************/
static int decoder_Probe( vlc_fourcc_t *pi_type ) static int decoder_Probe( vlc_fourcc_t *pi_type )
{ {
return( ( *pi_type == VLC_FOURCC('c','v','i','d') ) ? 0 : -1 ); switch( *pi_type )
{
case( VLC_FOURCC('c','v','i','d') ):
case( VLC_FOURCC('C','V','I','D') ):
return( 0);
default:
return( -1 );
}
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library * ffmpeg.c: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.19 2002/07/23 00:39:17 sam Exp $ * $Id: ffmpeg.c,v 1.20 2002/07/23 17:19:02 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -174,19 +174,33 @@ static int decoder_Run ( decoder_fifo_t * p_fifo ) ...@@ -174,19 +174,33 @@ static int decoder_Run ( decoder_fifo_t * p_fifo )
( *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) + \ ( *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) + \
( *((u8*)(p)+2) << 16 ) + ( *((u8*)(p)+3) << 24 ) ) ( *((u8*)(p)+2) << 16 ) + ( *((u8*)(p)+3) << 24 ) )
static void __ParseBitMapInfoHeader( bitmapinfoheader_t *h, byte_t *p_data ) static void ffmpeg_ParseBitMapInfoHeader( bitmapinfoheader_t *p_bh,
u8 *p_data )
{ {
h->i_size = GetDWLE( p_data ); p_bh->i_size = GetDWLE( p_data );
h->i_width = GetDWLE( p_data + 4 ); p_bh->i_width = GetDWLE( p_data + 4 );
h->i_height = GetDWLE( p_data + 8 ); p_bh->i_height = GetDWLE( p_data + 8 );
h->i_planes = GetWLE( p_data + 12 ); p_bh->i_planes = GetWLE( p_data + 12 );
h->i_bitcount = GetWLE( p_data + 14 ); p_bh->i_bitcount = GetWLE( p_data + 14 );
h->i_compression = GetDWLE( p_data + 16 ); p_bh->i_compression = GetDWLE( p_data + 16 );
h->i_sizeimage = GetDWLE( p_data + 20 ); p_bh->i_sizeimage = GetDWLE( p_data + 20 );
h->i_xpelspermeter = GetDWLE( p_data + 24 ); p_bh->i_xpelspermeter = GetDWLE( p_data + 24 );
h->i_ypelspermeter = GetDWLE( p_data + 28 ); p_bh->i_ypelspermeter = GetDWLE( p_data + 28 );
h->i_clrused = GetDWLE( p_data + 32 ); p_bh->i_clrused = GetDWLE( p_data + 32 );
h->i_clrimportant = GetDWLE( p_data + 36 ); p_bh->i_clrimportant = GetDWLE( p_data + 36 );
if( p_bh->i_size > 40 )
{
p_bh->i_data = p_bh->i_size - 40;
p_bh->p_data = malloc( p_bh->i_data );
memcpy( p_bh->p_data, p_data + 40, p_bh->i_data );
}
else
{
p_bh->i_data = 0;
p_bh->p_data = NULL;
}
} }
/* get the first pes from fifo */ /* get the first pes from fifo */
static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo ) static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo )
...@@ -423,89 +437,6 @@ static vout_thread_t *ffmpeg_CreateVout( videodec_thread_t *p_vdec, ...@@ -423,89 +437,6 @@ static vout_thread_t *ffmpeg_CreateVout( videodec_thread_t *p_vdec,
return( p_vout ); return( p_vout );
} }
#if 0
/* segfault some^Wevery times*/
static void ffmpeg_ConvertPictureI410toI420( picture_t *p_pic,
AVPicture *p_avpicture,
videodec_thread_t *p_vdec )
{
int i_plane;
int i_x, i_y;
int i_x_max, i_y_max;
int i_width;
int i_height;
int i_dst_stride;
int i_src_stride;
u8 *p_dest;
u8 *p_src;
i_width = p_vdec->p_context->width;
i_height= p_vdec->p_context->height;
p_dest = p_pic->p[0].p_pixels;
p_src = p_avpicture->data[0];
i_src_stride = p_avpicture->linesize[0];
i_dst_stride = p_pic->p[0].i_pitch;
if( i_src_stride == i_dst_stride )
{
p_vdec->p_fifo->p_vlc->pf_memcpy( p_dest, p_src, i_src_stride * i_height );
}
else
{
for( i_y = 0; i_y < i_height; i_y++ )
{
p_vdec->p_fifo->p_vlc->pf_memcpy( p_dest, p_src, i_width );
p_dest += i_dst_stride;
p_src += i_src_stride;
}
}
for( i_plane = 1; i_plane < 3; i_plane++ )
{
i_y_max = p_pic->p[i_plane].i_lines;
p_src = p_avpicture->data[i_plane];
p_dest = p_pic->p[i_plane].p_pixels;
i_dst_stride = p_pic->p[i_plane].i_pitch;
i_src_stride = p_avpicture->linesize[i_plane];
i_x_max = __MIN( i_dst_stride / 2, i_src_stride );
for( i_y = 0; i_y <( i_y_max + 1 ) / 2 ; i_y++ )
{
for( i_x = 0; i_x < i_x_max - 1; i_x++ )
{
p_dest[2 * i_x ] = p_src[i_x];
p_dest[2 * i_x + 1] = ( p_src[i_x] + p_src[i_x + 1] ) / 2;
}
p_dest[2 * i_x_max - 2] = p_src[i_x];
p_dest[2 * i_x_max - 1] = p_src[i_x];
p_dest += 2 * i_dst_stride;
p_src += i_src_stride;
}
p_src = p_pic->p[i_plane].p_pixels;
p_dest = p_src + i_dst_stride;
for( i_y = 0; i_y < ( i_y_max + 1 ) / 2 ; i_y++ )
{
p_vdec->p_fifo->p_vlc->pf_memcpy( p_dest, p_src, i_dst_stride );
p_dest += 2*i_dst_stride;
p_src += 2*i_dst_stride;
}
}
}
#endif
/* FIXME FIXME FIXME this is a big shit /* FIXME FIXME FIXME this is a big shit
does someone want to rewrite this function ? does someone want to rewrite this function ?
or said to me how write a better thing or said to me how write a better thing
...@@ -679,8 +610,8 @@ static int InitThread( videodec_thread_t *p_vdec ) ...@@ -679,8 +610,8 @@ static int InitThread( videodec_thread_t *p_vdec )
if( p_vdec->p_fifo->p_demux_data ) if( p_vdec->p_fifo->p_demux_data )
{ {
__ParseBitMapInfoHeader( &p_vdec->format, ffmpeg_ParseBitMapInfoHeader( &p_vdec->format,
(byte_t*)p_vdec->p_fifo->p_demux_data ); (u8*)p_vdec->p_fifo->p_demux_data );
} }
else else
{ {
...@@ -755,10 +686,29 @@ static int InitThread( videodec_thread_t *p_vdec ) ...@@ -755,10 +686,29 @@ static int InitThread( videodec_thread_t *p_vdec )
msg_Dbg( p_vdec->p_fifo, "ffmpeg codec (%s) started", msg_Dbg( p_vdec->p_fifo, "ffmpeg codec (%s) started",
p_vdec->psz_namecodec ); p_vdec->psz_namecodec );
} }
/* first give init data */
if( p_vdec->format.i_data )
{
AVPicture avpicture;
int b_gotpicture;
switch( i_ffmpeg_codec )
{
case( CODEC_ID_MPEG4 ):
avcodec_decode_video( p_vdec->p_context, &avpicture,
&b_gotpicture,
p_vdec->format.p_data,
p_vdec->format.i_data );
break;
default:
break;
}
}
/* This will be created after the first decoded frame */ /* This will be created after the first decoded frame */
p_vdec->p_vout = NULL; p_vdec->p_vout = NULL;
return( 0 ); return( 0 );
} }
...@@ -921,6 +871,11 @@ static void EndThread( videodec_thread_t *p_vdec ) ...@@ -921,6 +871,11 @@ static void EndThread( videodec_thread_t *p_vdec )
vlc_object_detach( p_vdec->p_vout, p_vdec->p_fifo ); vlc_object_detach( p_vdec->p_vout, p_vdec->p_fifo );
vlc_object_attach( p_vdec->p_vout, p_vdec->p_fifo->p_vlc ); vlc_object_attach( p_vdec->p_vout, p_vdec->p_fifo->p_vlc );
} }
if( p_vdec->format.p_data != NULL)
{
free( p_vdec->format.p_data );
}
free( p_vdec ); free( p_vdec );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg_vdec.h: video decoder using ffmpeg library * ffmpeg_vdec.h: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: ffmpeg.h,v 1.7 2002/07/23 00:39:17 sam Exp $ * $Id: ffmpeg.h,v 1.8 2002/07/23 17:19:02 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -35,6 +35,10 @@ typedef struct bitmapinfoheader_s ...@@ -35,6 +35,10 @@ typedef struct bitmapinfoheader_s
u32 i_ypelspermeter; u32 i_ypelspermeter;
u32 i_clrused; u32 i_clrused;
u32 i_clrimportant; u32 i_clrimportant;
int i_data;
u8 *p_data;
} bitmapinfoheader_t; } bitmapinfoheader_t;
/* MPEG4 video */ /* MPEG4 video */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libmp4.c : LibMP4 library for mp4 module for vlc * libmp4.c : LibMP4 library for mp4 module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: libmp4.c,v 1.4 2002/07/23 00:39:17 sam Exp $ * $Id: libmp4.c,v 1.5 2002/07/23 17:19:02 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -1208,6 +1208,9 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1208,6 +1208,9 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES( p_box->data.p_sample_soun->i_sampleratehi ); MP4_GET2BYTES( p_box->data.p_sample_soun->i_sampleratehi );
MP4_GET2BYTES( p_box->data.p_sample_soun->i_sampleratelo ); MP4_GET2BYTES( p_box->data.p_sample_soun->i_sampleratelo );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 28 );
MP4_ReadBoxContainerRaw( p_stream, p_box ); /* esds */
#ifdef MP4_VERBOSE #ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"soun\" in stsd channel %d sample size %d sampl rate %f", msg_Dbg( p_stream->p_input, "Read Box: \"soun\" in stsd channel %d sample size %d sampl rate %f",
p_box->data.p_sample_soun->i_channelcount, p_box->data.p_sample_soun->i_channelcount,
...@@ -1219,6 +1222,7 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1219,6 +1222,7 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_EXIT( 1 ); MP4_READBOX_EXIT( 1 );
} }
#if 0
int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{ {
int i; int i;
...@@ -1257,6 +1261,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1257,6 +1261,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
#endif #endif
MP4_READBOX_EXIT( 1 ); MP4_READBOX_EXIT( 1 );
} }
#endif
int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{ {
...@@ -1991,7 +1996,7 @@ static struct ...@@ -1991,7 +1996,7 @@ static struct
/* for codecs */ /* for codecs */
{ FOURCC_soun, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_soun, MP4_ReadBox_sample_soun, MP4_FreeBox_Common },
{ FOURCC__mp3, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC__mp3, MP4_ReadBox_sample_soun, MP4_FreeBox_Common },
{ FOURCC_mp4a, MP4_ReadBox_sample_mp4a, MP4_FreeBox_Common }, { FOURCC_mp4a, MP4_ReadBox_sample_soun, MP4_FreeBox_Common },
{ FOURCC_vide, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_vide, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
{ FOURCC_mp4v, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_mp4v, MP4_ReadBox_sample_vide, MP4_FreeBox_Common },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libmp4.h : LibMP4 library for mp4 module for vlc * libmp4.h : LibMP4 library for mp4 module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: libmp4.h,v 1.4 2002/07/23 00:39:17 sam Exp $ * $Id: libmp4.h,v 1.5 2002/07/23 17:19:02 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -321,22 +321,6 @@ typedef struct MP4_Box_data_sample_soun_s ...@@ -321,22 +321,6 @@ typedef struct MP4_Box_data_sample_soun_s
} MP4_Box_data_sample_soun_t; } MP4_Box_data_sample_soun_t;
typedef struct MP4_Box_data_sample_mp4a_s
{
u8 i_reserved1[6];
u16 i_data_reference_index;
u32 i_reserved2[2];
u16 i_channelcount;
u16 i_samplesize;
u16 i_predefined;
u16 i_reserved3;
u16 i_sampleratehi; /* timescale of track */
u16 i_sampleratelo;
} MP4_Box_data_sample_mp4a_t;
typedef struct MP4_Box_data_sample_vide_s typedef struct MP4_Box_data_sample_vide_s
{ {
u8 i_reserved1[6]; u8 i_reserved1[6];
...@@ -362,34 +346,6 @@ typedef struct MP4_Box_data_sample_vide_s ...@@ -362,34 +346,6 @@ typedef struct MP4_Box_data_sample_vide_s
} MP4_Box_data_sample_vide_t; } MP4_Box_data_sample_vide_t;
/*
typedef struct MP4_Box_data_sample_mp4v_s
{
u8 i_reserved1[6];
u16 i_data_reference_index;
u16 i_predefined1;
u16 i_reserved2;
u32 i_predefined2[3];
s16 i_width;
s16 i_height;
u32 i_horizresolution;
u32 i_vertresolution;
u32 i_reserved3;
u16 i_predefined3;
u8 i_compressorname[32];
s16 i_depth;
s16 i_predefined4;
} MP4_Box_data_sample_mp4v_t;
*/
typedef struct MP4_Box_data_sample_hint_s typedef struct MP4_Box_data_sample_hint_s
{ {
u8 i_reserved1[6]; u8 i_reserved1[6];
...@@ -648,9 +604,7 @@ typedef union MP4_Box_data_s ...@@ -648,9 +604,7 @@ typedef union MP4_Box_data_s
MP4_Box_data_ctts_t *p_ctts; MP4_Box_data_ctts_t *p_ctts;
MP4_Box_data_stsd_t *p_stsd; MP4_Box_data_stsd_t *p_stsd;
MP4_Box_data_sample_vide_t *p_sample_vide; MP4_Box_data_sample_vide_t *p_sample_vide;
MP4_Box_data_sample_vide_t *p_sample_mp4v;
MP4_Box_data_sample_soun_t *p_sample_soun; MP4_Box_data_sample_soun_t *p_sample_soun;
MP4_Box_data_sample_soun_t *p_sample_mp4a;
MP4_Box_data_sample_hint_t *p_sample_hint; MP4_Box_data_sample_hint_t *p_sample_hint;
MP4_Box_data_esds_t *p_esds; MP4_Box_data_esds_t *p_esds;
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mp4.h : MP4 file input module for vlc * mp4.h : MP4 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: mp4.h,v 1.5 2002/07/23 00:39:17 sam Exp $ * $Id: mp4.h,v 1.6 2002/07/23 17:19:02 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -23,12 +23,11 @@ ...@@ -23,12 +23,11 @@
/***************************************************************************** /*****************************************************************************
* Structure needed for ffmpeg decoder * Structure needed for decoder
*****************************************************************************/ *****************************************************************************/
typedef struct bitmapinfoheader_s typedef struct bitmapinfoheader_s
{ {
u32 i_size; /* size of header */ u32 i_size; /* size of header 40 + size of data follwoing this header */
u32 i_width; u32 i_width;
u32 i_height; u32 i_height;
u16 i_planes; u16 i_planes;
...@@ -41,7 +40,17 @@ typedef struct bitmapinfoheader_s ...@@ -41,7 +40,17 @@ typedef struct bitmapinfoheader_s
u32 i_clrimportant; u32 i_clrimportant;
} bitmapinfoheader_t; } bitmapinfoheader_t;
typedef struct waveformatex_s
{
u16 i_format;
u16 i_channels;
u32 i_samplepersec;
u32 i_avgbytespersec;
u16 i_blockalign;
u16 i_bitspersample;
u16 i_size; /* This give size of data
imediatly following this header. */
} waveformatex_t;
/***************************************************************************** /*****************************************************************************
* Contain all information about a chunk * Contain all information about a chunk
...@@ -103,8 +112,6 @@ typedef struct track_data_mp4_s ...@@ -103,8 +112,6 @@ typedef struct track_data_mp4_s
too much time to do sumations each time*/ too much time to do sumations each time*/
es_descriptor_t *p_es; /* vlc es for this track */ es_descriptor_t *p_es; /* vlc es for this track */
data_packet_t *p_data_init; /* send this with the first packet,
and then discarded it*/
MP4_Box_t *p_stbl; /* will contain all timing information */ MP4_Box_t *p_stbl; /* will contain all timing information */
MP4_Box_t *p_stsd; /* will contain all data to initialize decoder */ MP4_Box_t *p_stsd; /* will contain all data to initialize decoder */
...@@ -199,4 +206,3 @@ static inline mtime_t MP4_GetMoviePTS(demux_data_mp4_t *p_demux ) ...@@ -199,4 +206,3 @@ static inline mtime_t MP4_GetMoviePTS(demux_data_mp4_t *p_demux )
(mtime_t)p_demux->i_timescale ) (mtime_t)p_demux->i_timescale )
); );
} }
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