delphi2007:"Invalid floating point operation" 错误的解决方法

 这两天用使用海思的库hi_h264dec_w.dll(版本v2.2.2.0.2)解码时,在直接拷贝时出现"Invalid floating point operation.”的错误;

目前根据网络资料,屏蔽FPU错误,由于功能正常,因此具体原因还没有去分析,代码如下:

function TVideoDecoder.DecodeVideoFrame(var frame: H264_frame): boolean;
var
  fOutFrame: H264_DEC_FRAME_S; //解码帧
  iy, iuv: integer; //yuv长度,u的长度
  Saved8087CW: Word;//Default 8087 control word. FPU control register is set to this value.
begin
  Saved8087CW := Get8087CW; //保存当前
  try
    Set8087CW($133F); { Disable all fpu exceptions. }
    result := DecodeVideoFrame(fOutFrame);
    if not result then exit;

    frame.FrameNo := fDecFrameCount;
    frame.Width := foutframe.uWidth;
    frame.Height := foutframe.uHeight;
    frame.FrameRate := 25; //默认
    frame.PicType := fDecAttr.uPictureFormat;
    //拷贝 I420的yuv数据
    iy := foutframe.uHeight * foutframe.uYStride;
    iuv := foutframe.uHeight * foutframe.uUVStride div 2;

    frame.datalen := iy + 2 * iuv;
    getmem(frame.data, frame.datalen + 10);
    copymemory(frame.data, foutframe.pY, iy);//不设置FPU,那么这句会报错
    copymemory(frame.data + iy, foutframe.pu, iuv);
    copymemory(frame.data + iy + iuv, foutframe.pv, iuv);
{$IFDEF __SaveH264}
    if result then
      fYuvStream.Write(frame.data[0], frame.datalen);
{$ENDIF}
  finally
    Set8087CW(Saved8087CW); //恢复
  end;
end;

 

关于FPU的设置,有几个建议:

1)It is  recommend that you disable all floating-point exceptions when using OpenGL to render 3D graphics;

2)如果在程序中使用了SceneControl.LoadSxFile载入了3D文档,那么必须在程序退出时,在Set8087CW之前调用IScene的ClearLayers方法清除图层,否则程序在退出时会出现异常。参考代码为:SceneControl1.Scene.ClearLayers;

参考文档(非常感谢以下文章):

1) http://www.langjisky.com/netdown/?type=detail&id=99

2) http://www.cnblogs.com/neugls/archive/2011/04/21/2023097.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值