Follow documented decoder API in apps and examples
The current logic in a few of the examples (including aomdec)
doesn't seem to follow the decoder API as documented in
aom/aom_decoder.h.
The decoder API suggests that, after each call to aom_codec_decode(),
we should repeatedly call aom_codec_get_frame() until it returns NULL.
But at the moment, some examples are only calling aom_codec_get_frame()
once, relying on the fact that the decoder currently produces at most
one output frame for each call to aom_codec_decode().
However, this assumption will soon be false, per the linked issue.
So we need to transform the logic from (schematically)
'img = ...; if (img) { do stuff }'
to
'while ((img = ...)) { do stuff }'
BUG=aomedia:1941
Change-Id: Id0c24437afa0c49974aa74c112c94d225721665c
diff --git a/examples/inspect.c b/examples/inspect.c
index 2b459e1..4887fc4 100644
--- a/examples/inspect.c
+++ b/examples/inspect.c
@@ -629,11 +629,14 @@
AOM_CODEC_OK) {
die_codec(&codec, "Failed to decode frame.");
}
- img = aom_codec_get_frame(&codec, &iter);
- if (img == NULL) {
+ int got_any_frames = 0;
+ while ((img = aom_codec_get_frame(&codec, &iter))) {
+ ++frame_count;
+ got_any_frames = 1;
+ }
+ if (!got_any_frames) {
return EXIT_FAILURE;
}
- ++frame_count;
return EXIT_SUCCESS;
}