[FFmpeg-devel] Patch to libavc/opus to create extradata if missing
James Almer
jamrial at gmail.com
Wed Dec 30 20:34:13 EET 2020
On 12/30/2020 3:00 PM, Jonathan Baudanza wrote:
>
> On Tue, Dec 29, 2020, at 3:25 PM, Jonathan Baudanza wrote:
>> Thank you for all the feedback everyone. I've updated the patch to build the opus header inside of ff_rtp_parse_open in libavformat/rtpdec.c.
>>
>> I set the mapping_family to 0, since I believe Opus/RTP only supports 2 channels. I set the input sample rate to 0, which the spec considers "unspecified". Let me know what you think of this approach for these values. Happy to switch them to 255/48000 if you prefer.
>>
>> I copied the bytestream code from opusenc.c. There's now 3 or 4 different places in the codebase where opus headers are getting built. Let me know if you'd like me to refactor this a bit. I didn't want to touch too many components with my first patch.
>>
>
> I had a follow-up thought to this. Do you think it makes sense to check st->codecpar->extradata for NULL before assigning it? Some other component may have assigned extradata, although I'm not sure why it would. And in that case we don't want a memory leak.
Nothing should have done it at that point. The demuxer allocates the
AVStream after all. But to be sure you can do
av_freep(&st->codecpar->extradata) to ensure it's NULL before anything
else is done.
More information about the ffmpeg-devel
mailing list