A method of encoding a high frequency signal relating to bandwidth expansion in speech encoding and audio encoding, the method comprising: determining a signal class of a high frequency signal of a current frame; and when the high frequency signal of the current frame is a NON-TRANSIENT signal and a high frequency signal of the previous frame is a TRANSIENT signal, smoothing and scaling time envelopes of the high frequency signal of the current frame to obtain time envelopes of the high frequency signal of the current frame that require to be encoded; quantizing and encoding the time envelopes of the high frequency signal of the current frame requiring to be encoded, and frequency information and signal class information of the high frequency signal of the current frame, wherein the signal class information of a TRANSIENT signal is used when the signal class information of the high frequency signal of the current frame is quantized and encoded; and when the high frequency signal of the current frame is a TRANSIENT signal, quantizing and encoding the time envelopes, the frequency information, and the signal class information of the high frequency signal of the current frame; and when both the high frequency signal of the current frame and the high frequency signal of the previous frame are NON-TRANSIENT signals, quantizing and encoding the frequency information and the signal class information of the high frequency signal of the current frame; wherein the frequency information of the high frequency signal of the current frame includes at least one of the following: frequency envelopes of the high frequency signal of the current frame, global energy information of the high frequency signal of the current frame, and amplitude information of the high frequency signal of the current frame. determining a signal class of a high frequency signal of a current frame; and when the high frequency signal of the current frame is a NON-TRANSIENT signal and a high frequency signal of the previous frame is a TRANSIENT signal, smoothing and scaling time envelopes of the high frequency signal of the current frame to obtain time envelopes of the high frequency signal of the current frame that require to be encoded; quantizing and encoding the time envelopes of the high frequency signal of the current frame requiring to be encoded, and frequency information and signal class information of the high frequency signal of the current frame, wherein the signal class information of a TRANSIENT signal is used when the signal class information of the high frequency signal of the current frame is quantized and encoded; and when the high frequency signal of the current frame is a TRANSIENT signal, quantizing and encoding the time envelopes, the frequency information, and the signal class information of the high frequency signal of the current frame; and when both the high frequency signal of the current frame and the high frequency signal of the previous frame are NON-TRANSIENT signals, quantizing and encoding the frequency information and the signal class information of the high frequency signal of the current frame; wherein the frequency information of the high frequency signal of the current frame includes at least one of the following: frequency envelopes of the high frequency signal of the current frame, global energy information of the high frequency signal of the current frame, and amplitude information of the high frequency signal of the current frame.