Commit 16268f12 authored by conrad's avatar conrad

oggz-tools: split Dirac granulepos parsing out into a separate function, and use ogg int types


git-svn-id: http://svn.annodex.net/liboggz/trunk@3780 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 684dcae3
......@@ -27,7 +27,7 @@ endif
endif
noinst_HEADERS = oggz_tools.h skeleton.h
noinst_HEADERS = oggz_tools.h oggz_tools_dirac.h skeleton.h
# Programs to build
bin_PROGRAMS = $(oggz_any_programs) $(oggz_read_programs) $(oggz_rw_programs)
......
......@@ -38,7 +38,9 @@
#include <getopt.h>
#include <oggz/oggz.h>
#include "dirac.h"
#include "oggz_tools_dirac.h"
#if defined (WIN32) || defined (__EMX__)
#include <fcntl.h>
......@@ -441,6 +443,16 @@ ot_fprint_time (FILE * stream, double seconds)
return fprintf (stream, "%s%02d:%02d:%06.3f", sign, hrs, min, sec);
}
void
ot_dirac_gpos_parse (ogg_int64_t iframe, ogg_int64_t pframe,
struct ot_dirac_gpos * dg)
{
dg->pt = (iframe + pframe) >> 9;
dg->dist = ((iframe & 0xff) << 8) | (pframe & 0xff);
dg->delay = pframe >> 9;
dg->dt = (int64_t)dg->pt - dg->delay;
}
int
ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno,
ogg_int64_t granulepos)
......@@ -457,13 +469,11 @@ ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno,
if (oggz_stream_get_content (oggz, serialno) != OGGZ_CONTENT_DIRAC) {
ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe);
} else {
uint32_t pt = (iframe + pframe) >> 9;
uint16_t dist = ((iframe & 0xff) << 8) | (pframe & 0xff);
uint16_t delay = pframe >> 9;
int64_t dt = (int64_t)pt - delay;
struct ot_dirac_gpos dg;
ot_dirac_gpos_parse (iframe, pframe, &dg);
ret = fprintf (stream,
"(pt:%u,dt:%" PRId64 ",dist:%hu,delay:%hu)",
pt, dt, dist, delay);
dg.pt, dg.dt, dg.dist, dg.delay);
}
}
......
/*
Copyright (C) 2008 Annodex Association
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Annodex Association or the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ASSOCIATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __OGGZ_TOOLS_DIRAC_H__
#define __OGGZ_TOOLS_DIRAC_H__
#include "config.h"
/*
* Dirac specific granulepos interpretation
*/
struct ot_dirac_gpos {
ogg_uint32_t pt;
ogg_uint16_t dist;
ogg_uint16_t delay;
ogg_int64_t dt;
};
/* Parse a granulepos value using Dirac interpretation */
void ot_dirac_gpos_parse (ogg_int64_t iframe, ogg_int64_t pframe,
struct ot_dirac_gpos * dg);
#endif /* __OGGZ_TOOLS_DIRAC_H__ */
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