Index: nut.c =================================================================== RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/nut.c,v retrieving revision 1.1 diff -u -r1.1 nut.c --- nut.c 5 Sep 2003 18:45:32 -0000 1.1 +++ nut.c 6 Sep 2003 23:11:22 -0000 @@ -206,10 +206,10 @@ stream_length = s->streams[i]->duration * (AV_TIME_BASE / 1000); } + put_le64(bc, 1); /* FIXME: unique startcode */ put_packetheader(nut, bc, 16); /* FIXME: estimation */ /* main header */ - put_le64(bc, 1); /* FIXME: unique startcode */ put_v(bc, 0); /* version */ put_v(bc, s->nb_streams); put_v(bc, 0); /* file size */ @@ -222,9 +222,9 @@ { codec = &s->streams[i]->codec; + put_le64(bc, 1<<8|1); /* FIXME: unique startcode */ put_packetheader(nut, bc, 64); /* FIXME: estimation */ - put_le64(bc, 1); /* FIXME: unique startcode */ - put_v(bc, s->streams[i]->index); + put_v(bc, i/*s->streams[i]->id*/); put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0); if (codec->codec_tag) put_b(bc, codec->codec_tag, 4); @@ -272,11 +272,11 @@ } } -#if 0 +#if 1 /* info header */ + put_le64(bc, 3<<8|1); /* FIXME: unique startcode */ put_packetheader(nut, bc, 16+strlen(s->author)+strlen(s->title)+ strlen(s->comment)+strlen(s->copyright)); /* FIXME: estimation */ - put_le64(bc, 1); /* FIXME: unique startcode */ if (s->author[0]) { put_v(bc, 5); /* type */ @@ -299,7 +299,9 @@ } /* encoder */ put_v(bc, 9); /* type */ - put_b(bc, LIBAVFORMAT_IDENT, strlen(LIBAVFORMAT_IDENT)); + put_b(bc, LIBAVFORMAT_IDENT "\0", strlen(LIBAVFORMAT_IDENT)+1); + + put_v(bc, 0); put_padding(nut, bc); put_le32(bc, 0); /* FIXME: checksum */ @@ -324,14 +326,18 @@ enc = &s->streams[stream_index]->codec; if (enc->codec_type == CODEC_TYPE_VIDEO) key_frame = enc->coded_frame->key_frame; - - put_packetheader(nut, bc, size+(key_frame?16:8)+4); /* FIXME: estimation */ +// else +// key_frame = 1; if (key_frame) - put_le64(bc, 1); /* FIXME: unique startcode */ + put_le64(bc, 2<<8|1); /* FIXME: unique startcode */ + else + put_byte(bc, 128); + put_packetheader(nut, bc, size+(key_frame?16:8)+16); /* FIXME: estimation */ + put_byte(bc, (key_frame ? 1<<5 : 0) + (1 << 1)); /* flags */ put_v(bc, stream_index); - put_s(bc, 0); /* lsb_timestamp */ + put_s(bc, force_pts); /* lsb_timestamp */ put_buffer(bc, buf, size); @@ -380,10 +386,10 @@ int cur_stream, nb_streams; /* main header */ - get_packetheader(nut, bc); tmp = get_le64(bc); if (tmp != 1) fprintf(stderr, "damaged? startcode!=1 (%d)\n", tmp); + get_packetheader(nut, bc); tmp = get_v(bc); if (tmp != 0) @@ -405,10 +411,10 @@ int class; AVStream *st; - get_packetheader(nut, bc); tmp = get_le64(bc); - if (tmp != 1) - fprintf(stderr, "damaged? startcode!=1 (%d)\n", tmp); + if (tmp != (1<<8|1)) + fprintf(stderr, "damaged? startcode!=1<<8|1 (%d)\n", tmp); + get_packetheader(nut, bc); st = av_new_stream(s, get_v(bc)); if (!st) return AVERROR_NOMEM; @@ -478,11 +484,22 @@ int tmp, id, timestamp, size; int key_frame = 0; - get_packetheader(nut, bc); if (url_feof(bc)) return -1; - + + tmp = get_byte(bc); + if (tmp != 128) + { + tmp = get_byte(bc); + if ((tmp != 2) || (get_le32(bc)+get_le16(bc))) + fprintf(stderr, "damaged startcode!=2<<8|1 (%d)\n", tmp); + } + + get_packetheader(nut, bc); + tmp = get_byte(bc); + +#if 0 tmp = get_byte(bc); if ((tmp & 0x7f) == 1) /* zero bit set? */ { @@ -497,6 +514,7 @@ } if ((tmp & 0x9f) > 3) /* priority <= 3 */ fprintf(stderr, "sanity check failed!\n"); +#endif id = get_v(bc); timestamp = get_s(bc); @@ -539,7 +557,7 @@ #elif defined(CONFIG_MP3LAME) CODEC_ID_MP3LAME, #else - CODEC_ID_MP2, + CODEC_ID_AC3, #endif CODEC_ID_MPEG4, nut_write_header,