Commit 37348866 authored by michaelni's avatar michaelni

get_bi(), be/le fix


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@2254 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 821c3d35
...@@ -86,16 +86,35 @@ static int64_t get_s(ByteIOContext *bc) ...@@ -86,16 +86,35 @@ static int64_t get_s(ByteIOContext *bc)
return (v>>1); return (v>>1);
} }
static int get_b(ByteIOContext *bc) static int get_b(ByteIOContext *bc, char *data, int maxlen)
{
int i, len;
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);
}
return 0;
}
static int get_bi(ByteIOContext *bc)
{ {
int i, len, val; int i, len, val;
len = get_v(bc); len = get_v(bc);
if(len > 4) return -1;
val = 0; val = 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (i < 4)
val |= get_byte(bc) << (i * 8); val |= get_byte(bc) << (i * 8);
} }
return val; return val;
} }
...@@ -337,7 +356,6 @@ static int nut_write_packet(AVFormatContext *s, int stream_index, ...@@ -337,7 +356,6 @@ static int nut_write_packet(AVFormatContext *s, int stream_index,
return 1; return 1;
enc = &s->streams[stream_index]->codec; enc = &s->streams[stream_index]->codec;
if (enc->codec_type == CODEC_TYPE_VIDEO)
key_frame = enc->coded_frame->key_frame; key_frame = enc->coded_frame->key_frame;
if (key_frame) if (key_frame)
...@@ -397,7 +415,6 @@ static int nut_probe(AVProbeData *p) ...@@ -397,7 +415,6 @@ static int nut_probe(AVProbeData *p)
for (i = 0; i < p->buf_size; i++) { for (i = 0; i < p->buf_size; i++) {
int c = p->buf[i]; int c = p->buf[i];
code = (code << 8) | c; code = (code << 8) | c;
code &= 0xFFFFFFFFFFFFFFFFULL;
if (code == MAIN_STARTCODE) if (code == MAIN_STARTCODE)
return AVPROBE_SCORE_MAX; return AVPROBE_SCORE_MAX;
} }
...@@ -444,18 +461,17 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -444,18 +461,17 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
class = get_v(bc); class = get_v(bc);
tmp = get_bi(bc);
switch(class) switch(class)
{ {
case 0: case 0:
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec.codec_type = CODEC_TYPE_VIDEO;
tmp = get_b(bc);
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_b(bc);
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");
...@@ -465,9 +481,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -465,9 +481,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1; return -1;
} }
s->bit_rate += get_v(bc); s->bit_rate += get_v(bc);
tmp = get_v(bc); /* language code */ get_b(bc, NULL, 0); /* language code */
while(tmp--)
get_byte(bc);
st->codec.frame_rate_base = get_v(bc); st->codec.frame_rate_base = get_v(bc);
st->codec.frame_rate = get_v(bc); st->codec.frame_rate = get_v(bc);
get_v(bc); /* FIXME: msb timestamp base */ get_v(bc); /* FIXME: msb timestamp base */
...@@ -483,13 +497,13 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -483,13 +497,13 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_v(bc); /* aspected w */ get_v(bc); /* aspected w */
get_v(bc); /* aspected h */ get_v(bc); /* aspected h */
get_v(bc); /* csp type */ get_v(bc); /* csp type */
get_le32(bc); /* checksum */ get_be32(bc); /* checksum */
} }
if (class == 32) /* AUDIO */ if (class == 32) /* AUDIO */
{ {
st->codec.sample_rate = get_v(bc) * (double)(st->codec.frame_rate_base / st->codec.frame_rate); st->codec.sample_rate = get_v(bc) * (double)(st->codec.frame_rate_base / st->codec.frame_rate);
st->codec.channels = get_v(bc); st->codec.channels = get_v(bc);
get_le32(bc); /* checksum */ get_be32(bc); /* checksum */
} }
} }
......
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