【问题标题】:RIFF AVI RLE different to GDI RLERIFF AVI RLE 与 GDI RLE 不同
【发布时间】:2015-03-10 05:27:43
【问题描述】:

我有一个 1990 年代初期制作的基本 RIFF AVI,我正准备用原生 VB/C# 代码制作一个基本的视频播放器。根据标题,它使用旧的 MS RLE 编解码器。 AVI 中的位图头表明它是 RLE8 压缩的。

  1. 这是将原始“xxdc”压缩数据写入位图的结果,该位图是从头开始实用地创建并在 Windows 照片查看器中打开的
  2. 使用 VirtualDub 提取的同一帧
  3. 下面的代码解压 RLE8 位图

问题在于下面的代码和 Windows 都做同样的事情,缺少部分导致我从旧的 VirtualDub blog post 得到以下内容;

(GDI 的 RLE 与 AVI 的 RLE 不同)”。

问题是我找不到区别 :(。我在 Internet 上找不到任何资源或 MSDN 上的任何材料。

我将一个 RLE8 解压示例从 htttp://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 编解码器的情况下做到这一点......有人有什么想法吗?

【问题讨论】:

    标签: c# vb.net bitmap avi riff


    【解决方案1】:

    我找到了解决方案,所以我会在这里回答,以便像我这样的其他人有一个起点。

    帧数据已正确解压缩。问题是我没有正确遵循 RIFF AVI 规范。对于我的视频,每一帧都比前一帧解压缩。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-29
      • 2011-01-16
      • 2011-01-16
      • 1970-01-01
      • 2011-05-17
      • 2011-12-04
      • 1970-01-01
      相关资源
      最近更新 更多