avcodec: Use av_reallocp where suitable

Signed-off-by: Martin Storsjö <martin@martin.st>