[Ffmpeg-devel] [PATCH] Machine endian bytestream functions

ramiro at lisha.ufsc.br ramiro
Sun Mar 11 03:06:41 CET 2007


Hello,

Attached patch makes the AV_{R,W}{L,B}xx macros have a machine endian for
the simple 16 and 32 bit types. Those macros are then #ifdef'd for the
correct endianess. 24 bit remains the same, as it would be more complex.

This simple testcase:
#include "avcodec.h"
#include "bytestream.h"

extern int res1;
extern uint8_t * res2;

void read_something( uint8_t *buf )
{
    res1 = bytestream_get_le32(&buf);
    res2 = buf;
}


was giving the following machine code (which is pretty dumb):
   0:   53                      push   %ebx
   1:   8b 5c 24 08             mov    0x8(%esp),%ebx
   5:   83 c3 04                add    $0x4,%ebx
   8:   0f b6 53 ff             movzbl 0xffffffff(%ebx),%edx
   c:   0f b6 43 fe             movzbl 0xfffffffe(%ebx),%eax
  10:   0f b6 4b fd             movzbl 0xfffffffd(%ebx),%ecx
  14:   c1 e2 18                shl    $0x18,%edx
  17:   c1 e0 10                shl    $0x10,%eax
  1a:   09 c2                   or     %eax,%edx
  1c:   0f b6 43 fc             movzbl 0xfffffffc(%ebx),%eax
  20:   89 1d 00 00 00 00       mov    %ebx,0x0
  26:   c1 e1 08                shl    $0x8,%ecx
  29:   5b                      pop    %ebx
  2a:   09 c2                   or     %eax,%edx
  2c:   09 d1                   or     %edx,%ecx
  2e:   89 0d 00 00 00 00       mov    %ecx,0x0
  34:   c3                      ret

and now gives:
   0:   8b 54 24 04             mov    0x4(%esp),%edx
   4:   83 c2 04                add    $0x4,%edx
   7:   8b 42 fc                mov    0xfffffffc(%edx),%eax
   a:   89 15 00 00 00 00       mov    %edx,0x0
  10:   a3 00 00 00 00          mov    %eax,0x0
  15:   c3                      ret

Regression tests fail miserably, but consistently with unpatched version.

Ramiro Polla
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intreadwrite_me.diff
Type: application/octet-stream
Size: 3383 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070310/b14e88b9/attachment.obj>



More information about the ffmpeg-devel mailing list