* 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
pull/126/head
Zdenek Kabelac 22 years ago
parent 0570bf06d4
commit 1101abfe77
  1. 47
      libav/avidec.c

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

Loading…
Cancel
Save