Use the continue statement in while loop
The while loop near the end of encoder_encode() has a very long
"if (frame_size)" statement that extends to the end of the loop body.
Replace that with "if (!frame_size) continue;"
Change-Id: Id0a69c8d31f533b1cc76f5b8b67e4f3e56398fbc
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 89390d2..ec0223e 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -2361,60 +2361,59 @@
}
cpi->seq_params_locked = 1;
- if (frame_size) {
- assert(cx_data != NULL && cx_data_sz != 0);
- const int write_temporal_delimiter =
- !cpi->common.spatial_layer_id && !ctx->pending_cx_data_sz;
+ if (!frame_size) continue;
+ assert(cx_data != NULL && cx_data_sz != 0);
+ const int write_temporal_delimiter =
+ !cpi->common.spatial_layer_id && !ctx->pending_cx_data_sz;
- if (write_temporal_delimiter) {
- uint32_t obu_header_size = 1;
- const uint32_t obu_payload_size = 0;
- const size_t length_field_size =
- aom_uleb_size_in_bytes(obu_payload_size);
+ if (write_temporal_delimiter) {
+ uint32_t obu_header_size = 1;
+ const uint32_t obu_payload_size = 0;
+ const size_t length_field_size =
+ aom_uleb_size_in_bytes(obu_payload_size);
- const size_t move_offset = obu_header_size + length_field_size;
- memmove(ctx->cx_data + move_offset, ctx->cx_data, frame_size);
- obu_header_size = av1_write_obu_header(
- &cpi->level_params, OBU_TEMPORAL_DELIMITER, 0, ctx->cx_data);
+ const size_t move_offset = obu_header_size + length_field_size;
+ memmove(ctx->cx_data + move_offset, ctx->cx_data, frame_size);
+ obu_header_size = av1_write_obu_header(
+ &cpi->level_params, OBU_TEMPORAL_DELIMITER, 0, ctx->cx_data);
- // OBUs are preceded/succeeded by an unsigned leb128 coded integer.
- if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size,
- ctx->cx_data) != AOM_CODEC_OK) {
- aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
- }
-
- frame_size += obu_header_size + obu_payload_size + length_field_size;
+ // OBUs are preceded/succeeded by an unsigned leb128 coded integer.
+ if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size,
+ ctx->cx_data) != AOM_CODEC_OK) {
+ aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
}
- if (ctx->oxcf.save_as_annexb) {
- size_t curr_frame_size = frame_size;
- if (av1_convert_sect5obus_to_annexb(cx_data, &curr_frame_size) !=
- AOM_CODEC_OK) {
- aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
- }
- frame_size = curr_frame_size;
-
- // B_PRIME (add frame size)
- const size_t length_field_size = aom_uleb_size_in_bytes(frame_size);
- memmove(cx_data + length_field_size, cx_data, frame_size);
- if (av1_write_uleb_obu_size(0, (uint32_t)frame_size, cx_data) !=
- AOM_CODEC_OK) {
- aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
- }
- frame_size += length_field_size;
- }
-
- ctx->pending_cx_data_sz += frame_size;
-
- cx_data += frame_size;
- cx_data_sz -= frame_size;
-
- is_frame_visible = cpi->common.show_frame;
-
- has_no_show_keyframe |=
- (!is_frame_visible &&
- cpi->common.current_frame.frame_type == KEY_FRAME);
+ frame_size += obu_header_size + obu_payload_size + length_field_size;
}
+
+ if (ctx->oxcf.save_as_annexb) {
+ size_t curr_frame_size = frame_size;
+ if (av1_convert_sect5obus_to_annexb(cx_data, &curr_frame_size) !=
+ AOM_CODEC_OK) {
+ aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
+ }
+ frame_size = curr_frame_size;
+
+ // B_PRIME (add frame size)
+ const size_t length_field_size = aom_uleb_size_in_bytes(frame_size);
+ memmove(cx_data + length_field_size, cx_data, frame_size);
+ if (av1_write_uleb_obu_size(0, (uint32_t)frame_size, cx_data) !=
+ AOM_CODEC_OK) {
+ aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR, NULL);
+ }
+ frame_size += length_field_size;
+ }
+
+ ctx->pending_cx_data_sz += frame_size;
+
+ cx_data += frame_size;
+ cx_data_sz -= frame_size;
+
+ is_frame_visible = cpi->common.show_frame;
+
+ has_no_show_keyframe |=
+ (!is_frame_visible &&
+ cpi->common.current_frame.frame_type == KEY_FRAME);
}
if (is_frame_visible) {
// Add the frame packet to the list of returned packets.