Example #1
0
int mpeg_instance_init(mpeg_struct_t *Mpeg_Struct, FileInfo_t *mpgfile)
{
#ifndef AVR32
    timer_interval(&Mpeg_Struct->FrameDisplay, 1000/24);
#endif
	mpgfile->Offset = 0;
	optind = 1;
	opterr = 0;
	optopt = '?';
	Mpeg_Struct->framenum = 0;

	Mpeg_Struct->decoder = mpeg2_init ();
	if (Mpeg_Struct->decoder == NULL) {
	return 0;
	}
	Mpeg_Struct->info = mpeg2_info (Mpeg_Struct->decoder);
	Mpeg_Struct->size = (unsigned int)-1;
	Mpeg_Struct->temporal_reference =(unsigned int)-1;
#ifdef Mpeg_Buffering
    RtcTimeCalDisplay();
	_FatData_ReadSection(mpgfile, (unsigned char*)0x80000000 + 0x2000000, 0, 0x2000000);
    RtcTimeCalDisplay();
#endif
	return 1;
}
Example #2
0
void decode_init()
{
    int i;

    // decoding
    uint32_t accel = 0;
    vo_driver_t *drivers;

    drivers = vo_drivers();
    for (i = 0; drivers[i].name; i++)
        if (!strcmp(drivers[i].name, "xv"))
            output_open = drivers[i].open;

    if (!output_open)
    {
        fprintf(stderr, "%s", _("can't find 'xv' output\n"));
        exit(1);
    }

    accel = (mm_accel() | MM_ACCEL_MLIB);
    vo_accel(accel);
    output = vo_open(output_open);

    if (!output)
    {
        fprintf(stderr, "%s", _("can't open 'xv' output\n"));
        exit(1);
    }

    mpeg2_init(&mpeg2dec, accel, output);
}
Example #3
0
static void sample1 (FILE * file)
{
#define BUFFER_SIZE 4096
    uint8_t buffer[BUFFER_SIZE];
    mpeg2dec_t * mpeg2dec;
    const mpeg2_info_t * info;
    int state;
    int size;
    int framenum = 0;

    mpeg2dec = mpeg2_init ();
    if (mpeg2dec == NULL)
	exit (1);
    info = mpeg2_info (mpeg2dec);

    size = BUFFER_SIZE;
    do {
	state = mpeg2_parse (mpeg2dec);
	switch (state) {
	case -1:
	    size = fread (buffer, 1, BUFFER_SIZE, file);
	    mpeg2_buffer (mpeg2dec, buffer, buffer + size);
	    break;
	case STATE_SLICE:
	case STATE_END:
	    if (info->display_fbuf)
		save_pgm (info->sequence->width, info->sequence->height,
			  info->display_fbuf->buf, framenum++);
	    break;
	}
    } while (size);

    mpeg2_close (mpeg2dec);
}
Example #4
0
Mpeg2 *glueMpeg2_open(char *filename, int stream_from_disk) {
  Mpeg2 *mpg=malloc(sizeof(Mpeg2));
  
  memset(mpg, 0, sizeof(Mpeg2));
  
  mpg->decoder = mpeg2_init();
  if (mpg->decoder == NULL) {
	  glueError("Could not allocate a decoder object (libmpeg2)");
  }
    
  mpg->info = mpeg2_info(mpg->decoder);
  
  if (stream_from_disk) {
    mpg->f = fopen(filename, "rb");
    mpg->stream_from_disk=1;
  } else {
    mpg->data = glueLoadfile(filename);
    mpg->stream_from_disk=0;
  }
  mpg->whereami = 0;
  mpg->framenum = 0;
  mpg->prevtime = 0;
  mpg->end = 0;
  
  glueLoading();
  
  return mpg;
}
// -----------------------------------------------------------------------------
// Initialize libmpeg2 and create a decoder object
// -----------------------------------------------------------------------------
bool TTMpeg2Decoder::initDecoder()
{

  // TODO: check for subsequent calling initDecoder

  mpeg2Decoder = mpeg2_init();

  if ( mpeg2Decoder == NULL )
  {
    fprintf (stderr, "%sCould not allocate a decoder object.\n",c_name);
    isDecoder = false;
    return isDecoder;
  }

  isDecoder = true;

  // initialize the decoder buffer
  decoderBuffer = new uint8_t [initialDecoderBufferSize];
  decoderBufferSize = initialDecoderBufferSize;

  mpeg2Info = mpeg2_info(mpeg2Decoder);

  if ( !ttAssigned(mpeg2Info) )
  {
    isDecoder = false;
  }

  // read the first sequence header
  if ( isDecoder )
  {
     decodeFirstMPEG2Frame( formatRGB24 );
  }

  return isDecoder;
}
void TvideoCodecLibmpeg2::init(void)
{
    mpeg2dec=mpeg2_init();
    info=mpeg2_info(mpeg2dec);
    wait4Iframe=true;
    sequenceFlag=FIELD_TYPE::SEQ_START;
    m_fFilm = false;
}
void decode_mpeg2(decode_t *decode)
{
    mpeg2dec_t *decoder = NULL;
    const mpeg2_info_t *info = NULL;
    const mpeg2_sequence_t *sequence = NULL;
    mpeg2_state_t state;
    size_t size;
    uint32_t ac = 0;

    WriteDataFn writer = write_yuv420p;
    if (decode->format == TC_CODEC_RGB) {
        tc_log_info(__FILE__, "using libmpeg2convert"
                              " RGB24 conversion");
        writer = write_rgb24;
    }

    ac = mpeg2_accel(MPEG2_ACCEL_DETECT);
    show_accel(ac);

    decoder = mpeg2_init();
    if (decoder == NULL) {
        tc_log_error(__FILE__, "Could not allocate a decoder object.");
        import_exit(1);
    }
    info = mpeg2_info(decoder);

    size = (size_t)-1;
    do {
        state = mpeg2_parse(decoder);
        sequence = info->sequence;
        switch (state) {
          case STATE_BUFFER:
            size = tc_pread(decode->fd_in, buffer, BUFFER_SIZE);
            mpeg2_buffer(decoder, buffer, buffer + size);
            break;
          case STATE_SEQUENCE:
            if (decode->format == TC_CODEC_RGB) {
                mpeg2_convert(decoder, mpeg2convert_rgb24, NULL);
            }
            break;
          case STATE_SLICE:
          case STATE_END:
          case STATE_INVALID_END:
            if (info->display_fbuf) {
                writer(decode, info, sequence);
            }
            break;
          default:
            /* can't happen */
            break;
        }
    } while (size);

    mpeg2_close(decoder);
    import_exit(0);
}
uint8_t decoderMpeg::init_codec (void)
{

  printf ("\n initializing mpeg2 decoder");
  output =yv12_open ();
  _decoder=mpeg2_init();
  printf ("\n done\n");

  return 1;
}
Example #9
0
MPEGDecoder::MPEGDecoder() : Codec() {
	_pixelFormat = g_system->getScreenFormat();
	_surface = 0;

	_mpegDecoder = mpeg2_init();

	if (!_mpegDecoder)
		error("Could not initialize libmpeg2");

	_mpegInfo = mpeg2_info(_mpegDecoder);
}
Example #10
0
static gboolean
gst_mpeg2dec_open (GstVideoDecoder * decoder)
{
  GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);

  mpeg2_accel (MPEG2_ACCEL_DETECT);
  if ((mpeg2dec->decoder = mpeg2_init ()) == NULL)
    return FALSE;
  mpeg2dec->info = mpeg2_info (mpeg2dec->decoder);

  return TRUE;
}
/*
______________________________________________________________________________________
		Constructor for mpeg decoder
______________________________________________________________________________________
*/
decoderMpeg::decoderMpeg(uint32_t w,uint32_t h,uint32_t extraLen, uint8_t *extraData)
	: decoders(w,h)
{
mpeg2_decoder_t *dec;
uint32_t wmb,hmb;
yv12_instance_t *inst;
			_seqLen=extraLen;
			if(extraLen)
			{
				_seqHeader=new uint8_t [extraLen];
				memcpy(_seqHeader,extraData,extraLen);
			}
			else
			{
				_seqHeader=NULL;
			}
			// store for future use
			_seqFound=0;
			postprocessed=NULL;
			// now init libmpeg2
 			printf ("\n initializing mpeg2 decoder %lu x %lu\n",_w,_h);
  			output =yv12_open ();
			inst=(yv12_instance_t *)output;
			unpackBuffer=new uint8_t [(w*h*9)>>1];
			inst->buffer=unpackBuffer;
  			_decoder=mpeg2_init();
			dec=&((MPEG2DEC)->decoder);
			wmb=(_w+15)>>4;;
			hmb=(_h+15)>>4;;
			dec->quant_stride=wmb;
			dec->quant=(int8_t*)malloc( (wmb*hmb)*sizeof(int8_t));
			//
			feedData(extraLen,_seqHeader);
			feedData(extraLen,_seqHeader);
			
			// Post processing settings
			//___________________________
			
			_swapUV=0;
			// Post Proc is disabled by default
			initPostProc(&_postproc,w,h);	    
			
			updatePostProc(&_postproc);	
  			printf ("\n done\n");

}
bool CMpeg2Decoder::Open()
{
	Close();

	mpeg2_threads(m_NumThreads);

	m_pDec = mpeg2_init();

	if (!m_pDec)
		return false;

	for (auto &e: m_PictureStatus) {
		e.rtStart = INVALID_TIME;
	}

	return true;
}
Example #13
0
int
main (int argc, char *argv[])
{
  int fd, count = 20000;
  mpeg2dec_t *decoder;
  char buffer[2048];

  fd = open (argv[1], O_RDONLY);

  gst_init (&argc, &argv);
  mpeg2_init (decoder, new_frame, NULL);

  while (read (fd, buffer, 2048) && count--) {
    mpeg2_decode_data (decoder, buffer, buffer + 2048);
  }
  g_print ("\n");
}
Example #14
0
bool PrivateDecoderMPEG2::Init(const QString &decoder,
                               bool no_hardware_decode,
                               AVCodecContext *avctx)
{
    if (!((decoder == "libmpeg2") &&
        (CODEC_IS_MPEG(avctx->codec_id))))
        return false;

    if (mpeg2dec)
        mpeg2_close(mpeg2dec);
    ClearFrames();
    mpeg2dec = mpeg2_init();
    if (mpeg2dec)
    {
        VERBOSE(VB_PLAYBACK, LOC + "Using libmpeg2 for video decoding");
        return true;
    }
    return false;
}
Example #15
0
File: sample2.c Project: 1c0n/xbmc
static void sample2 (FILE * mpgfile)
{
#define BUFFER_SIZE 4096
    uint8_t buffer[BUFFER_SIZE];
    mpeg2dec_t * decoder;
    const mpeg2_info_t * info;
    mpeg2_state_t state;
    size_t size;
    int framenum = 0;

    decoder = mpeg2_init ();
    if (decoder == NULL) {
	fprintf (stderr, "Could not allocate a decoder object.\n");
	exit (1);
    }
    info = mpeg2_info (decoder);

    size = (size_t)-1;
    do {
	state = mpeg2_parse (decoder);
	switch (state) {
	case STATE_BUFFER:
	    size = fread (buffer, 1, BUFFER_SIZE, mpgfile);
	    mpeg2_buffer (decoder, buffer, buffer + size);
	    break;
	case STATE_SEQUENCE:
	    mpeg2_convert (decoder, mpeg2convert_rgb24, NULL);
	    break;
	case STATE_SLICE:
	case STATE_END:
	case STATE_INVALID_END:
	    if (info->display_fbuf)
		save_ppm (info->sequence->width, info->sequence->height,
			  info->display_fbuf->buf[0], framenum++);
	    break;
	default:
	    break;
	}
    } while (size);

    mpeg2_close (decoder);
}
Example #16
0
static codec_data_t *mpeg2dec_create (const char *stream_type,
				      const char *compressor,
				      int type, 
				      int profile, 
				      format_list_t *media_fmt,
				      video_info_t *vinfo,
				      const uint8_t *userdata,
				      uint32_t ud_size,
				      video_vft_t *vft,
				      void *ifptr)
{
  mpeg2dec_codec_t *mpeg2dec;

  mpeg2dec = MALLOC_STRUCTURE(mpeg2dec_codec_t);
  memset(mpeg2dec, 0, sizeof(*mpeg2dec));

  mpeg2dec->m_vft = vft;
  mpeg2dec->m_ifptr = ifptr;

  mpeg2dec->m_decoder = mpeg2_init();

  mpeg2dec->m_did_pause = 1;
  return ((codec_data_t *)mpeg2dec);
}
Example #17
0
File: libmpeg2.c Project: Kafay/vlc
/*****************************************************************************
 * OpenDecoder: probe the decoder and return score
 *****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
    decoder_t *p_dec = (decoder_t*)p_this;
    decoder_sys_t *p_sys;
    uint32_t i_accel = 0;

    if( p_dec->fmt_in.i_codec != VLC_CODEC_MPGV )
        return VLC_EGENERIC;

    /* Select onl recognized original format (standard mpeg video) */
    switch( p_dec->fmt_in.i_original_fourcc )
    {
    case VLC_FOURCC('m','p','g','1'):
    case VLC_FOURCC('m','p','g','2'):
    case VLC_FOURCC('m','p','g','v'):
    case VLC_FOURCC('P','I','M','1'):
    case VLC_FOURCC('h','d','v','2'):
        break;
    default:
        if( p_dec->fmt_in.i_original_fourcc )
            return VLC_EGENERIC;
        break;
    }

    /* Allocate the memory needed to store the decoder's structure */
    if( ( p_dec->p_sys = p_sys = calloc( 1, sizeof(*p_sys)) ) == NULL )
        return VLC_ENOMEM;

    /* Initialize the thread properties */
    p_sys->p_mpeg2dec = NULL;
    p_sys->p_synchro  = NULL;
    p_sys->p_info     = NULL;
    p_sys->i_current_pts  = 0;
    p_sys->i_previous_pts = 0;
    p_sys->i_current_dts  = 0;
    p_sys->i_previous_dts = 0;
    p_sys->b_garbage_pic = false;
    p_sys->b_slice_i  = false;
    p_sys->b_second_field = false;
    p_sys->b_skip     = false;
    p_sys->b_preroll = false;
    DpbInit( p_dec );

    p_sys->i_cc_pts = 0;
    p_sys->i_cc_dts = 0;
    p_sys->i_cc_flags = 0;
#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0)
    p_dec->pf_get_cc = GetCc;
    cc_Init( &p_sys->cc );
#endif
    p_sys->p_gop_user_data = NULL;
    p_sys->i_gop_user_data = 0;

#if defined( __i386__ ) || defined( __x86_64__ )
    if( vlc_CPU() & CPU_CAPABILITY_MMX )
    {
        i_accel |= MPEG2_ACCEL_X86_MMX;
    }

    if( vlc_CPU() & CPU_CAPABILITY_3DNOW )
    {
        i_accel |= MPEG2_ACCEL_X86_3DNOW;
    }

    if( vlc_CPU() & CPU_CAPABILITY_MMXEXT )
    {
        i_accel |= MPEG2_ACCEL_X86_MMXEXT;
    }

#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
    if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC )
    {
        i_accel |= MPEG2_ACCEL_PPC_ALTIVEC;
    }

#else
    /* If we do not know this CPU, trust libmpeg2's feature detection */
    i_accel = MPEG2_ACCEL_DETECT;

#endif

    /* Set CPU acceleration features */
    mpeg2_accel( i_accel );

    /* Initialize decoder */
    p_sys->p_mpeg2dec = mpeg2_init();
    if( p_sys->p_mpeg2dec == NULL)
    {
        msg_Err( p_dec, "mpeg2_init() failed" );
        free( p_sys );
        return VLC_EGENERIC;
    }

    p_sys->p_info = mpeg2_info( p_sys->p_mpeg2dec );

    p_dec->pf_decode_video = DecodeBlock;
    p_dec->fmt_out.i_cat = VIDEO_ES;
    p_dec->fmt_out.i_codec = 0;

    return VLC_SUCCESS;
}
Example #18
0
int init(char* file) {
  decoder = mpeg2_init();
  source = fopen(file, "rb");
  return source ? 0 : -1;
}
Example #19
0
static void sample5 (FILE * mpgfile)
{
#define BUFFER_SIZE 4096
#define ALIGN_16(p) ((void *)(((uintptr_t)(p) + 15) & ~((uintptr_t)15)))
    uint8_t buffer[BUFFER_SIZE];
    mpeg2dec_t * decoder;
    const mpeg2_info_t * info;
    const mpeg2_sequence_t * sequence;
    mpeg2_state_t state;
    size_t size;
    int framenum = 0;
    int i, j;
    struct fbuf_s * current_fbuf;

    decoder = mpeg2_init ();
    if (decoder == NULL) {
	fprintf (stderr, "Could not allocate a decoder object.\n");
	exit (1);
    }
    info = mpeg2_info (decoder);

    size = (size_t)-1;
    do {
	state = mpeg2_parse (decoder);
	sequence = info->sequence;
	switch (state) {
	case STATE_BUFFER:
	    size = fread (buffer, 1, BUFFER_SIZE, mpgfile);
	    mpeg2_buffer (decoder, buffer, buffer + size);
	    break;
	case STATE_SEQUENCE:
	    mpeg2_custom_fbuf (decoder, 1);
	    for (i = 0; i < 3; i++) {
		fbuf[i].mbuf[0] = (uint8_t *) malloc (sequence->width *
						 sequence->height + 15);
		fbuf[i].mbuf[1] = (uint8_t *) malloc (sequence->chroma_width * 
						 sequence->chroma_height + 15);
		fbuf[i].mbuf[2] = (uint8_t *) malloc (sequence->chroma_width *  
						 sequence->chroma_height + 15);
		if (!fbuf[i].mbuf[0] || !fbuf[i].mbuf[1] || !fbuf[i].mbuf[2]) {
		    fprintf (stderr, "Could not allocate an output buffer.\n");
		    exit (1);
		}
		for (j = 0; j < 3; j++)
		    fbuf[i].yuv[j] = ALIGN_16 (fbuf[i].mbuf[j]);
		fbuf[i].used = 0;
	    }
	    for (i = 0; i < 2; i++) {
		current_fbuf = get_fbuf ();
		mpeg2_set_buf (decoder, current_fbuf->yuv, current_fbuf);
	    }
	    break;
	case STATE_PICTURE:
	    current_fbuf = get_fbuf ();
	    mpeg2_set_buf (decoder, current_fbuf->yuv, current_fbuf);
	    break;
	case STATE_SLICE:
	case STATE_END:
	case STATE_INVALID_END:
	    if (info->display_fbuf)
		save_pgm (sequence->width, sequence->height,
			  sequence->chroma_width, sequence->chroma_height,
			  info->display_fbuf->buf, framenum++);
	    if (info->discard_fbuf)
                ((struct fbuf_s *)info->discard_fbuf->id)->used = 0;
	    if (state != STATE_SLICE)
		for (i = 0; i < 3; i++)
		    for (j = 0; j < 3; j++)
			free (fbuf[i].mbuf[j]);
	    break;
	default:
	    break;
	}
    } while (size);

    mpeg2_close (decoder);
}
Example #20
0
static int _initmpeg2(FILE *mpgfile,int *w, int *h)
{
    static uint8_t buffer[BUFFER_SIZE];
    mpeg2_state_t state;
    struct fbuf_s * current_fbuf;
    size_t size;
    int pixels;
		int i;

	global_mpegfile=mpgfile;

		if (decoder!=NULL) {
 	mpeg2_close (decoder);
	decoder=NULL;
		}
    decoder = mpeg2_init ();
    if (decoder == NULL) {
	fprintf (stderr, "Could not allocate a decoder object.\n");
	exit (1);
    }
    info = mpeg2_info (decoder);

    size = (size_t)-1;
		do {
	state = mpeg2_parse (decoder);
	if (state==STATE_BUFFER) {
		//fprintf(stderr,"Got STATE_BUFFER\n");
	    size = fread (buffer, 1, BUFFER_SIZE, global_mpegfile);
	    mpeg2_buffer (decoder, buffer, buffer + size);
	}
	else if (state==STATE_SEQUENCE) {
		//fprintf(stderr,"Got STATE_SEQUENCE\n");
	    mpeg2_convert (decoder, mpeg2convert_rgb24, NULL);
	    mpeg2_custom_fbuf (decoder, 1);
			if (w!=NULL) *w=info->sequence->width;
			if (h!=NULL) *h=info->sequence->height;
	    pixels = info->sequence->width * info->sequence->height;
	    for (i = 0; i < 3; i++) {
		fbuf[i].rgb[0] = (uint8_t *) malloc (3 * pixels);
		fbuf[i].rgb[1] = fbuf[i].rgb[2] = NULL;
		if (!fbuf[i].rgb[0]) {
		    fprintf (stderr, "Could not allocate an output buffer.\n");
		    exit (1);
		}
		fbuf[i].used = 0;
	    }
	    for (i = 0; i < 2; i++) {
		current_fbuf = get_fbuf ();
		mpeg2_set_buf (decoder, current_fbuf->rgb, current_fbuf);
	    }
			break;
	}
	else if (state==STATE_PICTURE
			|| state==STATE_SLICE
			|| state==STATE_END
			|| state==STATE_INVALID_END) {
		//if (state==STATE_SLICE) fprintf(stderr,"Got STATE_PICTURE\n");
		//if (state==STATE_SLICE) fprintf(stderr,"Got STATE_SLICE\n");
		//if (state==STATE_END) fprintf(stderr,"Got STATE_END\n");
		//if (state==STATE_INVALID_END) fprintf(stderr,"Got STATE_INVALID_END\n");
		  fprintf(stderr,"GOT unexpected state during initialization.\n");
		  return 0;
	}
    } while (size);

		return 1;
}
Example #21
0
static void sample3 (FILE * mpgfile)
{
#define BUFFER_SIZE 4096
    uint8_t buffer[BUFFER_SIZE];
    mpeg2dec_t * decoder;
    const mpeg2_info_t * info;
    const mpeg2_sequence_t * sequence;
    mpeg2_state_t state;
    size_t size;
    int framenum = 0;
    uint8_t * fbuf[3][3];
    int i, j;

    decoder = mpeg2_init ();
    if (decoder == NULL) {
	fprintf (stderr, "Could not allocate a decoder object.\n");
	exit (1);
    }
    info = mpeg2_info (decoder);

    size = (size_t)-1;
    do {
	state = mpeg2_parse (decoder);
	sequence = info->sequence;
	switch (state) {
	case STATE_BUFFER:
	    size = fread (buffer, 1, BUFFER_SIZE, mpgfile);
	    mpeg2_buffer (decoder, buffer, buffer + size);
	    break;
	case STATE_SEQUENCE:
	    for (i = 0; i < 3; i++) {
		fbuf[i][0] = (uint8_t *) malloc (sequence->width *
						 sequence->height);
		fbuf[i][1] = (uint8_t *) malloc (sequence->chroma_width * 
						 sequence->chroma_height);
		fbuf[i][2] = (uint8_t *) malloc (sequence->chroma_width *  
						 sequence->chroma_height);
		if (!fbuf[i][0] || !fbuf[i][1] || !fbuf[i][2]) {
		    fprintf (stderr, "Could not allocate an output buffer.\n");
		    exit (1);
		}
		mpeg2_set_buf (decoder, fbuf[i], NULL);
	    }
	    break;
	case STATE_SLICE:
	case STATE_END:
	case STATE_INVALID_END:
	    if (info->display_fbuf)
		save_pgm (sequence->width, sequence->height,
			  sequence->chroma_width, sequence->chroma_height,
			  info->display_fbuf->buf, framenum++);
	    if (state != STATE_SLICE)
		for (i = 0; i < 3; i++)
		    for (j = 0; j < 3; j++)
			free (fbuf[i][j]);
	    break;
	default:
	    break;
	}
    } while (size);

    mpeg2_close (decoder);
}
Example #22
0
bool BaseAnimationState::init(const char *name) {
#ifdef USE_MPEG2
	char tempFile[512];

	_mpegDecoder = NULL;
	_mpegFile = NULL;

#ifdef BACKEND_8BIT

	uint i, p;

	// Load lookup palettes
	sprintf(tempFile, "%s.pal", name);

	Common::File f;

	if (!f.open(tempFile)) {
		warning("Cutscene: %s palette missing", tempFile);
		return false;
	}

	p = 0;
	while (!f.eos()) {
		_palettes[p].end = f.readUint16LE();
		_palettes[p].cnt = f.readUint16LE();

		for (i = 0; i < _palettes[p].cnt; i++) {
			_palettes[p].pal[4 * i] = f.readByte();
			_palettes[p].pal[4 * i + 1] = f.readByte();
			_palettes[p].pal[4 * i + 2] = f.readByte();
			_palettes[p].pal[4 * i + 3] = 0;
		}
		for (; i < 256; i++) {
			_palettes[p].pal[4 * i] = 0;
			_palettes[p].pal[4 * i + 1] = 0;
			_palettes[p].pal[4 * i + 2] = 0;
			_palettes[p].pal[4 * i + 3] = 0;
		}

		p++;
	}

	f.close();

	_palNum = 0;
	_maxPalNum = p;
	setPalette(_palettes[_palNum].pal);
	_lut = _lut2 = _yuvLookup[0];
	_curPal = -1;
	_cr = 0;
	buildLookup(_palNum, 256);
	_lut2 = _yuvLookup[1];
	_lutCalcNum = (BITDEPTH + _palettes[_palNum].end + 2) / (_palettes[_palNum].end + 2);
#else
	buildLookup();
	_overlay = (OverlayColor *)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor));
	_sys->showOverlay();
#endif

	// Open MPEG2 stream
	_mpegFile = new Common::File();
	sprintf(tempFile, "%s.mp2", name);
	if (!_mpegFile->open(tempFile)) {
		warning("Cutscene: Could not open %s", tempFile);
		return false;
	}

	// Load and configure decoder
	_mpegDecoder = mpeg2_init();
	if (_mpegDecoder == NULL) {
		warning("Cutscene: Could not allocate an MPEG2 decoder");
		return false;
	}

	_mpegInfo = mpeg2_info(_mpegDecoder);
	_frameNum = 0;

	return true;
#else /* USE_MPEG2 */
	return false;
#endif
}