Commit ef13c05a authored by conrad's avatar conrad

Parse BOS page before calling first page reader callback.

Fixes ticket:416, "oggz-chop writes wrong granulerate in fisbone"
by correcting the library behaviour.
  - Rename internal oggz_auto_get_granulerate() to oggz_auto_read_bos_packet()
  - Add internal oggz_auto_read_bos_page()
  - Use oggz_auto_read_bos_page() when a new bos page is encountered, before
    calling the user's page reader callback
  - Correct the granulerate denominator reported by oggz_get_granulerate,
    removing the internal OGGZ_AUTO_MULT scaling


git-svn-id: http://svn.annodex.net/liboggz/trunk@3718 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 45dd94c5
......@@ -158,7 +158,7 @@ oggz_get_granulerate (OGGZ * oggz, long serialno,
if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
*granulerate_n = stream->granulerate_n;
*granulerate_d = stream->granulerate_d;
*granulerate_d = stream->granulerate_d / OGGZ_AUTO_MULT;
return 0;
}
......
......@@ -63,8 +63,6 @@ int oggz_set_metric_linear (OGGZ * oggz, long serialno,
#define INT32_BE_AT(x) _be_32((*(ogg_int32_t *)(x)))
#define INT64_LE_AT(x) _le_64((*(ogg_int64_t *)(x)))
#define OGGZ_AUTO_MULT 1000Ull
static int
oggz_stream_set_numheaders (OGGZ * oggz, long serialno, int numheaders)
{
......@@ -1111,7 +1109,23 @@ oggz_auto_identify_packet (OGGZ * oggz, ogg_packet * op, long serialno)
}
int
oggz_auto_get_granulerate (OGGZ * oggz, ogg_packet * op, long serialno,
oggz_auto_read_bos_page (OGGZ * oggz, ogg_page * og, long serialno,
void * user_data)
{
int content = 0;
content = oggz_stream_get_content(oggz, serialno);
if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) {
return 0;
} else if (content == OGGZ_CONTENT_SKELETON && !ogg_page_bos(og)) {
return auto_fisbone(oggz, serialno, og->body, og->body_len, user_data);
} else {
return oggz_auto_codec_ident[content].reader(oggz, serialno, og->body, og->body_len, user_data);
}
}
int
oggz_auto_read_bos_packet (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data)
{
int content = 0;
......
......@@ -44,6 +44,8 @@
#include "oggz_vector.h"
#include "oggz_dlist.h"
#define OGGZ_AUTO_MULT 1000Ull
typedef struct _OGGZ OGGZ;
typedef struct _OggzComment OggzComment;
typedef struct _OggzIO OggzIO;
......@@ -283,7 +285,10 @@ int oggz_get_granuleshift (OGGZ * oggz, long serialno);
/* oggz_auto */
int
oggz_auto_get_granulerate (OGGZ * oggz, ogg_packet * op, long serialno,
oggz_auto_read_bos_page (OGGZ * oggz, ogg_page * og, long serialno,
void * user_data);
int
oggz_auto_read_bos_packet (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data);
int
......
......@@ -414,7 +414,7 @@ oggz_read_sync (OGGZ * oggz)
(oggz->flags & OGGZ_AUTO)
)
{
oggz_auto_get_granulerate (oggz, op, serialno, NULL);
oggz_auto_read_bos_packet (oggz, op, serialno, NULL);
}
/* attempt to determine granulepos for this packet */
......@@ -524,6 +524,10 @@ oggz_read_sync (OGGZ * oggz)
/* identify stream type */
oggz_auto_identify_page (oggz, &og, serialno);
/* read bos data */
if (oggz->flags & OGGZ_AUTO)
oggz_auto_read_bos_page (oggz, &og, serialno, NULL);
}
else if (oggz_stream_get_content(oggz, serialno) == OGGZ_CONTENT_ANXDATA)
{
......
......@@ -290,7 +290,7 @@ oggz_write_feed (OGGZ * oggz, ogg_packet * op, long serialno, int flush,
/* OK -- Update stream's memory of packet details */
if (!stream->metric && (oggz->flags & OGGZ_AUTO)) {
oggz_auto_get_granulerate (oggz, op, serialno, NULL);
oggz_auto_read_bos_packet (oggz, op, serialno, NULL);
}
stream->b_o_s = 0; /* The stream is henceforth no longer at bos */
......
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