encoding.patch

Johannes Gajdosik , 08/06/2010 08:09 am

Download (2.8 kB)

 
b/solo6010-v4l2-enc.c
53 53
	0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x20,
54 54
	0x02, 0x48, 0x05, 0xc0, 0x00, 0x40, 0x00, 0x40,
55 55
	0x00, 0x40, 0x00, 0x80, 0x00, 0x97, 0x53, 0x04,
56
	0x1f, 0x4c, 0x58, 0x10, 0x78, 0x51, 0x18, 0x3e,
56
	0x1f, 0x4c, 0x58, 0x10, 0x78, 0x51, 0x18,
57
		// fix: 0x3f means next_start_code(),
58
		// 0x3e is wrong because one marker bit is missing
59
	0x3f,
57 60
};
58 61

  
59 62
/*
......
403 406
	if (ret)
404 407
		return -1;
405 408

  
409
if (vh.size != vh.end_nops[4]) {
410
    // header inconsistency
411
  return -1;
412
}
413
if (enc_buf->size <= vh.size+sizeof(vh)) {
414
    // size inconsistency
415
  return -1;
416
}
417
if (enc_buf->size > vh.size+sizeof(vh)+32) {
418
    // size inconsistency
419
  return -1;
420
}
421

  
406 422
	if (WARN_ON_ONCE(vh.size > enc_buf->size))
407 423
		return -1;
408 424

  
......
412 428

  
413 429
	/* If this is a key frame, add extra m4v header */
414 430
	if (!enc_buf->vop) {
415
		u16 fps = solo_dev->fps * 1000;
416
		u16 interval = solo_enc->interval * 1000;
431
		const u16 factor = 30000 / solo_dev->fps;
432
		const u16 fps = 30000;
433
		const u16 interval = solo_enc->interval * factor;
417 434
		u8 *p = videobuf_queue_to_vmalloc(&fh->vidq, vb);
418 435

  
419 436
		memcpy(p, vid_vop_header, sizeof(vid_vop_header));
......
424 441
			p[10] |= ((XVID_PAR_43_PAL << 3) & 0x78);
425 442

  
426 443
		/* Frame rate and interval */
444
		p[21] = (p[21] & 0xf0) | (fps >> 12);
427 445
		p[22] = fps >> 4;
428 446
		p[23] = ((fps << 4) & 0xf0) | 0x0c | ((interval >> 13) & 0x3);
429 447
		p[24] = (interval >> 5) & 0xff;
......
642 660
		/* XXX I think this means we had a ring overflow? */
643 661
		if (mpeg_current > mpeg_next && mpeg_size != reg_mpeg_size) {
644 662
			enc_reset_gop(solo_dev, ch);
663
                  // this actally happens. But dont log here, because this is
664
                  // much too slow and causes system instability.
645 665
			continue;
646 666
		}
647 667

  
......
854 874
	if (solo_dev->video_type == SOLO_VO_FMT_TYPE_NTSC)
855 875
		input->std = V4L2_STD_NTSC_M;
856 876
	else
857
		input->std = V4L2_STD_PAL_M;
877
		input->std = V4L2_STD_PAL_B;
858 878

  
859 879
	if (!tw28_get_video_status(solo_dev, solo_enc->ch))
860 880
		input->status = V4L2_IN_ST_NO_SIGNAL;
......
1485 1505
	.minor			= -1,
1486 1506
	.release		= video_device_release,
1487 1507

  
1488
	.tvnorms		= V4L2_STD_NTSC_M | V4L2_STD_PAL_M,
1508
	.tvnorms		= V4L2_STD_NTSC_M | V4L2_STD_PAL_B,
1489 1509
	.current_norm		= V4L2_STD_NTSC_M,
1490 1510
};
1491 1511