|
|
@@ -152,7 +152,6 @@ static int FUNC(interpolation_filter)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
VP9RawFrameHeader *current)
|
|
|
|
VP9RawFrameHeader *current)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CodedBitstreamVP9Context *vp9 = ctx->priv_data;
|
|
|
|
|
|
|
|
int err, i;
|
|
|
|
int err, i;
|
|
|
|
|
|
|
|
|
|
|
|
f(6, loop_filter_level);
|
|
|
|
f(6, loop_filter_level);
|
|
|
@@ -160,8 +159,6 @@ static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
|
|
|
|
|
|
|
|
f(1, loop_filter_delta_enabled);
|
|
|
|
f(1, loop_filter_delta_enabled);
|
|
|
|
if (current->loop_filter_delta_enabled) {
|
|
|
|
if (current->loop_filter_delta_enabled) {
|
|
|
|
memcpy(current->loop_filter_ref_deltas, vp9->loop_filter_ref_deltas, sizeof(vp9->loop_filter_ref_deltas));
|
|
|
|
|
|
|
|
memcpy(current->loop_filter_mode_deltas, vp9->loop_filter_mode_deltas, sizeof(vp9->loop_filter_mode_deltas));
|
|
|
|
|
|
|
|
f(1, loop_filter_delta_update);
|
|
|
|
f(1, loop_filter_delta_update);
|
|
|
|
if (current->loop_filter_delta_update) {
|
|
|
|
if (current->loop_filter_delta_update) {
|
|
|
|
for (i = 0; i < VP9_MAX_REF_FRAMES; i++) {
|
|
|
|
for (i = 0; i < VP9_MAX_REF_FRAMES; i++) {
|
|
|
@@ -174,9 +171,9 @@ static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
if (current->update_mode_delta[i])
|
|
|
|
if (current->update_mode_delta[i])
|
|
|
|
ss(6, loop_filter_mode_deltas[i], 1, i);
|
|
|
|
ss(6, loop_filter_mode_deltas[i], 1, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy(vp9->loop_filter_ref_deltas, current->loop_filter_ref_deltas, sizeof(vp9->loop_filter_ref_deltas));
|
|
|
|
|
|
|
|
memcpy(vp9->loop_filter_mode_deltas, current->loop_filter_mode_deltas, sizeof(vp9->loop_filter_mode_deltas));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
infer(loop_filter_delta_update, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@@ -201,18 +198,11 @@ static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static const uint8_t segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 };
|
|
|
|
static const uint8_t segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 };
|
|
|
|
static const uint8_t segmentation_feature_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 };
|
|
|
|
static const uint8_t segmentation_feature_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 };
|
|
|
|
|
|
|
|
|
|
|
|
CodedBitstreamVP9Context *vp9 = ctx->priv_data;
|
|
|
|
|
|
|
|
int err, i, j;
|
|
|
|
int err, i, j;
|
|
|
|
|
|
|
|
|
|
|
|
f(1, segmentation_enabled);
|
|
|
|
f(1, segmentation_enabled);
|
|
|
|
|
|
|
|
|
|
|
|
if (current->segmentation_enabled) {
|
|
|
|
if (current->segmentation_enabled) {
|
|
|
|
memcpy(current->segmentation_tree_probs, vp9->segmentation_tree_probs, sizeof(vp9->segmentation_tree_probs));
|
|
|
|
|
|
|
|
memcpy(current->segmentation_pred_prob, vp9->segmentation_pred_prob, sizeof(vp9->segmentation_pred_prob));
|
|
|
|
|
|
|
|
memcpy(current->feature_enabled, vp9->feature_enabled, sizeof(vp9->feature_enabled));
|
|
|
|
|
|
|
|
memcpy(current->feature_value, vp9->feature_value, sizeof(vp9->feature_value));
|
|
|
|
|
|
|
|
memcpy(current->feature_sign, vp9->feature_sign, sizeof(vp9->feature_sign));
|
|
|
|
|
|
|
|
f(1, segmentation_update_map);
|
|
|
|
f(1, segmentation_update_map);
|
|
|
|
if (current->segmentation_update_map) {
|
|
|
|
if (current->segmentation_update_map) {
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
@@ -224,8 +214,6 @@ static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
else
|
|
|
|
else
|
|
|
|
infer(segmentation_pred_prob[i], 255);
|
|
|
|
infer(segmentation_pred_prob[i], 255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy(vp9->segmentation_tree_probs, current->segmentation_tree_probs, sizeof(vp9->segmentation_tree_probs));
|
|
|
|
|
|
|
|
memcpy(vp9->segmentation_pred_prob, current->segmentation_pred_prob, sizeof(vp9->segmentation_pred_prob));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
f(1, segmentation_update_data);
|
|
|
|
f(1, segmentation_update_data);
|
|
|
@@ -248,10 +236,9 @@ static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy(vp9->feature_enabled, current->feature_enabled, sizeof(vp9->feature_enabled));
|
|
|
|
|
|
|
|
memcpy(vp9->feature_value, current->feature_value, sizeof(vp9->feature_value));
|
|
|
|
|
|
|
|
memcpy(vp9->feature_sign, current->feature_sign, sizeof(vp9->feature_sign));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
infer(segmentation_update_data, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@@ -368,18 +355,6 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
|
|
|
|
|
|
|
|
f(2, frame_context_idx);
|
|
|
|
f(2, frame_context_idx);
|
|
|
|
|
|
|
|
|
|
|
|
if (current->frame_type == VP9_KEY_FRAME || current->error_resilient_mode || current->intra_only) {
|
|
|
|
|
|
|
|
infer(update_ref_delta[0], 1);
|
|
|
|
|
|
|
|
infer(update_ref_delta[1], 0);
|
|
|
|
|
|
|
|
infer(update_ref_delta[2], -1);
|
|
|
|
|
|
|
|
infer(update_ref_delta[3], -1);
|
|
|
|
|
|
|
|
infer(loop_filter_mode_deltas[0], 0);
|
|
|
|
|
|
|
|
infer(loop_filter_mode_deltas[1], 0);
|
|
|
|
|
|
|
|
memset(vp9->feature_enabled, 0, sizeof(current->feature_enabled));
|
|
|
|
|
|
|
|
memset(vp9->feature_value, 0, sizeof(current->feature_value));
|
|
|
|
|
|
|
|
memset(vp9->feature_sign, 0, sizeof(current->feature_sign));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHECK(FUNC(loop_filter_params)(ctx, rw, current));
|
|
|
|
CHECK(FUNC(loop_filter_params)(ctx, rw, current));
|
|
|
|
CHECK(FUNC(quantization_params)(ctx, rw, current));
|
|
|
|
CHECK(FUNC(quantization_params)(ctx, rw, current));
|
|
|
|
CHECK(FUNC(segmentation_params)(ctx, rw, current));
|
|
|
|
CHECK(FUNC(segmentation_params)(ctx, rw, current));
|
|
|
@@ -399,6 +374,60 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update top-level loop filter and segmentation state with changes
|
|
|
|
|
|
|
|
// from this frame.
|
|
|
|
|
|
|
|
if (current->frame_type == VP9_KEY_FRAME ||
|
|
|
|
|
|
|
|
current->intra_only ||
|
|
|
|
|
|
|
|
current->error_resilient_mode) {
|
|
|
|
|
|
|
|
// setup_past_independence() - fill with the initial values.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vp9->loop_filter_ref_deltas[VP9_INTRA_FRAME] = 1;
|
|
|
|
|
|
|
|
vp9->loop_filter_ref_deltas[VP9_LAST_FRAME] = 0;
|
|
|
|
|
|
|
|
vp9->loop_filter_ref_deltas[VP9_GOLDEN_FRAME] = -1;
|
|
|
|
|
|
|
|
vp9->loop_filter_ref_deltas[VP9_ALTREF_FRAME] = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vp9->loop_filter_mode_deltas[0] = 0;
|
|
|
|
|
|
|
|
vp9->loop_filter_mode_deltas[1] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(vp9->feature_enabled, 0, sizeof(vp9->feature_enabled));
|
|
|
|
|
|
|
|
memset(vp9->feature_value, 0, sizeof(vp9->feature_value));
|
|
|
|
|
|
|
|
memset(vp9->feature_sign, 0, sizeof(vp9->feature_sign));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Modify previous state based on updates in this frame.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (current->loop_filter_delta_update) {
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
|
|
|
|
if (current->update_ref_delta[i])
|
|
|
|
|
|
|
|
vp9->loop_filter_ref_deltas[i] =
|
|
|
|
|
|
|
|
current->loop_filter_ref_deltas[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
|
|
|
|
if (current->update_mode_delta[i])
|
|
|
|
|
|
|
|
vp9->loop_filter_mode_deltas[i] =
|
|
|
|
|
|
|
|
current->loop_filter_mode_deltas[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (current->segmentation_update_data) {
|
|
|
|
|
|
|
|
memcpy(vp9->feature_enabled, current->feature_enabled,
|
|
|
|
|
|
|
|
sizeof(vp9->feature_enabled));
|
|
|
|
|
|
|
|
memcpy(vp9->feature_value, current->feature_value,
|
|
|
|
|
|
|
|
sizeof(vp9->feature_value));
|
|
|
|
|
|
|
|
memcpy(vp9->feature_sign, current->feature_sign,
|
|
|
|
|
|
|
|
sizeof(vp9->feature_sign));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (current->segmentation_update_map) {
|
|
|
|
|
|
|
|
memcpy(vp9->segmentation_tree_probs,
|
|
|
|
|
|
|
|
current->segmentation_tree_probs,
|
|
|
|
|
|
|
|
sizeof(vp9->segmentation_tree_probs));
|
|
|
|
|
|
|
|
memcpy(vp9->segmentation_pred_prob,
|
|
|
|
|
|
|
|
current->segmentation_pred_prob,
|
|
|
|
|
|
|
|
sizeof(vp9->segmentation_pred_prob));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame: size %dx%d "
|
|
|
|
av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame: size %dx%d "
|
|
|
|
"subsample %dx%d bit_depth %d tiles %dx%d.\n",
|
|
|
|
"subsample %dx%d bit_depth %d tiles %dx%d.\n",
|
|
|
|
vp9->frame_width, vp9->frame_height,
|
|
|
|
vp9->frame_width, vp9->frame_height,
|
|
|
|