我有一个 1990 年代初期制作的基本 RIFF AVI,我很想用原生 VB/C# 代码制作一个基本的视频播放器。根据标题,它使用旧的 MS RLE 编解码器。AVI 中的位图头表明它是 RLE8 压缩的。
- 这是原始“xxdc”压缩数据写入位图的结果,该位图从头开始务实地创建并在 Windows 照片查看器中打开
- 使用 VirtualDub 提取的同一帧
- 下面的代码解压 RLE8 位图
问题是下面的代码和 Windows 都做同样的事情,缺少部分,这导致我从旧的VirtualDub 博客文章中找到以下内容;
(GDI 的 RLE 与 AVI 的 RLE 不同)”。
问题是我找不到区别:(。我在互联网上找不到任何资源或 MSDN 上的任何材料。
我将一个 RLE8 解压示例从 http://dirkbertels.net/computing/bitmap_decompression.php 移植到 VB(为简洁起见,位图结构省略)。这是一种享受。问题是它对于使用 RLE8 的 AVI 帧不能正常工作。
Dim firstByte As Byte
Dim secondByte As Byte
Dim currX As UInteger = 0
Dim currY As UInteger = 0
Dim i As UInteger
Do
firstByte = br.ReadByte
If 0 <> firstByte Then
' Encoded Mode
secondByte = br.ReadByte
For i = 0 To firstByte - 1
frame.SetPixel(currX, currY, _bitmap.biClut(secondByte))
currX += 1
Next i
Else
' Absolute Mode
firstByte = br.ReadByte ' store next byte
Select Case firstByte
Case 0 ' new line
currX = 0
currY += 1 ' move cursor to beginning of next line
Case 1 ' end of bitmap
Exit Do
Case 2 ' delta = goto X and Y
currX += CInt(br.ReadByte) ' read byte and add value to x value
currY += CInt(br.ReadByte) ' read byte and add value to y value
Case Else
For i = 0 To firstByte - 1
secondByte = br.ReadByte
frame.SetPixel(currX, currY, _bitmap.biClut(secondByte))
currX += 1
Next i
'If 0 <> (firstByte And &H1) Then
' br.ReadByte()
'End If
If firstByte And &H1 Then ' if the run doesn't end on a word boundary,
br.ReadByte()
End If
End Select
End If
Loop
我现在不知道 VirtualDub、FFMPEG 和其他人如何在不使用旧的 MSRLE.DLL 编解码器的情况下做到这一点......有人有什么想法吗?