Recherche avancée

Médias (2)

Mot : - Tags -/map

Autres articles (58)

  • Encodage et transformation en formats lisibles sur Internet

    10 avril 2011

    MediaSPIP transforme et ré-encode les documents mis en ligne afin de les rendre lisibles sur Internet et automatiquement utilisables sans intervention du créateur de contenu.
    Les vidéos sont automatiquement encodées dans les formats supportés par HTML5 : MP4, Ogv et WebM. La version "MP4" est également utilisée pour le lecteur flash de secours nécessaire aux anciens navigateurs.
    Les documents audios sont également ré-encodés dans les deux formats utilisables par HTML5 :MP3 et Ogg. La version "MP3" (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

Sur d’autres sites (8831)

  • libavcodec audio decoding is producing garbeld samples

    14 novembre 2024, par user28288805

    I'm trying to write a function that extracts the raw sample data from audio files. But when debugging with a test file I found that the samples in floating point planar format were not in range of -1.0f to 1.0f as specified in the documentation.

    


    Here is the function :

    


    AudioResource::ReturnCode AudioResource::LoadFromFile(std::string FilePath)&#xA;{&#xA;    std::string FileURL = "file:" &#x2B; FilePath;&#xA;    AVFormatContext* FormatContext = nullptr;&#xA;    int Error = avformat_open_input(&amp;FormatContext, FileURL.c_str(), nullptr, nullptr);&#xA;&#xA;    if (Error &lt; 0)&#xA;    {&#xA;        return ERROR_OPENING_FILE;&#xA;    }&#xA;&#xA;    Error = avformat_find_stream_info(FormatContext, nullptr);&#xA;    if (Error &lt; 0)&#xA;    {&#xA;        return ERROR_FINDING_STREAM_INFO;&#xA;    }&#xA;&#xA;    int AudioStream = -1;&#xA;    AVCodecParameters* CodecParams;&#xA;    for (int i = 0; i &lt; FormatContext->nb_streams; i&#x2B;&#x2B;)&#xA;    {&#xA;        if (FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)&#xA;        {&#xA;            CodecParams = FormatContext->streams[i]->codecpar;&#xA;            AudioStream = i;&#xA;        }&#xA;    }&#xA;&#xA;    if (AudioStream == -1)&#xA;    {&#xA;        return ERROR_AUDIO_STREAM_NOT_FOUND;&#xA;    }&#xA;&#xA;    SampleRate = FormatContext->streams[AudioStream]->codecpar->sample_rate;&#xA;    AVSampleFormat SampleFormat = (AVSampleFormat) FormatContext->streams[AudioStream]->codecpar->format;&#xA;    Channels = FormatContext->streams[AudioStream]->codecpar->ch_layout.nb_channels;&#xA;&#xA;    if (Channels > 2)&#xA;    {&#xA;        return ERROR_UNSUPPORTED_CHANNEL_COUNT;&#xA;    }&#xA;&#xA;    switch (SampleFormat)&#xA;    {&#xA;    case AV_SAMPLE_FMT_NONE:&#xA;        return ERROR_UNKWON_SAMPLE_FORMAT;&#xA;        break;&#xA;    case AV_SAMPLE_FMT_U8:&#xA;        BytesPerSample = 1;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType == MONO_8BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_8BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_S16:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_S32:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType= STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_FLT:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_DBL:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_U8P:&#xA;        BytesPerSample = 1;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_8BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_8BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_S16P:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_S32P:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_FLTP:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_DBLP:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_S64:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    case AV_SAMPLE_FMT_S64P:&#xA;        BytesPerSample = 2;&#xA;        if (Channels == 1)&#xA;        {&#xA;            SampleType = MONO_16BIT;&#xA;        }&#xA;        else&#xA;        {&#xA;            SampleType = STEREO_16BIT;&#xA;        }&#xA;        break;&#xA;    default:&#xA;        return ERROR_UNKWON_SAMPLE_FORMAT;&#xA;        break;&#xA;    }&#xA;&#xA;    const AVCodec* AudioCodec = avcodec_find_decoder(CodecParams->codec_id);&#xA;    AVCodecContext* CodecContext = avcodec_alloc_context3(AudioCodec);&#xA;    avcodec_parameters_to_context(CodecContext, CodecParams);&#xA;    avcodec_open2(CodecContext, AudioCodec, nullptr);&#xA;&#xA;    AVPacket* CurrentPacket = av_packet_alloc();&#xA;    AVFrame* CurrentFrame = av_frame_alloc();&#xA;&#xA;    while (av_read_frame(FormatContext, CurrentPacket) >= 0)&#xA;    {&#xA;        avcodec_send_packet(CodecContext, CurrentPacket);&#xA;        for (;;)&#xA;        {&#xA;            Error = avcodec_receive_frame(CodecContext, CurrentFrame);&#xA;            if ((Error == AVERROR(EAGAIN)) || (Error == AVERROR_EOF))&#xA;            {&#xA;                break;&#xA;            }&#xA;            else if (Error == AVERROR(EINVAL))&#xA;            {&#xA;                return ERROR_RECIVING_FRAME;&#xA;            }&#xA;            else if (Error != 0)&#xA;            {&#xA;                return ERROR_UNEXSPECTED;&#xA;            }&#xA;&#xA;            if (SampleFormat == AV_SAMPLE_FMT_U8)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_S16)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_S32)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_FLT)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_DBL)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_U8P)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_S16P)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_S32P)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_FLTP) //&#xA;            {&#xA;                if (Channels == 2)&#xA;                {&#xA;                    for (size_t i = 0; i &lt; CurrentFrame->linesize[0]; i &#x2B;= sizeof(float))&#xA;                    {&#xA;                        float CurrentLeftSample = 0.0f;&#xA;                        float CurrentRightSample = 0.0f;&#xA;                        memcpy(&amp;CurrentLeftSample, &amp;CurrentFrame->data[0][i], sizeof(float));&#xA;                        memcpy(&amp;CurrentRightSample, &amp;CurrentFrame->data[1][i], sizeof(float));&#xA;&#xA;                        short int QuantizedLeftSample = roundf(CurrentLeftSample * 0x7fff);&#xA;                        short int QuantizedRightSample = roundf(CurrentRightSample * 0x7fff);&#xA;&#xA;                        LoadByteData<short int="int">(QuantizedLeftSample, AudioData);&#xA;                        LoadByteData<short int="int">(QuantizedRightSample, AudioData);&#xA;                    }&#xA;                }&#xA;                else&#xA;                {&#xA;&#xA;                }&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_DBLP)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_S64)&#xA;            {&#xA;&#xA;            }&#xA;            else if (SampleFormat == AV_SAMPLE_FMT_S64P)&#xA;            {&#xA;&#xA;            }&#xA;            else&#xA;            {&#xA;                return ERROR_UNEXSPECTED;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    av_frame_free(&amp;CurrentFrame);&#xA;    av_packet_free(&amp;CurrentPacket);&#xA;    avcodec_free_context(&amp;CodecContext);&#xA;    avformat_free_context(FormatContext);&#xA;    return OK;&#xA;}&#xA;</short></short>

    &#xA;

    Here is where I am reading from AVFrame's buffer

    &#xA;

    for (size_t i = 0; i &lt; CurrentFrame->linesize[0]; i &#x2B;= sizeof(float))&#xA;                    {&#xA;                        float CurrentLeftSample = 0.0f;&#xA;                        float CurrentRightSample = 0.0f;&#xA;                        memcpy(&amp;CurrentLeftSample, &amp;CurrentFrame->data[0][i], sizeof(float));&#xA;                        memcpy(&amp;CurrentRightSample, &amp;CurrentFrame->data[1][i], sizeof(float));&#xA;&#xA;                        short int QuantizedLeftSample = roundf(CurrentLeftSample * 0x7fff);&#xA;                        short int QuantizedRightSample = roundf(CurrentRightSample * 0x7fff);&#xA;&#xA;                        LoadByteData<short int="int">(QuantizedLeftSample, AudioData);&#xA;                        LoadByteData<short int="int">(QuantizedRightSample, AudioData);&#xA;                    }&#xA;</short></short>

    &#xA;

    Ive tried using different parameters like CurrentFrame->nb_samples, CurrentFrame->buf[0].size in the for loop with no success it still produces the same results.

    &#xA;

    Any help would be much appreciated.

    &#xA;

  • sws_scale generates malformed video

    29 juillet 2024, par GiuTor

    I have to encode a series of frames from CAIRO_FORMAT_ARGB32 to AV_PIX_FMT_YUV420P with sws_scale. From the ffmpeg docs I came to know the AV equivalent of the source format is AV_PIX_FMT_ARGB so here is my code :

    &#xA;

     // Set up conversion context&#xA;    img->sws_ctx = sws_getCachedContext(&#xA;        img->sws_ctx,&#xA;        img->video_size[0],&#xA;        img->video_size[1],&#xA;        AV_PIX_FMT_ARGB,&#xA;        img->video_size[0],&#xA;        img->video_size[1],&#xA;        AV_PIX_FMT_YUV420P,&#xA;        SWS_BILINEAR,&#xA;        NULL,&#xA;        NULL,&#xA;        NULL);&#xA;&#xA;    width  = cairo_image_surface_get_width( surface );&#xA;    height = cairo_image_surface_get_height( surface );&#xA;    stride = cairo_image_surface_get_stride( surface );&#xA;    pix    = cairo_image_surface_get_data( surface );&#xA;    const int in_linesize[1] = { stride };&#xA;    &#xA;    sws_scale(  img->sws_ctx, (const uint8_t * const *) &amp;pix, in_linesize, 0,&#xA;                img->video_size[1], img->video_frame->data, img->video_frame->linesize);&#xA;    img->video_frame->pts&#x2B;&#x2B;;&#xA;

    &#xA;

    Sadly the video doesn't play and VLC shows a bunch of these useless messages :

    &#xA;

    [h264 @ 0x7f6ce0cbc1c0] mmco: unref short failure&#xA;[h264 @ 0x7f6ce0c39a80] co located POCs unavailable&#xA;[h264 @ 0x7f6ce0c82800] co located POCs unavailable&#xA;[h264 @ 0x7f6ce0c9f400] mmco: unref short failure&#xA;

    &#xA;

    The encoding process runs just fine. I also tried with const int in_linesize[1] = 3 * width  ; Where am I wrong ?

    &#xA;

  • speedhq : fix out-of-bounds write

    1er février 2017, par Steinar H. Gunderson
    speedhq : fix out-of-bounds write
    

    Certain alpha run lengths (for SHQ1/SHQ3/SHQ5) could be stored in
    both long and short versions, and we would only accept the short version,
    returning -1 (invalid code) for the others. This could cause an
    out-of-bounds write on malicious input, as discovered by
    Andreas Cadhalpun during fuzzing.

    Fix by simply allowing both versions, leaving no invalid codes
    in the alpha VLC.

    Signed-off-by : Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>

    • [DH] libavcodec/speedhq.c
    • [DH] libavcodec/vlc.h