Changeset 2734
- Timestamp:
- 2007-05-17 01:03:14 (2 years ago)
- Files:
-
- liboggplay/trunk/plugin/plugin_gui_linux.c (modified) (1 diff)
- liboggplay/trunk/plugin/plugin_oggplay.c (modified) (11 diffs)
- liboggplay/trunk/plugin/plugin_oggplay.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
liboggplay/trunk/plugin/plugin_gui_linux.c
r2725 r2734 83 83 frame_data.size = 0; 84 84 85 get_oggplay_frame(info->ogg_handle, &frame_data );85 get_oggplay_frame(info->ogg_handle, &frame_data, BGR); 86 86 if (frame_data.frame == NULL) { 87 87 return TRUE; liboggplay/trunk/plugin/plugin_oggplay.c
r2727 r2734 224 224 225 225 void 226 get_oggplay_frame(void *pointers, PluginOggFrame* frame_data) { 226 get_oggplay_frame(void *pointers, PluginOggFrame *frame_data, 227 PluginColourFormat output_format) { 227 228 228 229 int i; … … 231 232 int y_height; 232 233 int required; 233 int j;234 int j; 234 235 unsigned char * out; 235 236 OggPlayVideoData * video_data; 236 OggPlayAudioData * audio_data;237 OggPlayAudioData * audio_data; 237 238 PluginPointers * handle = (PluginPointers *)pointers; 238 239 OggPlay * player = handle->player; … … 241 242 int num_tracks; 242 243 244 frame_data->frame = NULL; 245 frame_data->samples = NULL; 243 246 244 247 /* … … 246 249 */ 247 250 if (player == NULL) { 248 frame_data->frame = NULL;249 251 return; 250 252 } 251 253 track_info = oggplay_buffer_retrieve_next(player); 252 254 if (track_info == NULL) { 253 frame_data->frame = NULL;254 255 return; 255 256 } … … 285 286 oggplay_buffer_free_info(track_info); 286 287 oggplay_buffer_release_next(player); 287 frame_data->frame = NULL;288 288 return; 289 289 } … … 291 291 oggplay_get_video_y_size(player, i, &y_width, &y_height); 292 292 out = (unsigned char*)malloc(y_width * y_height * 4); 293 /*convert_to_rgb_frame(video_data->y, video_data->u, video_data->v, 294 y_width, y_height, out);*/ 293 295 294 yuv.ptry = video_data->y; 296 295 yuv.ptru = video_data->u; … … 304 303 rgb.rgb_width = y_width; 305 304 rgb.rgb_height = y_height; 305 306 306 /* convert frame from YUV to RGB */ 307 oggplay_yuv2bgr(&yuv, &rgb); 308 307 switch (output_format) { 308 case BGR: 309 oggplay_yuv2bgr(&yuv, &rgb); 310 break; 311 case RGB: 312 default: 313 oggplay_yuv2rgb(&yuv, &rgb); 314 break; 315 } 316 309 317 frame_data->frame = out; 310 318 frame_data->width = y_width; … … 314 322 oggplay_callback_info_get_presentation_time(headers[0]); 315 323 316 break;324 break; 317 325 case OGGPLAY_FLOATS_AUDIO: 318 required = oggplay_callback_info_get_required(track_info[i]);319 for (j = 0; j < required; j++) {320 int samples;321 samples = oggplay_callback_info_get_record_size(headers[j]);322 audio_data = oggplay_callback_info_get_audio_data(headers[j]);323 // atm: sample size = sizeof(short), channels = 2324 buffer_audio_data(&(frame_data->samples), &(frame_data->size), (unsigned char*)audio_data, samples, sizeof(short), 2);325 };326 break;326 required = oggplay_callback_info_get_required(track_info[i]); 327 for (j = 0; j < required; j++) { 328 int samples; 329 samples = oggplay_callback_info_get_record_size(headers[j]); 330 audio_data = oggplay_callback_info_get_audio_data(headers[j]); 331 // atm: sample size = sizeof(short), channels = 2 332 buffer_audio_data(&(frame_data->samples), &(frame_data->size), (unsigned char*)audio_data, samples, sizeof(short), 2); 333 }; 334 break; 327 335 default: 328 336 break; … … 330 338 } 331 339 332 //frame_data->frame = NULL;333 340 oggplay_buffer_free_info(track_info); 334 341 return; … … 351 358 if (frame_data->samples != NULL) { 352 359 free(frame_data->samples); 353 frame_data->samples = NULL; 360 frame_data->samples = NULL; 354 361 } 355 362 frame_data->size = 0; … … 367 374 void 368 375 buffer_audio_data(unsigned char ** buffer, int* buffer_length, unsigned char * data, int samples, int sample_size, int channels) { 369 int _buf_length = (*buffer_length);370 int bytes = samples * sample_size * channels;371 *buffer = realloc(*buffer, _buf_length + bytes);372 if (data != 0) {373 float_to_short_array((float *) data, (short*)(*buffer + _buf_length), samples * channels);374 _buf_length += bytes;375 }376 (*buffer_length) = _buf_length;376 int _buf_length = (*buffer_length); 377 int bytes = samples * sample_size * channels; 378 *buffer = realloc(*buffer, _buf_length + bytes); 379 if (data != 0) { 380 float_to_short_array((float *) data, (short*)(*buffer + _buf_length), samples * channels); 381 _buf_length += bytes; 382 } 383 (*buffer_length) = _buf_length; 377 384 } 378 385 liboggplay/trunk/plugin/plugin_oggplay.h
r2727 r2734 40 40 } PluginErrorCode; 41 41 42 typedef enum { 43 RGB, 44 BGR 45 } PluginColourFormat; 46 42 47 typedef struct { 43 48 // theora frame related … … 57 62 58 63 void 59 get_oggplay_frame(void *pointers, PluginOggFrame* frame_data); 64 get_oggplay_frame(void *pointers, PluginOggFrame* frame_data, 65 PluginColourFormat output_format); 60 66 61 67 void