"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/plugin.c" (9 Jan 2007, 6337 Bytes) of package /linux/privat/old/quicktime4linux-2.3-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <stdio.h>
    2 #include <dirent.h>
    3 #include <dlfcn.h>
    4 #include "funcprotos.h"
    5 #include "quicktime.h"
    6 
    7 
    8 static int total_vcodecs = 0;
    9 static int total_acodecs = 0;
   10 static quicktime_codectable_t *vcodecs = NULL; 
   11 static quicktime_codectable_t *acodecs = NULL; 
   12 
   13 
   14 
   15 
   16 static int register_vcodec(void (*init_vcodec)(quicktime_video_map_t *))
   17 {
   18     total_vcodecs++;
   19     vcodecs = (quicktime_codectable_t *)realloc(vcodecs,
   20         total_vcodecs * sizeof(quicktime_codectable_t));
   21 
   22     vcodecs[total_vcodecs - 1].init_vcodec = init_vcodec;
   23     return total_vcodecs - 1;
   24 }
   25 
   26 static int register_acodec(void (*init_acodec)(quicktime_audio_map_t *))
   27 {
   28     total_acodecs++;
   29     acodecs = (quicktime_codectable_t *)realloc(acodecs,
   30         total_acodecs * sizeof(quicktime_codectable_t));
   31     acodecs[total_acodecs - 1].init_acodec = init_acodec;
   32     return total_acodecs - 1;
   33 }
   34 
   35 
   36 
   37 
   38 #include "ima4.h"
   39 #include "mp4a.h"
   40 #include "qdm2.h"
   41 #include "qtvorbis.h"
   42 #include "qtmp3.h"
   43 #include "rawaudio.h"
   44 #include "twos.h"
   45 #include "ulaw.h"
   46 #include "wma.h"
   47 #include "wmx2.h"
   48 
   49 static void register_acodecs()
   50 {
   51     register_acodec(quicktime_init_codec_twos);
   52     register_acodec(quicktime_init_codec_rawaudio);
   53     register_acodec(quicktime_init_codec_ima4);
   54     register_acodec(quicktime_init_codec_mp4a);
   55     register_acodec(quicktime_init_codec_qdm2);
   56     register_acodec(quicktime_init_codec_ulaw);
   57 
   58     register_acodec(quicktime_init_codec_vorbis);
   59     register_acodec(quicktime_init_codec_mp3);
   60     register_acodec(quicktime_init_codec_wmx2);
   61     register_acodec(quicktime_init_codec_wmav1);
   62     register_acodec(quicktime_init_codec_wmav2);
   63 }
   64 
   65 
   66 
   67 
   68 
   69 #include "qth264.h"
   70 #include "raw.h"
   71 #include "qtdv.h"
   72 #include "jpeg.h"
   73 #include "mpeg4.h"
   74 #include "qtpng.h"
   75 #include "rle.h"
   76 #include "v308.h"
   77 #include "v408.h"
   78 #include "v410.h"
   79 #include "yuv2.h"
   80 #include "yuv4.h"
   81 #include "yv12.h"
   82 
   83 static void register_vcodecs()
   84 {
   85 
   86     register_vcodec(quicktime_init_codec_raw);
   87 
   88     register_vcodec(quicktime_init_codec_h264);
   89     register_vcodec(quicktime_init_codec_hv64);
   90     register_vcodec(quicktime_init_codec_divx);
   91     register_vcodec(quicktime_init_codec_hv60);
   92     register_vcodec(quicktime_init_codec_div5);
   93     register_vcodec(quicktime_init_codec_div3);
   94     register_vcodec(quicktime_init_codec_div3lower);
   95     register_vcodec(quicktime_init_codec_mp4v);
   96     register_vcodec(quicktime_init_codec_xvid);
   97     register_vcodec(quicktime_init_codec_svq1);
   98     register_vcodec(quicktime_init_codec_svq3);
   99     register_vcodec(quicktime_init_codec_h263);
  100     register_vcodec(quicktime_init_codec_dv);
  101     register_vcodec(quicktime_init_codec_dvsd);
  102     register_vcodec(quicktime_init_codec_dvcp);
  103 
  104     register_vcodec(quicktime_init_codec_jpeg);
  105     register_vcodec(quicktime_init_codec_mjpa);
  106     register_vcodec(quicktime_init_codec_mjpg);
  107     register_vcodec(quicktime_init_codec_png);
  108     register_vcodec(quicktime_init_codec_rle);
  109 
  110     register_vcodec(quicktime_init_codec_yuv2);
  111     register_vcodec(quicktime_init_codec_2vuy);
  112     register_vcodec(quicktime_init_codec_yuv4);
  113     register_vcodec(quicktime_init_codec_yv12);
  114     register_vcodec(quicktime_init_codec_v410);
  115     register_vcodec(quicktime_init_codec_v308);
  116     register_vcodec(quicktime_init_codec_v408);
  117 }
  118 
  119 
  120 
  121 
  122 int quicktime_find_vcodec(quicktime_video_map_t *vtrack)
  123 {
  124     int i;
  125     char *compressor = vtrack->track->mdia.minf.stbl.stsd.table[0].format;
  126     quicktime_codec_t *codec_base = (quicktime_codec_t*)vtrack->codec;
  127     if(!total_vcodecs) register_vcodecs();
  128 
  129     for(i = 0; i < total_vcodecs; i++)
  130     {
  131         quicktime_codectable_t *table = &vcodecs[i];
  132         table->init_vcodec(vtrack);
  133         if(quicktime_match_32(compressor, codec_base->fourcc))
  134         {
  135             return 0;
  136         }
  137         else
  138         {
  139             codec_base->delete_vcodec(vtrack);
  140             codec_base->priv = 0;
  141         }
  142     }
  143 
  144     return -1;
  145 }
  146 
  147 
  148 int quicktime_find_acodec(quicktime_audio_map_t *atrack)
  149 {
  150     int i;
  151     char *compressor = atrack->track->mdia.minf.stbl.stsd.table[0].format;
  152     int compression_id = atrack->track->mdia.minf.stbl.stsd.table[0].compression_id;
  153     quicktime_codec_t *codec_base = (quicktime_codec_t*)atrack->codec;
  154     int32_t compressor_int = *(int32_t*)compressor;
  155     if(!total_acodecs) register_acodecs();
  156 
  157     for(i = 0; i < total_acodecs; i++)
  158     {
  159         quicktime_codectable_t *table = &acodecs[i];
  160         table->init_acodec(atrack);
  161 
  162 // For writing and reading Quicktime
  163         if(quicktime_match_32(compressor, codec_base->fourcc))
  164             return 0;
  165         else
  166 // For reading AVI, sometimes the fourcc is 0 and the compression_id is used instead.
  167 // Sometimes the compression_id is the fourcc.
  168         if((compressor[0] == 0 || compressor_int == codec_base->wav_id) && 
  169             codec_base->wav_id == compression_id)
  170         {
  171             quicktime_copy_char32(compressor, codec_base->fourcc);
  172             return 0;
  173         }
  174         else
  175         {
  176             codec_base->delete_acodec(atrack);
  177             codec_base->priv = 0;
  178         }
  179     }
  180 
  181     return -1;
  182 }
  183 
  184 
  185 char* quicktime_acodec_title(char *fourcc)
  186 {
  187     int i;
  188     char *result = 0;
  189     quicktime_audio_map_t *atrack = 
  190         (quicktime_audio_map_t*)calloc(1, sizeof(quicktime_audio_map_t));
  191     quicktime_codec_t *codec_base = 
  192         atrack->codec = 
  193         (quicktime_codec_t*)calloc(1, sizeof(quicktime_codec_t));
  194     int done = 0;
  195     if(!total_acodecs) register_acodecs();
  196     for(i = 0; i < total_acodecs && !done; i++)
  197     {
  198 //printf("quicktime_acodec_title 1\n");
  199         quicktime_codectable_t *table = &acodecs[i];
  200 //printf("quicktime_acodec_title 2\n");
  201         table->init_acodec(atrack);
  202 //printf("quicktime_acodec_title 3\n");
  203         if(quicktime_match_32(fourcc, codec_base->fourcc))
  204         {
  205             result = codec_base->title;
  206             done = 1;
  207         }
  208 //printf("quicktime_acodec_title 4\n");
  209         codec_base->delete_acodec(atrack);
  210 //printf("quicktime_acodec_title 5\n");
  211     }
  212     free(codec_base);
  213     free(atrack);
  214     
  215     if(!result)
  216         return fourcc;
  217     else
  218         return result;
  219 }
  220 
  221 char* quicktime_vcodec_title(char *fourcc)
  222 {
  223     int i;
  224     char *result = 0;
  225 
  226     quicktime_video_map_t *vtrack = 
  227         (quicktime_video_map_t*)calloc(1, sizeof(quicktime_video_map_t));
  228     quicktime_codec_t *codec_base = 
  229         vtrack->codec = 
  230         (quicktime_codec_t*)calloc(1, sizeof(quicktime_codec_t));
  231     int done = 0;
  232 
  233 
  234     if(!total_vcodecs) register_vcodecs();
  235     for(i = 0; i < total_vcodecs && !done; i++)
  236     {
  237         quicktime_codectable_t *table = &vcodecs[i];
  238         table->init_vcodec(vtrack);
  239         if(quicktime_match_32(fourcc, codec_base->fourcc))
  240         {
  241             result = codec_base->title;
  242             done = 1;
  243         }
  244         codec_base->delete_vcodec(vtrack);
  245     }
  246 
  247 
  248 
  249     free(codec_base);
  250     free(vtrack);
  251 
  252     if(!result)
  253         return fourcc;
  254     else
  255         return result;
  256 }
  257 
  258 
  259 
  260 
  261 
  262 
  263 
  264