diff options
author | Dmitry Kovalev <dkovalev@google.com> | 2013-05-28 02:24:52 -0700 |
---|---|---|
committer | Dmitry Kovalev <dkovalev@google.com> | 2013-05-28 02:24:52 -0700 |
commit | 1a24011469d524f24213c955677d27561c56697c (patch) | |
tree | 76e1c2bc3ddb71d157dafebbe461393bbf0f9443 /vp9/encoder | |
parent | 601bab4fdeb4191474bbd3337c64a622b81e968a (diff) | |
download | libvpx-1a24011469d524f24213c955677d27561c56697c.tar libvpx-1a24011469d524f24213c955677d27561c56697c.tar.gz libvpx-1a24011469d524f24213c955677d27561c56697c.tar.bz2 libvpx-1a24011469d524f24213c955677d27561c56697c.zip |
Revert "Adding API to read/write uncompressed frame header bits." because of bitstream mismatches.
This reverts commit df037b615fcc0196386977faae060fdfd9a887a8
Change-Id: I1a529f2590df7bc912f5035d22311268933e3dd6
Diffstat (limited to 'vp9/encoder')
-rw-r--r-- | vp9/encoder/vp9_bitstream.c | 97 | ||||
-rw-r--r-- | vp9/encoder/vp9_onyx_if.c | 3 | ||||
-rw-r--r-- | vp9/encoder/vp9_write_bit_buffer.h | 38 |
3 files changed, 60 insertions, 78 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 7e6b44a54..4ab55b891 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -12,15 +12,20 @@ #include <stdio.h> #include <limits.h> -#include "vpx/vpx_encoder.h" -#include "vpx_mem/vpx_mem.h" - +#include "vp9/common/vp9_header.h" +#include "vp9/encoder/vp9_encodemv.h" #include "vp9/common/vp9_entropymode.h" #include "vp9/common/vp9_entropymv.h" #include "vp9/common/vp9_findnearmv.h" #include "vp9/common/vp9_tile_common.h" +#include "vp9/encoder/vp9_mcomp.h" #include "vp9/common/vp9_systemdependent.h" #include "vp9/common/vp9_pragmas.h" +#include "vpx/vpx_encoder.h" +#include "vpx_mem/vpx_mem.h" +#include "vp9/encoder/vp9_bitstream.h" +#include "vp9/encoder/vp9_segmentation.h" + #include "vp9/common/vp9_seg_common.h" #include "vp9/common/vp9_pred_common.h" #include "vp9/common/vp9_entropy.h" @@ -28,12 +33,6 @@ #include "vp9/common/vp9_mvref_common.h" #include "vp9/common/vp9_treecoder.h" -#include "vp9/encoder/vp9_encodemv.h" -#include "vp9/encoder/vp9_mcomp.h" -#include "vp9/encoder/vp9_bitstream.h" -#include "vp9/encoder/vp9_segmentation.h" -#include "vp9/encoder/vp9_write_bit_buffer.h" - #if defined(SECTIONBITS_OUTPUT) unsigned __int64 Sectionbits[500]; #endif @@ -1279,6 +1278,10 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) { } } +#ifdef PACKET_TESTING +FILE *vpxlogc = 0; +#endif + static void decide_kf_ymode_entropy(VP9_COMP *cpi) { int mode_cost[MB_MODE_COUNT]; int bestcost = INT_MAX; @@ -1489,34 +1492,44 @@ static void encode_segmentation(VP9_COMP *cpi, vp9_writer *w) { void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { int i; + VP9_HEADER oh; VP9_COMMON *const pc = &cpi->common; - MACROBLOCKD *const xd = &cpi->mb.e_mbd; vp9_writer header_bc, residual_bc; + MACROBLOCKD *const xd = &cpi->mb.e_mbd; int extra_bytes_packed = 0; + uint8_t *cx_data = dest; - cx_data += HEADER_SIZE_IN_BYTES; + oh.show_frame = (int) pc->show_frame; + oh.type = (int)pc->frame_type; + oh.version = pc->version; + oh.first_partition_length_in_bytes = 0; + + cx_data += 3; #if defined(SECTIONBITS_OUTPUT) - Sectionbits[active_section = 1] += HEADER_SIZE_IN_BYTES * 8 * 256; + Sectionbits[active_section = 1] += sizeof(VP9_HEADER) * 8 * 256; #endif compute_update_table(); - if (pc->frame_type == KEY_FRAME) { + /* every keyframe send startcode, width, height, scale factor, clamp + * and color type. + */ + if (oh.type == KEY_FRAME) { // Start / synch code cx_data[0] = 0x49; cx_data[1] = 0x83; cx_data[2] = 0x42; - extra_bytes_packed += 3; - cx_data += 3; + extra_bytes_packed = 3; + cx_data += extra_bytes_packed; } if (pc->width != pc->display_width || pc->height != pc->display_height) { write_le16(cx_data, pc->display_width); write_le16(cx_data + 2, pc->display_height); - extra_bytes_packed += 4; cx_data += 4; + extra_bytes_packed += 4; } write_le16(cx_data, pc->width); @@ -1526,6 +1539,12 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_start_encode(&header_bc, cx_data); + // TODO(jkoleszar): remove these two unused bits? + vp9_write_bit(&header_bc, pc->clr_type); + + // error resilient mode + vp9_write_bit(&header_bc, pc->error_resilient_mode); + encode_loopfilter(pc, xd, &header_bc); encode_quantization(pc, &header_bc); @@ -1574,8 +1593,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_write_literal(&header_bc, cpi->alt_fb_idx, NUM_REF_FRAMES_LG2); // Indicate the sign bias for each reference frame buffer. - for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) + for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) { vp9_write_bit(&header_bc, pc->ref_frame_sign_bias[LAST_FRAME + i]); + } // Signal whether to allow high MV precision vp9_write_bit(&header_bc, (xd->allow_high_precision_mv) ? 1 : 0); @@ -1605,6 +1625,11 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_write_literal(&header_bc, (pc->mcomp_filter_type), 2); } + if (!pc->error_resilient_mode) { + vp9_write_bit(&header_bc, pc->refresh_frame_context); + vp9_write_bit(&header_bc, pc->frame_parallel_decoding_mode); + } + vp9_write_literal(&header_bc, pc->frame_context_idx, NUM_FRAME_CONTEXTS_LG2); @@ -1803,35 +1828,27 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_stop_encode(&header_bc); + oh.first_partition_length_in_bytes = header_bc.pos; + /* update frame tag */ { - const int first_partition_length_in_bytes = header_bc.pos; int scaling = (pc->width != pc->display_width || pc->height != pc->display_height); - - struct vp9_write_bit_buffer wb = {dest, 0}; - - assert(first_partition_length_in_bytes <= 0xffff); - - vp9_wb_write_bit(&wb, pc->frame_type); - vp9_wb_write_literal(&wb, pc->version, 3); - vp9_wb_write_bit(&wb, pc->show_frame); - vp9_wb_write_bit(&wb, scaling); - vp9_wb_write_bit(&wb, pc->subsampling_x); - vp9_wb_write_bit(&wb, pc->subsampling_y); - - vp9_wb_write_bit(&wb, pc->clr_type); - vp9_wb_write_bit(&wb, pc->error_resilient_mode); - if (!pc->error_resilient_mode) { - vp9_wb_write_bit(&wb, pc->refresh_frame_context); - vp9_wb_write_bit(&wb, pc->frame_parallel_decoding_mode); - } - - - vp9_wb_write_literal(&wb, first_partition_length_in_bytes, 16); + int v = (oh.first_partition_length_in_bytes << 8) | + (pc->subsampling_y << 7) | + (pc->subsampling_x << 6) | + (scaling << 5) | + (oh.show_frame << 4) | + (oh.version << 1) | + oh.type; + + assert(oh.first_partition_length_in_bytes <= 0xffff); + dest[0] = v; + dest[1] = v >> 8; + dest[2] = v >> 16; } - *size = HEADER_SIZE_IN_BYTES + extra_bytes_packed + header_bc.pos; + *size = VP9_HEADER_SIZE + extra_bytes_packed + header_bc.pos; if (pc->frame_type == KEY_FRAME) { decide_kf_ymode_entropy(cpi); diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 0dc4e3fea..36a79a048 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -258,6 +258,9 @@ void vp9_initialize_enc() { init_done = 1; } } +#ifdef PACKET_TESTING +extern FILE *vpxlogc; +#endif static void setup_features(VP9_COMP *cpi) { MACROBLOCKD *xd = &cpi->mb.e_mbd; diff --git a/vp9/encoder/vp9_write_bit_buffer.h b/vp9/encoder/vp9_write_bit_buffer.h deleted file mode 100644 index 88da236d0..000000000 --- a/vp9/encoder/vp9_write_bit_buffer.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef VP9_BIT_WRITE_BUFFER_H_ -#define VP9_BIT_WRITE_BUFFER_H_ - -#include "vpx/vpx_integer.h" - -struct vp9_write_bit_buffer { - uint8_t *const bit_buffer; - size_t bit_offset; -}; - -static void vp9_wb_write_bit(struct vp9_write_bit_buffer *wb, int bit) { - const int off = wb->bit_offset; - const int p = off / CHAR_BIT; - const int q = /*CHAR_BIT - 1 -*/ off % CHAR_BIT; - wb->bit_buffer[p] &= ~(1 << q); - wb->bit_buffer[p] |= bit << q; - wb->bit_offset = off + 1; -} - -static void vp9_wb_write_literal(struct vp9_write_bit_buffer *wb, - int data, int bits) { - int bit; - for (bit = bits - 1; bit >= 0; bit--) - vp9_wb_write_bit(wb, (data >> bit) & 1); -} - - -#endif // VP9_BIT_WRITE_BUFFER_H_ |