zoukankan      html  css  js  c++  java
  • swf文件头和tag结构解析

    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls;
    type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        OpenDialog1: TOpenDialog;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Edit5: TEdit;
        Edit6: TEdit;
        Edit7: TEdit;
        Edit8: TEdit;
        ListView1: TListView;
        Button2: TButton;
        Edit9: TEdit;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form1: TForm1;
    implementation
    {$R *.dfm}
    type    Tbuff=record
            F:byte;
            W:byte;
            S:byte;
            version:byte;
            File_length:cardinal;
            end;
    var    buff:Tbuff;
           dt:array of byte;
    procedure TForm1.Button1Click(Sender: TObject);
    var
        Filename:string;
        Fileid:cardinal;
        Fileinfo:OFSTRUCT;
        nbits:integer;
        vbitpos:integer;
        vbyte:integer;
        nBytesRead:cardinal;
        xmin,xmax,ymin,ymax:longword;
        id,length,_from,_to:word;
        _tlist:tlistitem;
        function getbitval:longword;
        var vvsam:longword;
        begin
            vvsam:=dt[vbyte]*$1000000+dt[vbyte+1]*$10000+dt[vbyte+2]*$100+dt[vbyte+3];    //取数
            result:=longword(vvsam shl vbitpos) shr (32-nbits);                           //移位取值
            inc(vbitpos,nbits);                                                           //移位
            inc(vbyte,vbitpos div 8);                                                     //移字节 定新字节
            vbitpos:=vbitpos mod 8;                                                       //定新位
        end;
    begin
    if OpenDialog1.Execute then
        Filename:=OpenDialog1.FileName;
    Fileid:=openfile(pchar(Filename),Fileinfo,OF_READ);
    readfile(Fileid,buff,8,nBytesRead,nil);
    setlength(dt,buff.File_length);
    readfile(Fileid,dt[0],buff.File_length,nBytesRead,nil);               //已有8个字节读入buff中,不算在dt内
    setlength(dt,nBytesRead);
          edit1.Text:='F='+inttostr(buff.F);
          edit2.Text:='W='+inttostr(buff.W);
          edit3.Text:='S='+inttostr(buff.S);
          edit4.Text:='version='+inttostr(buff.version);
          edit5.Text:='File_length='+inttostr(buff.File_length);
    nbits:=byte(dt[0] shr 3);
    edit8.Text:='nbits='+inttostr(nbits);
    vbyte:=0;
    vbitpos:=5;
    xmin:=getbitval;
    xmax:=getbitval div 20;
    ymin:=getbitval;
    ymax:=getbitval div 20;
    edit9.Text:=('xmin='+inttostr(xmin)+' , '+
                  'xmax='+inttostr(xmax)+' , '+
                  'ymin='+inttostr(ymin)+' , '+
                  'ymax='+inttostr(ymax)       ) ;
    if vbitpos>0 then inc(vbyte);
    edit6.Text:='rate='+inttostr(dt[vbyte+1]);
    edit7.Text:='count='+inttostr(word((@dt[vbyte+2])^));
    //-----------------------------------------------------------------------SWF文件头
    _from:=vbyte+4;
        while (_from<=nBytesRead-1) do  begin
           _tlist:=listview1.Items.Add;            //生成对象,对象存在才能给其赋值
           id:=word((@dt[_from])^);
           length:=id and $3f;
           if length=$3f then length:=longword((@dt[_from+2])^)+4;
           inc(length,2);
           id:=id shr 6;
           _to:=_from+length;

           _tlist.Caption:=inttostr(id);
           _tlist.SubItems.Add(inttostr(length));
           _tlist.SubItems.Add(inttostr(_from));
           _tlist.SubItems.Add(inttostr(_to));
           _from:=_to;
        end;
    //----------------------------------------------------------------------Tag=length+Tag头(2或者6);
    end;
  • 相关阅读:
    【做题】51NOD1518 稳定多米诺覆盖——容斥&dp
    【做题】TCSRM592 Div1 500 LittleElephantAndPermutationDiv1——计数&dp
    【做题】TCSRM591 Div1 500 PyramidSequences——数形结合&思维
    【做题】NOWCODER142A Ternary String——数列&欧拉定理
    【做题】CF196E. Opening Portals 排除无用边&最小生成树
    【做题】HDU6331 Walking Plan——矩阵&分块
    【做题】BZOJ2534 L-gap字符串——调和级数
    【做题】BZOJ2342 双倍回文——马拉车&并查集
    overleaf 提交arXiv 不成功
    神经网络 (2)- Alexnet Training on MNIST
  • 原文地址:https://www.cnblogs.com/smallmuda/p/1438105.html
Copyright © 2011-2022 走看看