[Ffmpeg-devel] [patch] gcc4 visibility support

Michael Niedermayer michaelni
Fri Jun 2 19:39:36 CEST 2006


Hi

On Fri, Jun 02, 2006 at 06:18:59PM +0200, Luca Barbato wrote:
> Diego Petten? started adding support for gcc visibility on every
> application he could touch, including ffmpeg.
> 
> Looks ok and helped already to find application playing with private
> symbols. (should also trim a bit the binary size)

is putting EXPORT at the end a good idea readablity wise? IMHO putting 
it before the identifer looks nicer, dunno about portability


[...]

> -extern int motion_estimation_method;
> +extern int motion_estimation_method EXPORTED;

this variable doesnt exist anymore according to grep


[...]

> -int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
> +int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height) EXPORTED;
>  
>  /* Free a picture previously allocated by avpicture_alloc. */
> -void avpicture_free(AVPicture *picture);
> +void avpicture_free(AVPicture *picture) EXPORTED;
>  
>  int avpicture_fill(AVPicture *picture, uint8_t *ptr,
> -                   int pix_fmt, int width, int height);
> +                   int pix_fmt, int width, int height) EXPORTED;
>  int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
> -                     unsigned char *dest, int dest_size);
> -int avpicture_get_size(int pix_fmt, int width, int height);
> -void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
> -const char *avcodec_get_pix_fmt_name(int pix_fmt);
> -void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
> -enum PixelFormat avcodec_get_pix_fmt(const char* name);
> -unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
> +                     unsigned char *dest, int dest_size) EXPORTED;
> +int avpicture_get_size(int pix_fmt, int width, int height) EXPORTED;
> +void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift) EXPORTED;
> +const char *avcodec_get_pix_fmt_name(int pix_fmt) EXPORTED;
> +void avcodec_set_dimensions(AVCodecContext *s, int width, int height) EXPORTED;
> +enum PixelFormat avcodec_get_pix_fmt(const char* name) EXPORTED;
> +unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p) EXPORTED;
>  
>  #define FF_LOSS_RESOLUTION  0x0001 /* loss due to resolution change */
>  #define FF_LOSS_DEPTH       0x0002 /* loss due to color depth change */
> @@ -2343,98 +2342,98 @@ unsigned int avcodec_pix_fmt_to_codec_ta
>  #define FF_LOSS_CHROMA      0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
>  
>  int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
> -                             int has_alpha);
> +                             int has_alpha) EXPORTED;
>  int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
> -                              int has_alpha, int *loss_ptr);
> +                              int has_alpha, int *loss_ptr) EXPORTED;
>  
>  #define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
>  #define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
>  int img_get_alpha_info(const AVPicture *src,
> -                       int pix_fmt, int width, int height);
> +                       int pix_fmt, int width, int height) EXPORTED;

i am not sure if all of these should be EXPORTED


[...]
>  /* add by bero : in adx.c */
> -int is_adx(const unsigned char *buf,size_t bufsize);
> +int is_adx(const unsigned char *buf,size_t bufsize) EXPORTED;

this should not even be in avcodec.h


[...]
> +#ifndef EXPORTED
> +# if __GNUC__ >= 4
> +#  define EXPORTED __attribute__((visibility("default")))

if i understand things correctly this should be protected instead of default


[...]
> -void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den);
> -void av_frac_add(AVFrac *f, int64_t incr);
> -void av_frac_set(AVFrac *f, int64_t val);
> +void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den) EXPORTED;
> +void av_frac_add(AVFrac *f, int64_t incr) EXPORTED;
> +void av_frac_set(AVFrac *f, int64_t val) EXPORTED;

IMHO this doesnt need EXPORTED


> -extern AVImageFormat pnm_image_format;
> -extern AVImageFormat pbm_image_format;
> -extern AVImageFormat pgm_image_format;
> -extern AVImageFormat ppm_image_format;
> -extern AVImageFormat pam_image_format;
> -extern AVImageFormat pgmyuv_image_format;
> -extern AVImageFormat yuv_image_format;
> +extern AVImageFormat pnm_image_format EXPORTED;
> +extern AVImageFormat pbm_image_format EXPORTED;
> +extern AVImageFormat pgm_image_format EXPORTED;
> +extern AVImageFormat ppm_image_format EXPORTED;
> +extern AVImageFormat pam_image_format EXPORTED;
> +extern AVImageFormat pgmyuv_image_format EXPORTED;
> +extern AVImageFormat yuv_image_format EXPORTED;
>  #ifdef CONFIG_ZLIB
> -extern AVImageFormat png_image_format;
> +extern AVImageFormat png_image_format EXPORTED;
>  #endif
> -extern AVImageFormat jpeg_image_format;
> -extern AVImageFormat gif_image_format;
> -extern AVImageFormat sgi_image_format;
> +extern AVImageFormat jpeg_image_format EXPORTED;
> +extern AVImageFormat gif_image_format EXPORTED;
> +extern AVImageFormat sgi_image_format EXPORTED;

half of these dont exist anymore ...


>  
>  /* XXX: use automatic init with either ELF sections or C file parser */
>  /* modules */
>  
>  /* mpeg.c */
>  extern AVInputFormat mpegps_demux;
> -int mpegps_init(void);
> +int mpegps_init(void) EXPORTED;
>  
>  /* mpegts.c */
>  extern AVInputFormat mpegts_demux;
> -int mpegts_init(void);
> +int mpegts_init(void) EXPORTED;
>  
>  /* rm.c */
> -int rm_init(void);
> +int rm_init(void) EXPORTED;
>  
>  /* crc.c */
> -int crc_init(void);
> +int crc_init(void) EXPORTED;
>  
>  /* img.c */
> -int img_init(void);
> +int img_init(void) EXPORTED;
>  
>  /* img2.c */
> -int img2_init(void);
> +int img2_init(void) EXPORTED;
>  
>  /* asf.c */
> -int asf_init(void);
> +int asf_init(void) EXPORTED;
>  
>  /* avienc.c */
> -int avienc_init(void);
> +int avienc_init(void) EXPORTED;
>  
>  /* avidec.c */
> -int avidec_init(void);
> +int avidec_init(void) EXPORTED;
>  
>  /* swf.c */
> -int swf_init(void);
> +int swf_init(void) EXPORTED;
>  
>  /* mov.c */
> -int mov_init(void);
> +int mov_init(void) EXPORTED;
>  
>  /* movenc.c */
> -int movenc_init(void);
> +int movenc_init(void) EXPORTED;
>  
>  /* flvenc.c */
> -int flvenc_init(void);
> +int flvenc_init(void) EXPORTED;
>  
>  /* flvdec.c */
> -int flvdec_init(void);
> +int flvdec_init(void) EXPORTED;
>  
>  /* jpeg.c */
> -int jpeg_init(void);
> +int jpeg_init(void) EXPORTED;
>  
>  /* gif.c */
> -int gif_init(void);
> +int gif_init(void) EXPORTED;
>  
>  /* au.c */
> -int au_init(void);
> +int au_init(void) EXPORTED;
>  
>  /* amr.c */
> -int amr_init(void);
> +int amr_init(void) EXPORTED;
>  
>  /* wav.c */
> -int ff_wav_init(void);
> +int ff_wav_init(void) EXPORTED;
>  
>  /* mmf.c */
> -int ff_mmf_init(void);
> +int ff_mmf_init(void) EXPORTED;
>  
>  /* raw.c */
>  int pcm_read_seek(AVFormatContext *s,
>                    int stream_index, int64_t timestamp, int flags);
> -int raw_init(void);
> +int raw_init(void) EXPORTED;
>  
>  /* mp3.c */
> -int mp3_init(void);
> +int mp3_init(void) EXPORTED;
>  
>  /* yuv4mpeg.c */
> -int yuv4mpeg_init(void);
> +int yuv4mpeg_init(void) EXPORTED;
>  
>  /* ogg2.c */
> -int ogg_init(void);
> +int ogg_init(void) EXPORTED;
>  
>  /* ogg.c */
> -int libogg_init(void);
> +int libogg_init(void) EXPORTED;
>  
>  /* dv.c */
> -int ff_dv_init(void);
> +int ff_dv_init(void) EXPORTED;
>  
>  /* ffm.c */
> -int ffm_init(void);
> +int ffm_init(void) EXPORTED;
>  
>  /* rtsp.c */
> -extern AVInputFormat redir_demux;
> -int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f);
> +extern AVInputFormat redir_demux EXPORTED;
> +int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f) EXPORTED;
>  
>  /* 4xm.c */
> -int fourxm_init(void);
> +int fourxm_init(void) EXPORTED;
>  
>  /* psxstr.c */
> -int str_init(void);
> +int str_init(void) EXPORTED;
>  
>  /* idroq.c */
> -int roq_init(void);
> +int roq_init(void) EXPORTED;
>  
>  /* ipmovie.c */
> -int ipmovie_init(void);
> +int ipmovie_init(void) EXPORTED;
>  
>  /* nut.c */
> -int nut_init(void);
> +int nut_init(void) EXPORTED;
>  
>  /* wc3movie.c */
> -int wc3_init(void);
> +int wc3_init(void) EXPORTED;
>  
>  /* westwood.c */
> -int westwood_init(void);
> +int westwood_init(void) EXPORTED;
>  
>  /* segafilm.c */
> -int film_init(void);
> +int film_init(void) EXPORTED;
>  
>  /* idcin.c */
> -int idcin_init(void);
> +int idcin_init(void) EXPORTED;
>  
>  /* flic.c */
> -int flic_init(void);
> +int flic_init(void) EXPORTED;
>  
>  /* sierravmd.c */
> -int vmd_init(void);
> +int vmd_init(void) EXPORTED;
>  
>  /* matroska.c */
> -int matroska_init(void);
> +int matroska_init(void) EXPORTED;
>  
>  /* sol.c */
> -int sol_init(void);
> +int sol_init(void) EXPORTED;
>  
>  /* electronicarts.c */
> -int ea_init(void);
> +int ea_init(void) EXPORTED;
>  
>  /* nsvdec.c */
> -int nsvdec_init(void);
> +int nsvdec_init(void) EXPORTED;
>  
>  /* daud.c */
> -int daud_init(void);
> +int daud_init(void) EXPORTED;
>  
>  /* nuv.c */
> -int nuv_init(void);
> +int nuv_init(void) EXPORTED;
>  
>  /* aiff.c */
> -int ff_aiff_init(void);
> +int ff_aiff_init(void) EXPORTED;
>  
>  /* voc.c */
> -int voc_init(void);
> +int voc_init(void) EXPORTED;
>  
>  /* tta.c */
> -int tta_init(void);
> +int tta_init(void) EXPORTED;
>  
>  /* adts.c */
> -int ff_adts_init(void);
> +int ff_adts_init(void) EXPORTED;
>  
>  /* mm.c */
> -int mm_init(void);
> +int mm_init(void) EXPORTED;
>  
>  /* avs.c */
> -int avs_init(void);
> +int avs_init(void) EXPORTED;
>  
>  /* smacker.c */
> -int smacker_init(void);
> +int smacker_init(void) EXPORTED;

these should not be EXPORTED


[...]
>  void av_set_pts_info(AVStream *s, int pts_wrap_bits,
> -                     int pts_num, int pts_den);
> +                     int pts_num, int pts_den) EXPORTED;

this should not be EXPORTED

many more unneeded EXPORTED symbols skiped (too much work to review)


[...]
> Index: ffmpeg-0.4.9-p20060530/configure
> ===================================================================
> --- ffmpeg-0.4.9-p20060530.orig/configure
> +++ ffmpeg-0.4.9-p20060530/configure
> @@ -417,6 +417,7 @@ os2="yes"
>  ;;
>  *) ;;
>  esac
> +CFLAGS="$CFLAGS -I\$(BUILD_ROOT)/libavcodec -I\$(BUILD_ROOT)/libavformat -I\$(BUILD_ROOT)/libavutil"

random unrelated change?

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list