Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

libmpeg3plugin.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2001 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #include "libmpeg3plugin.h"
00021 
00022 
00023 #ifdef OLD_MEDIAPLAYER_API
00024 
00025 
00026 bool LibMpeg3Plugin::audioReadSamples( short *output, int channel, long samples, int stream ) {
00027     return file ? mpeg3_read_audio( file, 0, output, 0, channel, samples, stream ) == 1 : FALSE; 
00028 }
00029 
00030 
00031 bool LibMpeg3Plugin::audioReReadSamples( short *output, int channel, long samples, int stream ) {
00032     return file ? mpeg3_reread_audio( file, 0, output, 0, channel, samples, stream ) == 1 : FALSE; 
00033 }
00034 
00035 
00036 bool LibMpeg3Plugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) {
00037     samplesRead = samples;
00038     return file ? mpeg3_read_audio( file, 0, output, 0, 0, samples, stream ) == 1 : FALSE; 
00039 }
00040 
00041 
00042 bool LibMpeg3Plugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) {
00043     bool err = FALSE;
00044     if ( file ) {
00045 #if 1
00046         err = mpeg3_read_audio  ( file, 0,  output, 1, 0, samples, stream ) == 1;
00047         if ( err == FALSE ) {
00048             err = mpeg3_reread_audio( file, 0, output + 1, 1, 1, samples, stream ) == 1;
00049 #else
00050         short left[samples];
00051         short right[samples];
00052         err = mpeg3_read_audio  ( file, 0,  left, 0, samples, stream ) == 1;
00053         if ( !err )
00054             err = mpeg3_reread_audio( file, 0, right, 1, samples, stream ) == 1;
00055         for ( int j = 0; j < samples; j++ ) {
00056             output[j*2+0] =  left[j];
00057             output[j*2+1] = right[j];
00058 #endif
00059         }
00060     }
00061     samplesRead = samples;
00062     return err;
00063 }
00064 
00065 
00066 #else
00067 
00068 
00069 bool LibMpeg3Plugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) {
00070     samplesRead = samples;
00071     switch ( channels ) {
00072         case 1:
00073             return file ? mpeg3_read_audio( file, 0, output, 0, 0, samples, stream ) == 1 : FALSE;
00074         case 2:
00075             if ( ( file ) && ( mpeg3_read_audio( file, 0, output, 1, 0, samples, stream ) != 1 ) &&
00076                     ( mpeg3_reread_audio( file, 0, output + 1, 1, 1, samples, stream ) != 1 ) )
00077                 return TRUE;
00078             return FALSE;
00079     }
00080     return FALSE;
00081 }
00082 
00083 
00084 #endif
00085 
00086 
00087 bool LibMpeg3Plugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) {
00088     int format = MPEG3_RGB565;
00089     switch ( color_model ) {
00090         case RGB565:    format = MPEG3_RGB565;   break;
00091         case BGR565:    /*format = MPEG3_BGR565;*/   break;
00092         case RGBA8888:  format = MPEG3_RGBA8888; break;
00093         case BGRA8888:  format = MPEG3_BGRA8888; break;
00094     }
00095     return file ? mpeg3_read_frame( file, output_rows, in_x, in_y, in_w, in_h, in_w, in_h, format, stream ) == 1 : FALSE;
00096 }
00097 
00098 
00099 bool LibMpeg3Plugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) {
00100     int format = MPEG3_RGB565;
00101     switch ( color_model ) {
00102         case RGB565:    format = MPEG3_RGB565;   break;
00103         case BGR565:    /*format = MPEG3_BGR565;*/   break;
00104         case RGBA8888:  format = MPEG3_RGBA8888; break;
00105         case BGRA8888:  format = MPEG3_BGRA8888; break;
00106     }
00107     return file ? mpeg3_read_frame( file, output_rows, in_x, in_y, in_w, in_h, out_w, out_h, format, stream ) == 1 : FALSE;
00108 }
00109 
00110 
00111 bool LibMpeg3Plugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) {
00112     return file ? mpeg3_read_yuvframe( file, y_output, u_output, v_output, in_x, in_y, in_w, in_h, stream ) == 1 : FALSE;
00113 }
00114 
00115 

Generated on Sat Nov 5 16:15:37 2005 for OPIE by  doxygen 1.4.2