[FFmpeg-devel] Patch to libavc/opus to create extradata if missing
Lynne
dev at lynne.ee
Mon Jan 4 01:05:15 EET 2021
Jan 3, 2021, 23:48 by jon at jonb.org:
>
>
> On Sun, Jan 3, 2021, at 2:25 PM, Lynne wrote:
>
>> > + /* Input sample rate (0 = unspecified) */> + bytestream_put_le32 (&bs, 0);
>> Put in 48000 here. Stream copy will preserve extradata, and we don't want to
>> generate weird streams, even if our decoder ignores this.
>>
>> > + /* Channel count */> + bytestream_put_byte (&bs, codecpar->channels);> + /* Mapping family */> + bytestream_put_byte (&bs, 0x0);
>> This will only work for mono and stereo. The decoder will error out if more than
>> 2 channels are present. For now maybe error out if the number of channels is greater than 2?
>>
>
> Ok! Sample rate changed to 48000. If codecpar->channels is greater than 2, AVERROR_INVALIDDATA will be returned. Please advise if there is a better error code.
>
> Thanks Lynne!
>
> +static int opus_write_extradata(AVCodecParameters *codecpar) {
Function opening brackets must be put by themselves on a new line.
> + if (codecpar->channels > 2) {
> + return AVERROR_INVALIDDATA;
> + }
> +
> + ret = ff_alloc_extradata(codecpar, 19);
> + if (ret < 0) {
> + return ret;
> + }
We don't wrap 1-line conditions in brackets, so just remove them.
> + av_log(s1, AV_LOG_ERROR,
> + "Error creating opus extradata: %s\n",
> + av_err2str(ret));
Weird indentation. There's an extra space in the 2 lines.
Apart from that LGTM.
More information about the ffmpeg-devel
mailing list