1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

* cleanup statics & const

* some minor initial parsing fixes (yet it's very simple parser at this moment)

Originally committed as revision 1189 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Zdenek Kabelac 2002-11-11 09:21:59 +00:00
parent 0570bf06d4
commit 1101abfe77

View File

@ -31,10 +31,11 @@ typedef struct {
INT64 movi_end;
offset_t movi_list;
AVIIndex *first, *last;
int framenum;
} AVIContext;
#ifdef DEBUG
void print_tag(const char *str, unsigned int tag, int size)
static void print_tag(const char *str, unsigned int tag, int size)
{
printf("%s: tag=%c%c%c%c size=0x%x\n",
str, tag & 0xff,
@ -45,7 +46,7 @@ void print_tag(const char *str, unsigned int tag, int size)
}
#endif
int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVIContext *avi = s->priv_data;
ByteIOContext *pb = &s->pb;
@ -68,6 +69,7 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
stream_index = -1;
codec_type = -1;
frame_period = 0;
avi->framenum = 0;
for(;;) {
if (url_feof(pb))
goto fail;
@ -93,19 +95,18 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
break;
case MKTAG('a', 'v', 'i', 'h'):
/* avi header */
/* avi header */
/* using frame_period is bad idea */
frame_period = get_le32(pb);
bit_rate = get_le32(pb) * 8;
url_fskip(pb, 4 * 4);
url_fskip(pb, 4 * 4);
s->nb_streams = get_le32(pb);
for(i=0;i<s->nb_streams;i++) {
AVStream *st;
st = av_malloc(sizeof(AVStream));
AVStream *st = av_mallocz(sizeof(AVStream));
if (!st)
goto fail;
memset(st, 0, sizeof(AVStream));
s->streams[i] = st;
}
}
url_fskip(pb, size - 7 * 4);
break;
case MKTAG('s', 't', 'r', 'h'):
@ -122,16 +123,13 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_le32(pb); /* XXX: initial frame ? */
get_le32(pb); /* scale */
get_le32(pb); /* rate */
url_fskip(pb, size - 7 * 4);
size -= 6 * 4;
break;
case MKTAG('a', 'u', 'd', 's'):
codec_type = CODEC_TYPE_AUDIO;
/* nothing really useful */
url_fskip(pb, size - 4);
break;
default:
goto fail;
}
url_fskip(pb, size - 4);
break;
case MKTAG('s', 't', 'r', 'f'):
/* stream header */
@ -159,7 +157,7 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
url_fskip(pb, size - 5 * 4);
break;
case CODEC_TYPE_AUDIO:
case CODEC_TYPE_AUDIO:
get_wav_header(pb, &st->codec, (size >= 18));
break;
default:
@ -188,35 +186,34 @@ int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
return 0;
}
int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIContext *avi = s->priv_data;
ByteIOContext *pb = &s->pb;
int n, d1, d2, size;
find_next:
if (url_feof(pb) || url_ftell(pb) >= avi->movi_end)
return -1;
d1 = get_byte(pb);
if (d1 < '0' || d1 > '9')
goto find_next;
d2 = get_byte(pb);
if (d2 < '0' || d2 > '9')
goto find_next;
n = (d1 - '0') * 10 + (d2 - '0');
for(;;) {
if (url_feof(pb) || url_ftell(pb) >= avi->movi_end)
return -1;
d1 = get_byte(pb) - '0';
d2 = get_byte(pb) - '0';
if (d1 < 0 || d1 > 9 || d2 < 0 || d2 > 9)
continue;
if (n < 0 || n >= s->nb_streams)
goto find_next;
d1 = get_byte(pb);
d2 = get_byte(pb);
if ((d1 != 'd' && d2 != 'c') &&
(d1 != 'w' && d2 != 'b'))
goto find_next;
n = d1 * 10 + d2;
if (n < 0 || n >= s->nb_streams)
continue;
d1 = get_byte(pb);
d2 = get_byte(pb);
if ((d1 == 'd' && d2 == 'c')
|| (d1 == 'w' && d2 == 'b'))
break;
}
size = get_le32(pb);
av_new_packet(pkt, size);
pkt->stream_index = n;
pkt->pts = avi->framenum++;
get_buffer(pb, pkt->data, pkt->size);
@ -226,7 +223,7 @@ int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
return 0;
}
int avi_read_close(AVFormatContext *s)
static int avi_read_close(AVFormatContext *s)
{
return 0;
}