[Mplayer-cvslog] CVS: main/libmpdemux mf.c,NONE,1.1 mf.h,NONE,1.1 demux_mf.c,NONE,1.1

Zoltan Ponekker pontscho at mplayer.dev.hu
Wed Feb 6 20:23:51 CET 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv3799/libmpdemux

Added Files:
	mf.c mf.h demux_mf.c 
Log Message:
add mfi support

--- NEW FILE ---

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <glob.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>

#include "config.h"

#include "mp_msg.h"
#include "help_mp.h"
#include "stream.h"

#include "mf.h"

int    mf_support = 0;
int    mf_w = 352;
int    mf_h = 288;
int    mf_fps = 25;
char * mf_type = "jpg";

int stream_open_mf(char * filename,stream_t * stream)
{
 glob_t        gg;
 struct stat   fs;
 int           i;
 char        * fname;
 mf_t        * mf;

 fname=malloc( strlen( filename ) + 2 );
 strcpy( fname,filename ); strcat( fname,"*" );

 if ( glob( fname,0,NULL,&gg ) )
  { free( fname ); return 0; }

 printf( "[mf] search expr: %s\n",fname );

 mf=malloc( sizeof( mf_t ) );
 mf->nr_of_files=gg.gl_pathc;
 mf->names=malloc( gg.gl_pathc * sizeof( char* ) );

 printf( "[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) );

 for( i=0;i < gg.gl_pathc;i++ )
  {
   stat( gg.gl_pathv[i],&fs );
   if( S_ISDIR( fs.st_mode ) ) continue;
   mf->names[i]=strdup( gg.gl_pathv[i] );
//   printf( "[mf] added file %d.: %s\n",i,mf->names[i] );
  }
 globfree( &gg );

 free( fname );
 stream->priv=(void*)mf;

 return 1;
}

#if 0

stream_t stream;

int main( void )
{
 stream_open_mf( "tmp/a",&stream );
 return 0;
}

#endif

--- NEW FILE ---

#ifndef _MF_H
#define _MF_H

extern int    mf_support;
extern int    mf_w;
extern int    mf_h;
extern int    mf_fps;
extern char * mf_type;

typedef struct
{
 int     nr_of_files;
 char ** names;
} mf_t;

#endif
--- NEW FILE ---

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"

#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
#include "mf.h"

typedef struct
{
 int nr_of_frames;
 int curr_frame;
} demuxer_mf_t;

void demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,int flags){
}

// return value:
//     0 = EOF or no stream found
//     1 = successfully read a packet
int demux_mf_fill_buffer(demuxer_t *demuxer){
  mf_t         * mf;
  demuxer_mf_t * dmf;
  struct stat    fs;
  FILE         * f;

  mf=(mf_t*)demuxer->stream->priv;
  dmf=(demuxer_mf_t*)demuxer->priv;

  if ( dmf->curr_frame >= dmf->nr_of_frames ) return 0;

  stat( mf->names[dmf->curr_frame],&fs );
//  printf( "[demux_mf] frame: %d (%s,%d)\n",dmf->curr_frame,mf->names[dmf->curr_frame],fs.st_size );

  if ( !( f=fopen( mf->names[dmf->curr_frame],"r" ) ) ) return 0;
  {
   sh_video_t     * sh_video = demuxer->video->sh;
   demux_packet_t * dp = new_demux_packet( fs.st_size );
//    stream_read(stream,dp->buffer,len);
   if ( !fread( dp->buffer,1,fs.st_size,f ) ) return 0;
   dp->pts=dmf->curr_frame / sh_video->fps;
   dp->pos=dmf->curr_frame;
   dp->flags=0;
   // append packet to DS stream:
   ds_add_packet( demuxer->video,dp );
  }
  fclose( f );

  dmf->curr_frame++;
  return 1;
}

demuxer_t* demux_open_mf(demuxer_t* demuxer){
  sh_video_t   *sh_video = NULL;
  mf_t         *mf = NULL;
  demuxer_mf_t *dmf = NULL;

  mp_msg( MSGT_DEMUX,MSGL_V,"[demux_mf] mf demuxer opened.\n" );
  mf=(mf_t*)demuxer->stream->priv;
  dmf=calloc( 1,sizeof( demuxer_mf_t ) );

  // go back to the beginning
  stream_reset(demuxer->stream);
  stream_seek(demuxer->stream, 0);
  demuxer->movi_start = 0;
  demuxer->movi_end = mf->nr_of_files - 1;
  dmf->nr_of_frames= mf->nr_of_files;
  dmf->curr_frame=0;

  // create a new video stream header
  sh_video = new_sh_video(demuxer, 0);
  // make sure the demuxer knows about the new video stream header
  // (even though new_sh_video() ought to take care of it)
  demuxer->video->sh = sh_video;

  // make sure that the video demuxer stream header knows about its
  // parent video demuxer stream (this is getting wacky), or else
  // video_read_properties() will choke
  sh_video->ds = demuxer->video;

  if ( !strcmp( mf_type,"jpg" ) ) sh_video->format = mmioFOURCC('M', 'J', 'P', 'G');
   else { mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] unknow input file type.\n" ); free( dmf ); return NULL; }

  sh_video->disp_w = mf_w;
  sh_video->disp_h = mf_h;
  sh_video->fps = mf_fps;
  sh_video->frametime = 1 / sh_video->fps;

  /* disable seeking */
  demuxer->seekable = 0;

  demuxer->priv=(void*)dmf;

  return demuxer;
}




More information about the MPlayer-cvslog mailing list