Commit 2143a674 authored by conrad's avatar conrad

metric_internal: add a custom metric for Dirac. This moves the Dirac

granulepos handling (specifically the shift of (iframe+pframe)>>9)
to where it is more generally used for converting granulepos to time.
Now oggz merge and oggz sort seem to handle Dirac; please test.


git-svn-id: http://svn.annodex.net/liboggz/trunk@3801 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent b77afd5c
......@@ -34,6 +34,37 @@
#include "oggz_private.h"
static ogg_int64_t
oggz_metric_dirac (OGGZ * oggz, long serialno,
ogg_int64_t granulepos, void * user_data)
{
oggz_stream_t * stream;
ogg_int64_t iframe, pframe;
ogg_uint32_t pt;
ogg_uint16_t dist;
ogg_uint16_t delay;
ogg_int64_t dt;
ogg_int64_t units;
stream = oggz_get_stream (oggz, serialno);
if (stream == NULL) return -1;
iframe = granulepos >> stream->granuleshift;
pframe = granulepos - (iframe << stream->granuleshift);
pt = (iframe + pframe) >> 9;
delay = pframe >> 9;
dt = (int64_t)pt - delay;
units = dt * stream->granulerate_d / stream->granulerate_n;
#ifdef DEBUG
printf ("oggz_..._granuleshift: serialno %010ld Got frame or field %lld (%lld + %lld): %lld units\n",
serialno, dt, iframe, pframe, units);
#endif
return units;
}
static ogg_int64_t
oggz_metric_default_granuleshift (OGGZ * oggz, long serialno,
ogg_int64_t granulepos, void * user_data)
......@@ -92,6 +123,10 @@ oggz_metric_update (OGGZ * oggz, long serialno)
return oggz_set_metric_internal (oggz, serialno,
oggz_metric_default_linear,
NULL, 1);
} else if (oggz_stream_get_content (oggz, serialno) == OGGZ_CONTENT_DIRAC) {
return oggz_set_metric_internal (oggz, serialno,
oggz_metric_dirac,
NULL, 1);
} else {
return oggz_set_metric_internal (oggz, serialno,
oggz_metric_default_granuleshift,
......
......@@ -375,11 +375,9 @@ auto_dirac (OGGZ * oggz, long serialno, unsigned char * data, long length, void
fps_numerator, fps_denominator, granule_shift);
#endif
/* the granulerate is twice the frame rate (in order to handle interlace)
* it is also multiplied by (1<<9) since the decode time is stored in
* the top 32bits of granulepos, but the granule_shift is 22. */
/* the granulerate is twice the frame rate (in order to handle interlace) */
oggz_set_granulerate (oggz, serialno,
2*(1<<9)*(ogg_int64_t)info->fps_numerator,
2 * (ogg_int64_t)info->fps_numerator,
OGGZ_AUTO_MULT * (ogg_int64_t)info->fps_denominator);
oggz_set_granuleshift (oggz, serialno, granule_shift);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment