Use avcodec_check_dimensions() for checking the frame size validity.