[vlc-devel] [PATCH 2/2] core: change var_InheritURational to output a vlc_rational_t

Rémi Denis-Courmont remi at remlab.net
Mon Apr 10 19:23:31 CEST 2017


Le maanantaina 10. huhtikuuta 2017, 18.07.52 EEST Steve Lhomme a écrit :
> On Mon, Apr 10, 2017 at 5:12 PM, Rémi Denis-Courmont <remi at remlab.net> 
wrote:
> > Le maanantaina 10. huhtikuuta 2017, 8.34.54 EEST Steve Lhomme a écrit :
> >> ---
> >> 
> >>  include/vlc_variables.h                  |  4 ++--
> >>  modules/access/decklink.cpp              |  2 +-
> >>  modules/access/imem.c                    |  4 ++--
> >>  modules/access/timecode.c                |  3 +--
> >>  modules/access/v4l2/video.c              |  9 ++++-----
> >>  modules/demux/image.c                    |  4 ++--
> >>  modules/demux/rawvid.c                   |  5 ++---
> >>  modules/stream_out/transcode/transcode.c |  2 +-
> >>  modules/video_filter/fps.c               |  2 +-
> >>  src/misc/variables.c                     | 16 ++++++++--------
> >>  src/video_output/video_output.c          |  3 +--
> >>  test/src/misc/variables.c                | 32
> >> 
> >> ++++++++++++++++---------------- 12 files changed, 41 insertions(+), 45
> >> deletions(-)
> >> 
> >> diff --git a/include/vlc_variables.h b/include/vlc_variables.h
> >> index 83752b171f..59ad99367c 100644
> >> --- a/include/vlc_variables.h
> >> +++ b/include/vlc_variables.h
> >> @@ -652,8 +652,8 @@ static inline void *var_InheritAddress( vlc_object_t
> >> *obj, const char *name ) }
> >> 
> >>  #define var_InheritAddress(o, n) var_InheritAddress(VLC_OBJECT(o), n)
> >> 
> >> -VLC_API int var_InheritURational( vlc_object_t *, unsigned *num,
> >> unsigned
> >> *den, const char *var ); -#define var_InheritURational(a,b,c,d)
> >> var_InheritURational(VLC_OBJECT(a), b, c, d) +VLC_API int
> >> var_InheritURational( vlc_object_t *, vlc_rational_t *dst, const char
> >> *var
> >> ); +#define var_InheritURational(a,b,d)
> >> var_InheritURational(VLC_OBJECT(a),
> >> b, d)
> > 
> > Why don´t you return the rational directly?
> 
> Because it does a copy every from the value in the stack to the output
> ?

Oh noes! Copying 64 bytes, the horror!

And seriously, I don´t see how that´s different from your patch: the caller 
ends up supplying the memory to the callee.

For instance, on 64-bits ARM, it´s the exact same thing, except for the 
register numbers. Your patch passes the storage area in x1, and the variable 
name in x2, while the return value would go to x0. With structure return, the 
variable name would be in x1, and the storage area in x8.

And then, some calling conventions probably return the result in registers. 
Also, this is no different from the standard div().

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list