Avcodec: use av_malloc/av_free for buffers

Ref #11490
Avcodec: remove trailing space