Revision 8c653280

View differences:

libavformat/nut.c
86 86
        return (v>>1);
87 87
}
88 88

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

  
103
    return 0;
104
}
105

  
106
static int get_bi(ByteIOContext *bc)
107
{
108
   int i, len, val;
109
    
110
    len = get_v(bc);
111
    if(len > 4) return -1;
112
    
94 113
    val = 0;
95 114
    for (i = 0; i < len; i++) {
96
        if (i < 4)
97
            val |= get_byte(bc) << (i * 8);
115
        val |= get_byte(bc) << (i * 8);
98 116
    }
117

  
99 118
    return val;
100 119
}
101 120

  
......
337 356
	return 1;
338 357

  
339 358
    enc = &s->streams[stream_index]->codec;
340
    if (enc->codec_type == CODEC_TYPE_VIDEO)
341
	key_frame = enc->coded_frame->key_frame;
359
    key_frame = enc->coded_frame->key_frame;
342 360

  
343 361
    if (key_frame)
344 362
	put_be64(bc, KEYFRAME_STARTCODE);
......
397 415
    for (i = 0; i < p->buf_size; i++) {
398 416
        int c = p->buf[i];
399 417
        code = (code << 8) | c;
400
        code &= 0xFFFFFFFFFFFFFFFFULL;
401 418
        if (code == MAIN_STARTCODE)
402 419
            return AVPROBE_SCORE_MAX;
403 420
    }
......
444 461
	if (!st)
445 462
	    return AVERROR_NOMEM;
446 463
	class = get_v(bc);
464
	tmp = get_bi(bc);
447 465
	switch(class)
448 466
	{
449 467
	    case 0:
450 468
		st->codec.codec_type = CODEC_TYPE_VIDEO;
451
		tmp = get_b(bc);
452 469
		st->codec.codec_id = codec_get_bmp_id(tmp);
453 470
		if (st->codec.codec_id == CODEC_ID_NONE)
454 471
		    fprintf(stderr, "Unknown codec?!\n");
455 472
		break;
456 473
	    case 32:
457 474
		st->codec.codec_type = CODEC_TYPE_AUDIO;
458
		tmp = get_b(bc);
459 475
		st->codec.codec_id = codec_get_wav_id(tmp);
460 476
		if (st->codec.codec_id == CODEC_ID_NONE)
461 477
		    fprintf(stderr, "Unknown codec?!\n");
......
465 481
		return -1;
466 482
	}
467 483
	s->bit_rate += get_v(bc);
468
	tmp = get_v(bc); /* language code */
469
	while(tmp--)
470
	    get_byte(bc);
484
	get_b(bc, NULL, 0); /* language code */
471 485
	st->codec.frame_rate_base = get_v(bc);
472 486
	st->codec.frame_rate = get_v(bc);
473 487
	get_v(bc); /* FIXME: msb timestamp base */
......
483 497
	    get_v(bc); /* aspected w */
484 498
	    get_v(bc); /* aspected h */
485 499
	    get_v(bc); /* csp type */
486
	    get_le32(bc); /* checksum */
500
	    get_be32(bc); /* checksum */
487 501
	}
488 502
	if (class == 32) /* AUDIO */
489 503
	{
490 504
	    st->codec.sample_rate = get_v(bc) * (double)(st->codec.frame_rate_base / st->codec.frame_rate);
491 505
	    st->codec.channels = get_v(bc);
492
	    get_le32(bc); /* checksum */
506
	    get_be32(bc); /* checksum */
493 507
	}
494 508
    }    
495 509
    

Also available in: Unified diff