Recherche avancée

Médias (0)

Mot : - Tags -/optimisation

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

Autres articles (70)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (11102)

  • swscale : move yuv2yuvX_sse3 to yasm, unrolls main loop

    14 janvier 2021, par Alan Kelly
    swscale : move yuv2yuvX_sse3 to yasm, unrolls main loop
    

    And other small optimizations for 20% speedup.

    • [DH] libswscale/x86/Makefile
    • [DH] libswscale/x86/swscale.c
    • [DH] libswscale/x86/swscale_template.c
    • [DH] libswscale/x86/yuv2yuvX.asm
    • [DH] tests/checkasm/sw_scale.c
  • avformat/nutdec : Check timebase count against main header length

    19 décembre 2020, par Michael Niedermayer
    avformat/nutdec : Check timebase count against main header length
    

    Fixes : Timeout (long -> 3ms)
    Fixes : 28514/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6078669009321984
    Fixes : 30095/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-5074433016463360

    Found-by : continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] libavformat/nutdec.c
  • Reading mp3 file using ffmpeg caues memory leaks, even after freeing it in main

    12 août 2020, par leonardltk1

    i am continuously reading mp3 files and processing them, but the memory keeps getting build up even though i freed it.

    &#xA;

    At the bottom read_audio_mp3(), they are already freeing some variable.&#xA;why do i still face a memory build up and how do i deal with it ?

    &#xA;

    following this code : https://rodic.fr/blog/libavcodec-tutorial-decode-audio-file/, i read mp3 using this function

    &#xA;

        int read_audio_mp3(string filePath_str, const int sample_rate, &#xA;      double** output_buffer, int &amp;AUDIO_DURATION){&#xA;      const char* path = filePath_str.c_str();&#xA;&#xA;      /* Reads the file header and stores information about the file format. */&#xA;        AVFormatContext* format = avformat_alloc_context();&#xA;        if (avformat_open_input(&amp;format, path, NULL, NULL) != 0) {&#xA;            fprintf(stderr, "Could not open file &#x27;%s&#x27;\n", path);&#xA;            return -1;&#xA;        }&#xA;&#xA;      /* Check out the stream information in the file. */&#xA;        if (avformat_find_stream_info(format, NULL) &lt; 0) {&#xA;            fprintf(stderr, "Could not retrieve stream info from file &#x27;%s&#x27;\n", path);&#xA;            return -1;&#xA;        }&#xA;&#xA;      /* find an audio stream. */&#xA;        int stream_index =- 1;&#xA;        for (unsigned i=0; inb_streams; i&#x2B;&#x2B;) {&#xA;          if (format->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            stream_index = i;&#xA;            break;&#xA;          }&#xA;        }&#xA;        if (stream_index == -1) {&#xA;            fprintf(stderr, "Could not retrieve audio stream from file &#x27;%s&#x27;\n", path);&#xA;            return -1;&#xA;        }&#xA;        AVStream* stream = format->streams[stream_index];&#xA;&#xA;      // find &amp; open codec&#xA;        AVCodecContext* codec = stream->codec;&#xA;        if (avcodec_open2(codec, avcodec_find_decoder(codec->codec_id), NULL) &lt; 0) {&#xA;            fprintf(stderr, "Failed to open decoder for stream #%u in file &#x27;%s&#x27;\n", stream_index, path);&#xA;            return -1;&#xA;        }&#xA;&#xA;      // prepare resampler&#xA;        struct SwrContext* swr = swr_alloc();&#xA;        av_opt_set_int(swr, "in_channel_count",  codec->channels, 0);&#xA;        av_opt_set_int(swr, "out_channel_count", 1, 0);&#xA;        av_opt_set_int(swr, "in_channel_layout",  codec->channel_layout, 0);&#xA;        av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);&#xA;        av_opt_set_int(swr, "in_sample_rate", codec->sample_rate, 0);&#xA;        av_opt_set_int(swr, "out_sample_rate", sample_rate, 0);&#xA;        av_opt_set_sample_fmt(swr, "in_sample_fmt",  codec->sample_fmt, 0);&#xA;        av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_DBL,  0);&#xA;        swr_init(swr);&#xA;        if (!swr_is_initialized(swr)) {&#xA;            fprintf(stderr, "Resampler has not been properly initialized\n");&#xA;            return -1;&#xA;        }&#xA;&#xA;      /* Allocate an audio frame. */&#xA;        AVPacket packet;&#xA;        av_init_packet(&amp;packet);&#xA;        AVFrame* frame = av_frame_alloc();&#xA;        if (!frame) {&#xA;          fprintf(stderr, "Error allocating the frame\n");&#xA;          return -1;&#xA;        }&#xA;&#xA;      // iterate through frames&#xA;        *output_buffer = NULL;&#xA;        AUDIO_DURATION = 0;&#xA;        while (av_read_frame(format, &amp;packet) >= 0) {&#xA;          // decode one frame&#xA;            int gotFrame;&#xA;            if (avcodec_decode_audio4(codec, frame, &amp;gotFrame, &amp;packet) &lt; 0) {&#xA;              // free packet&#xA;                av_free_packet(&amp;packet);&#xA;                break;&#xA;            }&#xA;            if (!gotFrame) {&#xA;              // free packet&#xA;                av_free_packet(&amp;packet);&#xA;                continue;&#xA;            }&#xA;          // resample frames&#xA;            double* buffer;&#xA;            av_samples_alloc((uint8_t**) &amp;buffer, NULL, 1, frame->nb_samples, AV_SAMPLE_FMT_DBL, 0);&#xA;            int frame_count = swr_convert(swr, (uint8_t**) &amp;buffer, frame->nb_samples, (const uint8_t**) frame->data, frame->nb_samples);&#xA;          // append resampled frames to output_buffer&#xA;            *output_buffer = (double*) realloc(*output_buffer,&#xA;             (AUDIO_DURATION &#x2B; frame->nb_samples) * sizeof(double));&#xA;            memcpy(*output_buffer &#x2B; AUDIO_DURATION, buffer, frame_count * sizeof(double));&#xA;            AUDIO_DURATION &#x2B;= frame_count;&#xA;          // free buffer &amp; packet&#xA;            av_free_packet(&amp;packet);&#xA;            av_free( buffer );&#xA;        }&#xA;&#xA;      // clean up&#xA;        av_frame_free(&amp;frame);&#xA;        swr_free(&amp;swr);&#xA;        avcodec_close(codec);&#xA;        avformat_free_context(format);&#xA;&#xA;      return 0;&#xA;    }&#xA;

    &#xA;

    Main Script : MemoryLeak.cpp

    &#xA;

        // imports&#xA;      #include <fstream>&#xA;      #include &#xA;      #include &#xA;      #include &#xA;      #include &#xA;      #include <iostream>&#xA;      #include <sstream>&#xA;      #include <vector>&#xA;      #include <sys></sys>time.h> &#xA;      extern "C"&#xA;      {&#xA;      #include <libavutil></libavutil>opt.h>&#xA;      #include <libavcodec></libavcodec>avcodec.h>&#xA;      #include <libavformat></libavformat>avformat.h>&#xA;      #include <libswresample></libswresample>swresample.h>&#xA;      }&#xA;      using namespace std;&#xA;&#xA;    int main (int argc, char ** argv) {&#xA;      string wavpath = argv[1];&#xA;      printf("wavpath=%s\n", wavpath.c_str());&#xA;&#xA;      printf("\n==== Params =====\n");&#xA;      // Init&#xA;        int AUDIO_DURATION;&#xA;        int sample_rate = 8000;&#xA;        av_register_all();&#xA;&#xA;      printf("\n==== Reading MP3 =====\n");&#xA;        while (true) {&#xA;            // Read mp3&#xA;              double* buffer;&#xA;              if (read_audio_mp3(wavpath, sample_rate, &amp;buffer, AUDIO_DURATION) != 0) {&#xA;                printf("Cannot read %s\n", wavpath.c_str());&#xA;                continue;&#xA;              }&#xA;&#xA;            /* &#xA;              Process the buffer for down stream tasks.&#xA;            */&#xA;&#xA;            // Freeing the buffer&#xA;            free(buffer);&#xA;        }&#xA;&#xA;      return 0 ;&#xA;    }&#xA;</vector></sstream></iostream></fstream>

    &#xA;

    Compiling

    &#xA;

        g&#x2B;&#x2B; -o ./MemoryLeak.out -Ofast -Wall -Wextra \&#xA;        -std=c&#x2B;&#x2B;11 "./MemoryLeak.cpp" \&#xA;        -lavformat -lavcodec -lavutil -lswresample&#xA;

    &#xA;

    Running, by right my input an argument wav.scp that reads text file of all the mp3s.&#xA;But for easy to replicate purpose, i only read 1 file song.mp3 in and i keep re-reading it

    &#xA;

    ./MemoryLeak.out song.mp3&#xA;

    &#xA;

    Why do i know i have memory leaks ?

    &#xA;

      &#xA;
    1. I was running up 32 jobs in parallel for 14 million files, and when i wake up in the morning, they were abruptly killed.
    2. &#xA;

    3. I run htop and i monitor the progress when i re-run it, and i saw that the VIRT & RES & Mem are continuously increasing.
    4. &#xA;

    &#xA;

    &#xA;

    Edit 1 :&#xA;My setup :

    &#xA;

    &#xA;

    ffmpeg version 2.8.15-0ubuntu0.16.04.1&#xA;built with gcc 5.4.0&#xA;

    &#xA;