2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-02-10 20:41:38 +01:00
|
|
|
#include "vp8/common/header.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "encodemv.h"
|
2011-02-10 20:41:38 +01:00
|
|
|
#include "vp8/common/entropymode.h"
|
|
|
|
#include "vp8/common/findnearmv.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "mcomp.h"
|
2011-02-10 20:41:38 +01:00
|
|
|
#include "vp8/common/systemdependent.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
2011-06-10 11:11:15 +02:00
|
|
|
#include <limits.h>
|
2011-02-10 20:41:38 +01:00
|
|
|
#include "vp8/common/pragmas.h"
|
2011-06-10 11:11:15 +02:00
|
|
|
#include "vpx/vpx_encoder.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
|
|
|
#include "bitstream.h"
|
2011-08-16 22:21:21 +02:00
|
|
|
|
|
|
|
#include "defaultcoefcounts.h"
|
2011-10-05 12:26:00 +02:00
|
|
|
|
|
|
|
#include "vp8/common/seg_common.h"
|
2012-01-28 11:24:43 +01:00
|
|
|
#include "vp8/common/pred_common.h"
|
2011-10-05 12:26:00 +02:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
#if defined(SECTIONBITS_OUTPUT)
|
|
|
|
unsigned __int64 Sectionbits[500];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
int intra_mode_stats[10][10][10];
|
2011-06-28 23:03:47 +02:00
|
|
|
static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] [2];
|
2011-02-14 23:18:18 +01:00
|
|
|
static unsigned int tree_update_hist_8x8 [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] [2];
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
extern unsigned int active_section;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MODE_STATS
|
|
|
|
int count_mb_seg[4] = { 0, 0, 0, 0 };
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void update_mode(
|
|
|
|
vp8_writer *const w,
|
|
|
|
int n,
|
|
|
|
vp8_token tok [/* n */],
|
|
|
|
vp8_tree tree,
|
|
|
|
vp8_prob Pnew [/* n-1 */],
|
|
|
|
vp8_prob Pcur [/* n-1 */],
|
|
|
|
unsigned int bct [/* n-1 */] [2],
|
|
|
|
const unsigned int num_events[/* n */]
|
|
|
|
)
|
|
|
|
{
|
|
|
|
unsigned int new_b = 0, old_b = 0;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
vp8_tree_probs_from_distribution(
|
|
|
|
n--, tok, tree,
|
|
|
|
Pnew, bct, num_events,
|
|
|
|
256, 1
|
|
|
|
);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
new_b += vp8_cost_branch(bct[i], Pnew[i]);
|
|
|
|
old_b += vp8_cost_branch(bct[i], Pcur[i]);
|
|
|
|
}
|
|
|
|
while (++i < n);
|
|
|
|
|
|
|
|
if (new_b + (n << 8) < old_b)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
vp8_write_bit(w, 1);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const vp8_prob p = Pnew[i];
|
|
|
|
|
|
|
|
vp8_write_literal(w, Pcur[i] = p ? p : 1, 8);
|
|
|
|
}
|
|
|
|
while (++i < n);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(w, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_mbintra_mode_probs(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
VP8_COMMON *const x = & cpi->common;
|
|
|
|
|
|
|
|
vp8_writer *const w = & cpi->bc;
|
|
|
|
|
|
|
|
{
|
|
|
|
vp8_prob Pnew [VP8_YMODES-1];
|
|
|
|
unsigned int bct [VP8_YMODES-1] [2];
|
|
|
|
|
|
|
|
update_mode(
|
|
|
|
w, VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
|
|
|
|
Pnew, x->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count
|
|
|
|
);
|
|
|
|
}
|
|
|
|
{
|
2011-12-08 20:43:09 +01:00
|
|
|
#if CONFIG_UVINTRA
|
|
|
|
//vp8_write_bit(w, 0);
|
|
|
|
#else
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_prob Pnew [VP8_UV_MODES-1];
|
|
|
|
unsigned int bct [VP8_UV_MODES-1] [2];
|
|
|
|
update_mode(
|
|
|
|
w, VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
|
|
|
|
Pnew, x->fc.uv_mode_prob, bct, (unsigned int *)cpi->uv_mode_count
|
|
|
|
);
|
2011-12-08 20:43:09 +01:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_ymode(vp8_writer *bc, int m, const vp8_prob *p)
|
|
|
|
{
|
|
|
|
vp8_write_token(bc, vp8_ymode_tree, p, vp8_ymode_encodings + m);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void kfwrite_ymode(vp8_writer *bc, int m, const vp8_prob *p)
|
|
|
|
{
|
|
|
|
vp8_write_token(bc, vp8_kf_ymode_tree, p, vp8_kf_ymode_encodings + m);
|
|
|
|
}
|
|
|
|
|
2011-08-05 01:30:27 +02:00
|
|
|
static void write_i8x8_mode(vp8_writer *bc, int m, const vp8_prob *p)
|
|
|
|
{
|
|
|
|
vp8_write_token(bc,vp8_i8x8_mode_tree, p, vp8_i8x8_mode_encodings + m);
|
|
|
|
}
|
2011-12-07 22:03:57 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
static void write_uv_mode(vp8_writer *bc, int m, const vp8_prob *p)
|
|
|
|
{
|
|
|
|
vp8_write_token(bc, vp8_uv_mode_tree, p, vp8_uv_mode_encodings + m);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_bmode(vp8_writer *bc, int m, const vp8_prob *p)
|
|
|
|
{
|
|
|
|
vp8_write_token(bc, vp8_bmode_tree, p, vp8_bmode_encodings + m);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_split(vp8_writer *bc, int x)
|
|
|
|
{
|
|
|
|
vp8_write_token(
|
|
|
|
bc, vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + x
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
|
|
|
|
{
|
|
|
|
const TOKENEXTRA *const stop = p + xcount;
|
|
|
|
unsigned int split;
|
|
|
|
unsigned int shift;
|
|
|
|
int count = w->count;
|
|
|
|
unsigned int range = w->range;
|
|
|
|
unsigned int lowvalue = w->lowvalue;
|
|
|
|
|
|
|
|
while (p < stop)
|
|
|
|
{
|
|
|
|
const int t = p->Token;
|
|
|
|
vp8_token *const a = vp8_coef_encodings + t;
|
|
|
|
const vp8_extra_bit_struct *const b = vp8_extra_bits + t;
|
|
|
|
int i = 0;
|
|
|
|
const unsigned char *pp = p->context_tree;
|
|
|
|
int v = a->value;
|
|
|
|
int n = a->Len;
|
|
|
|
|
|
|
|
if (p->skip_eob_node)
|
|
|
|
{
|
|
|
|
n--;
|
|
|
|
i = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const int bb = (v >> --n) & 1;
|
|
|
|
split = 1 + (((range - 1) * pp[i>>1]) >> 8);
|
|
|
|
i = vp8_coef_tree[i+bb];
|
|
|
|
|
|
|
|
if (bb)
|
|
|
|
{
|
|
|
|
lowvalue += split;
|
|
|
|
range = range - split;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
range = split;
|
|
|
|
}
|
|
|
|
|
2011-07-19 15:17:25 +02:00
|
|
|
shift = vp8_norm[range];
|
2010-05-18 17:58:33 +02:00
|
|
|
range <<= shift;
|
|
|
|
count += shift;
|
|
|
|
|
|
|
|
if (count >= 0)
|
|
|
|
{
|
|
|
|
int offset = shift - count;
|
|
|
|
|
|
|
|
if ((lowvalue << (offset - 1)) & 0x80000000)
|
|
|
|
{
|
|
|
|
int x = w->pos - 1;
|
|
|
|
|
|
|
|
while (x >= 0 && w->buffer[x] == 0xff)
|
|
|
|
{
|
|
|
|
w->buffer[x] = (unsigned char)0;
|
|
|
|
x--;
|
|
|
|
}
|
|
|
|
|
|
|
|
w->buffer[x] += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
w->buffer[w->pos++] = (lowvalue >> (24 - offset));
|
|
|
|
lowvalue <<= offset;
|
|
|
|
shift = count;
|
|
|
|
lowvalue &= 0xffffff;
|
|
|
|
count -= 8 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
lowvalue <<= shift;
|
|
|
|
}
|
|
|
|
while (n);
|
|
|
|
|
|
|
|
|
|
|
|
if (b->base_val)
|
|
|
|
{
|
|
|
|
const int e = p->Extra, L = b->Len;
|
|
|
|
|
|
|
|
if (L)
|
|
|
|
{
|
|
|
|
const unsigned char *pp = b->prob;
|
|
|
|
int v = e >> 1;
|
|
|
|
int n = L; /* number of bits in v, assumed nonzero */
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const int bb = (v >> --n) & 1;
|
|
|
|
split = 1 + (((range - 1) * pp[i>>1]) >> 8);
|
|
|
|
i = b->tree[i+bb];
|
|
|
|
|
|
|
|
if (bb)
|
|
|
|
{
|
|
|
|
lowvalue += split;
|
|
|
|
range = range - split;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
range = split;
|
|
|
|
}
|
|
|
|
|
2011-07-19 15:17:25 +02:00
|
|
|
shift = vp8_norm[range];
|
2010-05-18 17:58:33 +02:00
|
|
|
range <<= shift;
|
|
|
|
count += shift;
|
|
|
|
|
|
|
|
if (count >= 0)
|
|
|
|
{
|
|
|
|
int offset = shift - count;
|
|
|
|
|
|
|
|
if ((lowvalue << (offset - 1)) & 0x80000000)
|
|
|
|
{
|
|
|
|
int x = w->pos - 1;
|
|
|
|
|
|
|
|
while (x >= 0 && w->buffer[x] == 0xff)
|
|
|
|
{
|
|
|
|
w->buffer[x] = (unsigned char)0;
|
|
|
|
x--;
|
|
|
|
}
|
|
|
|
|
|
|
|
w->buffer[x] += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
w->buffer[w->pos++] = (lowvalue >> (24 - offset));
|
|
|
|
lowvalue <<= offset;
|
|
|
|
shift = count;
|
|
|
|
lowvalue &= 0xffffff;
|
|
|
|
count -= 8 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
lowvalue <<= shift;
|
|
|
|
}
|
|
|
|
while (n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
split = (range + 1) >> 1;
|
|
|
|
|
|
|
|
if (e & 1)
|
|
|
|
{
|
|
|
|
lowvalue += split;
|
|
|
|
range = range - split;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
range = split;
|
|
|
|
}
|
|
|
|
|
|
|
|
range <<= 1;
|
|
|
|
|
|
|
|
if ((lowvalue & 0x80000000))
|
|
|
|
{
|
|
|
|
int x = w->pos - 1;
|
|
|
|
|
|
|
|
while (x >= 0 && w->buffer[x] == 0xff)
|
|
|
|
{
|
|
|
|
w->buffer[x] = (unsigned char)0;
|
|
|
|
x--;
|
|
|
|
}
|
|
|
|
|
|
|
|
w->buffer[x] += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
lowvalue <<= 1;
|
|
|
|
|
|
|
|
if (!++count)
|
|
|
|
{
|
|
|
|
count = -8;
|
|
|
|
w->buffer[w->pos++] = (lowvalue >> 24);
|
|
|
|
lowvalue &= 0xffffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
w->count = count;
|
|
|
|
w->lowvalue = lowvalue;
|
|
|
|
w->range = range;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_partition_size(unsigned char *cx_data, int size)
|
|
|
|
{
|
|
|
|
signed char csize;
|
|
|
|
|
|
|
|
csize = size & 0xff;
|
|
|
|
*cx_data = csize;
|
|
|
|
csize = (size >> 8) & 0xff;
|
|
|
|
*(cx_data + 1) = csize;
|
|
|
|
csize = (size >> 16) & 0xff;
|
|
|
|
*(cx_data + 2) = csize;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_mv_ref
|
|
|
|
(
|
|
|
|
vp8_writer *w, MB_PREDICTION_MODE m, const vp8_prob *p
|
|
|
|
)
|
|
|
|
{
|
2011-06-07 15:34:47 +02:00
|
|
|
#if CONFIG_DEBUG
|
2010-05-18 17:58:33 +02:00
|
|
|
assert(NEARESTMV <= m && m <= SPLITMV);
|
2011-06-07 15:34:47 +02:00
|
|
|
#endif
|
2010-08-09 19:27:26 +02:00
|
|
|
vp8_write_token(w, vp8_mv_ref_tree, p,
|
|
|
|
vp8_mv_ref_encoding_array - NEARESTMV + m);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_sub_mv_ref
|
|
|
|
(
|
|
|
|
vp8_writer *w, B_PREDICTION_MODE m, const vp8_prob *p
|
|
|
|
)
|
|
|
|
{
|
2011-06-07 15:34:47 +02:00
|
|
|
#if CONFIG_DEBUG
|
2010-05-18 17:58:33 +02:00
|
|
|
assert(LEFT4X4 <= m && m <= NEW4X4);
|
2011-06-07 15:34:47 +02:00
|
|
|
#endif
|
2010-08-09 19:27:26 +02:00
|
|
|
vp8_write_token(w, vp8_sub_mv_ref_tree, p,
|
|
|
|
vp8_sub_mv_ref_encoding_array - LEFT4X4 + m);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_mv
|
|
|
|
(
|
2011-05-12 16:50:16 +02:00
|
|
|
vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT *mvc
|
2010-05-18 17:58:33 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
MV e;
|
2011-05-12 16:50:16 +02:00
|
|
|
e.row = mv->row - ref->as_mv.row;
|
|
|
|
e.col = mv->col - ref->as_mv.col;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
vp8_encode_motion_vector(w, &e, mvc);
|
|
|
|
}
|
|
|
|
|
2012-02-27 19:22:38 +01:00
|
|
|
#if CONFIG_HIGH_PRECISION_MV
|
|
|
|
static void write_mv_hp
|
|
|
|
(
|
|
|
|
vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT_HP *mvc
|
|
|
|
)
|
|
|
|
{
|
|
|
|
MV e;
|
|
|
|
e.row = mv->row - ref->as_mv.row;
|
|
|
|
e.col = mv->col - ref->as_mv.col;
|
|
|
|
|
|
|
|
vp8_encode_motion_vector_hp(w, &e, mvc);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-11 11:10:06 +01:00
|
|
|
// This function writes the current macro block's segnment id to the bitstream
|
|
|
|
// It should only be called if a segment map update is indicated.
|
|
|
|
static void write_mb_segid(vp8_writer *w,
|
|
|
|
const MB_MODE_INFO *mi, const MACROBLOCKD *x)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
// Encode the MB segment id.
|
|
|
|
if (x->segmentation_enabled && x->update_mb_segmentation_map)
|
|
|
|
{
|
|
|
|
switch (mi->segment_id)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
vp8_write(w, 0, x->mb_segment_tree_probs[0]);
|
|
|
|
vp8_write(w, 0, x->mb_segment_tree_probs[1]);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
vp8_write(w, 0, x->mb_segment_tree_probs[0]);
|
|
|
|
vp8_write(w, 1, x->mb_segment_tree_probs[1]);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
vp8_write(w, 1, x->mb_segment_tree_probs[0]);
|
|
|
|
vp8_write(w, 0, x->mb_segment_tree_probs[2]);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
vp8_write(w, 1, x->mb_segment_tree_probs[0]);
|
|
|
|
vp8_write(w, 1, x->mb_segment_tree_probs[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// TRAP.. This should not happen
|
|
|
|
default:
|
|
|
|
vp8_write(w, 0, x->mb_segment_tree_probs[0]);
|
|
|
|
vp8_write(w, 0, x->mb_segment_tree_probs[1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-02 14:30:10 +01:00
|
|
|
// This function encodes the reference frame
|
|
|
|
static void encode_ref_frame( vp8_writer *const w,
|
2012-01-28 09:50:33 +01:00
|
|
|
VP8_COMMON *const cm,
|
2011-11-02 14:30:10 +01:00
|
|
|
MACROBLOCKD *xd,
|
|
|
|
int segment_id,
|
2012-01-28 09:50:33 +01:00
|
|
|
MV_REFERENCE_FRAME rf )
|
2011-11-02 14:30:10 +01:00
|
|
|
{
|
|
|
|
int seg_ref_active;
|
2012-01-31 13:45:30 +01:00
|
|
|
int seg_ref_count = 0;
|
2011-11-02 14:30:10 +01:00
|
|
|
seg_ref_active = segfeature_active( xd,
|
|
|
|
segment_id,
|
|
|
|
SEG_LVL_REF_FRAME );
|
|
|
|
|
2012-01-31 13:45:30 +01:00
|
|
|
if ( seg_ref_active )
|
|
|
|
{
|
|
|
|
seg_ref_count = check_segref( xd, segment_id, INTRA_FRAME ) +
|
|
|
|
check_segref( xd, segment_id, LAST_FRAME ) +
|
|
|
|
check_segref( xd, segment_id, GOLDEN_FRAME ) +
|
|
|
|
check_segref( xd, segment_id, ALTREF_FRAME );
|
|
|
|
}
|
|
|
|
|
2012-01-28 09:50:33 +01:00
|
|
|
// If segment level coding of this signal is disabled...
|
2012-01-31 13:45:30 +01:00
|
|
|
// or the segment allows multiple reference frame options
|
|
|
|
if ( !seg_ref_active || (seg_ref_count > 1) )
|
2011-11-02 14:30:10 +01:00
|
|
|
{
|
2012-01-28 13:20:14 +01:00
|
|
|
// Values used in prediction model coding
|
|
|
|
unsigned char prediction_flag;
|
|
|
|
vp8_prob pred_prob;
|
2012-02-03 14:46:18 +01:00
|
|
|
MV_REFERENCE_FRAME pred_rf;
|
2012-01-28 13:20:14 +01:00
|
|
|
|
|
|
|
// Get the context probability the prediction flag
|
|
|
|
pred_prob = get_pred_prob( cm, xd, PRED_REF );
|
|
|
|
|
2012-02-03 14:46:18 +01:00
|
|
|
// Get the predicted value.
|
|
|
|
pred_rf = get_pred_ref( cm, xd );
|
|
|
|
|
|
|
|
// Did the chosen reference frame match its predicted value.
|
|
|
|
prediction_flag =
|
|
|
|
( xd->mode_info_context->mbmi.ref_frame == pred_rf );
|
|
|
|
|
|
|
|
set_pred_flag( xd, PRED_REF, prediction_flag );
|
2012-01-28 13:20:14 +01:00
|
|
|
vp8_write( w, prediction_flag, pred_prob );
|
|
|
|
|
|
|
|
// If not predicted correctly then code value explicitly
|
|
|
|
if ( !prediction_flag )
|
|
|
|
{
|
2012-01-31 13:45:30 +01:00
|
|
|
vp8_prob mod_refprobs[PREDICTION_PROBS];
|
|
|
|
|
|
|
|
vpx_memcpy( mod_refprobs,
|
|
|
|
cm->mod_refprobs[pred_rf], sizeof(mod_refprobs) );
|
|
|
|
|
|
|
|
// If segment coding enabled blank out options that cant occur by
|
|
|
|
// setting the branch probability to 0.
|
|
|
|
if ( seg_ref_active )
|
|
|
|
{
|
|
|
|
mod_refprobs[INTRA_FRAME] *=
|
|
|
|
check_segref( xd, segment_id, INTRA_FRAME );
|
|
|
|
mod_refprobs[LAST_FRAME] *=
|
|
|
|
check_segref( xd, segment_id, LAST_FRAME );
|
|
|
|
mod_refprobs[GOLDEN_FRAME] *=
|
|
|
|
( check_segref( xd, segment_id, GOLDEN_FRAME ) *
|
|
|
|
check_segref( xd, segment_id, ALTREF_FRAME ) );
|
|
|
|
}
|
2012-01-28 13:20:14 +01:00
|
|
|
|
|
|
|
if ( mod_refprobs[0] )
|
|
|
|
{
|
|
|
|
vp8_write(w, (rf != INTRA_FRAME), mod_refprobs[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inter coded
|
|
|
|
if (rf != INTRA_FRAME)
|
|
|
|
{
|
|
|
|
if ( mod_refprobs[1] )
|
|
|
|
{
|
|
|
|
vp8_write(w, (rf != LAST_FRAME), mod_refprobs[1] );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rf != LAST_FRAME)
|
|
|
|
{
|
|
|
|
if ( mod_refprobs[2] )
|
|
|
|
{
|
|
|
|
vp8_write(w, (rf != GOLDEN_FRAME), mod_refprobs[2] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-02 14:30:10 +01:00
|
|
|
}
|
2012-01-31 13:45:30 +01:00
|
|
|
|
|
|
|
// if using the prediction mdoel we have nothing further to do because
|
|
|
|
// the reference frame is fully coded by the segment
|
2011-11-02 14:30:10 +01:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-03 14:46:18 +01:00
|
|
|
// Update the probabilities used to encode reference frame data
|
|
|
|
static void update_ref_probs( VP8_COMP *const cpi )
|
|
|
|
{
|
|
|
|
VP8_COMMON *const cm = & cpi->common;
|
|
|
|
|
|
|
|
const int *const rfct = cpi->count_mb_ref_frame_usage;
|
|
|
|
const int rf_intra = rfct[INTRA_FRAME];
|
|
|
|
const int rf_inter = rfct[LAST_FRAME] +
|
|
|
|
rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
|
|
|
|
|
|
|
|
cm->prob_intra_coded = (rf_intra + rf_inter)
|
|
|
|
? rf_intra * 255 / (rf_intra + rf_inter) : 1;
|
|
|
|
|
|
|
|
if (!cm->prob_intra_coded)
|
|
|
|
cm->prob_intra_coded = 1;
|
|
|
|
|
|
|
|
cm->prob_last_coded = rf_inter ? (rfct[LAST_FRAME] * 255) / rf_inter : 128;
|
|
|
|
|
|
|
|
if (!cm->prob_last_coded)
|
|
|
|
cm->prob_last_coded = 1;
|
|
|
|
|
|
|
|
cm->prob_gf_coded = (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME])
|
|
|
|
? (rfct[GOLDEN_FRAME] * 255) /
|
|
|
|
(rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]) : 128;
|
|
|
|
|
|
|
|
if (!cm->prob_gf_coded)
|
|
|
|
cm->prob_gf_coded = 1;
|
|
|
|
|
|
|
|
// Compute a modified set of probabilities to use when prediction of the
|
|
|
|
// reference frame fails
|
|
|
|
compute_mod_refprobs( cm );
|
|
|
|
}
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
static void pack_inter_mode_mvs(VP8_COMP *const cpi)
|
|
|
|
{
|
|
|
|
VP8_COMMON *const pc = & cpi->common;
|
|
|
|
vp8_writer *const w = & cpi->bc;
|
|
|
|
const MV_CONTEXT *mvc = pc->fc.mvc;
|
2012-02-27 19:22:38 +01:00
|
|
|
#if CONFIG_HIGH_PRECISION_MV
|
|
|
|
const MV_CONTEXT_HP *mvc_hp = pc->fc.mvc_hp;
|
|
|
|
#endif
|
2011-07-20 21:14:50 +02:00
|
|
|
MACROBLOCKD *xd = &cpi->mb.e_mbd;
|
2011-11-15 17:15:23 +01:00
|
|
|
|
2011-07-20 21:14:50 +02:00
|
|
|
int i;
|
2011-11-15 12:13:33 +01:00
|
|
|
int pred_context;
|
2011-11-15 17:15:23 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-11-16 01:16:30 +01:00
|
|
|
MODE_INFO *m = pc->mi;
|
|
|
|
MODE_INFO *prev_m = pc->prev_mi;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
const int mis = pc->mode_info_stride;
|
|
|
|
int mb_row = -1;
|
|
|
|
|
|
|
|
int prob_skip_false = 0;
|
2012-02-02 18:30:27 +01:00
|
|
|
|
2012-01-28 11:24:43 +01:00
|
|
|
// Values used in prediction model coding
|
|
|
|
vp8_prob pred_prob;
|
|
|
|
unsigned char prediction_flag;
|
|
|
|
|
2010-09-02 22:17:52 +02:00
|
|
|
cpi->mb.partition_info = cpi->mb.pi;
|
|
|
|
|
2012-02-03 14:46:18 +01:00
|
|
|
// Update the probabilities used to encode reference frame data
|
|
|
|
update_ref_probs( cpi );
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
active_section = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pc->mb_no_coeff_skip)
|
|
|
|
{
|
2011-10-28 16:27:23 +02:00
|
|
|
// Divide by 0 check. 0 case possible with segment features
|
|
|
|
if ( (cpi->skip_false_count + cpi->skip_true_count) )
|
|
|
|
{
|
|
|
|
prob_skip_false = cpi->skip_false_count * 256 /
|
|
|
|
(cpi->skip_false_count + cpi->skip_true_count);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-28 16:27:23 +02:00
|
|
|
if (prob_skip_false <= 1)
|
|
|
|
prob_skip_false = 1;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-28 16:27:23 +02:00
|
|
|
if (prob_skip_false > 255)
|
|
|
|
prob_skip_false = 255;
|
|
|
|
}
|
|
|
|
else
|
2010-05-18 17:58:33 +02:00
|
|
|
prob_skip_false = 255;
|
|
|
|
|
|
|
|
cpi->prob_skip_false = prob_skip_false;
|
|
|
|
vp8_write_literal(w, prob_skip_false, 8);
|
|
|
|
}
|
|
|
|
|
2012-01-28 09:50:33 +01:00
|
|
|
vp8_write_literal(w, pc->prob_intra_coded, 8);
|
|
|
|
vp8_write_literal(w, pc->prob_last_coded, 8);
|
|
|
|
vp8_write_literal(w, pc->prob_gf_coded, 8);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-29 02:25:45 +01:00
|
|
|
if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
{
|
|
|
|
vp8_write(w, 1, 128);
|
|
|
|
vp8_write(w, 1, 128);
|
2012-02-29 02:25:45 +01:00
|
|
|
for (i = 0; i < COMP_PRED_CONTEXTS; i++)
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
{
|
2012-02-29 02:25:45 +01:00
|
|
|
if (cpi->single_pred_count[i] + cpi->comp_pred_count[i])
|
2012-02-02 18:30:27 +01:00
|
|
|
{
|
2012-02-29 02:25:45 +01:00
|
|
|
pc->prob_comppred[i] = cpi->single_pred_count[i] * 255 /
|
|
|
|
(cpi->single_pred_count[i] + cpi->comp_pred_count[i]);
|
|
|
|
if (pc->prob_comppred[i] < 1)
|
|
|
|
pc->prob_comppred[i] = 1;
|
2012-02-08 16:52:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-29 02:25:45 +01:00
|
|
|
pc->prob_comppred[i] = 128;
|
2012-02-08 16:52:07 +01:00
|
|
|
}
|
2012-02-29 02:25:45 +01:00
|
|
|
vp8_write_literal(w, pc->prob_comppred[i], 8);
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
}
|
|
|
|
}
|
2012-02-29 02:25:45 +01:00
|
|
|
else if (cpi->common.comp_pred_mode == SINGLE_PREDICTION_ONLY)
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
{
|
|
|
|
vp8_write(w, 0, 128);
|
|
|
|
}
|
2012-02-29 02:25:45 +01:00
|
|
|
else /* compound prediction only */
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
{
|
|
|
|
vp8_write(w, 1, 128);
|
|
|
|
vp8_write(w, 0, 128);
|
|
|
|
}
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
update_mbintra_mode_probs(cpi);
|
|
|
|
|
2012-02-27 19:22:38 +01:00
|
|
|
#if CONFIG_HIGH_PRECISION_MV
|
|
|
|
if (xd->allow_high_precision_mv)
|
|
|
|
vp8_write_mvprobs_hp(cpi);
|
|
|
|
else
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_write_mvprobs(cpi);
|
2011-11-11 11:10:06 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
while (++mb_row < pc->mb_rows)
|
|
|
|
{
|
|
|
|
int mb_col = -1;
|
|
|
|
|
|
|
|
while (++mb_col < pc->mb_cols)
|
|
|
|
{
|
|
|
|
const MB_MODE_INFO *const mi = & m->mbmi;
|
|
|
|
const MV_REFERENCE_FRAME rf = mi->ref_frame;
|
|
|
|
const MB_PREDICTION_MODE mode = mi->mode;
|
2011-10-05 12:26:00 +02:00
|
|
|
const int segment_id = mi->segment_id;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
// Distance of Mb to the various image edges.
|
|
|
|
// These specified to 8th pel as they are always compared to MV values that are in 1/8th pel units
|
|
|
|
xd->mb_to_left_edge = -((mb_col * 16) << 3);
|
|
|
|
xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
|
|
|
|
xd->mb_to_top_edge = -((mb_row * 16)) << 3;
|
|
|
|
xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
|
2011-11-02 14:30:10 +01:00
|
|
|
|
|
|
|
// Make sure the MacroBlockD mode info pointer is set correctly
|
|
|
|
xd->mode_info_context = m;
|
2012-01-28 11:24:43 +01:00
|
|
|
|
2011-11-16 01:16:30 +01:00
|
|
|
xd->prev_mode_info_context = prev_m;
|
2011-11-02 14:30:10 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
active_section = 9;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (cpi->mb.e_mbd.update_mb_segmentation_map)
|
2010-09-01 02:43:14 +02:00
|
|
|
{
|
2011-11-15 16:22:26 +01:00
|
|
|
// Is temporal coding of the segment map enabled
|
2012-01-27 19:29:07 +01:00
|
|
|
if (pc->temporal_update)
|
2010-09-01 02:43:14 +02:00
|
|
|
{
|
2012-01-28 11:24:43 +01:00
|
|
|
prediction_flag =
|
|
|
|
get_pred_flag( xd, PRED_SEG_ID );
|
|
|
|
pred_prob =
|
|
|
|
get_pred_prob( pc, xd, PRED_SEG_ID);
|
|
|
|
|
|
|
|
// Code the segment id prediction flag for this mb
|
|
|
|
vp8_write( w, prediction_flag, pred_prob );
|
2011-11-15 16:22:26 +01:00
|
|
|
|
|
|
|
// If the mbs segment id was not predicted code explicitly
|
2012-01-28 11:24:43 +01:00
|
|
|
if (!prediction_flag)
|
2011-11-11 11:10:06 +01:00
|
|
|
write_mb_segid(w, mi, &cpi->mb.e_mbd);
|
2010-09-01 02:43:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-15 16:22:26 +01:00
|
|
|
// Normal undpredicted coding
|
2011-11-11 11:10:06 +01:00
|
|
|
write_mb_segid(w, mi, &cpi->mb.e_mbd);
|
2010-09-01 02:43:14 +02:00
|
|
|
}
|
2010-09-24 00:25:33 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-05 12:26:00 +02:00
|
|
|
if ( pc->mb_no_coeff_skip &&
|
|
|
|
( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
|
2011-11-03 17:58:26 +01:00
|
|
|
( get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0 ) ) )
|
2011-10-05 12:26:00 +02:00
|
|
|
{
|
|
|
|
vp8_encode_bool(w, mi->mb_skip_coeff, prob_skip_false);
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-11-02 14:30:10 +01:00
|
|
|
// Encode the reference frame.
|
2012-01-28 09:50:33 +01:00
|
|
|
encode_ref_frame( w, pc, xd,
|
|
|
|
segment_id, rf );
|
2011-11-02 14:30:10 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
if (rf == INTRA_FRAME)
|
|
|
|
{
|
2012-02-27 19:22:38 +01:00
|
|
|
#ifdef ENTROPY_STATS
|
2010-05-18 17:58:33 +02:00
|
|
|
active_section = 6;
|
2012-02-27 19:22:38 +01:00
|
|
|
#endif
|
2011-11-02 14:30:10 +01:00
|
|
|
|
|
|
|
if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
|
|
|
|
write_ymode(w, mode, pc->fc.ymode_prob);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
if (mode == B_PRED)
|
|
|
|
{
|
2012-03-06 18:52:15 +01:00
|
|
|
int j = 0;
|
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
|
|
|
int uses_second = m->bmi[0].as_mode.second != (B_PREDICTION_MODE) (B_DC_PRED - 1);
|
2012-03-02 20:18:24 +01:00
|
|
|
vp8_write(w, uses_second, 128);
|
2012-03-06 18:52:15 +01:00
|
|
|
#endif
|
2012-02-29 02:12:08 +01:00
|
|
|
do {
|
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
|
|
|
B_PREDICTION_MODE mode2 = m->bmi[j].as_mode.second;
|
|
|
|
#endif
|
|
|
|
write_bmode(w, m->bmi[j].as_mode.first, pc->fc.bmode_prob);
|
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
2012-03-02 20:18:24 +01:00
|
|
|
if (uses_second)
|
2012-02-29 02:12:08 +01:00
|
|
|
{
|
|
|
|
write_bmode(w, mode2, pc->fc.bmode_prob);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} while (++j < 16);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-12-01 01:25:00 +01:00
|
|
|
if(mode == I8X8_PRED)
|
|
|
|
{
|
2012-02-29 02:12:08 +01:00
|
|
|
write_i8x8_mode(w, m->bmi[0].as_mode.first, pc->i8x8_mode_prob);
|
|
|
|
write_i8x8_mode(w, m->bmi[2].as_mode.first, pc->i8x8_mode_prob);
|
|
|
|
write_i8x8_mode(w, m->bmi[8].as_mode.first, pc->i8x8_mode_prob);
|
|
|
|
write_i8x8_mode(w, m->bmi[10].as_mode.first, pc->i8x8_mode_prob);
|
2011-12-01 01:25:00 +01:00
|
|
|
}
|
|
|
|
else
|
2011-12-08 20:43:09 +01:00
|
|
|
{
|
|
|
|
#if CONFIG_UVINTRA
|
|
|
|
write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob[mode]);
|
|
|
|
#ifdef MODE_STATS
|
|
|
|
if(mode!=B_PRED)
|
|
|
|
++cpi->y_uv_mode_count[mode][mi->uv_mode];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
2011-12-07 22:03:57 +01:00
|
|
|
write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob);
|
2011-12-08 20:43:09 +01:00
|
|
|
#endif /*CONFIG_UVINTRA*/
|
|
|
|
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-11-02 14:30:10 +01:00
|
|
|
else
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-05-12 16:50:16 +02:00
|
|
|
int_mv best_mv;
|
2011-12-06 21:03:42 +01:00
|
|
|
int ct[4];
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_prob mv_ref_p [VP8_MVREFS-1];
|
|
|
|
|
|
|
|
{
|
2011-05-12 16:50:16 +02:00
|
|
|
int_mv n1, n2;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-11-16 01:16:30 +01:00
|
|
|
vp8_find_near_mvs(xd, m,
|
|
|
|
prev_m,
|
|
|
|
&n1, &n2, &best_mv, ct, rf, cpi->common.ref_frame_sign_bias);
|
2011-12-06 21:03:42 +01:00
|
|
|
vp8_mv_ref_probs(&cpi->common, mv_ref_p, ct);
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
accum_mv_refs(mode, ct);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
active_section = 3;
|
|
|
|
#endif
|
|
|
|
|
2012-01-27 19:29:07 +01:00
|
|
|
// Is the segment coding of mode enabled
|
2011-10-05 12:26:00 +02:00
|
|
|
if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-09-30 17:45:16 +02:00
|
|
|
write_mv_ref(w, mode, mv_ref_p);
|
2011-12-06 21:03:42 +01:00
|
|
|
vp8_accum_mv_refs(&cpi->common, mode, ct);
|
2011-11-02 14:30:10 +01:00
|
|
|
}
|
2011-11-03 13:50:09 +01:00
|
|
|
|
2011-11-02 14:30:10 +01:00
|
|
|
{
|
2011-09-30 17:45:16 +02:00
|
|
|
switch (mode) /* new, split require MVs */
|
|
|
|
{
|
|
|
|
case NEWMV:
|
2012-02-27 19:22:38 +01:00
|
|
|
#ifdef ENTROPY_STATS
|
2011-09-30 17:45:16 +02:00
|
|
|
active_section = 5;
|
2012-02-27 19:22:38 +01:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-27 19:22:38 +01:00
|
|
|
#if CONFIG_HIGH_PRECISION_MV
|
|
|
|
if (xd->allow_high_precision_mv)
|
|
|
|
write_mv_hp(w, &mi->mv.as_mv, &best_mv, mvc_hp);
|
|
|
|
else
|
|
|
|
#endif
|
2011-09-30 17:45:16 +02:00
|
|
|
write_mv(w, &mi->mv.as_mv, &best_mv, mvc);
|
2012-02-10 01:11:00 +01:00
|
|
|
|
2012-02-29 02:25:45 +01:00
|
|
|
if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
{
|
2012-02-02 18:30:27 +01:00
|
|
|
vp8_write(w, mi->second_ref_frame != INTRA_FRAME,
|
2012-02-29 02:25:45 +01:00
|
|
|
get_pred_prob( pc, xd, PRED_COMP ) );
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
}
|
|
|
|
if (mi->second_ref_frame)
|
|
|
|
{
|
|
|
|
const int second_rf = mi->second_ref_frame;
|
|
|
|
int_mv n1, n2;
|
|
|
|
int ct[4];
|
2011-12-07 14:32:45 +01:00
|
|
|
vp8_find_near_mvs(xd, m,
|
|
|
|
prev_m,
|
|
|
|
&n1, &n2, &best_mv,
|
|
|
|
ct, second_rf,
|
|
|
|
cpi->common.ref_frame_sign_bias);
|
2012-02-27 19:22:38 +01:00
|
|
|
#if CONFIG_HIGH_PRECISION_MV
|
|
|
|
if (xd->allow_high_precision_mv)
|
|
|
|
write_mv_hp(w, &mi->second_mv.as_mv, &best_mv, mvc_hp);
|
|
|
|
else
|
|
|
|
#endif
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
write_mv(w, &mi->second_mv.as_mv, &best_mv, mvc);
|
|
|
|
}
|
2011-09-30 17:45:16 +02:00
|
|
|
break;
|
|
|
|
case SPLITMV:
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-09-30 17:45:16 +02:00
|
|
|
int j = 0;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-27 19:22:38 +01:00
|
|
|
#ifdef MODE_STATS
|
2011-09-30 17:45:16 +02:00
|
|
|
++count_mb_seg [mi->partitioning];
|
2012-02-27 19:22:38 +01:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-09-30 17:45:16 +02:00
|
|
|
write_split(w, mi->partitioning);
|
|
|
|
|
|
|
|
do
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-09-30 17:45:16 +02:00
|
|
|
B_PREDICTION_MODE blockmode;
|
|
|
|
int_mv blockmv;
|
|
|
|
const int *const L = vp8_mbsplits [mi->partitioning];
|
|
|
|
int k = -1; /* first block in subset j */
|
|
|
|
int mv_contz;
|
|
|
|
int_mv leftmv, abovemv;
|
|
|
|
|
|
|
|
blockmode = cpi->mb.partition_info->bmi[j].mode;
|
|
|
|
blockmv = cpi->mb.partition_info->bmi[j].mv;
|
2012-02-27 19:22:38 +01:00
|
|
|
#if CONFIG_DEBUG
|
2011-09-30 17:45:16 +02:00
|
|
|
while (j != L[++k])
|
|
|
|
if (k >= 16)
|
|
|
|
assert(0);
|
2012-02-27 19:22:38 +01:00
|
|
|
#else
|
2011-09-30 17:45:16 +02:00
|
|
|
while (j != L[++k]);
|
2012-02-27 19:22:38 +01:00
|
|
|
#endif
|
2011-09-30 17:45:16 +02:00
|
|
|
leftmv.as_int = left_block_mv(m, k);
|
|
|
|
abovemv.as_int = above_block_mv(m, k, mis);
|
|
|
|
mv_contz = vp8_mv_cont(&leftmv, &abovemv);
|
|
|
|
|
|
|
|
write_sub_mv_ref(w, blockmode, vp8_sub_mv_ref_prob2 [mv_contz]);
|
|
|
|
|
|
|
|
if (blockmode == NEW4X4)
|
|
|
|
{
|
2012-02-27 19:22:38 +01:00
|
|
|
#ifdef ENTROPY_STATS
|
2011-09-30 17:45:16 +02:00
|
|
|
active_section = 11;
|
2012-02-27 19:22:38 +01:00
|
|
|
#endif
|
|
|
|
#if CONFIG_HIGH_PRECISION_MV
|
|
|
|
if (xd->allow_high_precision_mv)
|
|
|
|
write_mv_hp(w, &blockmv.as_mv, &best_mv, (const MV_CONTEXT_HP *) mvc_hp);
|
|
|
|
else
|
|
|
|
#endif
|
2011-09-30 17:45:16 +02:00
|
|
|
write_mv(w, &blockmv.as_mv, &best_mv, (const MV_CONTEXT *) mvc);
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-09-30 17:45:16 +02:00
|
|
|
while (++j < cpi->mb.partition_info->count);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2011-09-30 17:45:16 +02:00
|
|
|
default:
|
2012-02-29 02:25:45 +01:00
|
|
|
if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
{
|
2012-02-02 18:30:27 +01:00
|
|
|
vp8_write(w, mi->second_ref_frame != INTRA_FRAME,
|
2012-02-29 02:25:45 +01:00
|
|
|
get_pred_prob( pc, xd, PRED_COMP ) );
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
}
|
2011-09-30 17:45:16 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++m;
|
2011-11-16 01:16:30 +01:00
|
|
|
++prev_m;
|
|
|
|
assert((prev_m-cpi->common.prev_mip)==(m-cpi->common.mip));
|
|
|
|
assert((prev_m-cpi->common.prev_mi)==(m-cpi->common.mi));
|
2010-09-02 22:17:52 +02:00
|
|
|
cpi->mb.partition_info++;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
++m; /* skip L prediction border */
|
2011-11-16 01:16:30 +01:00
|
|
|
++prev_m;
|
2010-09-02 22:17:52 +02:00
|
|
|
cpi->mb.partition_info++;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
2012-02-02 18:04:40 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
static void write_kfmodes(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
vp8_writer *const bc = & cpi->bc;
|
|
|
|
const VP8_COMMON *const c = & cpi->common;
|
|
|
|
/* const */
|
|
|
|
MODE_INFO *m = c->mi;
|
|
|
|
int mb_row = -1;
|
|
|
|
int prob_skip_false = 0;
|
|
|
|
|
2011-10-05 12:26:00 +02:00
|
|
|
MACROBLOCKD *xd = &cpi->mb.e_mbd;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
if (c->mb_no_coeff_skip)
|
|
|
|
{
|
2011-10-28 16:27:23 +02:00
|
|
|
// Divide by 0 check. 0 case possible with segment features
|
|
|
|
if ( (cpi->skip_false_count + cpi->skip_true_count) )
|
|
|
|
{
|
|
|
|
prob_skip_false = cpi->skip_false_count * 256 /
|
|
|
|
(cpi->skip_false_count + cpi->skip_true_count);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-28 16:27:23 +02:00
|
|
|
if (prob_skip_false <= 1)
|
|
|
|
prob_skip_false = 1;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-28 16:27:23 +02:00
|
|
|
if (prob_skip_false > 255)
|
|
|
|
prob_skip_false = 255;
|
|
|
|
}
|
|
|
|
else
|
2010-05-18 17:58:33 +02:00
|
|
|
prob_skip_false = 255;
|
|
|
|
|
|
|
|
cpi->prob_skip_false = prob_skip_false;
|
|
|
|
vp8_write_literal(bc, prob_skip_false, 8);
|
|
|
|
}
|
|
|
|
|
2011-08-31 21:01:58 +02:00
|
|
|
#if CONFIG_QIMODE
|
|
|
|
if(!c->kf_ymode_probs_update)
|
|
|
|
{
|
|
|
|
vp8_write_literal(bc, c->kf_ymode_probs_index, 3);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
while (++mb_row < c->mb_rows)
|
|
|
|
{
|
|
|
|
int mb_col = -1;
|
|
|
|
|
|
|
|
while (++mb_col < c->mb_cols)
|
|
|
|
{
|
|
|
|
const int ym = m->mbmi.mode;
|
2011-10-05 12:26:00 +02:00
|
|
|
int segment_id = m->mbmi.segment_id;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
if (cpi->mb.e_mbd.update_mb_segmentation_map)
|
2010-09-01 02:43:14 +02:00
|
|
|
{
|
2011-11-15 12:13:33 +01:00
|
|
|
write_mb_segid(bc, &m->mbmi, &cpi->mb.e_mbd);
|
2010-09-01 02:43:14 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-05 12:26:00 +02:00
|
|
|
if ( c->mb_no_coeff_skip &&
|
|
|
|
( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
|
2011-11-03 17:58:26 +01:00
|
|
|
(get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0) ) )
|
2011-10-05 12:26:00 +02:00
|
|
|
{
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
|
2011-10-05 12:26:00 +02:00
|
|
|
}
|
2011-08-05 01:30:27 +02:00
|
|
|
#if CONFIG_QIMODE
|
2011-08-31 21:01:58 +02:00
|
|
|
kfwrite_ymode(bc, ym, c->kf_ymode_prob[c->kf_ymode_probs_index]);
|
2011-08-05 01:30:27 +02:00
|
|
|
#else
|
2010-05-18 17:58:33 +02:00
|
|
|
kfwrite_ymode(bc, ym, c->kf_ymode_prob);
|
2011-08-05 01:30:27 +02:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
if (ym == B_PRED)
|
|
|
|
{
|
|
|
|
const int mis = c->mode_info_stride;
|
2012-03-06 18:52:15 +01:00
|
|
|
int i = 0;
|
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
|
|
|
int uses_second = m->bmi[0].as_mode.second != (B_PREDICTION_MODE) (B_DC_PRED - 1);
|
2012-03-02 20:18:24 +01:00
|
|
|
vp8_write(bc, uses_second, 128);
|
2012-03-06 18:52:15 +01:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
do
|
|
|
|
{
|
2011-05-24 19:24:52 +02:00
|
|
|
const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
|
|
|
|
const B_PREDICTION_MODE L = left_block_mode(m, i);
|
2012-02-29 02:12:08 +01:00
|
|
|
const int bm = m->bmi[i].as_mode.first;
|
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
|
|
|
const int bm2 = m->bmi[i].as_mode.second;
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
++intra_mode_stats [A] [L] [bm];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
write_bmode(bc, bm, c->kf_bmode_prob [A] [L]);
|
2012-02-29 02:12:08 +01:00
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
2012-03-02 20:18:24 +01:00
|
|
|
if (uses_second)
|
2012-02-29 02:12:08 +01:00
|
|
|
{
|
|
|
|
write_bmode(bc, bm2, c->kf_bmode_prob [A] [L]);
|
|
|
|
}
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
while (++i < 16);
|
|
|
|
}
|
2011-08-05 01:30:27 +02:00
|
|
|
if(ym == I8X8_PRED)
|
|
|
|
{
|
2012-02-29 02:12:08 +01:00
|
|
|
write_i8x8_mode(bc, m->bmi[0].as_mode.first, c->i8x8_mode_prob);
|
|
|
|
write_i8x8_mode(bc, m->bmi[2].as_mode.first, c->i8x8_mode_prob);
|
|
|
|
write_i8x8_mode(bc, m->bmi[8].as_mode.first, c->i8x8_mode_prob);
|
|
|
|
write_i8x8_mode(bc, m->bmi[10].as_mode.first, c->i8x8_mode_prob);
|
2011-08-05 01:30:27 +02:00
|
|
|
m++;
|
|
|
|
}
|
|
|
|
else
|
2011-08-05 01:30:27 +02:00
|
|
|
#if CONFIG_UVINTRA
|
2011-12-07 22:03:57 +01:00
|
|
|
write_uv_mode(bc, (m++)->mbmi.uv_mode, c->kf_uv_mode_prob[ym]);
|
2011-08-05 01:30:27 +02:00
|
|
|
#else
|
2011-12-07 22:03:57 +01:00
|
|
|
write_uv_mode(bc, (m++)->mbmi.uv_mode, c->kf_uv_mode_prob);
|
2011-08-05 01:30:27 +02:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-08-05 01:30:27 +02:00
|
|
|
//printf("\n");
|
2010-05-18 17:58:33 +02:00
|
|
|
m++; // skip L prediction border
|
|
|
|
}
|
|
|
|
}
|
2012-02-02 18:04:40 +01:00
|
|
|
|
2011-06-10 11:11:15 +02:00
|
|
|
|
|
|
|
/* This function is used for debugging probability trees. */
|
|
|
|
static void print_prob_tree(vp8_prob
|
2011-06-28 23:03:47 +02:00
|
|
|
coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES])
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 11:11:15 +02:00
|
|
|
/* print coef probability tree */
|
|
|
|
int i,j,k,l;
|
|
|
|
FILE* f = fopen("enc_tree_probs.txt", "a");
|
|
|
|
fprintf(f, "{\n");
|
|
|
|
for (i = 0; i < BLOCK_TYPES; i++)
|
|
|
|
{
|
|
|
|
fprintf(f, " {\n");
|
|
|
|
for (j = 0; j < COEF_BANDS; j++)
|
|
|
|
{
|
|
|
|
fprintf(f, " {\n");
|
|
|
|
for (k = 0; k < PREV_COEF_CONTEXTS; k++)
|
|
|
|
{
|
|
|
|
fprintf(f, " {");
|
2011-06-28 23:03:47 +02:00
|
|
|
for (l = 0; l < ENTROPY_NODES; l++)
|
2011-06-10 11:11:15 +02:00
|
|
|
{
|
|
|
|
fprintf(f, "%3u, ",
|
|
|
|
(unsigned int)(coef_probs [i][j][k][l]));
|
|
|
|
}
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
}
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
}
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
}
|
|
|
|
fprintf(f, "}\n");
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sum_probs_over_prev_coef_context(
|
2011-06-28 23:03:47 +02:00
|
|
|
const unsigned int probs[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS],
|
2011-06-10 11:11:15 +02:00
|
|
|
unsigned int* out)
|
|
|
|
{
|
|
|
|
int i, j;
|
2011-06-28 23:03:47 +02:00
|
|
|
for (i=0; i < MAX_ENTROPY_TOKENS; ++i)
|
2011-06-10 11:11:15 +02:00
|
|
|
{
|
|
|
|
for (j=0; j < PREV_COEF_CONTEXTS; ++j)
|
|
|
|
{
|
|
|
|
const int tmp = out[i];
|
|
|
|
out[i] += probs[j][i];
|
|
|
|
/* check for wrap */
|
|
|
|
if (out[i] < tmp)
|
|
|
|
out[i] = UINT_MAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int prob_update_savings(const unsigned int *ct,
|
|
|
|
const vp8_prob oldp, const vp8_prob newp,
|
|
|
|
const vp8_prob upd)
|
|
|
|
{
|
|
|
|
const int old_b = vp8_cost_branch(ct, oldp);
|
|
|
|
const int new_b = vp8_cost_branch(ct, newp);
|
|
|
|
const int update_b = 8 +
|
|
|
|
((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
|
|
|
|
|
|
|
|
return old_b - new_b - update_b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int default_coef_context_savings(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
int savings = 0;
|
|
|
|
int i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int k = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* at every context */
|
|
|
|
|
|
|
|
/* calc probs and branch cts for this frame only */
|
2011-06-28 23:03:47 +02:00
|
|
|
//vp8_prob new_p [ENTROPY_NODES];
|
|
|
|
//unsigned int branch_ct [ENTROPY_NODES] [2];
|
2011-06-10 11:11:15 +02:00
|
|
|
|
|
|
|
int t = 0; /* token/prob index */
|
|
|
|
|
|
|
|
|
|
|
|
vp8_tree_probs_from_distribution(
|
2011-06-28 23:03:47 +02:00
|
|
|
MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
|
2011-06-10 11:11:15 +02:00
|
|
|
cpi->frame_coef_probs [i][j][k],
|
|
|
|
cpi->frame_branch_ct [i][j][k],
|
|
|
|
cpi->coef_counts [i][j][k],
|
|
|
|
256, 1
|
|
|
|
);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
|
|
|
|
const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
|
|
|
|
const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t];
|
|
|
|
const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
|
|
|
|
const int s = prob_update_savings(ct, oldp, newp, upd);
|
|
|
|
|
|
|
|
if (s > 0)
|
|
|
|
{
|
|
|
|
savings += s;
|
|
|
|
}
|
|
|
|
}
|
2011-06-28 23:03:47 +02:00
|
|
|
while (++t < ENTROPY_NODES);
|
2011-06-10 11:11:15 +02:00
|
|
|
}
|
|
|
|
while (++k < PREV_COEF_CONTEXTS);
|
|
|
|
}
|
|
|
|
while (++j < COEF_BANDS);
|
|
|
|
}
|
|
|
|
while (++i < BLOCK_TYPES);
|
|
|
|
return savings;
|
|
|
|
}
|
|
|
|
|
|
|
|
int vp8_estimate_entropy_savings(VP8_COMP *cpi)
|
|
|
|
{
|
2010-05-18 17:58:33 +02:00
|
|
|
int savings = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
int i=0;
|
2012-01-28 09:50:33 +01:00
|
|
|
VP8_COMMON *const cm = & cpi->common;
|
2010-05-18 17:58:33 +02:00
|
|
|
const int *const rfct = cpi->count_mb_ref_frame_usage;
|
|
|
|
const int rf_intra = rfct[INTRA_FRAME];
|
|
|
|
const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
|
2012-02-03 18:08:37 +01:00
|
|
|
int new_intra, new_last, new_gf_alt, oldtotal, newtotal;
|
2010-05-18 17:58:33 +02:00
|
|
|
int ref_frame_cost[MAX_REF_FRAMES];
|
|
|
|
|
|
|
|
vp8_clear_system_state(); //__asm emms;
|
|
|
|
|
2012-02-03 18:08:37 +01:00
|
|
|
// Estimate reference frame cost savings.
|
|
|
|
// For now this is just based on projected overall frequency of
|
|
|
|
// each reference frame coded using an unpredicted coding tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
if (cpi->common.frame_type != KEY_FRAME)
|
|
|
|
{
|
2011-09-30 17:45:16 +02:00
|
|
|
new_intra = (rf_intra + rf_inter)
|
|
|
|
? rf_intra * 255 / (rf_intra + rf_inter) : 1;
|
2012-02-03 18:08:37 +01:00
|
|
|
new_intra += !new_intra;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
new_last = rf_inter ? (rfct[LAST_FRAME] * 255) / rf_inter : 128;
|
2012-02-03 18:08:37 +01:00
|
|
|
new_last += !new_last;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-03 18:08:37 +01:00
|
|
|
new_gf_alt = (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME])
|
|
|
|
? (rfct[GOLDEN_FRAME] * 255) /
|
|
|
|
(rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]) : 128;
|
|
|
|
new_gf_alt += !new_gf_alt;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
// new costs
|
|
|
|
ref_frame_cost[INTRA_FRAME] = vp8_cost_zero(new_intra);
|
|
|
|
ref_frame_cost[LAST_FRAME] = vp8_cost_one(new_intra)
|
|
|
|
+ vp8_cost_zero(new_last);
|
|
|
|
ref_frame_cost[GOLDEN_FRAME] = vp8_cost_one(new_intra)
|
|
|
|
+ vp8_cost_one(new_last)
|
2012-02-03 18:08:37 +01:00
|
|
|
+ vp8_cost_zero(new_gf_alt);
|
2010-05-18 17:58:33 +02:00
|
|
|
ref_frame_cost[ALTREF_FRAME] = vp8_cost_one(new_intra)
|
|
|
|
+ vp8_cost_one(new_last)
|
2012-02-03 18:08:37 +01:00
|
|
|
+ vp8_cost_one(new_gf_alt);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
newtotal =
|
|
|
|
rfct[INTRA_FRAME] * ref_frame_cost[INTRA_FRAME] +
|
|
|
|
rfct[LAST_FRAME] * ref_frame_cost[LAST_FRAME] +
|
|
|
|
rfct[GOLDEN_FRAME] * ref_frame_cost[GOLDEN_FRAME] +
|
|
|
|
rfct[ALTREF_FRAME] * ref_frame_cost[ALTREF_FRAME];
|
|
|
|
|
|
|
|
// old costs
|
2012-01-28 09:50:33 +01:00
|
|
|
ref_frame_cost[INTRA_FRAME] = vp8_cost_zero(cm->prob_intra_coded);
|
|
|
|
ref_frame_cost[LAST_FRAME] = vp8_cost_one(cm->prob_intra_coded)
|
|
|
|
+ vp8_cost_zero(cm->prob_last_coded);
|
|
|
|
ref_frame_cost[GOLDEN_FRAME] = vp8_cost_one(cm->prob_intra_coded)
|
|
|
|
+ vp8_cost_one(cm->prob_last_coded)
|
|
|
|
+ vp8_cost_zero(cm->prob_gf_coded);
|
|
|
|
ref_frame_cost[ALTREF_FRAME] = vp8_cost_one(cm->prob_intra_coded)
|
|
|
|
+ vp8_cost_one(cm->prob_last_coded)
|
|
|
|
+ vp8_cost_one(cm->prob_gf_coded);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
oldtotal =
|
|
|
|
rfct[INTRA_FRAME] * ref_frame_cost[INTRA_FRAME] +
|
|
|
|
rfct[LAST_FRAME] * ref_frame_cost[LAST_FRAME] +
|
|
|
|
rfct[GOLDEN_FRAME] * ref_frame_cost[GOLDEN_FRAME] +
|
|
|
|
rfct[ALTREF_FRAME] * ref_frame_cost[ALTREF_FRAME];
|
|
|
|
|
|
|
|
savings += (oldtotal - newtotal) / 256;
|
|
|
|
|
2012-02-03 18:08:37 +01:00
|
|
|
// Update the reference frame probability numbers to reflect
|
|
|
|
// the observed counts in this frame. Doing this here insures
|
|
|
|
// that if there are multiple recode iterations the baseline
|
|
|
|
// probabilities used are updated in each iteration.
|
|
|
|
cm->prob_intra_coded = new_intra;
|
|
|
|
cm->prob_last_coded = new_last;
|
|
|
|
cm->prob_gf_coded = new_gf_alt;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-26 02:15:47 +01:00
|
|
|
savings += default_coef_context_savings(cpi);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-29 02:11:12 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
/* do not do this if not evena allowed */
|
|
|
|
if(cpi->common.txfm_mode == ALLOW_8X8)
|
2011-02-14 23:18:18 +01:00
|
|
|
{
|
2012-03-01 02:41:19 +01:00
|
|
|
int savings8x8 = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
do
|
|
|
|
{
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
int j = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
do
|
|
|
|
{
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
int k = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
do
|
|
|
|
{
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
/* at every context */
|
|
|
|
/* calc probs and branch cts for this frame only */
|
|
|
|
//vp8_prob new_p [ENTROPY_NODES];
|
|
|
|
//unsigned int branch_ct [ENTROPY_NODES] [2];
|
|
|
|
int t = 0; /* token/prob index */
|
|
|
|
vp8_tree_probs_from_distribution(
|
|
|
|
MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
|
|
|
|
cpi->frame_coef_probs_8x8 [i][j][k],
|
|
|
|
cpi->frame_branch_ct_8x8 [i][j][k],
|
|
|
|
cpi->coef_counts_8x8 [i][j][k],
|
|
|
|
256, 1
|
|
|
|
);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
|
|
|
|
const vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
const vp8_prob old = cpi->common.fc.coef_probs_8x8 [i][j][k][t];
|
|
|
|
const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
const int old_b = vp8_cost_branch(ct, old);
|
|
|
|
const int new_b = vp8_cost_branch(ct, newp);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
const int update_b = 8 +
|
|
|
|
((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
const int s = old_b - new_b - update_b;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
if (s > 0)
|
2012-03-01 02:41:19 +01:00
|
|
|
savings8x8 += s;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
}
|
|
|
|
while (++t < MAX_ENTROPY_TOKENS - 1);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
while (++k < PREV_COEF_CONTEXTS);
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
while (++j < COEF_BANDS);
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
while (++i < BLOCK_TYPES);
|
2012-03-01 02:41:19 +01:00
|
|
|
|
|
|
|
savings += savings8x8 >> 8;
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
return savings;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_coef_probs(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
vp8_writer *const w = & cpi->bc;
|
2012-02-07 00:10:13 +01:00
|
|
|
int update = 0;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
vp8_clear_system_state(); //__asm emms;
|
2012-02-07 00:10:13 +01:00
|
|
|
/* dry run to see if there is any udpate at all needed */
|
2010-05-18 17:58:33 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int k = 0;
|
2011-06-28 23:03:47 +02:00
|
|
|
int prev_coef_savings[ENTROPY_NODES] = {0};
|
2010-05-18 17:58:33 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
//note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
|
|
|
|
/* at every context */
|
|
|
|
/* calc probs and branch cts for this frame only */
|
2011-06-28 23:03:47 +02:00
|
|
|
//vp8_prob new_p [ENTROPY_NODES];
|
|
|
|
//unsigned int branch_ct [ENTROPY_NODES] [2];
|
2010-05-18 17:58:33 +02:00
|
|
|
int t = 0; /* token/prob index */
|
|
|
|
//vp8_tree_probs_from_distribution(
|
2011-06-28 23:03:47 +02:00
|
|
|
// MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
|
2010-05-18 17:58:33 +02:00
|
|
|
// new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][k],
|
|
|
|
// 256, 1
|
|
|
|
// );
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
|
|
|
|
vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
|
|
|
|
const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
|
2011-06-10 11:11:15 +02:00
|
|
|
int s = prev_coef_savings[t];
|
|
|
|
int u = 0;
|
2012-02-26 02:15:47 +01:00
|
|
|
|
|
|
|
s = prob_update_savings(
|
|
|
|
cpi->frame_branch_ct [i][j][k][t],
|
|
|
|
*Pold, newp, upd);
|
|
|
|
|
2011-06-10 11:11:15 +02:00
|
|
|
if (s > 0)
|
|
|
|
u = 1;
|
2012-02-26 02:15:47 +01:00
|
|
|
|
2012-02-07 00:10:13 +01:00
|
|
|
update += u;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-06-28 23:03:47 +02:00
|
|
|
while (++t < ENTROPY_NODES);
|
2010-05-18 17:58:33 +02:00
|
|
|
/* Accum token counts for generation of default statistics */
|
2012-02-07 00:10:13 +01:00
|
|
|
}
|
|
|
|
while (++k < PREV_COEF_CONTEXTS);
|
|
|
|
}
|
|
|
|
while (++j < COEF_BANDS);
|
|
|
|
}
|
|
|
|
while (++i < BLOCK_TYPES);
|
|
|
|
/* Is coef updated at all */
|
|
|
|
if(update==0)
|
|
|
|
{
|
|
|
|
vp8_write_bit(w, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp8_write_bit(w, 1);
|
|
|
|
i=0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int k = 0;
|
|
|
|
int prev_coef_savings[ENTROPY_NODES] = {0};
|
2012-02-26 02:15:47 +01:00
|
|
|
|
2012-02-07 00:10:13 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
//note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
|
|
|
|
/* at every context */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-07 00:10:13 +01:00
|
|
|
/* calc probs and branch cts for this frame only */
|
|
|
|
//vp8_prob new_p [ENTROPY_NODES];
|
|
|
|
//unsigned int branch_ct [ENTROPY_NODES] [2];
|
|
|
|
int t = 0; /* token/prob index */
|
|
|
|
//vp8_tree_probs_from_distribution(
|
|
|
|
// MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
|
|
|
|
// new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][k],
|
|
|
|
// 256, 1
|
|
|
|
// );
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
|
|
|
|
vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
|
|
|
|
const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
|
|
|
|
int s = prev_coef_savings[t];
|
|
|
|
int u = 0;
|
2012-02-26 02:15:47 +01:00
|
|
|
|
|
|
|
s = prob_update_savings(
|
|
|
|
cpi->frame_branch_ct [i][j][k][t],
|
|
|
|
*Pold, newp, upd);
|
|
|
|
|
2012-02-07 00:10:13 +01:00
|
|
|
if (s > 0)
|
|
|
|
u = 1;
|
2012-02-26 02:15:47 +01:00
|
|
|
|
2012-02-07 00:10:13 +01:00
|
|
|
vp8_write(w, u, upd);
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
++ tree_update_hist [i][j][k][t] [u];
|
2010-05-18 17:58:33 +02:00
|
|
|
#endif
|
2012-02-07 00:10:13 +01:00
|
|
|
if (u)
|
|
|
|
{
|
|
|
|
/* send/use new probability */
|
|
|
|
*Pold = newp;
|
|
|
|
vp8_write_literal(w, newp, 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (++t < ENTROPY_NODES);
|
|
|
|
/* Accum token counts for generation of default statistics */
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
t = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
context_counters [i][j][k][t] += cpi->coef_counts [i][j][k][t];
|
|
|
|
}
|
|
|
|
while (++t < MAX_ENTROPY_TOKENS);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
while (++k < PREV_COEF_CONTEXTS);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-02-07 00:10:13 +01:00
|
|
|
while (++j < COEF_BANDS);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-02-07 00:10:13 +01:00
|
|
|
while (++i < BLOCK_TYPES);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-02-07 00:10:13 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
/* do not do this if not evena allowed */
|
|
|
|
if(cpi->common.txfm_mode == ALLOW_8X8)
|
2011-02-14 23:18:18 +01:00
|
|
|
{
|
2012-02-07 00:10:13 +01:00
|
|
|
/* dry run to see if update is necessary */
|
2012-02-28 03:23:15 +01:00
|
|
|
update = 0;
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
i = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
do
|
|
|
|
{
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
int j = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
do
|
|
|
|
{
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
int k = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
//note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
|
|
|
|
/* at every context */
|
|
|
|
/* calc probs and branch cts for this frame only */
|
|
|
|
//vp8_prob new_p [ENTROPY_NODES];
|
|
|
|
//unsigned int branch_ct [ENTROPY_NODES] [2];
|
|
|
|
int t = 0; /* token/prob index */
|
|
|
|
//vp8_tree_probs_from_distribution(
|
|
|
|
// MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
|
|
|
|
// new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][k],
|
|
|
|
// 256, 1
|
|
|
|
// );
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
|
|
|
|
const vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
|
|
|
|
vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
|
|
|
|
const vp8_prob old = *Pold;
|
|
|
|
const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
|
|
|
|
const int old_b = vp8_cost_branch(ct, old);
|
|
|
|
const int new_b = vp8_cost_branch(ct, newp);
|
|
|
|
const int update_b = 8 +
|
|
|
|
((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
|
|
|
|
const int s = old_b - new_b - update_b;
|
|
|
|
const int u = s > 0 ? 1 : 0;
|
2012-01-21 00:30:31 +01:00
|
|
|
|
2011-02-14 23:18:18 +01:00
|
|
|
#ifdef ENTROPY_STATS
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
++ tree_update_hist_8x8 [i][j][k][t] [u];
|
2011-02-14 23:18:18 +01:00
|
|
|
#endif
|
2012-02-07 00:10:13 +01:00
|
|
|
update += u;
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
}
|
|
|
|
while (++t < MAX_ENTROPY_TOKENS - 1);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
/* Accum token counts for generation of default statistics */
|
2011-02-14 23:18:18 +01:00
|
|
|
#ifdef ENTROPY_STATS
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
t = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
context_counters_8x8 [i][j][k][t] += cpi->coef_counts_8x8 [i][j][k][t];
|
|
|
|
}
|
|
|
|
while (++t < MAX_ENTROPY_TOKENS);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
|
|
|
#endif
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
}
|
|
|
|
while (++k < PREV_COEF_CONTEXTS);
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
while (++j < COEF_BANDS);
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
while (++i < BLOCK_TYPES);
|
2012-02-07 00:10:13 +01:00
|
|
|
|
|
|
|
if(update == 0)
|
|
|
|
{
|
|
|
|
vp8_write_bit(w, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp8_write_bit(w, 1);
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int k = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
//note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
|
|
|
|
/* at every context */
|
|
|
|
/* calc probs and branch cts for this frame only */
|
|
|
|
//vp8_prob new_p [ENTROPY_NODES];
|
|
|
|
//unsigned int branch_ct [ENTROPY_NODES] [2];
|
|
|
|
int t = 0; /* token/prob index */
|
|
|
|
//vp8_tree_probs_from_distribution(
|
|
|
|
// MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
|
|
|
|
// new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][k],
|
|
|
|
// 256, 1
|
|
|
|
// );
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const unsigned int *ct = cpi->frame_branch_ct_8x8 [i][j][k][t];
|
|
|
|
const vp8_prob newp = cpi->frame_coef_probs_8x8 [i][j][k][t];
|
|
|
|
vp8_prob *Pold = cpi->common.fc.coef_probs_8x8 [i][j][k] + t;
|
|
|
|
const vp8_prob old = *Pold;
|
|
|
|
const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
|
|
|
|
const int old_b = vp8_cost_branch(ct, old);
|
|
|
|
const int new_b = vp8_cost_branch(ct, newp);
|
|
|
|
const int update_b = 8 +
|
|
|
|
((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
|
|
|
|
const int s = old_b - new_b - update_b;
|
|
|
|
const int u = s > 0 ? 1 : 0;
|
|
|
|
vp8_write(w, u, upd);
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
++ tree_update_hist_8x8 [i][j][k][t] [u];
|
|
|
|
#endif
|
|
|
|
if (u)
|
|
|
|
{
|
|
|
|
/* send/use new probability */
|
|
|
|
*Pold = newp;
|
|
|
|
vp8_write_literal(w, newp, 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (++t < MAX_ENTROPY_TOKENS - 1);
|
|
|
|
/* Accum token counts for generation of default statistics */
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
t = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
context_counters_8x8 [i][j][k][t] += cpi->coef_counts_8x8 [i][j][k][t];
|
|
|
|
}
|
|
|
|
while (++t < MAX_ENTROPY_TOKENS);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
while (++k < PREV_COEF_CONTEXTS);
|
|
|
|
}
|
|
|
|
while (++j < COEF_BANDS);
|
|
|
|
}
|
|
|
|
while (++i < BLOCK_TYPES);
|
|
|
|
}
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
#ifdef PACKET_TESTING
|
|
|
|
FILE *vpxlogc = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void put_delta_q(vp8_writer *bc, int delta_q)
|
|
|
|
{
|
|
|
|
if (delta_q != 0)
|
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
vp8_write_literal(bc, abs(delta_q), 4);
|
|
|
|
|
|
|
|
if (delta_q < 0)
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
2011-08-31 21:01:58 +02:00
|
|
|
#if CONFIG_QIMODE
|
|
|
|
extern const unsigned int kf_y_mode_cts[8][VP8_YMODES];
|
|
|
|
static void decide_kf_ymode_entropy(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
|
|
|
|
int mode_cost[MB_MODE_COUNT];
|
|
|
|
int cost;
|
|
|
|
int bestcost = INT_MAX;
|
|
|
|
int bestindex = 0;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for(i=0; i<8; i++)
|
|
|
|
{
|
|
|
|
vp8_cost_tokens(mode_cost, cpi->common.kf_ymode_prob[i], vp8_kf_ymode_tree);
|
|
|
|
cost = 0;
|
|
|
|
for(j=0;j<VP8_YMODES;j++)
|
|
|
|
{
|
|
|
|
cost += mode_cost[j] * cpi->ymode_count[j];
|
|
|
|
}
|
|
|
|
if(cost < bestcost)
|
|
|
|
{
|
|
|
|
bestindex = i;
|
|
|
|
bestcost = cost;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cpi->common.kf_ymode_probs_index = bestindex;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2012-01-26 19:04:34 +01:00
|
|
|
static segment_reference_frames(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
VP8_COMMON *oci = &cpi->common;
|
|
|
|
MODE_INFO *mi = oci->mi;
|
|
|
|
int ref[MAX_MB_SEGMENTS]={0};
|
|
|
|
int i,j;
|
|
|
|
int mb_index=0;
|
|
|
|
MACROBLOCKD *const xd = & cpi->mb.e_mbd;
|
|
|
|
|
|
|
|
for (i = 0; i < oci->mb_rows; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < oci->mb_cols; j++, mb_index++)
|
|
|
|
{
|
|
|
|
ref[mi[mb_index].mbmi.segment_id]|=(1<<mi[mb_index].mbmi.ref_frame);
|
|
|
|
}
|
|
|
|
mb_index++;
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAX_MB_SEGMENTS; i++)
|
|
|
|
{
|
|
|
|
enable_segfeature(xd,i,SEG_LVL_REF_FRAME);
|
|
|
|
set_segdata( xd,i, SEG_LVL_REF_FRAME, ref[i]);
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-01-26 19:04:34 +01:00
|
|
|
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
VP8_HEADER oh;
|
|
|
|
VP8_COMMON *const pc = & cpi->common;
|
|
|
|
vp8_writer *const bc = & cpi->bc;
|
|
|
|
MACROBLOCKD *const xd = & cpi->mb.e_mbd;
|
|
|
|
int extra_bytes_packed = 0;
|
|
|
|
|
|
|
|
unsigned char *cx_data = dest;
|
|
|
|
|
|
|
|
oh.show_frame = (int) pc->show_frame;
|
|
|
|
oh.type = (int)pc->frame_type;
|
|
|
|
oh.version = pc->version;
|
2011-03-11 11:34:57 +01:00
|
|
|
oh.first_partition_length_in_bytes = 0;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
cx_data += 3;
|
|
|
|
|
|
|
|
#if defined(SECTIONBITS_OUTPUT)
|
|
|
|
Sectionbits[active_section = 1] += sizeof(VP8_HEADER) * 8 * 256;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//vp8_kf_default_bmode_probs() is called in vp8_setup_key_frame() once for each
|
|
|
|
//K frame before encode frame. pc->kf_bmode_prob doesn't get changed anywhere
|
|
|
|
//else. No need to call it again here. --yw
|
|
|
|
//vp8_kf_default_bmode_probs( pc->kf_bmode_prob);
|
|
|
|
|
|
|
|
// every keyframe send startcode, width, height, scale factor, clamp and color type
|
|
|
|
if (oh.type == KEY_FRAME)
|
|
|
|
{
|
2011-02-17 12:47:39 +01:00
|
|
|
int v;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
// Start / synch code
|
|
|
|
cx_data[0] = 0x9D;
|
|
|
|
cx_data[1] = 0x01;
|
|
|
|
cx_data[2] = 0x2a;
|
|
|
|
|
2011-02-17 12:47:39 +01:00
|
|
|
v = (pc->horiz_scale << 14) | pc->Width;
|
|
|
|
cx_data[3] = v;
|
|
|
|
cx_data[4] = v >> 8;
|
|
|
|
|
|
|
|
v = (pc->vert_scale << 14) | pc->Height;
|
|
|
|
cx_data[5] = v;
|
|
|
|
cx_data[6] = v >> 8;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
extra_bytes_packed = 7;
|
|
|
|
cx_data += extra_bytes_packed ;
|
|
|
|
|
|
|
|
vp8_start_encode(bc, cx_data);
|
|
|
|
|
|
|
|
// signal clr type
|
|
|
|
vp8_write_bit(bc, pc->clr_type);
|
|
|
|
vp8_write_bit(bc, pc->clamp_type);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_start_encode(bc, cx_data);
|
2011-11-08 16:40:32 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
// Signal whether or not Segmentation is enabled
|
|
|
|
vp8_write_bit(bc, (xd->segmentation_enabled) ? 1 : 0);
|
|
|
|
|
|
|
|
// Indicate which features are enabled
|
2012-02-13 17:21:24 +01:00
|
|
|
if ( xd->segmentation_enabled )
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-11-11 11:10:06 +01:00
|
|
|
// Indicate whether or not the segmentation map is being updated.
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_write_bit(bc, (xd->update_mb_segmentation_map) ? 1 : 0);
|
2011-11-15 17:15:23 +01:00
|
|
|
|
2011-11-11 11:10:06 +01:00
|
|
|
// If it is, then indicate the method that will be used.
|
|
|
|
if ( xd->update_mb_segmentation_map )
|
2012-01-27 19:29:07 +01:00
|
|
|
vp8_write_bit(bc, (pc->temporal_update) ? 1:0);
|
2011-11-15 17:15:23 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_write_bit(bc, (xd->update_mb_segmentation_data) ? 1 : 0);
|
|
|
|
|
2012-01-31 14:09:49 +01:00
|
|
|
//segment_reference_frames(cpi);
|
2012-01-26 19:04:34 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
if (xd->update_mb_segmentation_data)
|
|
|
|
{
|
|
|
|
signed char Data;
|
|
|
|
|
2012-02-27 22:42:36 +01:00
|
|
|
vp8_write_bit(bc, (xd->mb_segment_abs_delta) ? 1 : 0);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-09-13 16:24:45 +02:00
|
|
|
// For each segments id...
|
2011-11-03 13:50:09 +01:00
|
|
|
for (i = 0; i < MAX_MB_SEGMENTS; i++)
|
2011-09-13 16:24:45 +02:00
|
|
|
{
|
|
|
|
// For each segmentation codable feature...
|
2011-11-03 13:50:09 +01:00
|
|
|
for (j = 0; j < SEG_LVL_MAX; j++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-11-03 13:50:09 +01:00
|
|
|
Data = get_segdata( xd, i, j );
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-13 17:21:24 +01:00
|
|
|
|
|
|
|
#if CONFIG_FEATUREUPDATES
|
|
|
|
|
|
|
|
// check if there's an update
|
|
|
|
if(segfeature_changed( xd,i,j) )
|
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
|
|
|
|
if ( segfeature_active( xd, i, j ) )
|
|
|
|
{
|
|
|
|
// this bit is to say we are still
|
|
|
|
// active/ if we were inactive
|
|
|
|
// this is unnecessary
|
|
|
|
if ( old_segfeature_active( xd, i, j ))
|
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
}
|
|
|
|
// Is the segment data signed..
|
|
|
|
if ( is_segfeature_signed(j) )
|
|
|
|
{
|
|
|
|
// Encode the relevant feature data
|
|
|
|
if (Data < 0)
|
|
|
|
{
|
|
|
|
Data = - Data;
|
|
|
|
vp8_write_literal(bc, Data,
|
|
|
|
seg_feature_data_bits(j));
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp8_write_literal(bc, Data,
|
|
|
|
seg_feature_data_bits(j));
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Unsigned data element so no sign bit needed
|
|
|
|
else
|
|
|
|
vp8_write_literal(bc, Data,
|
|
|
|
seg_feature_data_bits(j));
|
|
|
|
}
|
|
|
|
// feature is inactive now
|
|
|
|
else if ( old_segfeature_active( xd, i, j ))
|
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp8_write_bit(bc,0);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
2011-09-14 19:20:25 +02:00
|
|
|
// If the feature is enabled...
|
2011-11-03 13:50:09 +01:00
|
|
|
if ( segfeature_active( xd, i, j ) )
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
|
2011-10-07 17:58:28 +02:00
|
|
|
// Is the segment data signed..
|
2011-11-03 13:50:09 +01:00
|
|
|
if ( is_segfeature_signed(j) )
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-10-07 17:58:28 +02:00
|
|
|
// Encode the relevant feature data
|
|
|
|
if (Data < 0)
|
|
|
|
{
|
|
|
|
Data = - Data;
|
|
|
|
vp8_write_literal(bc, Data,
|
2012-02-13 17:21:24 +01:00
|
|
|
seg_feature_data_bits(j));
|
2011-10-07 17:58:28 +02:00
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp8_write_literal(bc, Data,
|
2012-02-13 17:21:24 +01:00
|
|
|
seg_feature_data_bits(j));
|
2011-10-07 17:58:28 +02:00
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-10-07 17:58:28 +02:00
|
|
|
// Unsigned data element so no sign bit needed
|
2010-05-18 17:58:33 +02:00
|
|
|
else
|
2011-09-13 16:24:45 +02:00
|
|
|
vp8_write_literal(bc, Data,
|
2012-02-13 17:21:24 +01:00
|
|
|
seg_feature_data_bits(j));
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
2012-02-13 17:21:24 +01:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-13 17:21:24 +01:00
|
|
|
#if CONFIG_FEATUREUPDATES
|
|
|
|
// save the segment info for updates next frame
|
|
|
|
save_segment_info ( xd );
|
|
|
|
#endif
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
if (xd->update_mb_segmentation_map)
|
|
|
|
{
|
2011-11-15 12:13:33 +01:00
|
|
|
// Send the tree probabilities used to decode unpredicted
|
|
|
|
// macro-block segments
|
2010-05-18 17:58:33 +02:00
|
|
|
for (i = 0; i < MB_FEATURE_TREE_PROBS; i++)
|
|
|
|
{
|
|
|
|
int Data = xd->mb_segment_tree_probs[i];
|
|
|
|
|
|
|
|
if (Data != 255)
|
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
vp8_write_literal(bc, Data, 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
2011-11-15 17:15:23 +01:00
|
|
|
|
2011-11-15 12:13:33 +01:00
|
|
|
// If predictive coding of segment map is enabled send the
|
|
|
|
// prediction probabilities.
|
2012-01-27 19:29:07 +01:00
|
|
|
if ( pc->temporal_update )
|
2011-11-15 12:13:33 +01:00
|
|
|
{
|
2012-01-27 19:29:07 +01:00
|
|
|
for (i = 0; i < PREDICTION_PROBS; i++)
|
2011-11-15 12:13:33 +01:00
|
|
|
{
|
2012-01-27 19:29:07 +01:00
|
|
|
int Data = pc->segment_pred_probs[i];
|
2011-11-15 12:13:33 +01:00
|
|
|
|
|
|
|
if (Data != 255)
|
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
vp8_write_literal(bc, Data, 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-28 13:20:14 +01:00
|
|
|
// Encode the common prediction model status flag probability updates for
|
|
|
|
// the reference frame
|
|
|
|
if ( pc->frame_type != KEY_FRAME )
|
|
|
|
{
|
|
|
|
for (i = 0; i < PREDICTION_PROBS; i++)
|
|
|
|
{
|
2012-02-03 14:46:18 +01:00
|
|
|
if ( cpi->ref_pred_probs_update[i] )
|
2012-01-28 13:20:14 +01:00
|
|
|
{
|
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
vp8_write_literal(bc, pc->ref_pred_probs[i], 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
vp8_write_bit(bc, pc->txfm_mode);
|
|
|
|
|
2012-01-27 19:29:07 +01:00
|
|
|
// Encode the loop filter level and type
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_write_bit(bc, pc->filter_type);
|
|
|
|
vp8_write_literal(bc, pc->filter_level, 6);
|
|
|
|
vp8_write_literal(bc, pc->sharpness_level, 3);
|
|
|
|
|
|
|
|
// Write out loop filter deltas applied at the MB level based on mode or ref frame (if they are enabled).
|
|
|
|
vp8_write_bit(bc, (xd->mode_ref_lf_delta_enabled) ? 1 : 0);
|
|
|
|
|
|
|
|
if (xd->mode_ref_lf_delta_enabled)
|
|
|
|
{
|
|
|
|
// Do the deltas need to be updated
|
2012-02-26 02:15:47 +01:00
|
|
|
int send_update = xd->mode_ref_lf_delta_update;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-29 19:04:04 +02:00
|
|
|
vp8_write_bit(bc, send_update);
|
|
|
|
if (send_update)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
int Data;
|
|
|
|
|
|
|
|
// Send update
|
|
|
|
for (i = 0; i < MAX_REF_LF_DELTAS; i++)
|
|
|
|
{
|
|
|
|
Data = xd->ref_lf_deltas[i];
|
|
|
|
|
|
|
|
// Frame level data
|
2012-02-26 02:15:47 +01:00
|
|
|
if (xd->ref_lf_deltas[i] != xd->last_ref_lf_deltas[i])
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2010-09-29 19:04:04 +02:00
|
|
|
xd->last_ref_lf_deltas[i] = xd->ref_lf_deltas[i];
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
|
|
|
|
if (Data > 0)
|
|
|
|
{
|
|
|
|
vp8_write_literal(bc, (Data & 0x3F), 6);
|
|
|
|
vp8_write_bit(bc, 0); // sign
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Data = -Data;
|
|
|
|
vp8_write_literal(bc, (Data & 0x3F), 6);
|
|
|
|
vp8_write_bit(bc, 1); // sign
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send update
|
|
|
|
for (i = 0; i < MAX_MODE_LF_DELTAS; i++)
|
|
|
|
{
|
|
|
|
Data = xd->mode_lf_deltas[i];
|
|
|
|
|
2012-02-26 02:15:47 +01:00
|
|
|
if (xd->mode_lf_deltas[i] != xd->last_mode_lf_deltas[i])
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2010-09-29 19:04:04 +02:00
|
|
|
xd->last_mode_lf_deltas[i] = xd->mode_lf_deltas[i];
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_write_bit(bc, 1);
|
|
|
|
|
|
|
|
if (Data > 0)
|
|
|
|
{
|
|
|
|
vp8_write_literal(bc, (Data & 0x3F), 6);
|
|
|
|
vp8_write_bit(bc, 0); // sign
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Data = -Data;
|
|
|
|
vp8_write_literal(bc, (Data & 0x3F), 6);
|
|
|
|
vp8_write_bit(bc, 1); // sign
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_write_bit(bc, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//signal here is multi token partition is enabled
|
2012-02-27 23:23:38 +01:00
|
|
|
//vp8_write_literal(bc, pc->multi_token_partition, 2);
|
|
|
|
vp8_write_literal(bc, 0, 2);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-12-12 19:27:25 +01:00
|
|
|
// Frame Q baseline quantizer index
|
|
|
|
vp8_write_literal(bc, pc->base_qindex, QINDEX_BITS);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
// Transmit Dc, Second order and Uv quantizer delta information
|
|
|
|
put_delta_q(bc, pc->y1dc_delta_q);
|
|
|
|
put_delta_q(bc, pc->y2dc_delta_q);
|
|
|
|
put_delta_q(bc, pc->y2ac_delta_q);
|
|
|
|
put_delta_q(bc, pc->uvdc_delta_q);
|
|
|
|
put_delta_q(bc, pc->uvac_delta_q);
|
|
|
|
|
|
|
|
// When there is a key frame all reference buffers are updated using the new key frame
|
|
|
|
if (pc->frame_type != KEY_FRAME)
|
|
|
|
{
|
|
|
|
// Should the GF or ARF be updated using the transmitted frame or buffer
|
|
|
|
vp8_write_bit(bc, pc->refresh_golden_frame);
|
|
|
|
vp8_write_bit(bc, pc->refresh_alt_ref_frame);
|
|
|
|
|
|
|
|
// If not being updated from current frame should either GF or ARF be updated from another buffer
|
|
|
|
if (!pc->refresh_golden_frame)
|
|
|
|
vp8_write_literal(bc, pc->copy_buffer_to_gf, 2);
|
|
|
|
|
|
|
|
if (!pc->refresh_alt_ref_frame)
|
|
|
|
vp8_write_literal(bc, pc->copy_buffer_to_arf, 2);
|
|
|
|
|
|
|
|
// Indicate reference frame sign bias for Golden and ARF frames (always 0 for last frame buffer)
|
|
|
|
vp8_write_bit(bc, pc->ref_frame_sign_bias[GOLDEN_FRAME]);
|
|
|
|
vp8_write_bit(bc, pc->ref_frame_sign_bias[ALTREF_FRAME]);
|
2012-02-16 18:29:54 +01:00
|
|
|
|
|
|
|
#if CONFIG_HIGH_PRECISION_MV
|
|
|
|
// Signal whether to allow high MV precision
|
|
|
|
vp8_write_bit(bc, (xd->allow_high_precision_mv) ? 1 : 0);
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
vp8_write_bit(bc, pc->refresh_entropy_probs);
|
|
|
|
|
|
|
|
if (pc->frame_type != KEY_FRAME)
|
|
|
|
vp8_write_bit(bc, pc->refresh_last_frame);
|
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
|
|
|
|
if (pc->frame_type == INTER_FRAME)
|
|
|
|
active_section = 0;
|
|
|
|
else
|
|
|
|
active_section = 7;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
vp8_clear_system_state(); //__asm emms;
|
|
|
|
|
|
|
|
update_coef_probs(cpi);
|
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
active_section = 2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Write out the mb_no_coeff_skip flag
|
|
|
|
vp8_write_bit(bc, pc->mb_no_coeff_skip);
|
|
|
|
|
|
|
|
if (pc->frame_type == KEY_FRAME)
|
|
|
|
{
|
2011-08-31 21:01:58 +02:00
|
|
|
#if CONFIG_QIMODE
|
|
|
|
decide_kf_ymode_entropy(cpi);
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
write_kfmodes(cpi);
|
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
active_section = 8;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pack_inter_mode_mvs(cpi);
|
|
|
|
|
2011-12-08 20:43:09 +01:00
|
|
|
vp8_update_mode_context(&cpi->common);
|
2011-12-06 21:03:42 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
active_section = 1;
|
|
|
|
#endif
|
|
|
|
}
|
2011-07-20 23:21:24 +02:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
vp8_stop_encode(bc);
|
|
|
|
|
2011-03-11 11:34:57 +01:00
|
|
|
oh.first_partition_length_in_bytes = cpi->bc.pos;
|
|
|
|
|
|
|
|
/* update frame tag */
|
|
|
|
{
|
|
|
|
int v = (oh.first_partition_length_in_bytes << 5) |
|
|
|
|
(oh.show_frame << 4) |
|
|
|
|
(oh.version << 1) |
|
|
|
|
oh.type;
|
|
|
|
|
|
|
|
dest[0] = v;
|
|
|
|
dest[1] = v >> 8;
|
|
|
|
dest[2] = v >> 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = VP8_HEADER_SIZE + extra_bytes_packed + cpi->bc.pos;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-27 23:23:38 +01:00
|
|
|
vp8_start_encode(&cpi->bc2, cx_data + bc->pos);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-27 23:23:38 +01:00
|
|
|
pack_tokens(&cpi->bc2, cpi->tok, cpi->tok_count);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-27 23:23:38 +01:00
|
|
|
vp8_stop_encode(&cpi->bc2);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-27 23:23:38 +01:00
|
|
|
*size += cpi->bc2.pos;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
|
|
|
void print_tree_update_probs()
|
|
|
|
{
|
|
|
|
int i, j, k, l;
|
|
|
|
FILE *f = fopen("context.c", "a");
|
|
|
|
int Sum;
|
|
|
|
fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n");
|
2011-06-28 23:03:47 +02:00
|
|
|
fprintf(f, "const vp8_prob tree_update_probs[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {\n");
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
for (i = 0; i < BLOCK_TYPES; i++)
|
|
|
|
{
|
|
|
|
fprintf(f, " { \n");
|
|
|
|
|
|
|
|
for (j = 0; j < COEF_BANDS; j++)
|
|
|
|
{
|
|
|
|
fprintf(f, " {\n");
|
|
|
|
|
|
|
|
for (k = 0; k < PREV_COEF_CONTEXTS; k++)
|
|
|
|
{
|
|
|
|
fprintf(f, " {");
|
|
|
|
|
2011-06-28 23:03:47 +02:00
|
|
|
for (l = 0; l < ENTROPY_NODES; l++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
Sum = tree_update_hist[i][j][k][l][0] + tree_update_hist[i][j][k][l][1];
|
|
|
|
|
|
|
|
if (Sum > 0)
|
|
|
|
{
|
|
|
|
if (((tree_update_hist[i][j][k][l][0] * 255) / Sum) > 0)
|
|
|
|
fprintf(f, "%3ld, ", (tree_update_hist[i][j][k][l][0] * 255) / Sum);
|
|
|
|
else
|
|
|
|
fprintf(f, "%3ld, ", 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf(f, "%3ld, ", 128);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "},\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, " },\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, " },\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "};\n");
|
2011-02-14 23:18:18 +01:00
|
|
|
|
|
|
|
fprintf(f, "const vp8_prob tree_update_probs_8x8[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {\n");
|
|
|
|
|
|
|
|
for (i = 0; i < BLOCK_TYPES; i++)
|
|
|
|
{
|
|
|
|
fprintf(f, " { \n");
|
|
|
|
|
|
|
|
for (j = 0; j < COEF_BANDS; j++)
|
|
|
|
{
|
|
|
|
fprintf(f, " {\n");
|
|
|
|
|
|
|
|
for (k = 0; k < PREV_COEF_CONTEXTS; k++)
|
|
|
|
{
|
|
|
|
fprintf(f, " {");
|
|
|
|
|
|
|
|
for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++)
|
|
|
|
{
|
|
|
|
Sum = tree_update_hist_8x8[i][j][k][l][0] + tree_update_hist_8x8[i][j][k][l][1];
|
|
|
|
|
|
|
|
if (Sum > 0)
|
|
|
|
{
|
|
|
|
if (((tree_update_hist_8x8[i][j][k][l][0] * 255) / Sum) > 0)
|
|
|
|
fprintf(f, "%3ld, ", (tree_update_hist_8x8[i][j][k][l][0] * 255) / Sum);
|
|
|
|
else
|
|
|
|
fprintf(f, "%3ld, ", 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf(f, "%3ld, ", 128);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "},\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, " },\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, " },\n");
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
#endif
|