[FFmpeg-devel] 0001-fix-segment-fault-in-function-decode
Stefano Sabatini
stefasab at gmail.com
Sun Jan 21 20:31:05 EET 2024
On date Saturday 2024-01-13 05:57:18 +0800, 陈督 wrote:
>
>
> /*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.
>
The problem with this approach is that this is generating output in a
format which cannot be played by ffplay, which is assuming packed
(i.e. non planar) format. So it is expecting the output file to be
written as:
LRLRLR...
rather than as:
LLLLLL....RRRRR
also because ffplay does not know the linesize.
...
But I see the example code should be fixed, it was designed with the
assumption that the input sample format was always packed, which is
not the case anymore.
[...]
More information about the ffmpeg-devel
mailing list