avcodec: ref the frame before copying pointers in case the data is copied.
Fix copying of packed image buffers