Commit 009d15ca authored by conrad's avatar conrad

oggz-chop: simplify states, cleanup


git-svn-id: http://svn.annodex.net/liboggz/trunk@3619 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent d91f5658
......@@ -65,8 +65,6 @@ typedef struct _OCTrackState {
int headers_remaining;
int rec_skeleton;
/* Greatest previously inferred keyframe value */
ogg_int64_t prev_keyframe;
......@@ -432,7 +430,7 @@ write_accum (OCState * state)
ogg_page * og, * min_og;
double min_time;
if (state->status >= OC_WRITTEN_ACCUM) return -1;
if (state->status >= OC_GLUE_DONE) return -1;
/*
* We create a table of candidate tracks, which are all those which
......@@ -501,7 +499,7 @@ write_accum (OCState * state)
oggz_table_delete (candidates);
state->status = OC_WRITTEN_ACCUM;
state->status = OC_GLUE_DONE;
return 0;
}
......@@ -517,7 +515,7 @@ chop_glue (OCState * state, OGGZ * oggz)
long serialno;
OCTrackState * ts;
if (state->status < OC_WRITTEN_ACCUM) {
if (state->status < OC_GLUE_DONE) {
/* Write in fisbones */
fisbones_write (state);
......@@ -532,7 +530,7 @@ chop_glue (OCState * state, OGGZ * oggz)
}
}
state->status = OC_WRITTEN_ACCUM;
state->status = OC_GLUE_DONE;
return 0;
}
......@@ -566,17 +564,10 @@ read_plain (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
} else if (page_time >= state->start &&
(state->end == -1 || page_time <= state->end)) {
if (state->status < OC_WRITTEN_ACCUM) {
if (state->status < OC_GLUE_DONE) {
chop_glue (state, oggz);
}
if (!ts->rec_skeleton) {
#ifdef DEBUG
printf ("read_plain: start granule for serialno %010ld: %ld\n",
serialno, ts->fisbone.start_granule);
#endif
ts->rec_skeleton = 1;
}
fwrite_ogg_page (state->outfile, og);
} else if (state->end != -1.0 && page_time > state->end) {
/* This is the first page past the end time; set EOS */
......@@ -615,14 +606,6 @@ read_gs (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
/* Glue in fisbones, write out accumulated pages */
chop_glue (state, oggz);
if (!ts->rec_skeleton) {
#ifdef DEBUG
printf ("read_gs: start granule for serialno %010ld: %ld\n",
serialno, ts->fisbone.start_granule);
#endif
ts->rec_skeleton = 1;
}
/* Switch to the plain page reader */
oggz_set_read_page (oggz, serialno, read_plain, state);
return read_plain (oggz, og, serialno, user_data);
......@@ -721,7 +704,7 @@ read_bos (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data)
/* Write the Skeleton BOS page out */
if (state->status == OC_INIT) {
fishead_write (state);
state->status = OC_HEADERS;
state->status = OC_GLUING;
}
oggz_set_read_page (oggz, serialno, read_headers, state);
......
......@@ -42,10 +42,8 @@
typedef enum {
OC_INIT = 0, /* Done nothing yet */
OC_HEADERS, /* Done Skeleton BOS, copying media headers */
OC_SKIP, /* Skipping pages before start */
OC_WRITTEN_ACCUM, /* Written accum pages */
OC_BLAT /* Copying pages after start */
OC_GLUING, /* Done Skeleton BOS, copying media headers */
OC_GLUE_DONE /* Written accum pages, copy remaining data to end */
} OCStatus;
typedef struct _OCState {
......
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