summaryrefslogtreecommitdiff
path: root/libavformat/nut.c
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2003-10-02 14:59:54 +0000
committerAlex Beregszaszi <alex@rtfs.hu>2003-10-02 14:59:54 +0000
commit5aa0a6449435473d8ed531a6eee85857abb8e158 (patch)
tree252da9172a8ee58d9a4849167968864aedf22d63 /libavformat/nut.c
parent7fe4c82382b641c9eae538afb5b17b47f2405072 (diff)
fix fabrice's broken get_bi and some minor changes in draft
Originally committed as revision 2335 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/nut.c')
-rw-r--r--libavformat/nut.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/libavformat/nut.c b/libavformat/nut.c
index a1e98a20a4..20d0e61975 100644
--- a/libavformat/nut.c
+++ b/libavformat/nut.c
@@ -63,7 +63,6 @@ static uint64_t get_v(ByteIOContext *bc)
{
uint64_t val = 0;
-// for (; bytes_left(s)*8 > 0; )
for(; bytes_left(bc) > 0; )
{
int tmp = get_byte(bc);
@@ -93,27 +92,23 @@ static int get_b(ByteIOContext *bc, char *data, int maxlen)
len = get_v(bc);
for (i = 0; i < len && i < maxlen; i++)
data[i] = get_byte(bc);
- if (i < len)
- {
- len = i;
- for (i = 0; i < len; i++)
- get_byte(bc);
- }
+ /* skip remaining bytes */
+ for (; i < len; i++)
+ get_byte(bc);
return 0;
}
static int get_bi(ByteIOContext *bc)
{
- int i, len, val;
+ int i, len, val = 0;
len = get_v(bc);
- if(len > 4) return -1;
-
- val = 0;
- for (i = 0; i < len; i++) {
+ for (i = 0; i < len && i <= 4; i++)
val |= get_byte(bc) << (i * 8);
- }
+ /* skip remaining bytes */
+ for (; i < len; i++)
+ get_byte(bc);
return val;
}
@@ -232,21 +227,12 @@ static int nut_write_header(AVFormatContext *s)
ByteIOContext *bc = &s->pb;
AVCodecContext *codec;
int i;
- int stream_length = 0;
-
- for (i = 0; i < s->nb_streams; i++)
- {
- if (stream_length < (s->streams[i]->duration * (AV_TIME_BASE / 1000)))
- stream_length = s->streams[i]->duration * (AV_TIME_BASE / 1000);
- }
/* main header */
put_be64(bc, MAIN_STARTCODE);
put_packetheader(nut, bc, 120);
put_v(bc, 0); /* version */
put_v(bc, s->nb_streams);
- put_v(bc, 0); /* file size */
- put_v(bc, stream_length); /* len in msec */
put_be32(bc, 0); /* FIXME: checksum */
update_packetheader(nut, bc, 0);
@@ -439,10 +425,6 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
fprintf(stderr, "bad version (%Ld)\n", tmp);
nb_streams = get_v(bc);
-
- s->file_size = get_v(bc);
- s->duration = get_v(bc) / (AV_TIME_BASE / 1000);
-
get_be32(bc); /* checkusm */
s->bit_rate = 0;