oggdec: K&R cosmetic formatting
This commit is contained in:
@@ -155,7 +155,6 @@ static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size)
|
|||||||
|
|
||||||
static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
|
static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ogg *ogg = s->priv_data;
|
struct ogg *ogg = s->priv_data;
|
||||||
int idx = ogg->nstreams++;
|
int idx = ogg->nstreams++;
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
@@ -164,6 +163,7 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
|
|||||||
ogg->streams = av_realloc(ogg->streams,
|
ogg->streams = av_realloc(ogg->streams,
|
||||||
ogg->nstreams * sizeof(*ogg->streams));
|
ogg->nstreams * sizeof(*ogg->streams));
|
||||||
memset(ogg->streams + idx, 0, sizeof(*ogg->streams));
|
memset(ogg->streams + idx, 0, sizeof(*ogg->streams));
|
||||||
|
|
||||||
os = ogg->streams + idx;
|
os = ogg->streams + idx;
|
||||||
os->serial = serial;
|
os->serial = serial;
|
||||||
os->bufsize = DECODER_BUFFER_SIZE;
|
os->bufsize = DECODER_BUFFER_SIZE;
|
||||||
@@ -188,10 +188,12 @@ static int ogg_new_buf(struct ogg *ogg, int idx)
|
|||||||
struct ogg_stream *os = ogg->streams + idx;
|
struct ogg_stream *os = ogg->streams + idx;
|
||||||
uint8_t *nb = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
|
uint8_t *nb = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
int size = os->bufpos - os->pstart;
|
int size = os->bufpos - os->pstart;
|
||||||
|
|
||||||
if (os->buf) {
|
if (os->buf) {
|
||||||
memcpy(nb, os->buf + os->pstart, size);
|
memcpy(nb, os->buf + os->pstart, size);
|
||||||
av_free(os->buf);
|
av_free(os->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
os->buf = nb;
|
os->buf = nb;
|
||||||
os->bufpos = size;
|
os->bufpos = size;
|
||||||
os->pstart = 0;
|
os->pstart = 0;
|
||||||
@@ -225,13 +227,15 @@ static int ogg_read_page(AVFormatContext *s, int *str)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
c = avio_r8(bc);
|
c = avio_r8(bc);
|
||||||
|
|
||||||
if (bc->eof_reached)
|
if (bc->eof_reached)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
sync[sp++ & 3] = c;
|
sync[sp++ & 3] = c;
|
||||||
} while (i++ < MAX_PAGE_SIZE);
|
} while (i++ < MAX_PAGE_SIZE);
|
||||||
|
|
||||||
if (i >= MAX_PAGE_SIZE) {
|
if (i >= MAX_PAGE_SIZE) {
|
||||||
av_log (s, AV_LOG_INFO, "ogg, can't find sync word\n");
|
av_log(s, AV_LOG_INFO, "cannot find sync word\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,11 +255,14 @@ static int ogg_read_page(AVFormatContext *s, int *str)
|
|||||||
|
|
||||||
for (n = 0; n < ogg->nstreams; n++) {
|
for (n = 0; n < ogg->nstreams; n++) {
|
||||||
av_freep(&ogg->streams[n].buf);
|
av_freep(&ogg->streams[n].buf);
|
||||||
if (!ogg->state || ogg->state->streams[n].private != ogg->streams[n].private)
|
if (!ogg->state ||
|
||||||
|
ogg->state->streams[n].private != ogg->streams[n].private)
|
||||||
av_freep(&ogg->streams[n].private);
|
av_freep(&ogg->streams[n].private);
|
||||||
}
|
}
|
||||||
|
|
||||||
ogg->curidx = -1;
|
ogg->curidx = -1;
|
||||||
ogg->nstreams = 0;
|
ogg->nstreams = 0;
|
||||||
|
|
||||||
idx = ogg_new_stream(s, serial, 0);
|
idx = ogg_new_stream(s, serial, 0);
|
||||||
} else {
|
} else {
|
||||||
idx = ogg_new_stream(s, serial, 1);
|
idx = ogg_new_stream(s, serial, 1);
|
||||||
@@ -378,7 +385,9 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
|
|||||||
idx, os->psize, os->pstart);
|
idx, os->psize, os->pstart);
|
||||||
|
|
||||||
if (os->granule == -1)
|
if (os->granule == -1)
|
||||||
av_log(s, AV_LOG_WARNING, "Page at %"PRId64" is missing granule\n", os->page_pos);
|
av_log(s, AV_LOG_WARNING,
|
||||||
|
"Page at %"PRId64" is missing granule\n",
|
||||||
|
os->page_pos);
|
||||||
|
|
||||||
ogg->curidx = idx;
|
ogg->curidx = idx;
|
||||||
os->incomplete = 0;
|
os->incomplete = 0;
|
||||||
@@ -398,6 +407,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
|
|||||||
// compute the data_offset.
|
// compute the data_offset.
|
||||||
if (!s->data_offset)
|
if (!s->data_offset)
|
||||||
s->data_offset = os->sync_pos;
|
s->data_offset = os->sync_pos;
|
||||||
|
|
||||||
for (i = 0; i < ogg->nstreams; i++) {
|
for (i = 0; i < ogg->nstreams; i++) {
|
||||||
struct ogg_stream *cur_os = ogg->streams + i;
|
struct ogg_stream *cur_os = ogg->streams + i;
|
||||||
|
|
||||||
@@ -625,7 +635,8 @@ static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
|
|||||||
avio_seek(bc, *pos_arg, SEEK_SET);
|
avio_seek(bc, *pos_arg, SEEK_SET);
|
||||||
ogg_reset(ogg);
|
ogg_reset(ogg);
|
||||||
|
|
||||||
while (avio_tell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) {
|
while (avio_tell(bc) < pos_limit &&
|
||||||
|
!ogg_packet(s, &i, NULL, NULL, pos_arg)) {
|
||||||
if (i == stream_index) {
|
if (i == stream_index) {
|
||||||
struct ogg_stream *os = ogg->streams + stream_index;
|
struct ogg_stream *os = ogg->streams + stream_index;
|
||||||
pts = ogg_calc_pts(s, i, NULL);
|
pts = ogg_calc_pts(s, i, NULL);
|
||||||
|
Reference in New Issue
Block a user