Changeset 3765

Show
Ignore:
Timestamp:
2008-11-04 12:25:31 (2 months ago)
Author:
giles
Message:

Update granulepos scheme to the new Dirac spec. Patch from David Flynn.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • liboggz/trunk/src/liboggz/oggz_auto.c

    r3764 r3765  
    360360auto_dirac (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) 
    361361{ 
    362   char keyframe_granule_shift = 32; 
    363   int keyframe_shift; 
     362  int granule_shift = 22; /* not a typo */ 
    364363  dirac_info *info; 
    365364 
     
    368367  dirac_parse_info(info, data, length); 
    369368 
    370   /* 
    371   FIXME: where is this in Ogg Dirac? 
    372   keyframe_granule_shift = (char) ((header[40] & 0x03) << 3); 
    373   keyframe_granule_shift |= (header[41] & 0xe0) >> 5; 
    374   */ 
    375   keyframe_shift = keyframe_granule_shift; 
    376  
    377369#ifdef DEBUG 
    378   printf ("Got dirac fps %d/%d, keyframe_shift %d\n", 
    379           fps_numerator, fps_denominator, keyframe_shift); 
    380 #endif 
    381  
    382   oggz_set_granulerate (oggz, serialno, (ogg_int64_t)info->fps_numerator, 
    383                         OGGZ_AUTO_MULT * (ogg_int64_t)info->fps_denominator); 
    384   oggz_set_granuleshift (oggz, serialno, keyframe_shift); 
    385  
    386   oggz_stream_set_numheaders (oggz, serialno, 3); 
     370  printf ("Got dirac fps %d/%d granule_shift %d\n", 
     371    fps_numerator, fps_denominator, granule_shift); 
     372#endif 
     373 
     374  /* the granulerate is twice the frame rate (in order to handle interlace) 
     375   * it is also multiplied by (1<<9) since the decode time is stored in 
     376   * the top 32bits of granulepos, but the granule_shift is 22. */ 
     377  oggz_set_granulerate (oggz, serialno, 
     378        2*(1<<9)*(ogg_int64_t)info->fps_numerator, 
     379        OGGZ_AUTO_MULT * (ogg_int64_t)info->fps_denominator); 
     380  oggz_set_granuleshift (oggz, serialno, granule_shift); 
     381 
     382  oggz_stream_set_numheaders (oggz, serialno, 0); 
    387383 
    388384  free(info); 
  • liboggz/trunk/src/tools/oggz_tools.c

    r3763 r3765  
    455455    pframe = granulepos - (iframe << granuleshift); 
    456456 
    457     ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe); 
    458   } 
     457    if (oggz_stream_get_content (oggz, serialno) != OGGZ_CONTENT_DIRAC) { 
     458      ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe); 
     459    } else { 
     460      uint32_t pt = (iframe + pframe) >> 9; 
     461      uint16_t dist = ((iframe & 0xff) << 8) | (pframe & 0xff); 
     462      uint16_t delay = pframe >> 9; 
     463      int64_t dt = pt - delay; 
     464      ret = fprintf (stream, 
     465                     "(pt:%u,dt:%" PRId64 ",dist:%hu,delay:%hu)", 
     466                     pt, dt, dist, delay); 
     467    } 
     468 
     469
    459470 
    460471  return ret;