home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / quicktime / graphics.c < prev    next >
C/C++ Source or Header  |  2000-11-29  |  3KB  |  104 lines

  1. #include "graphics.h"
  2.  
  3. #include <string.h>
  4.  
  5. /* Graphics acceleration routines */
  6.  
  7. void quicktime_init_yuv(quicktime_yuv_t *yuv_table)
  8. {
  9.     int i;
  10.     for(i = 0; i < 256; i++)
  11.     {
  12. /* compression */
  13.         yuv_table->rtoy_tab[i] = (long)( 0.2990 * 65536 * i);
  14.         yuv_table->rtou_tab[i] = (long)(-0.1687 * 65536 * i);
  15.         yuv_table->rtov_tab[i] = (long)( 0.5000 * 65536 * i);
  16.  
  17.         yuv_table->gtoy_tab[i] = (long)( 0.5870 * 65536 * i);
  18.         yuv_table->gtou_tab[i] = (long)(-0.3320 * 65536 * i);
  19.         yuv_table->gtov_tab[i] = (long)(-0.4187 * 65536 * i);
  20.  
  21.         yuv_table->btoy_tab[i] = (long)( 0.1140 * 65536 * i);
  22.         yuv_table->btou_tab[i] = (long)( 0.5000 * 65536 * i);
  23.         yuv_table->btov_tab[i] = (long)(-0.0813 * 65536 * i);
  24.     }
  25.  
  26.     yuv_table->vtor = &(yuv_table->vtor_tab[128]);
  27.     yuv_table->vtog = &(yuv_table->vtog_tab[128]);
  28.     yuv_table->utog = &(yuv_table->utog_tab[128]);
  29.     yuv_table->utob = &(yuv_table->utob_tab[128]);
  30.     for(i = -128; i < 128; i++)
  31.     {
  32. /* decompression */
  33.         yuv_table->vtor[i] = (long)( 1.4020 * 65536 * i);
  34.         yuv_table->vtog[i] = (long)(-0.7141 * 65536 * i);
  35.  
  36.         yuv_table->utog[i] = (long)(-0.3441 * 65536 * i);
  37.         yuv_table->utob[i] = (long)( 1.7720 * 65536 * i);
  38.     }
  39. }
  40.  
  41. void quicktime_delete_yuv(quicktime_yuv_t *yuv_table)
  42. {
  43. }
  44.  
  45.  
  46. quicktime_scaletable_t* quicktime_new_scaletable(int input_w, int input_h, int output_w, int output_h)
  47. {
  48.     quicktime_scaletable_t *result = (quicktime_scaletable_t*)malloc(sizeof(quicktime_scaletable_t));
  49.     float i;
  50.     float scalex = (float)input_w / output_w, scaley = (float)input_h / output_h;
  51.  
  52.     result->input_x = (int*)malloc(sizeof(int) * output_w);
  53.     result->input_y = (int*)malloc(sizeof(int) * output_h);
  54.  
  55.     for(i = 0; i < output_w; i++)
  56.     {
  57.         result->input_x[(int)i] = (int)(scalex * i);
  58.     }
  59.  
  60.     for(i = 0; i < output_h; i++)
  61.     {
  62.         result->input_y[(int)i] = (int)(scaley * i);
  63.     }
  64.  
  65.     result->in_w = input_w;
  66.     result->in_h = input_h;
  67.     result->out_w = output_w;
  68.     result->out_h = output_h;
  69.     return result;
  70. }
  71.  
  72. void quicktime_delete_scaletable(quicktime_scaletable_t *scaletable)
  73. {
  74.     free(scaletable->input_x);
  75.     free(scaletable->input_y);
  76.     free(scaletable);
  77. }
  78.  
  79. /* Return 1 if dimensions are different from scaletable */
  80. int quicktime_compare_scaletable(quicktime_scaletable_t *scaletable, 
  81.     int in_w, 
  82.     int in_h, 
  83.     int out_w, 
  84.     int out_h)
  85. {
  86.     if(scaletable->in_w != in_w ||
  87.         scaletable->in_h != in_h ||
  88.         scaletable->out_w != out_w ||
  89.         scaletable->out_h != out_h)
  90.         return 1;
  91.     else
  92.         return 0;
  93. }
  94.  
  95. /* Return 1 if the scaletable is 1:1 */
  96. int quicktime_identity_scaletable(quicktime_scaletable_t *scaletable)
  97. {
  98.     if(scaletable->in_w == scaletable->out_w &&
  99.         scaletable->in_h == scaletable->out_h)
  100.         return 1;
  101.     else
  102.         return 0;
  103. }
  104.