diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2003-09-08 20:00:13 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2003-09-08 20:00:13 +0000 |
commit | a182f5da9366d5094c054858f5bd7804cbaa2cf3 (patch) | |
tree | f473b177916394c791c4854bec91503e2043b5ec /libavformat/nut.c | |
parent | 56c4a1846442f832055afeb43a4e873878f5b596 (diff) | |
download | ffmpeg-a182f5da9366d5094c054858f5bd7804cbaa2cf3.tar.gz |
fixed endianness dependancies (untested)
Originally committed as revision 2224 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/nut.c')
-rw-r--r-- | libavformat/nut.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/libavformat/nut.c b/libavformat/nut.c index 2eec692d29..92f478ee24 100644 --- a/libavformat/nut.c +++ b/libavformat/nut.c @@ -38,6 +38,7 @@ #include "avformat.h" #include "mpegaudio.h" +#include "avi.h" //from /dev/random @@ -85,21 +86,17 @@ static int64_t get_s(ByteIOContext *bc) return (v>>1); } -static int get_b(ByteIOContext *bc, char *data, int maxlen) +static int get_b(ByteIOContext *bc) { - int i, len; + int i, len, val; 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); + val = 0; + for (i = 0; i < len; i++) { + if (i < 4) + val |= get_byte(bc) << (i * 8); } - - return 0; + return val; } static int get_packetheader(NUTContext *nut, ByteIOContext *bc) @@ -167,6 +164,13 @@ static int put_b(ByteIOContext *bc, char *data, int len) return 0; } +static int put_bi(ByteIOContext *bc, int val) +{ + put_v(bc, 4); + put_le32(bc, val); + return 0; +} + static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size) { put_flush_packet(bc); @@ -238,20 +242,16 @@ static int nut_write_header(AVFormatContext *s) put_v(bc, i /*s->streams[i]->index*/); put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0); if (codec->codec_tag) - put_b(bc, &codec->codec_tag, 4); + put_bi(bc, codec->codec_tag); else if (codec->codec_type == CODEC_TYPE_VIDEO) { int tmp = codec_get_bmp_tag(codec->codec_id); - put_b(bc, &tmp, 4); -// put_v(bc, 4); /* len */ -// put_be32(bc, codec_get_bmp_tag(codec->codec_id)); + put_bi(bc, tmp); } else if (codec->codec_type == CODEC_TYPE_AUDIO) { int tmp = codec_get_wav_tag(codec->codec_id); - put_b(bc, &tmp, 4); -// put_v(bc, 4); /* len */ -// put_be32(bc, codec_get_wav_tag(codec->codec_id)); + put_bi(bc, tmp); } put_v(bc, codec->bit_rate); put_v(bc, 0); /* no language code */ @@ -278,6 +278,8 @@ static int nut_write_header(AVFormatContext *s) put_v(bc, 0); /* csp type -- unknown */ put_be32(bc, 0); /* FIXME: checksum */ break; + default: + break; } update_packetheader(nut, bc, 0); } @@ -328,7 +330,7 @@ static int nut_write_packet(AVFormatContext *s, int stream_index, NUTContext *nut = s->priv_data; ByteIOContext *bc = &s->pb; int key_frame = 0; - int flags, size2; + int flags; AVCodecContext *enc; if (stream_index > s->nb_streams) @@ -364,7 +366,6 @@ static int nut_write_packet(AVFormatContext *s, int stream_index, static int nut_write_trailer(AVFormatContext *s) { - NUTContext *nut = s->priv_data; ByteIOContext *bc = &s->pb; #if 0 int i; @@ -447,18 +448,14 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) { case 0: st->codec.codec_type = CODEC_TYPE_VIDEO; -// get_v(bc); -// tmp = get_be32(bc); - get_b(bc, (char*)&tmp, 4); + tmp = get_b(bc); st->codec.codec_id = codec_get_bmp_id(tmp); if (st->codec.codec_id == CODEC_ID_NONE) fprintf(stderr, "Unknown codec?!\n"); break; case 32: st->codec.codec_type = CODEC_TYPE_AUDIO; -// tmp = get_v(bc); -// tmp = get_be32(bc); - get_b(bc, (char*)&tmp, 4); + tmp = get_b(bc); st->codec.codec_id = codec_get_wav_id(tmp); if (st->codec.codec_id == CODEC_ID_NONE) fprintf(stderr, "Unknown codec?!\n"); |