summaryrefslogtreecommitdiff
path: root/vp10/vp10_cx_iface.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp10/vp10_cx_iface.c')
-rw-r--r--vp10/vp10_cx_iface.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/vp10/vp10_cx_iface.c b/vp10/vp10_cx_iface.c
index 304f74eee..409ed1ce2 100644
--- a/vp10/vp10_cx_iface.c
+++ b/vp10/vp10_cx_iface.c
@@ -91,7 +91,9 @@ struct vpx_codec_alg_priv {
size_t pending_cx_data_sz;
int pending_frame_count;
size_t pending_frame_sizes[8];
+#if !CONFIG_MISC_FIXES
size_t pending_frame_magnitude;
+#endif
vpx_image_t preview_img;
vpx_enc_frame_flags_t next_frame_flags;
vp8_postproc_cfg_t preview_ppcfg;
@@ -781,24 +783,39 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) {
uint8_t marker = 0xc0;
unsigned int mask;
int mag, index_sz;
+#if CONFIG_MISC_FIXES
+ int i;
+ size_t max_frame_sz = 0;
+#endif
assert(ctx->pending_frame_count);
assert(ctx->pending_frame_count <= 8);
// Add the number of frames to the marker byte
marker |= ctx->pending_frame_count - 1;
+#if CONFIG_MISC_FIXES
+ for (i = 0; i < ctx->pending_frame_count - 1; i++) {
+ const size_t frame_sz = (unsigned int) ctx->pending_frame_sizes[i];
+ max_frame_sz = frame_sz > max_frame_sz ? frame_sz : max_frame_sz;
+ }
+#endif
// Choose the magnitude
for (mag = 0, mask = 0xff; mag < 4; mag++) {
+#if CONFIG_MISC_FIXES
+ if (max_frame_sz <= mask)
+ break;
+#else
if (ctx->pending_frame_magnitude < mask)
break;
+#endif
mask <<= 8;
mask |= 0xff;
}
marker |= mag << 3;
// Write the index
- index_sz = 2 + (mag + 1) * ctx->pending_frame_count;
+ index_sz = 2 + (mag + 1) * (ctx->pending_frame_count - CONFIG_MISC_FIXES);
if (ctx->pending_cx_data_sz + index_sz < ctx->cx_data_sz) {
uint8_t *x = ctx->pending_cx_data + ctx->pending_cx_data_sz;
int i, j;
@@ -818,7 +835,7 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) {
#endif
*x++ = marker;
- for (i = 0; i < ctx->pending_frame_count; i++) {
+ for (i = 0; i < ctx->pending_frame_count - CONFIG_MISC_FIXES; i++) {
unsigned int this_sz = (unsigned int)ctx->pending_frame_sizes[i];
for (j = 0; j <= mag; j++) {
@@ -974,7 +991,9 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
ctx->pending_cx_data = cx_data;
ctx->pending_cx_data_sz += size;
ctx->pending_frame_sizes[ctx->pending_frame_count++] = size;
+#if !CONFIG_MISC_FIXES
ctx->pending_frame_magnitude |= size;
+#endif
cx_data += size;
cx_data_sz -= size;
@@ -991,7 +1010,9 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
ctx->pending_cx_data = NULL;
ctx->pending_cx_data_sz = 0;
ctx->pending_frame_count = 0;
+#if !CONFIG_MISC_FIXES
ctx->pending_frame_magnitude = 0;
+#endif
ctx->output_cx_pkt_cb.output_cx_pkt(
&pkt, ctx->output_cx_pkt_cb.user_priv);
}
@@ -1008,7 +1029,9 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
if (ctx->pending_cx_data) {
ctx->pending_frame_sizes[ctx->pending_frame_count++] = size;
+#if !CONFIG_MISC_FIXES
ctx->pending_frame_magnitude |= size;
+#endif
ctx->pending_cx_data_sz += size;
// write the superframe only for the case when
if (!ctx->output_cx_pkt_cb.output_cx_pkt)
@@ -1018,7 +1041,9 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
ctx->pending_cx_data = NULL;
ctx->pending_cx_data_sz = 0;
ctx->pending_frame_count = 0;
+#if !CONFIG_MISC_FIXES
ctx->pending_frame_magnitude = 0;
+#endif
} else {
pkt.data.frame.buf = cx_data;
pkt.data.frame.sz = size;