avcodec/libopenjpegenc: Check the return code of av_frame_ref()

Fixes CID1163842

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>