00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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: 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: 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