[FFmpeg-devel] [PATCH 1/3] Move lpc_compute_autocorr() from DSPContext to a new struct LPCContext.

Måns Rullgård mans
Fri Jan 21 04:48:30 CET 2011

Michael Niedermayer <michaelni at gmx.at> writes:

> On Fri, Jan 21, 2011 at 02:31:06AM +0000, M?ns Rullg?rd wrote:
>> Luca Barbato <lu_zero at gentoo.org> writes:
>> > On 01/21/2011 02:03 AM, Michael Niedermayer wrote:
>> >> Dont you think that the code that contains these offsets would
>> >> benefit more from cleanup to not break when random structs change
>> >> than regularly waiting for failure and then find someone with an
>> >> ARM build env to fix?
>> >
>> > It had been discussed a bit in the past. There isn't a portable way to
>> > get those offsets automatically given the field of use (arm is mostly
>> > cross-built, more than often with exotic toolchain).
>> A different approach would be to group the handful of field into a
>> sub-struct and pass a pointer to that instead of the MpegEncContext
>> pointer.  However, given the general appearance of MpegEncContext,
>> doing this can seem a bit scary.
> simply moving the affected fields close together and passing a
> pointer to the first seems easiest,

This is also unreliable.  Consider this struct:

struct foo {
    char a;
    int  b;

Here the offset from &a to &b is 4 (assuming a typical ABI).  Now add
a member to the struct:

struct foo {
    char x;
    char a;
    int  b;

After this change the offset from &a to &b is 3.  MpegEncContext is
full of padding holes, so effects like this are likely to arise with
any modification.

I'm as keen as anyone to find a better solution, but going from one
fragile method to another is pointless.

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list