Changeset 3512

Show
Ignore:
Timestamp:
2008-03-20 03:30:14 (9 months ago)
Author:
conrad
Message:

add Kate support to liboggz and oggzinfo, oggzdump, oggzrip etc.
See http://wiki.xiph.org/index.php/OggKate. Patch from ogg.k.ogg.k

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • liboggz/trunk/include/oggz/oggz_constants.h

    r3449 r3512  
    112112  OGGZ_CONTENT_ANXDATA, 
    113113  OGGZ_CONTENT_CELT, 
     114  OGGZ_CONTENT_KATE, 
    114115  OGGZ_CONTENT_UNKNOWN 
    115116} OggzStreamContent; 
  • liboggz/trunk/src/liboggz/oggz_auto.c

    r3450 r3512  
    141141  int keyframe_shift; 
    142142 
     143  /* TODO: this should check against 42 for the relevant version numbers */ 
    143144  if (op->bytes < 41) return 0; 
    144145 
     
    158159#else 
    159160  keyframe_granule_shift = (char) ((header[40] & 0x03) << 3); 
    160   keyframe_granule_shift |= (header[41] & 0xe0) >> 5; 
     161  keyframe_granule_shift |= (header[41] & 0xe0) >> 5; /* see TODO above */ 
    161162  keyframe_shift = keyframe_granule_shift; 
    162163#endif 
     
    322323 
    323324  oggz_stream_set_numheaders (oggz, serialno, 3); 
     325 
     326  return 1; 
     327} 
     328 
     329static int 
     330auto_kate (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data) 
     331{ 
     332  unsigned char * header = op->packet; 
     333  ogg_int32_t gps_numerator, gps_denominator; 
     334  unsigned char granule_shift = 0; 
     335  int numheaders; 
     336 
     337  if (op->bytes < 64) return 0; 
     338 
     339  gps_numerator = INT32_LE_AT(&header[24]); 
     340  gps_denominator = INT32_LE_AT(&header[28]); 
     341 
     342  granule_shift = (header[15]); 
     343  numheaders = (header[11]); 
     344 
     345#ifdef DEBUG 
     346  printf ("Got kate gps %d/%d, granule shift %d\n", 
     347          gps_numerator, gps_denominator, granule_shift); 
     348#endif 
     349 
     350  oggz_set_granulerate (oggz, serialno, gps_numerator, 
     351                        OGGZ_AUTO_MULT * gps_denominator); 
     352  oggz_set_granuleshift (oggz, serialno, granule_shift); 
     353  
     354  oggz_stream_set_numheaders (oggz, serialno, numheaders); 
    324355 
    325356  return 1; 
     
    10121043  {"AnxData", 7, "AnxData", auto_anxdata, NULL, NULL}, 
    10131044  {"CELT    ", 8, "CELT", auto_celt, auto_calc_celt, NULL}, 
     1045  {"\200kate\0\0\0\0", 9, "Kate", auto_kate, NULL, NULL}, 
    10141046  {"", 0, "Unknown", NULL, NULL, NULL} 
    10151047};  
     
    11061138        offset = 7; 
    11071139      break; 
     1140    case OGGZ_CONTENT_KATE: 
     1141      if (op->bytes > 9 && memcmp (op->packet, "\201kate\0\0\0\0", 9) == 0) { 
     1142        offset = 9; 
     1143      } 
     1144      break; 
    11081145    case OGGZ_CONTENT_FLAC: 
    11091146      if (op->bytes > 4 && (op->packet[0] & 0x7) == 4) { 
     
    11111148        offset = 4; 
    11121149      } 
     1150      break; 
    11131151    default: 
    11141152      break; 
  • liboggz/trunk/src/liboggz/oggz_auto.h

    r3449 r3512  
    429429 */ 
    430430 
     431/** 
     432 * Kate bitstream version 0.1 
     433 * 
     434 * Default field type: LITTLE ENDIAN unsigned integer 
     435 
     436 0               1               2               3              | 
     437 0                   1                   2                   3 
     438 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte 
     439+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     440| packtype      | Identifier char[8]: 'kate\0\0\0\0'            | 0-3 
     441+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     442| kate magic continued                                          | 4-7 
     443+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     444| kate magic    | version major | version minor | num headers   | 8-11 
     445+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     446| text encoding | directionality| reserved - 0  | granule shift | 12-15 
     447+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     448| reserved - 0                                                  | 16-19 
     449+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     450| reserved - 0                                                  | 20-23 
     451+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     452| granule rate numerator                                        | 24-27 
     453+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     454| granule rate denominator                                      | 28-31 
     455+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     456| language (NUL terminated)                                     | 32-35 
     457+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     458| language (continued)                                          | 36-39 
     459+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     460| language (continued)                                          | 40-43 
     461+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     462| language (continued)                                          | 44-47 
     463+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     464| category (NUL terminated)                                     | 48-51 
     465+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     466| category (continued)                                          | 52-55 
     467+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     468| category (continued)                                          | 56-59 
     469+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     470| category (continued)                                          | 60-63 
     471+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     472 
     473 */ 
     474 
    431475int oggz_auto_identify (OGGZ *oggz, ogg_page *og, long serialno); 
    432476 
  • liboggz/trunk/src/liboggz/oggz_comments.c

    r3424 r3512  
    734734  const unsigned char preamble_flac[4] = 
    735735    {0x04, 0x00, 0x00, 0x00}; 
     736  const unsigned char preamble_kate[9] = 
     737    {0x81, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00}; 
    736738 
    737739 
     
    748750      preamble_length = sizeof preamble_flac; 
    749751      preamble = preamble_flac; 
     752      break; 
     753    case OGGZ_CONTENT_KATE: 
     754      preamble_length = sizeof preamble_kate; 
     755      preamble = preamble_kate; 
    750756      break; 
    751757    case OGGZ_CONTENT_PCM: 
     
    809815} 
    810816 
    811 /* In Flac, OggPCM, Speex, Theora and Vorbis the comment packet will 
     817/* In Flac, OggPCM, Speex, Theora Vorbis, and Kate the comment packet will 
    812818   be second in the stream, i.e. packetno=1, and it will have granulepos=0 */ 
    813819ogg_packet * 
  • liboggz/trunk/src/tools/oggz_tools.c

    r3449 r3512  
    240240 
    241241static char * 
     242ot_kate_info (unsigned char * data, long len) 
     243{ 
     244  char * buf; 
     245 
     246  static const size_t KATE_INFO_BUFFER_LEN = 
     247    1 /* tab */ 
     248  +10 /* "Language: " */ 
     249  +15 /* 15 chars + NUL for language */ 
     250   +1 /* \n */ 
     251   +1 /* tab */ 
     252  +10 /* "Category: " */ 
     253  +15 /* 15 chars + NUL for category */ 
     254   +1 /* \n */ 
     255   +1;/* terminating NUL */ 
     256 
     257  if (len < 64) return NULL; 
     258 
     259  buf = malloc (KATE_INFO_BUFFER_LEN); 
     260 
     261  /* Are these headers coming from some standard ? If so, need to find what should these be for Kate */ 
     262  snprintf (buf, KATE_INFO_BUFFER_LEN, 
     263            "\tLanguage: %s\n" 
     264            "\tCategory: %s\n", 
     265            &data[32], &data[48]); 
     266 
     267#undef KATE_INFO_BUFFER_LEN 
     268 
     269  return buf; 
     270} 
     271 
     272static char * 
    242273ot_skeleton_info (unsigned char * data, long len) 
    243274{ 
     
    284315  NULL,             /* ANXDATA */ 
    285316  ot_celt_info,     /* CELT */ 
     317  ot_kate_info,     /* KATE */ 
    286318  NULL              /* UNKOWN */ 
    287319}; 
  • liboggz/trunk/src/tools/oggzdump.c

    r3432 r3512  
    9191  printf ("                         Dump only the logical bitstreams for a specified\n"); 
    9292  printf ("                         content-type. The following codecs are currently\n"); 
    93   printf ("                         detected: theora, vorbis, speex, cmml\n"); 
     93  printf ("                         detected: theora, vorbis, speex, cmml, kate\n"); 
    9494  printf ("  -s serialno, --serialno serialno\n"); 
    9595  printf ("                         Dump only the logical bitstream with specified serialno\n"); 
  • liboggz/trunk/src/tools/oggzrip.c

    r3254 r3512  
    9595  printf ("                         Filter by content-type.  The following codec\n"); 
    9696  printf ("                         names are currently detected: \"theora\",\n"); 
    97   printf ("                         \"vorbis\", \"speex\", \"cmml\"\n"); 
     97  printf ("                         \"vorbis\", \"speex\", \"cmml\", \"kate\"\n"); 
    9898  printf ("\nMiscellaneous options\n"); 
    9999  printf ("  -o filename, --output filename\n");