Every person who violates Section 313.1, other than subdivision (e), is punishable by fine of not more than two thousand dollars ($2,000), by imprisonment in the county jail for not more than one year, or by both that fine and imprisonment. However, if the person has been previously convicted of a violation of Section 313.1, other than subdivision (e), or of any section of Chapter 7.5 (commencing with Section 311) of Title 9 of Part 1 of this code, the person shall be punished by imprisonment pursuant to subdivision (h) of Section 1170.