Revision a182f5da libavformat/nut.c

View differences:

libavformat/nut.c
38 38

  
39 39
#include "avformat.h"
40 40
#include "mpegaudio.h"
41
#include "avi.h"
41 42

  
42 43
//from /dev/random
43 44

  
......
85 86
        return (v>>1);
86 87
}
87 88

  
88
static int get_b(ByteIOContext *bc, char *data, int maxlen)
89
static int get_b(ByteIOContext *bc)
89 90
{
90
    int i, len;
91
    int i, len, val;
91 92
    
92 93
    len = get_v(bc);
93
    for (i = 0; i < len && i < maxlen; i++)
94
	data[i] = get_byte(bc);
95
    if (i < len)
96
    {
97
	len = i;
98
	for (i = 0; i < len; i++)
99
	    get_byte(bc);
94
    val = 0;
95
    for (i = 0; i < len; i++) {
96
        if (i < 4)
97
            val |= get_byte(bc) << (i * 8);
100 98
    }
101

  
102
    return 0;
99
    return val;
103 100
}
104 101

  
105 102
static int get_packetheader(NUTContext *nut, ByteIOContext *bc)
......
167 164
    return 0;
168 165
}
169 166

  
167
static int put_bi(ByteIOContext *bc, int val)
168
{
169
    put_v(bc, 4);
170
    put_le32(bc, val);
171
    return 0;
172
}
173

  
170 174
static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size)
171 175
{
172 176
    put_flush_packet(bc);
......
238 242
	put_v(bc, i /*s->streams[i]->index*/);
239 243
	put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0);
240 244
	if (codec->codec_tag)
241
	    put_b(bc, &codec->codec_tag, 4);
245
	    put_bi(bc, codec->codec_tag);
242 246
	else if (codec->codec_type == CODEC_TYPE_VIDEO)
243 247
	{
244 248
	    int tmp = codec_get_bmp_tag(codec->codec_id);
245
	    put_b(bc, &tmp, 4);
246
//	    put_v(bc, 4); /* len */
247
//	    put_be32(bc, codec_get_bmp_tag(codec->codec_id));
249
	    put_bi(bc, tmp);
248 250
	}
249 251
	else if (codec->codec_type == CODEC_TYPE_AUDIO)
250 252
	{
251 253
	    int tmp = codec_get_wav_tag(codec->codec_id);
252
	    put_b(bc, &tmp, 4);
253
//	    put_v(bc, 4); /* len */
254
//	    put_be32(bc, codec_get_wav_tag(codec->codec_id));
254
	    put_bi(bc, tmp);
255 255
	}
256 256
	put_v(bc, codec->bit_rate);
257 257
	put_v(bc, 0); /* no language code */
......
278 278
		put_v(bc, 0); /* csp type -- unknown */
279 279
		put_be32(bc, 0); /* FIXME: checksum */
280 280
		break;
281
            default:
282
                break;
281 283
	}
282 284
        update_packetheader(nut, bc, 0);
283 285
    }
......
328 330
    NUTContext *nut = s->priv_data;
329 331
    ByteIOContext *bc = &s->pb;
330 332
    int key_frame = 0;
331
    int flags, size2;
333
    int flags;
332 334
    AVCodecContext *enc;
333 335

  
334 336
    if (stream_index > s->nb_streams)
......
364 366

  
365 367
static int nut_write_trailer(AVFormatContext *s)
366 368
{
367
    NUTContext *nut = s->priv_data;
368 369
    ByteIOContext *bc = &s->pb;
369 370
#if 0
370 371
    int i;
......
447 448
	{
448 449
	    case 0:
449 450
		st->codec.codec_type = CODEC_TYPE_VIDEO;
450
//		get_v(bc);
451
//		tmp = get_be32(bc);
452
		get_b(bc, (char*)&tmp, 4);
451
		tmp = get_b(bc);
453 452
		st->codec.codec_id = codec_get_bmp_id(tmp);
454 453
		if (st->codec.codec_id == CODEC_ID_NONE)
455 454
		    fprintf(stderr, "Unknown codec?!\n");
456 455
		break;
457 456
	    case 32:
458 457
		st->codec.codec_type = CODEC_TYPE_AUDIO;
459
//		tmp = get_v(bc);
460
//		tmp = get_be32(bc);
461
		get_b(bc, (char*)&tmp, 4);
458
		tmp = get_b(bc);
462 459
		st->codec.codec_id = codec_get_wav_id(tmp);
463 460
		if (st->codec.codec_id == CODEC_ID_NONE)
464 461
		    fprintf(stderr, "Unknown codec?!\n");

Also available in: Unified diff