Chipmakers Ambarella (AMBA -2.79%) and AMD (AMD 0.69%) had dramatically diverging fortunes over the past year. Ambarella, which makes image processing chips for a wide range of cameras, shed more than 30% of its market value over the past 12 months. AMD, which sells CPUs and GPUs, rallied over 90%.

Therefore, investors might be wondering if the market is too bearish on Ambarella and too bullish on AMD. Let's take a closer look at both chipmakers to see which stock is the better buy at current prices.

An Ambarella SoC floating over the earth.

Image source: Ambarella.

What do Ambarella and AMD do?

Ambarella supplies image processing SoCs to a wide variety of customers, including GoPro (GPRO -0.57%), DJI Innovations, and Hikvision -- which are respectively the largest makers of action cameras, drones, and security cameras in the world.

Ambarella is considered the "best in breed" player in that market, but it's being challenged by cheaper chips in China, mobile-based SoCs from Qualcomm, and first-party custom chips from big customers like GoPro.

AMD is the second largest manufacturer of x86 CPUs and discrete GPUs in the world. It mainly competes against Intel (INTC -1.79%) in the CPU market and NVIDIA (NVDA 0.76%) in the GPU market. It also produces embedded SoCs for non-PC devices like gaming consoles.

In the past, AMD struggled to counter Intel and NVIDIA's latest chips. But under CEO Lisa Su, who took over in late 2014, AMD launched new CPUs and GPUs which compared favorably to Intel and NVIDIA's chips again. It also invested more heavily in adjacent markets like data centers and connected cars.

How fast are Ambarella and AMD growing?

Ambarella's revenue fell 2% to $310 million last year, and analysts anticipate another 5% decline this year. Those declines were attributed to sluggish sales of action cameras, drones, and the decision by DJI to not install Ambarella SoCs in its cheaper Spark drones.

CFO George Laplante also warned of a "substantial decline" in GoPro revenues last quarter. That was recently confirmed when GoPro revealed that its latest camera, the Hero 6, would use a custom designed GP1 SoC instead of Ambarella's chip. Meanwhile, sales of Ambarella's SoCs for security cameras continues to face pressure from cheaper Chinese chipmakers.

AMD's Ryzen Pro CPU.

Image source: AMD.

AMD's revenue rose 7% last year, and analysts expect 18% growth this year. That bullish sentiment can be attributed to AMD's recent introduction of Ryzen, a next-gen CPU that offers performance comparable to that of Intel's higher-end processors at about half the price. Its new Vega GPUs are also expected to help AMD keep pace with NVIDIA's current-gen Pascal GPUs.

AMD's EESC (Enterprise, Embedded, and Semi-Custom) business should also benefit from the recent refreshes and upgrades for the PS4 and Xbox One, since it supplies custom SoCs for both consoles.

Which company is more profitable?

In terms of gross profit margins, Ambarella easily beats AMD because its chips cost much less to manufacture. Ambarella reported a gross margin of 62.6% last quarter, compared to AMD's 33%. However, Ambarella's gross margin declined 410 basis points annually due to the aforementioned competition, while AMD's rose 200 basis points.

Ambarella and AMD both have thin operating margins. But if we compare those results on a quarterly basis, AMD has steadily expanded its gross margins over the past three years, while Ambarella's margins gradually deteriorated.

AMBA Operating Margin (Quarterly) Chart

Source: YCharts

As a result, analysts expect AMD to report a full-year non-GAAP profit this year, compared to net losses over the past two years. Ambarella's non-GAAP earnings are expected to fall 35% this year.

Which stock is fundamentally cheaper?

Ambarella trades at 32.1 times earnings, which is higher than the industry average of 25.2 for semiconductor equipment companies. Its P/S ratio of 5.3 is also slightly higher than the industry average of 4.8.

AMD doesn't have a P/E ratio due to its lack of consistent profits, but it trades at 51 times next year's earnings -- which remains higher than the industry average of 24 for semiconductor companies. On a revenue basis, it trades at 2.6 times sales, compared to the industry average of 4.2. This indicates that neither stock can be considered a "cheap" play at current prices.

The winner: AMD

My Foolish colleague Chris Neiger compared Ambarella and AMD about a half year ago, and concluded that AMD had a better business but the stock was tough to recommend after its massive gains.

I have a similar opinion about both stocks -- investors should clearly avoid Ambarella, but remain cautiously optimistic about AMD. I might nibble on AMD shares during a big pullback, but I'm not eager to load up on the stock in this frothy market just yet.