Recherche avancée

Médias (0)

Mot : - Tags -/performance

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (93)

  • Déploiements possibles

    31 janvier 2010, par

    Deux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
    L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
    Version mono serveur
    La version mono serveur consiste à n’utiliser qu’une (...)

  • Qualité du média après traitement

    21 juin 2013, par

    Le bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
    Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (6761)

  • error : undefined reference to 'av_free_packet(AVPacket*)' when use NDK to compile ffmpeg

    23 juin 2015, par wolfz

    I compiled my cpps to use ffmpeg liberary with ANDROID NDK by my android MK as follow :

       LOCAL_PATH := $(call my-dir)
       DEFINES += -DTARGET_POSIX \
                  -DTARGET_LINUX \
              -D_LINUX \
              -DTARGET_ANDROID \
              -D__STDC_CONSTANT_MACROS

       include $(CLEAR_VARS)  
       LOCAL_MODULE := libavcodec
       LOCAL_SRC_FILES := lib/lib/libavcodec.so
       include $(PREBUILT_SHARED_LIBRARY)  

       include $(CLEAR_VARS)  
       LOCAL_MODULE := libavfilter  
       LOCAL_SRC_FILES := lib/lib/libavfilter.so
       include $(PREBUILT_SHARED_LIBRARY)  

       include $(CLEAR_VARS)  
       LOCAL_MODULE := libavformat  
       LOCAL_SRC_FILES := lib/lib/libavformat.so  
       include $(PREBUILT_SHARED_LIBRARY)  

       include $(CLEAR_VARS)  
       LOCAL_MODULE := libavutil  
       LOCAL_SRC_FILES := lib/lib/libavutil.so  
       include $(PREBUILT_SHARED_LIBRARY)  

       include $(CLEAR_VARS)  
       LOCAL_MODULE := libpostproc  
       LOCAL_SRC_FILES := lib/lib/libpostproc.so  
       include $(PREBUILT_SHARED_LIBRARY)  

       include $(CLEAR_VARS)  
       LOCAL_MODULE := libswresample  
       LOCAL_SRC_FILES := lib/lib/libswresample.so  
       include $(PREBUILT_SHARED_LIBRARY)  

       include $(CLEAR_VARS)  
       LOCAL_MODULE := libswscale  
       LOCAL_SRC_FILES := lib/lib/libswscale.so
       include $(PREBUILT_SHARED_LIBRARY)  

       include $(CLEAR_VARS)
       LOCAL_MODULE:= player
       base := $(LOCAL_PATH)
       LOCAL_SRC_FILES += cores/PlayDemux.cpp \
                      cores/PlayDemuxFFmpeg.cpp \
                      cores/PlayFactoryDemuxer.cpp

       LOCAL_C_INCLUDES += $(LOCAL_PATH) \
               $(LOCAL_PATH)/lib \
               $(LOCAL_PATH)/lib/include \
               $(LOCAL_PATH)/cores/player \
       LOCAL_CPPFLAGS += -Wall -fexceptions $(DEFINES)
       include $(BUILD_STATIC_LIBRARY)

       include $(CLEAR_VARS)
       LOCAL_MODULE:= testmain

       LOCAL_SRC_FILES := \
           testmain.cpp \

       LOCAL_C_INCLUDES += $(LOCAL_PATH) \
                   $(LOCAL_PATH)/lib
       LOCAL_CPPFLAGS += -Wall -fexceptions $(DEFINES)

       LOCAL_SHARED_LIBRARIES := libavcodec \
                   libavformat \
                   libavfilter \
                   libavutil \
                   libpostproc \
                   libswscale \
                   libswresample

       LOCAL_STATIC_LIBRARIES := player

       include $(BUILD_EXECUTABLE)

    but when i do "ndk-build v=1", After compiling, I got :

       Install        : libavcodec.so => libs/armeabi-v7a/libavcodec.so
       install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavcodec.so /cygdrive/d/player/libs/armeabi-v7a/libavcodec.so
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded D:/player/libs/armeabi-v7a/libavcodec.so
       Install        : libavfilter.so => libs/armeabi-v7a/libavfilter.so
       install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavfilter.so /cygdrive/d/player/libs/armeabi-v7a/libavfilter.so
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded D:/player/libs/armeabi-v7a/libavfilter.so
       Install        : libavformat.so => libs/armeabi-v7a/libavformat.so
       install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavformat.so /cygdrive/d/player/libs/armeabi-v7a/libavformat.so
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded D:/player/libs/armeabi-v7a/libavformat.so
       Install        : libavutil.so => libs/armeabi-v7a/libavutil.so
       install -p /cygdrive/d/player/obj/local/armeabi-v7a/libavutil.so /cygdrive/d/player/libs/armeabi-v7a/libavutil.so
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded D:/player/libs/armeabi-v7a/libavutil.so
       Install        : libpostproc.so => libs/armeabi-v7a/libpostproc.so
       install -p /cygdrive/d/player/obj/local/armeabi-v7a/libpostproc.so /cygdrive/d/player/libs/armeabi-v7a/libpostproc.so
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded D:/player/libs/armeabi-v7a/libpostproc.so
       Install        : libswresample.so => libs/armeabi-v7a/libswresample.so
       install -p /cygdrive/d/player/obj/local/armeabi-v7a/libswresample.so /cygdrive/d/player/libs/armeabi-v7a/libswresample.so
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded D:/player/libs/armeabi-v7a/libswresample.so
       Install        : libswscale.so => libs/armeabi-v7a/libswscale.so
       install -p /cygdrive/d/player/obj/local/armeabi-v7a/libswscale.so /cygdrive/d/player/libs/armeabi-v7a/libswscale.so
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded D:/player/libs/armeabi-v7a/libswscale.so
       Executable     : testmain
       /cygdrive/d/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-g++  -Wl,--gc-sections  -Wl,-z,nocopyreloc  --sysroot=D:/android/android-ndk-r8e/platforms/android-14/arch-arm  D:/player/obj/local/armeabi-v7a/objs/testmain/testmain.o D:/player/obj/local/armeabi-v7a/libplayer.a D:/android/android-ndk-r8e/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a -lgcc D:/player/obj/local/armeabi-v7a/libavcodec.so D:/player/obj/local/armeabi-v7a/libavformat.so D:/player/obj/local/armeabi-v7a/libavfilter.so D:/player/obj/local/armeabi-v7a/libavutil.so D:/player/obj/local/armeabi-v7a/libpostproc.so D:/player/obj/local/armeabi-v7a/libswscale.so D:/player/obj/local/armeabi-v7a/libswresample.so  -no-canonical-prefixes -march=armv7-a  -Wl,--fix-cortex-a8  -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now    -lc -lm  -o D:/player/obj/local/armeabi-v7a/testmain
       D:/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: D:/player/obj/local/armeabi-v7a/libplayer.a(PlayDemuxFFmpeg.o): in function PlayDemuxFFmpeg::Flush():D:/player/jni/lib/DllAvCodec.h:144: error: undefined reference to 'av_free_packet(AVPacket*)'

    I´m using windows 7 + cygwin + NDKR8,but the lib "libavcodec.so ,libavfilter.so,libavformat.so,libavutil.so,libpostproc.so,libswresample.so,libswscale.so " of ffmpeg was compiled with standalone mothed of NDK using "ubuntu + NDK8".
    and i include the extern "c" code in the head file.

    so, how to correct the error ?

    my DLLavcodec.h is :

    #pragma once
    #include "DllAvUtil.h"

    extern "C" {
     #include <libavcodec></libavcodec>avcodec.h>
    }


    class DllAvCodec : public DllAvCodecInterface
    {
    public:
     static CCriticalSection m_critSection;

     virtual ~DllAvCodec() {}
     virtual void avcodec_register_all()
     {
       ::avcodec_register_all();
     }
     virtual void avcodec_flush_buffers(AVCodecContext *avctx) { ::avcodec_flush_buffers(avctx); }
     virtual int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
     {
       return ::avcodec_open2(avctx, codec, options);
     }
     virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) { *(volatile int *)0x0 = 0; return 0; }
     virtual int avcodec_close_dont_call(AVCodecContext *avctx) { *(volatile int *)0x0 = 0; return 0; }
     virtual AVCodec *avcodec_find_decoder(enum CodecID id) { return ::avcodec_find_decoder(id); }
     virtual AVCodec *avcodec_find_encoder(enum CodecID id) { return ::avcodec_find_encoder(id); }
     virtual int avcodec_close(AVCodecContext *avctx)
     {
       return ::avcodec_close(avctx);
     }
     virtual AVFrame *avcodec_alloc_frame() { return ::avcodec_alloc_frame(); }
     virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height) { return ::avpicture_fill(picture, ptr, pix_fmt, width, height); }
     virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video2(avctx, picture, got_picture_ptr, avpkt); }
     virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio4(avctx, frame, got_frame_ptr, avpkt); }
     virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, avpkt); }
     virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples) { return ::avcodec_encode_audio(avctx, buf, buf_size, samples); }
     virtual int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { return ::avcodec_encode_audio2(avctx, avpkt, frame, got_packet_ptr); }
     virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height) { return ::avpicture_get_size(pix_fmt, width, height); }
     virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec) { return ::avcodec_alloc_context3(codec); }
     virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { ::avcodec_string(buf, buf_size, enc, encode); }
     virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec) { ::avcodec_get_context_defaults3(s, codec); }

     virtual AVCodecParserContext *av_parser_init(int codec_id) { return ::av_parser_init(codec_id); }
     virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size,
                       const uint8_t *buf, int buf_size,
                       int64_t pts, int64_t dts, int64_t pos)
     {
       return ::av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, pos);
     }
     virtual void av_parser_close(AVCodecParserContext *s) { ::av_parser_close(s); }

     virtual AVBitStreamFilterContext *av_bitstream_filter_init(const char *name) { return ::av_bitstream_filter_init(name); }
     virtual int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
       AVCodecContext *avctx, const char *args,
       uint8_t **poutbuf, int *poutbuf_size,
       const uint8_t *buf, int buf_size, int keyframe) { return ::av_bitstream_filter_filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe); }
     virtual void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc) { ::av_bitstream_filter_close(bsfc); }

     virtual void avpicture_free(AVPicture *picture) { ::avpicture_free(picture); }
     virtual void av_free_packet(AVPacket *pkt) { ::av_free_packet(pkt); }
     virtual int avpicture_alloc(AVPicture *picture, PixelFormat pix_fmt, int width, int height) { return ::avpicture_alloc(picture, pix_fmt, width, height); }
     virtual int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic) { return ::avcodec_default_get_buffer(s, pic); }
     virtual void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic) { ::avcodec_default_release_buffer(s, pic); }
     virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt) { return ::avcodec_default_get_format(s, fmt); }
     virtual AVCodec *av_codec_next(AVCodec *c) { return ::av_codec_next(c); }

     virtual int av_dup_packet(AVPacket *pkt) { return ::av_dup_packet(pkt); }
     virtual void av_init_packet(AVPacket *pkt) { return ::av_init_packet(pkt); }
     virtual int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align) { return ::avcodec_fill_audio_frame(frame, nb_channels, sample_fmt, buf, buf_size, align); }
     virtual void avcodec_free_frame(AVFrame **frame) { return ::avcodec_free_frame(frame); };
    };
  • Why ffmpeg command results in blank video ?

    17 juillet 2013, par kheya

    I am trying to conver mov file to H264 encoded mp4
    Same command converts another mov file just fine.

    But fails for a particular mov file. Original video is 29.6MB after conversion I get 966KB

    I get the sound and duration right. But all the frames are black even though original video is fine.

    Here is the command :

    ffmpeg -i file3.mov -movflags +faststart -vcodec libx264 -preset slow -crf 20 -vf -threads 0 -acodec libvo_aacenc -b:a 128k "file3.mp4"

    Here is the result of ffmpeg -i : >ffmpeg.exe -i file3.mov

    ffmpeg version N-54691-g7f4a1fd Copyright (c) 2000-2013 the FFmpeg developers
     built on Jul 12 2013 16:31:48 with gcc 4.7.3 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
    e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
    ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
    ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
    eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-
    amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
    enable-libxvid --enable-zlib
     libavutil      52. 39.100 / 52. 39.100
     libavcodec     55. 18.102 / 55. 18.102
     libavformat    55. 12.102 / 55. 12.102
     libavdevice    55.  3.100 / 55.  3.100
     libavfilter     3. 80.101 /  3. 80.101
     libswscale      2.  3.100 /  2.  3.100
     libswresample   0. 17.102 /  0. 17.102
     libpostproc    52.  3.100 / 52.  3.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 00000000003077e0] sample aspect ratio already set to
    118:81, ignoring &#39;pasp&#39; atom (10000:7031)
    Guessed Channel Layout for  Input Stream #0.1 : stereo
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#39;file3.mov&#39;:
     Metadata:
       creation_time   : 2009-02-12 01:19:22
     Duration: 00:00:08.00, start: 0.000000, bitrate: 30338 kb/s
       Stream #0:0(eng): Video: dvvideo (dvpp / 0x70707664), yuv411p, 720x576 [SAR
    64:45 DAR 16:9], 28800 kb/s, SAR 118:81 DAR 295:162, 25 fps, 25 tbr, 600 tbn, 25
    tbc
       Metadata:
         creation_time   : 2009-02-12 01:19:22
         handler_name    : Apple Alias Data Handler
       Stream #0:1(eng): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s1
    6, 1536 kb/s
       Metadata:
         creation_time   : 2009-02-12 01:19:22
         handler_name    : Apple Alias Data Handler

    During conversion here is what I see (nothing unusual or no errors) :

    ffmpeg version N-54691-g7f4a1fd Copyright (c) 2000-2013 the FFmpeg developers
     built on Jul 12 2013 16:31:48 with gcc 4.7.3 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
    e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
    ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
    ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
    eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-
    amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
    enable-libxvid --enable-zlib
     libavutil      52. 39.100 / 52. 39.100
     libavcodec     55. 18.102 / 55. 18.102
     libavformat    55. 12.102 / 55. 12.102
     libavdevice    55.  3.100 / 55.  3.100
     libavfilter     3. 80.101 /  3. 80.101
     libswscale      2.  3.100 /  2.  3.100
     libswresample   0. 17.102 /  0. 17.102
     libpostproc    52.  3.100 / 52.  3.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 00000000024aafe0] sample aspect ratio already set to
    118:81, ignoring &#39;pasp&#39; atom (10000:7031)
    Guessed Channel Layout for  Input Stream #0.1 : stereo
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#39;file3.mov&#39;:
     Metadata:
       creation_time   : 2009-02-12 01:19:22
     Duration: 00:00:08.00, start: 0.000000, bitrate: 30338 kb/s
       Stream #0:0(eng): Video: dvvideo (dvpp / 0x70707664), yuv411p, 720x576 [SAR
    64:45 DAR 16:9], 28800 kb/s, SAR 118:81 DAR 295:162, 25 fps, 25 tbr, 600 tbn, 25
    tbc
       Metadata:
         creation_time   : 2009-02-12 01:19:22
         handler_name    : Apple Alias Data Handler
       Stream #0:1(eng): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s1
    6, 1536 kb/s
       Metadata:
         creation_time   : 2009-02-12 01:19:22
         handler_name    : Apple Alias Data Handler
    No pixel format specified, yuv422p for H.264 encoding chosen.
    Use -pix_fmt yuv420p for compatibility with outdated media players.
    [libx264 @ 0000000000347340] using SAR=118/81
    [libx264 @ 0000000000347340] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    AVX
    [libx264 @ 0000000000347340] profile High 4:2:2, level 2.1, 4:2:2 8-bit
    [libx264 @ 0000000000347340] 264 - core 133 r2334 a3ac64b - H.264/MPEG-4 AVC cod
    ec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 r
    ef=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed
    _ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pski
    p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci
    mate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_
    adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=2
    5 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=20.0 qcomp=0.6
    0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to &#39;file4a.mp4&#39;:
     Metadata:
       encoder         : Lavf55.12.102
       Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p, 4
    80x320 [SAR 118:81 DAR 59:27], q=-1--1, 12800 tbn, 25 tbc
       Metadata:
         creation_time   : 2009-02-12 01:19:22
         handler_name    : Apple Alias Data Handler
       Stream #0:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 48000
    Hz, stereo, s16, 128 kb/s
       Metadata:
         creation_time   : 2009-02-12 01:19:22
         handler_name    : Apple Alias Data Handler
    Stream mapping:
     Stream #0:0 -> #0:0 (dvvideo -> libx264)
     Stream #0:1 -> #0:1 (pcm_s16be -> libvo_aacenc)
    Press [q] to stop, [?] for help
    [swscaler @ 00000000024b0740] Warning: data is not aligned! This can lead to a s
    peedloss
    frame=   78 fps=0.0 q=25.0 size=     128kB time=00:00:02.14 bitrate= 487.8kbits/
    frame=  113 fps=109 q=25.0 size=     272kB time=00:00:04.27 bitrate= 520.9kbits/
    frame=  145 fps= 94 q=25.0 size=     399kB time=00:00:05.36 bitrate= 609.2kbits/
    frame=  182 fps= 89 q=25.0 size=     571kB time=00:00:06.45 bitrate= 725.0kbits/
    Starting second pass: moving header on top of the file
    frame=  200 fps= 70 q=-1.0 Lsize=     965kB time=00:00:08.00 bitrate= 987.2kbits
    /s
    video:832kB audio:126kB subtitle:0 global headers:0kB muxing overhead 0.755121%
    [libx264 @ 0000000000347340] frame I:1     Avg QP:21.14  size: 39885
    [libx264 @ 0000000000347340] frame P:50    Avg QP:21.80  size:  7412
    [libx264 @ 0000000000347340] frame B:149   Avg QP:26.25  size:  2960
    [libx264 @ 0000000000347340] consecutive B-frames:  0.5%  0.0%  1.5% 98.0%
    [libx264 @ 0000000000347340] mb I  I16..4: 13.7% 46.7% 39.7%
    [libx264 @ 0000000000347340] mb P  I16..4:  0.5% 19.7%  3.8%  P16..4: 32.8% 11.9
    % 14.1%  0.0%  0.0%    skip:17.1%
    [libx264 @ 0000000000347340] mb B  I16..4:  0.0%  5.1%  1.3%  B16..8: 14.4%  9.2
    %  2.9%  direct: 7.3%  skip:59.8%  L0:42.8% L1:38.3% BI:19.0%
    [libx264 @ 0000000000347340] 8x8 transform intra:79.4% inter:71.7%
    [libx264 @ 0000000000347340] direct mvs  spatial:97.3% temporal:2.7%
    [libx264 @ 0000000000347340] coded y,uvDC,uvAC intra: 92.8% 80.1% 26.3% inter: 2
    4.2% 28.8% 8.1%
    [libx264 @ 0000000000347340] i16 v,h,dc,p: 64% 17%  3% 16%
    [libx264 @ 0000000000347340] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  1% 33%  4%  3%  8%
    2% 35%  2% 11%
    [libx264 @ 0000000000347340] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  3% 23%  5%  4% 11%
    5% 33%  4% 13%
    [libx264 @ 0000000000347340] i8c dc,h,v,p: 38% 40% 14%  8%
    [libx264 @ 0000000000347340] Weighted P-Frames: Y:2.0% UV:0.0%
    [libx264 @ 0000000000347340] ref P L0: 39.9% 10.0% 25.6%  8.7% 15.3%  0.6%
    [libx264 @ 0000000000347340] ref B L0: 76.9% 15.1%  5.7%  2.3%
    [libx264 @ 0000000000347340] ref B L1: 96.3%  3.7%
    [libx264 @ 0000000000347340] kb/s:851.49
  • Pointer peril

    18 octobre 2011, par Mans — Bugs, Optimisation

    Use of pointers in the C programming language is subject to a number of constraints, violation of which results in the dreaded undefined behaviour. If a situation with undefined behaviour occurs, anything is permitted to happen. The program may produce unexpected results, crash, or demons may fly out of the user’s nose.

    Some of these rules concern pointer arithmetic, addition and subtraction in which one or both operands are pointers. The C99 specification spells it out in section 6.5.6 :

    When an expression that has integer type is added to or subtracted from a pointer, the result has the type of the pointer operand. […] If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow ; otherwise, the behavior is undefined. […]

    When two pointers are subtracted, both shall point to elements of the same array object, or one past the last element of the array object ; the result is the difference of the subscripts of the two array elements.

    In simpler, if less accurate, terms, operands and results of pointer arithmetic must be within the same array object. If not, anything can happen.

    To see some of this undefined behaviour in action, consider the following example.

    #include <stdio.h>
    

    int foo(void)

    int a, b ;
    int d = &b - &a ; /* undefined */
    int *p = &a ;
    b = 0 ;
    p[d] = 1 ; /* undefined */
    return b ;

    int main(void)

    printf("%d\n", foo()) ;
    return 0 ;

    This program breaks the above rules twice. Firstly, the &a - &b calculation is undefined because the pointers being subtracted do not point to elements of the same array. Most compilers will nonetheless evaluate this to the distance between the two variables on the stack. Secondly, accessing p[d] is undefined because p and p + d do not point to elements of the same array (unless the result of the first undefined expression happened to be zero).

    It might be tempting to assume that on a modern system with a single, flat address space, these operations would result in the intuitively obvious outcomes, ultimately setting b to the value 1 and returning this same value. However, undefined is undefined, and the compiler is free to do whatever it wants :

    $ gcc -O undef.c
    $ ./a.out
    0

    Even on a perfectly normal system, compiled with optimisation enabled the program behaves as though the write to p[d] were ignored. In fact, this is exactly what happened, as this test shows :

    $ gcc -O -fno-tree-pta undef.c
    $ ./a.out
    1

    Disabling the tree-pta optimisation in gcc gives us back the intuitive behaviour. PTA stands for points-to analysis, which means the compiler analyses which objects any pointers can validly access. In the example, the pointer p, having been set to &a cannot be used in a valid access to the variable b, a and b not being part of the same array. Between the assignment b = 0 and the return statement, no valid access to b takes place, whence the return value is derived to be zero. The entire function is, in fact, reduced to the assembly equivalent of a simple return 0 statement, all because we decided to violate a couple of language rules.

    While this example is obviously contrived for clarity, bugs rooted in these rules occur in real programs from time to time. My most recent encounter with one was in PARI/GP, where a somewhat more complicated incarnation of the example above can be found. Unfortunately, the maintainers of this program are not responsive to reports of such bad practices in their code :

    Undefined according to what rule ? The code is only requiring the adress space to be flat which is true on all supported platforms.

    The rule in question is, of course, the one quoted above. Since the standard makes no exception for flat address spaces, no such exception exists. Although the behaviour could be logically defined in this case, it is not, and all programs must still follow the rules. Filing bug reports against the compiler will not make them go away. As of this writing, the issue remains unresolved.