Changeset 2734

Show
Ignore:
Timestamp:
2007-05-17 01:03:14 (2 years ago)
Author:
tahn
Message:

Changed get_oggplay_frame interface to allow either rgb or bgr data
to be generated. Better handling of the frame_data pointers. Fixed
some indenting issues.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • liboggplay/trunk/plugin/plugin_gui_linux.c

    r2725 r2734  
    8383  frame_data.size = 0; 
    8484 
    85   get_oggplay_frame(info->ogg_handle, &frame_data); 
     85  get_oggplay_frame(info->ogg_handle, &frame_data, BGR); 
    8686  if (frame_data.frame == NULL) { 
    8787    return TRUE; 
  • liboggplay/trunk/plugin/plugin_oggplay.c

    r2727 r2734  
    224224 
    225225void 
    226 get_oggplay_frame(void *pointers, PluginOggFrame* frame_data) { 
     226get_oggplay_frame(void *pointers, PluginOggFrame *frame_data, 
     227  PluginColourFormat output_format) { 
    227228 
    228229  int                     i; 
     
    231232  int                     y_height; 
    232233  int                     required; 
    233   int                    j; 
     234  int                     j; 
    234235  unsigned char         * out; 
    235236  OggPlayVideoData      * video_data; 
    236   OggPlayAudioData         * audio_data; 
     237  OggPlayAudioData      * audio_data; 
    237238  PluginPointers        * handle = (PluginPointers *)pointers; 
    238239  OggPlay               * player = handle->player; 
     
    241242  int                     num_tracks; 
    242243 
     244  frame_data->frame = NULL; 
     245  frame_data->samples = NULL; 
    243246   
    244247  /* 
     
    246249   */ 
    247250  if (player == NULL) { 
    248     frame_data->frame = NULL; 
    249251    return; 
    250252  } 
    251253  track_info = oggplay_buffer_retrieve_next(player); 
    252254  if (track_info == NULL) { 
    253     frame_data->frame = NULL; 
    254255    return; 
    255256  } 
     
    285286          oggplay_buffer_free_info(track_info); 
    286287          oggplay_buffer_release_next(player); 
    287           frame_data->frame = NULL; 
    288288          return; 
    289289        } 
     
    291291        oggplay_get_video_y_size(player, i, &y_width, &y_height); 
    292292        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 
    295294        yuv.ptry = video_data->y; 
    296295        yuv.ptru = video_data->u; 
     
    304303        rgb.rgb_width = y_width; 
    305304        rgb.rgb_height = y_height; 
     305 
    306306        /* 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 
    309317        frame_data->frame = out; 
    310318        frame_data->width = y_width; 
     
    314322            oggplay_callback_info_get_presentation_time(headers[0]); 
    315323   
    316              break; 
     324        break; 
    317325      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 = 2 
    324            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; 
    327335      default: 
    328336        break; 
     
    330338  } 
    331339  
    332   //frame_data->frame = NULL; 
    333340  oggplay_buffer_free_info(track_info); 
    334341  return; 
     
    351358  if (frame_data->samples != NULL) { 
    352359     free(frame_data->samples); 
    353      frame_data->samples = NULL;                    
     360     frame_data->samples = NULL; 
    354361  } 
    355362  frame_data->size = 0; 
     
    367374void  
    368375buffer_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; 
    377384} 
    378385 
  • liboggplay/trunk/plugin/plugin_oggplay.h

    r2727 r2734  
    4040} PluginErrorCode; 
    4141 
     42typedef enum { 
     43  RGB, 
     44  BGR 
     45} PluginColourFormat; 
     46 
    4247typedef struct { 
    4348   // theora frame related 
     
    5762 
    5863void 
    59 get_oggplay_frame(void *pointers, PluginOggFrame* frame_data); 
     64get_oggplay_frame(void *pointers, PluginOggFrame* frame_data, 
     65  PluginColourFormat output_format); 
    6066 
    6167void