Commit a182f5da authored by Fabrice Bellard's avatar Fabrice Bellard

fixed endianness dependancies (untested)

Originally committed as revision 2224 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 56c4a184
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "avformat.h" #include "avformat.h"
#include "mpegaudio.h" #include "mpegaudio.h"
#include "avi.h"
//from /dev/random //from /dev/random
...@@ -85,21 +86,17 @@ static int64_t get_s(ByteIOContext *bc) ...@@ -85,21 +86,17 @@ static int64_t get_s(ByteIOContext *bc)
return (v>>1); 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); len = get_v(bc);
for (i = 0; i < len && i < maxlen; i++) val = 0;
data[i] = get_byte(bc); for (i = 0; i < len; i++) {
if (i < len) if (i < 4)
{ val |= get_byte(bc) << (i * 8);
len = i;
for (i = 0; i < len; i++)
get_byte(bc);
} }
return val;
return 0;
} }
static int get_packetheader(NUTContext *nut, ByteIOContext *bc) static int get_packetheader(NUTContext *nut, ByteIOContext *bc)
...@@ -167,6 +164,13 @@ static int put_b(ByteIOContext *bc, char *data, int len) ...@@ -167,6 +164,13 @@ static int put_b(ByteIOContext *bc, char *data, int len)
return 0; 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) static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size)
{ {
put_flush_packet(bc); put_flush_packet(bc);
...@@ -238,20 +242,16 @@ static int nut_write_header(AVFormatContext *s) ...@@ -238,20 +242,16 @@ static int nut_write_header(AVFormatContext *s)
put_v(bc, i /*s->streams[i]->index*/); put_v(bc, i /*s->streams[i]->index*/);
put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0); put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0);
if (codec->codec_tag) 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) else if (codec->codec_type == CODEC_TYPE_VIDEO)
{ {
int tmp = codec_get_bmp_tag(codec->codec_id); int tmp = codec_get_bmp_tag(codec->codec_id);
put_b(bc, &tmp, 4); put_bi(bc, tmp);
// put_v(bc, 4); /* len */
// put_be32(bc, codec_get_bmp_tag(codec->codec_id));
} }
else if (codec->codec_type == CODEC_TYPE_AUDIO) else if (codec->codec_type == CODEC_TYPE_AUDIO)
{ {
int tmp = codec_get_wav_tag(codec->codec_id); int tmp = codec_get_wav_tag(codec->codec_id);
put_b(bc, &tmp, 4); put_bi(bc, tmp);
// put_v(bc, 4); /* len */
// put_be32(bc, codec_get_wav_tag(codec->codec_id));
} }
put_v(bc, codec->bit_rate); put_v(bc, codec->bit_rate);
put_v(bc, 0); /* no language code */ put_v(bc, 0); /* no language code */
...@@ -278,6 +278,8 @@ static int nut_write_header(AVFormatContext *s) ...@@ -278,6 +278,8 @@ static int nut_write_header(AVFormatContext *s)
put_v(bc, 0); /* csp type -- unknown */ put_v(bc, 0); /* csp type -- unknown */
put_be32(bc, 0); /* FIXME: checksum */ put_be32(bc, 0); /* FIXME: checksum */
break; break;
default:
break;
} }
update_packetheader(nut, bc, 0); update_packetheader(nut, bc, 0);
} }
...@@ -328,7 +330,7 @@ static int nut_write_packet(AVFormatContext *s, int stream_index, ...@@ -328,7 +330,7 @@ static int nut_write_packet(AVFormatContext *s, int stream_index,
NUTContext *nut = s->priv_data; NUTContext *nut = s->priv_data;
ByteIOContext *bc = &s->pb; ByteIOContext *bc = &s->pb;
int key_frame = 0; int key_frame = 0;
int flags, size2; int flags;
AVCodecContext *enc; AVCodecContext *enc;
if (stream_index > s->nb_streams) if (stream_index > s->nb_streams)
...@@ -364,7 +366,6 @@ static int nut_write_packet(AVFormatContext *s, int stream_index, ...@@ -364,7 +366,6 @@ static int nut_write_packet(AVFormatContext *s, int stream_index,
static int nut_write_trailer(AVFormatContext *s) static int nut_write_trailer(AVFormatContext *s)
{ {
NUTContext *nut = s->priv_data;
ByteIOContext *bc = &s->pb; ByteIOContext *bc = &s->pb;
#if 0 #if 0
int i; int i;
...@@ -447,18 +448,14 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -447,18 +448,14 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
{ {
case 0: case 0:
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec.codec_type = CODEC_TYPE_VIDEO;
// get_v(bc); tmp = get_b(bc);
// tmp = get_be32(bc);
get_b(bc, (char*)&tmp, 4);
st->codec.codec_id = codec_get_bmp_id(tmp); st->codec.codec_id = codec_get_bmp_id(tmp);
if (st->codec.codec_id == CODEC_ID_NONE) if (st->codec.codec_id == CODEC_ID_NONE)
fprintf(stderr, "Unknown codec?!\n"); fprintf(stderr, "Unknown codec?!\n");
break; break;
case 32: case 32:
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec.codec_type = CODEC_TYPE_AUDIO;
// tmp = get_v(bc); tmp = get_b(bc);
// tmp = get_be32(bc);
get_b(bc, (char*)&tmp, 4);
st->codec.codec_id = codec_get_wav_id(tmp); st->codec.codec_id = codec_get_wav_id(tmp);
if (st->codec.codec_id == CODEC_ID_NONE) if (st->codec.codec_id == CODEC_ID_NONE)
fprintf(stderr, "Unknown codec?!\n"); fprintf(stderr, "Unknown codec?!\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment