Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve seen this code referenced in two different places, yet I haven\'t seen any

ID: 652419 • Letter: I

Question

I've seen this code referenced in two different places, yet I haven't seen anybody bring this up, but it seems that on line 00339 there is an empty if block and I just copied the code to compile try it out but it won't even compile cause of that.

if (frame_count >= STREAM_NB_FRAMES) {
/* no more frame to compress. The codec has a latency of a few
    frames if using B frames, so we get the last frames by
    passing the same picture again */
} else {
Any idea or explanation why it is like that. Is it a mistake on the author's part when copying it? What is supposed to be going on in that if block anyways?

Explanation / Answer

There is no mistake. The if part of that block is indeed empty.

It is often easier to express the logic by making the if part empty and doing the work in the else part. In, this case, the if part has a comment specifically explaining why it is empty and why there is nothing to do.

The code is legal C and will compile fine.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote