A stereo encoding method, comprising: performing downmix processing on a left channel signal of a current frame and a right channel signal of the current frame, to obtain a primary channel signal of the current frame and a secondary channel signal of the current frame; and when determining to perform differential encoding on a pitch period of the secondary channel signal, performing differential encoding on the pitch period of the secondary channel signal by using an estimated pitch period value of the primary channel signal, to obtain a pitch period index value of the secondary channel signal, wherein the pitch period index value of the secondary channel signal is used to generate a to-be-sent stereo encoded bitstream, wherein the performing differential encoding on the pitch period of the secondary channel signal by using an estimated pitch period value of the primary channel signal, to obtain a pitch period index value of the secondary channel signal comprises: performing secondary channel signal closed-loop pitch period search based on the estimated pitch period value of the primary channel signal, to obtain an estimated pitch period value of the secondary channel signal; determining an upper limit of the pitch period index value of the secondary channel signal based on a pitch period search range adjustment factor of the secondary channel signal; and calculating the pitch period index value of the secondary channel signal based on the estimated pitch period value of the primary channel signal, the estimated pitch period value of the secondary channel signal, and the upper limit of the pitch period index value of the secondary channel signal. performing downmix processing on a left channel signal of a current frame and a right channel signal of the current frame, to obtain a primary channel signal of the current frame and a secondary channel signal of the current frame; and when determining to perform differential encoding on a pitch period of the secondary channel signal, performing differential encoding on the pitch period of the secondary channel signal by using an estimated pitch period value of the primary channel signal, to obtain a pitch period index value of the secondary channel signal, wherein the pitch period index value of the secondary channel signal is used to generate a to-be-sent stereo encoded bitstream, wherein the performing differential encoding on the pitch period of the secondary channel signal by using an estimated pitch period value of the primary channel signal, to obtain a pitch period index value of the secondary channel signal comprises: performing secondary channel signal closed-loop pitch period search based on the estimated pitch period value of the primary channel signal, to obtain an estimated pitch period value of the secondary channel signal; determining an upper limit of the pitch period index value of the secondary channel signal based on a pitch period search range adjustment factor of the secondary channel signal; and calculating the pitch period index value of the secondary channel signal based on the estimated pitch period value of the primary channel signal, the estimated pitch period value of the secondary channel signal, and the upper limit of the pitch period index value of the secondary channel signal. performing secondary channel signal closed-loop pitch period search based on the estimated pitch period value of the primary channel signal, to obtain an estimated pitch period value of the secondary channel signal; determining an upper limit of the pitch period index value of the secondary channel signal based on a pitch period search range adjustment factor of the secondary channel signal; and calculating the pitch period index value of the secondary channel signal based on the estimated pitch period value of the primary channel signal, the estimated pitch period value of the secondary channel signal, and the upper limit of the pitch period index value of the secondary channel signal.