/*When it is not a planar arrangement, data[1] is empty,

    and all the data is interleaved in data[0].

    This can result in a segmentation fault when accessing data[ch] .*/

    //So I delete the code below:

    for (i = 0; i < frame->nb_samples; i++)

        for (ch = 0; ch < dec_ctx->ch_layout.nb_channels; ch++)

            fwrite(frame->data[ch] + data_size*i, 1, data_size, outfile);




    //And I write this instead

        // L R data order

    if (av_sample_fmt_is_planar(dec_ctx->sample_fmt))

    {

        // planar:LLL...RRR... in different data[ch]

        for (ch = 0; ch < dec_ctx->ch_layout.nb_channels; ch++)

        {

            fwrite(frame->data[ch], 1, frame->linesize[0], outfile); // only 
linesize[0] has data.

        }

    }

    else

    {

        // not planar:LRLR...all in data[0]

        fwrite(frame->data[0], 1, frame->linesize[0], outfile);

    }


Attachment: 0001-fix-segment-fault-in-doc-examples-decode_audio.c.patch
Description: Binary data

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to