Merge "Adding API to read/write uncompressed frame header bits." into experimental
This commit is contained in:
commit
0b2b81249b
@ -60,4 +60,8 @@ static INLINE int multiple16(int value) {
|
|||||||
return (value + 15) & ~15;
|
return (value + 15) & ~15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(dkovalev): remove later
|
||||||
|
#define HEADER_SIZE_IN_BYTES 4
|
||||||
|
|
||||||
|
|
||||||
#endif // VP9_COMMON_VP9_COMMON_H_
|
#endif // VP9_COMMON_VP9_COMMON_H_
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2010 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_COMMON_VP9_HEADER_H_
|
|
||||||
#define VP9_COMMON_VP9_HEADER_H_
|
|
||||||
|
|
||||||
/* 24 bits total */
|
|
||||||
typedef struct {
|
|
||||||
unsigned int type: 1;
|
|
||||||
unsigned int version: 3;
|
|
||||||
unsigned int show_frame: 1;
|
|
||||||
|
|
||||||
/* Allow 2^20 bytes = 8 megabits for first partition */
|
|
||||||
|
|
||||||
unsigned int first_partition_length_in_bytes: 19;
|
|
||||||
|
|
||||||
#ifdef PACKET_TESTING
|
|
||||||
unsigned int frame_number;
|
|
||||||
unsigned int update_gold: 1;
|
|
||||||
unsigned int uses_gold: 1;
|
|
||||||
unsigned int update_last: 1;
|
|
||||||
unsigned int uses_last: 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} VP9_HEADER;
|
|
||||||
|
|
||||||
#ifdef PACKET_TESTING
|
|
||||||
#define VP9_HEADER_SIZE 8
|
|
||||||
#else
|
|
||||||
#define VP9_HEADER_SIZE 3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // VP9_COMMON_VP9_HEADER_H_
|
|
@ -24,10 +24,6 @@
|
|||||||
#include "vp9/common/vp9_postproc.h"
|
#include "vp9/common/vp9_postproc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*#ifdef PACKET_TESTING*/
|
|
||||||
#include "vp9/common/vp9_header.h"
|
|
||||||
/*#endif*/
|
|
||||||
|
|
||||||
/* Create/destroy static data structures. */
|
/* Create/destroy static data structures. */
|
||||||
|
|
||||||
void vp9_initialize_common(void);
|
void vp9_initialize_common(void);
|
||||||
@ -262,9 +258,6 @@ typedef struct VP9Common {
|
|||||||
int near_boffset[3];
|
int near_boffset[3];
|
||||||
int version;
|
int version;
|
||||||
|
|
||||||
#ifdef PACKET_TESTING
|
|
||||||
VP9_HEADER oh;
|
|
||||||
#endif
|
|
||||||
double bitrate;
|
double bitrate;
|
||||||
double framerate;
|
double framerate;
|
||||||
|
|
||||||
|
@ -10,29 +10,31 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "vp9/decoder/vp9_onyxd_int.h"
|
#include "./vp9_rtcd.h"
|
||||||
|
|
||||||
|
#include "vpx_scale/vpx_scale.h"
|
||||||
|
#include "vpx_mem/vpx_mem.h"
|
||||||
|
|
||||||
#include "vp9/common/vp9_common.h"
|
#include "vp9/common/vp9_common.h"
|
||||||
#include "vp9/common/vp9_header.h"
|
|
||||||
#include "vp9/common/vp9_reconintra.h"
|
#include "vp9/common/vp9_reconintra.h"
|
||||||
#include "vp9/common/vp9_reconinter.h"
|
#include "vp9/common/vp9_reconinter.h"
|
||||||
#include "vp9/common/vp9_entropy.h"
|
#include "vp9/common/vp9_entropy.h"
|
||||||
#include "vp9/decoder/vp9_decodframe.h"
|
|
||||||
#include "vp9/decoder/vp9_detokenize.h"
|
|
||||||
#include "vp9/common/vp9_invtrans.h"
|
#include "vp9/common/vp9_invtrans.h"
|
||||||
#include "vp9/common/vp9_alloccommon.h"
|
#include "vp9/common/vp9_alloccommon.h"
|
||||||
#include "vp9/common/vp9_entropymode.h"
|
#include "vp9/common/vp9_entropymode.h"
|
||||||
#include "vp9/common/vp9_quant_common.h"
|
#include "vp9/common/vp9_quant_common.h"
|
||||||
#include "vpx_scale/vpx_scale.h"
|
|
||||||
|
|
||||||
#include "vp9/decoder/vp9_decodemv.h"
|
|
||||||
#include "vp9/common/vp9_extend.h"
|
#include "vp9/common/vp9_extend.h"
|
||||||
#include "vp9/common/vp9_modecont.h"
|
#include "vp9/common/vp9_modecont.h"
|
||||||
#include "vpx_mem/vpx_mem.h"
|
|
||||||
#include "vp9/decoder/vp9_dboolhuff.h"
|
|
||||||
|
|
||||||
#include "vp9/common/vp9_seg_common.h"
|
#include "vp9/common/vp9_seg_common.h"
|
||||||
#include "vp9/common/vp9_tile_common.h"
|
#include "vp9/common/vp9_tile_common.h"
|
||||||
#include "vp9_rtcd.h"
|
|
||||||
|
#include "vp9/decoder/vp9_decodemv.h"
|
||||||
|
#include "vp9/decoder/vp9_dboolhuff.h"
|
||||||
|
#include "vp9/decoder/vp9_read_bit_buffer.h"
|
||||||
|
#include "vp9/decoder/vp9_onyxd_int.h"
|
||||||
|
#include "vp9/decoder/vp9_decodframe.h"
|
||||||
|
#include "vp9/decoder/vp9_detokenize.h"
|
||||||
|
|
||||||
|
|
||||||
// #define DEC_DEBUG
|
// #define DEC_DEBUG
|
||||||
#ifdef DEC_DEBUG
|
#ifdef DEC_DEBUG
|
||||||
@ -949,7 +951,7 @@ static void decode_tiles(VP9D_COMP *pbi,
|
|||||||
int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
||||||
vp9_reader header_bc, residual_bc;
|
vp9_reader header_bc, residual_bc;
|
||||||
VP9_COMMON *const pc = &pbi->common;
|
VP9_COMMON *const pc = &pbi->common;
|
||||||
MACROBLOCKD *const xd = &pbi->mb;
|
MACROBLOCKD *const xd = &pbi->mb;
|
||||||
const uint8_t *data = pbi->source;
|
const uint8_t *data = pbi->source;
|
||||||
const uint8_t *data_end = data + pbi->source_sz;
|
const uint8_t *data_end = data + pbi->source_sz;
|
||||||
size_t first_partition_size = 0;
|
size_t first_partition_size = 0;
|
||||||
@ -959,24 +961,40 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||||||
xd->corrupted = 0; // start with no corruption of current frame
|
xd->corrupted = 0; // start with no corruption of current frame
|
||||||
new_fb->corrupted = 0;
|
new_fb->corrupted = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (data_end - data < 3) {
|
if (data_end - data < 3) {
|
||||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet");
|
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet");
|
||||||
} else {
|
} else {
|
||||||
|
struct vp9_read_bit_buffer rb = {data, 0};
|
||||||
|
|
||||||
int scaling_active;
|
int scaling_active;
|
||||||
pc->last_frame_type = pc->frame_type;
|
pc->last_frame_type = pc->frame_type;
|
||||||
pc->frame_type = (FRAME_TYPE)(data[0] & 1);
|
|
||||||
pc->version = (data[0] >> 1) & 7;
|
pc->frame_type = (FRAME_TYPE) vp9_rb_read_bit(&rb);
|
||||||
pc->show_frame = (data[0] >> 4) & 1;
|
pc->version = vp9_rb_read_literal(&rb, 3);
|
||||||
scaling_active = (data[0] >> 5) & 1;
|
pc->show_frame = vp9_rb_read_bit(&rb);
|
||||||
pc->subsampling_x = (data[0] >> 6) & 1;
|
scaling_active = vp9_rb_read_bit(&rb);
|
||||||
pc->subsampling_y = (data[0] >> 7) & 1;
|
pc->subsampling_x = vp9_rb_read_bit(&rb);
|
||||||
first_partition_size = read_le16(data + 1);
|
pc->subsampling_y = vp9_rb_read_bit(&rb);
|
||||||
|
|
||||||
|
pc->clr_type = (YUV_TYPE)vp9_rb_read_bit(&rb);
|
||||||
|
pc->error_resilient_mode = vp9_rb_read_bit(&rb);
|
||||||
|
if (!pc->error_resilient_mode) {
|
||||||
|
pc->refresh_frame_context = vp9_rb_read_bit(&rb);
|
||||||
|
pc->frame_parallel_decoding_mode = vp9_rb_read_bit(&rb);
|
||||||
|
} else {
|
||||||
|
pc->refresh_frame_context = 0;
|
||||||
|
pc->frame_parallel_decoding_mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
first_partition_size = vp9_rb_read_literal(&rb, 16);
|
||||||
|
|
||||||
if (!read_is_valid(data, first_partition_size, data_end))
|
if (!read_is_valid(data, first_partition_size, data_end))
|
||||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||||
"Truncated packet or corrupt partition 0 length");
|
"Truncated packet or corrupt partition 0 length");
|
||||||
|
|
||||||
data += 3;
|
data += HEADER_SIZE_IN_BYTES; // header size
|
||||||
|
|
||||||
vp9_setup_version(pc);
|
vp9_setup_version(pc);
|
||||||
|
|
||||||
@ -1010,9 +1028,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||||||
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
|
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
|
||||||
"Failed to allocate bool decoder 0");
|
"Failed to allocate bool decoder 0");
|
||||||
|
|
||||||
pc->clr_type = (YUV_TYPE)vp9_read_bit(&header_bc);
|
|
||||||
pc->error_resilient_mode = vp9_read_bit(&header_bc);
|
|
||||||
|
|
||||||
setup_loopfilter(pc, xd, &header_bc);
|
setup_loopfilter(pc, xd, &header_bc);
|
||||||
|
|
||||||
setup_quantization(pbi, &header_bc);
|
setup_quantization(pbi, &header_bc);
|
||||||
@ -1059,14 +1074,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
|
|||||||
vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
|
vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pc->error_resilient_mode) {
|
|
||||||
pc->refresh_frame_context = vp9_read_bit(&header_bc);
|
|
||||||
pc->frame_parallel_decoding_mode = vp9_read_bit(&header_bc);
|
|
||||||
} else {
|
|
||||||
pc->refresh_frame_context = 0;
|
|
||||||
pc->frame_parallel_decoding_mode = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pc->frame_context_idx = vp9_read_literal(&header_bc, NUM_FRAME_CONTEXTS_LG2);
|
pc->frame_context_idx = vp9_read_literal(&header_bc, NUM_FRAME_CONTEXTS_LG2);
|
||||||
pc->fc = pc->frame_contexts[pc->frame_context_idx];
|
pc->fc = pc->frame_contexts[pc->frame_context_idx];
|
||||||
|
|
||||||
|
35
vp9/decoder/vp9_read_bit_buffer.h
Normal file
35
vp9/decoder/vp9_read_bit_buffer.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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_READ_BIT_BUFFER_
|
||||||
|
#define VP9_READ_BIT_BUFFER_
|
||||||
|
|
||||||
|
struct vp9_read_bit_buffer {
|
||||||
|
const uint8_t *const bit_buffer;
|
||||||
|
size_t bit_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int vp9_rb_read_bit(struct vp9_read_bit_buffer *rb) {
|
||||||
|
const int off = rb->bit_offset;
|
||||||
|
const int p = off / CHAR_BIT;
|
||||||
|
const int q = /*CHAR_BIT - 1 -*/ off % CHAR_BIT;
|
||||||
|
const int bit = (rb->bit_buffer[p] & (1 << q)) >> q;
|
||||||
|
rb->bit_offset = off + 1;
|
||||||
|
return bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vp9_rb_read_literal(struct vp9_read_bit_buffer *rb, int bits) {
|
||||||
|
int value = 0, bit;
|
||||||
|
for (bit = bits - 1; bit >= 0; bit--)
|
||||||
|
value |= vp9_rb_read_bit(rb) << bit;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // VP9_READ_BIT_BUFFER_
|
@ -12,28 +12,28 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "vp9/common/vp9_header.h"
|
#include "vpx/vpx_encoder.h"
|
||||||
#include "vp9/encoder/vp9_encodemv.h"
|
#include "vpx_mem/vpx_mem.h"
|
||||||
|
|
||||||
#include "vp9/common/vp9_entropymode.h"
|
#include "vp9/common/vp9_entropymode.h"
|
||||||
#include "vp9/common/vp9_entropymv.h"
|
#include "vp9/common/vp9_entropymv.h"
|
||||||
#include "vp9/common/vp9_findnearmv.h"
|
#include "vp9/common/vp9_findnearmv.h"
|
||||||
#include "vp9/common/vp9_tile_common.h"
|
#include "vp9/common/vp9_tile_common.h"
|
||||||
#include "vp9/encoder/vp9_mcomp.h"
|
|
||||||
#include "vp9/common/vp9_systemdependent.h"
|
#include "vp9/common/vp9_systemdependent.h"
|
||||||
#include "vp9/common/vp9_pragmas.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_seg_common.h"
|
||||||
#include "vp9/common/vp9_pred_common.h"
|
#include "vp9/common/vp9_pred_common.h"
|
||||||
#include "vp9/common/vp9_entropy.h"
|
#include "vp9/common/vp9_entropy.h"
|
||||||
#include "vp9/encoder/vp9_encodemv.h"
|
|
||||||
#include "vp9/common/vp9_entropymv.h"
|
#include "vp9/common/vp9_entropymv.h"
|
||||||
#include "vp9/common/vp9_mvref_common.h"
|
#include "vp9/common/vp9_mvref_common.h"
|
||||||
#include "vp9/common/vp9_treecoder.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)
|
#if defined(SECTIONBITS_OUTPUT)
|
||||||
unsigned __int64 Sectionbits[500];
|
unsigned __int64 Sectionbits[500];
|
||||||
#endif
|
#endif
|
||||||
@ -1299,10 +1299,6 @@ 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) {
|
static void decide_kf_ymode_entropy(VP9_COMP *cpi) {
|
||||||
int mode_cost[MB_MODE_COUNT];
|
int mode_cost[MB_MODE_COUNT];
|
||||||
int bestcost = INT_MAX;
|
int bestcost = INT_MAX;
|
||||||
@ -1513,44 +1509,34 @@ static void encode_segmentation(VP9_COMP *cpi, vp9_writer *w) {
|
|||||||
|
|
||||||
void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
|
void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
|
||||||
int i;
|
int i;
|
||||||
VP9_HEADER oh;
|
|
||||||
VP9_COMMON *const pc = &cpi->common;
|
VP9_COMMON *const pc = &cpi->common;
|
||||||
vp9_writer header_bc, residual_bc;
|
|
||||||
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
|
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
|
||||||
|
vp9_writer header_bc, residual_bc;
|
||||||
int extra_bytes_packed = 0;
|
int extra_bytes_packed = 0;
|
||||||
|
|
||||||
uint8_t *cx_data = dest;
|
uint8_t *cx_data = dest;
|
||||||
|
|
||||||
oh.show_frame = (int) pc->show_frame;
|
cx_data += HEADER_SIZE_IN_BYTES;
|
||||||
oh.type = (int)pc->frame_type;
|
|
||||||
oh.version = pc->version;
|
|
||||||
oh.first_partition_length_in_bytes = 0;
|
|
||||||
|
|
||||||
cx_data += 3;
|
|
||||||
|
|
||||||
#if defined(SECTIONBITS_OUTPUT)
|
#if defined(SECTIONBITS_OUTPUT)
|
||||||
Sectionbits[active_section = 1] += sizeof(VP9_HEADER) * 8 * 256;
|
Sectionbits[active_section = 1] += HEADER_SIZE_IN_BYTES * 8 * 256;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
compute_update_table();
|
compute_update_table();
|
||||||
|
|
||||||
/* every keyframe send startcode, width, height, scale factor, clamp
|
if (pc->frame_type == KEY_FRAME) {
|
||||||
* and color type.
|
|
||||||
*/
|
|
||||||
if (oh.type == KEY_FRAME) {
|
|
||||||
// Start / synch code
|
// Start / synch code
|
||||||
cx_data[0] = 0x49;
|
cx_data[0] = 0x49;
|
||||||
cx_data[1] = 0x83;
|
cx_data[1] = 0x83;
|
||||||
cx_data[2] = 0x42;
|
cx_data[2] = 0x42;
|
||||||
extra_bytes_packed = 3;
|
extra_bytes_packed += 3;
|
||||||
cx_data += extra_bytes_packed;
|
cx_data += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pc->width != pc->display_width || pc->height != pc->display_height) {
|
if (pc->width != pc->display_width || pc->height != pc->display_height) {
|
||||||
write_le16(cx_data, pc->display_width);
|
write_le16(cx_data, pc->display_width);
|
||||||
write_le16(cx_data + 2, pc->display_height);
|
write_le16(cx_data + 2, pc->display_height);
|
||||||
cx_data += 4;
|
|
||||||
extra_bytes_packed += 4;
|
extra_bytes_packed += 4;
|
||||||
|
cx_data += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_le16(cx_data, pc->width);
|
write_le16(cx_data, pc->width);
|
||||||
@ -1560,12 +1546,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
|
|||||||
|
|
||||||
vp9_start_encode(&header_bc, cx_data);
|
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_loopfilter(pc, xd, &header_bc);
|
||||||
|
|
||||||
encode_quantization(pc, &header_bc);
|
encode_quantization(pc, &header_bc);
|
||||||
@ -1614,9 +1594,8 @@ 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);
|
vp9_write_literal(&header_bc, cpi->alt_fb_idx, NUM_REF_FRAMES_LG2);
|
||||||
|
|
||||||
// Indicate the sign bias for each reference frame buffer.
|
// 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]);
|
vp9_write_bit(&header_bc, pc->ref_frame_sign_bias[LAST_FRAME + i]);
|
||||||
}
|
|
||||||
|
|
||||||
// Signal whether to allow high MV precision
|
// Signal whether to allow high MV precision
|
||||||
vp9_write_bit(&header_bc, (xd->allow_high_precision_mv) ? 1 : 0);
|
vp9_write_bit(&header_bc, (xd->allow_high_precision_mv) ? 1 : 0);
|
||||||
@ -1646,11 +1625,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
|
|||||||
vp9_write_literal(&header_bc, (pc->mcomp_filter_type), 2);
|
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,
|
vp9_write_literal(&header_bc, pc->frame_context_idx,
|
||||||
NUM_FRAME_CONTEXTS_LG2);
|
NUM_FRAME_CONTEXTS_LG2);
|
||||||
|
|
||||||
@ -1851,27 +1825,35 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
|
|||||||
|
|
||||||
vp9_stop_encode(&header_bc);
|
vp9_stop_encode(&header_bc);
|
||||||
|
|
||||||
oh.first_partition_length_in_bytes = header_bc.pos;
|
|
||||||
|
|
||||||
/* update frame tag */
|
/* update frame tag */
|
||||||
{
|
{
|
||||||
|
const int first_partition_length_in_bytes = header_bc.pos;
|
||||||
int scaling = (pc->width != pc->display_width ||
|
int scaling = (pc->width != pc->display_width ||
|
||||||
pc->height != pc->display_height);
|
pc->height != pc->display_height);
|
||||||
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);
|
struct vp9_write_bit_buffer wb = {dest, 0};
|
||||||
dest[0] = v;
|
|
||||||
dest[1] = v >> 8;
|
assert(first_partition_length_in_bytes <= 0xffff);
|
||||||
dest[2] = v >> 16;
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
*size = VP9_HEADER_SIZE + extra_bytes_packed + header_bc.pos;
|
*size = HEADER_SIZE_IN_BYTES + extra_bytes_packed + header_bc.pos;
|
||||||
|
|
||||||
if (pc->frame_type == KEY_FRAME) {
|
if (pc->frame_type == KEY_FRAME) {
|
||||||
decide_kf_ymode_entropy(cpi);
|
decide_kf_ymode_entropy(cpi);
|
||||||
|
@ -258,9 +258,6 @@ void vp9_initialize_enc() {
|
|||||||
init_done = 1;
|
init_done = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PACKET_TESTING
|
|
||||||
extern FILE *vpxlogc;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void setup_features(VP9_COMP *cpi) {
|
static void setup_features(VP9_COMP *cpi) {
|
||||||
MACROBLOCKD *xd = &cpi->mb.e_mbd;
|
MACROBLOCKD *xd = &cpi->mb.e_mbd;
|
||||||
|
38
vp9/encoder/vp9_write_bit_buffer.h
Normal file
38
vp9/encoder/vp9_write_bit_buffer.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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_
|
@ -38,7 +38,6 @@ VP9_COMMON_SRCS-yes += common/vp9_entropymv.h
|
|||||||
VP9_COMMON_SRCS-yes += common/vp9_enums.h
|
VP9_COMMON_SRCS-yes += common/vp9_enums.h
|
||||||
VP9_COMMON_SRCS-yes += common/vp9_extend.h
|
VP9_COMMON_SRCS-yes += common/vp9_extend.h
|
||||||
VP9_COMMON_SRCS-yes += common/vp9_findnearmv.h
|
VP9_COMMON_SRCS-yes += common/vp9_findnearmv.h
|
||||||
VP9_COMMON_SRCS-yes += common/vp9_header.h
|
|
||||||
VP9_COMMON_SRCS-yes += common/vp9_idct.h
|
VP9_COMMON_SRCS-yes += common/vp9_idct.h
|
||||||
VP9_COMMON_SRCS-yes += common/vp9_invtrans.h
|
VP9_COMMON_SRCS-yes += common/vp9_invtrans.h
|
||||||
VP9_COMMON_SRCS-yes += common/vp9_loopfilter.h
|
VP9_COMMON_SRCS-yes += common/vp9_loopfilter.h
|
||||||
|
@ -224,7 +224,7 @@ static vpx_codec_err_t vp8_peek_si(const uint8_t *data,
|
|||||||
si->is_kf = 0;
|
si->is_kf = 0;
|
||||||
|
|
||||||
if (data_sz >= 10 && !(data[0] & 0x01)) { /* I-Frame */
|
if (data_sz >= 10 && !(data[0] & 0x01)) { /* I-Frame */
|
||||||
const uint8_t *c = data + 3;
|
const uint8_t *c = data + HEADER_SIZE_IN_BYTES;
|
||||||
si->is_kf = 1;
|
si->is_kf = 1;
|
||||||
|
|
||||||
/* vet via sync code */
|
/* vet via sync code */
|
||||||
|
@ -19,6 +19,8 @@ VP9_CX_SRCS-yes += vp9_cx_iface.c
|
|||||||
|
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_bitstream.c
|
VP9_CX_SRCS-yes += encoder/vp9_bitstream.c
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_boolhuff.c
|
VP9_CX_SRCS-yes += encoder/vp9_boolhuff.c
|
||||||
|
VP9_CX_SRCS-yes += encoder/vp9_boolhuff.h
|
||||||
|
VP9_CX_SRCS-yes += encoder/vp9_write_bit_buffer.h
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_dct.c
|
VP9_CX_SRCS-yes += encoder/vp9_dct.c
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_encodeframe.c
|
VP9_CX_SRCS-yes += encoder/vp9_encodeframe.c
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_encodeframe.h
|
VP9_CX_SRCS-yes += encoder/vp9_encodeframe.h
|
||||||
@ -27,7 +29,6 @@ VP9_CX_SRCS-yes += encoder/vp9_encodemb.c
|
|||||||
VP9_CX_SRCS-yes += encoder/vp9_encodemv.c
|
VP9_CX_SRCS-yes += encoder/vp9_encodemv.c
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_firstpass.c
|
VP9_CX_SRCS-yes += encoder/vp9_firstpass.c
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_block.h
|
VP9_CX_SRCS-yes += encoder/vp9_block.h
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_boolhuff.h
|
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_bitstream.h
|
VP9_CX_SRCS-yes += encoder/vp9_bitstream.h
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_encodeintra.h
|
VP9_CX_SRCS-yes += encoder/vp9_encodeintra.h
|
||||||
VP9_CX_SRCS-yes += encoder/vp9_encodemb.h
|
VP9_CX_SRCS-yes += encoder/vp9_encodemb.h
|
||||||
|
@ -19,11 +19,12 @@ VP9_DX_SRCS-yes += vp9_dx_iface.c
|
|||||||
|
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_asm_dec_offsets.c
|
VP9_DX_SRCS-yes += decoder/vp9_asm_dec_offsets.c
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_dboolhuff.c
|
VP9_DX_SRCS-yes += decoder/vp9_dboolhuff.c
|
||||||
|
VP9_DX_SRCS-yes += decoder/vp9_dboolhuff.h
|
||||||
|
VP9_DX_SRCS-yes += decoder/vp9_read_bit_buffer.h
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_decodemv.c
|
VP9_DX_SRCS-yes += decoder/vp9_decodemv.c
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_decodframe.c
|
VP9_DX_SRCS-yes += decoder/vp9_decodframe.c
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_decodframe.h
|
VP9_DX_SRCS-yes += decoder/vp9_decodframe.h
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_detokenize.c
|
VP9_DX_SRCS-yes += decoder/vp9_detokenize.c
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_dboolhuff.h
|
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_decodemv.h
|
VP9_DX_SRCS-yes += decoder/vp9_decodemv.h
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_detokenize.h
|
VP9_DX_SRCS-yes += decoder/vp9_detokenize.h
|
||||||
VP9_DX_SRCS-yes += decoder/vp9_onyxd.h
|
VP9_DX_SRCS-yes += decoder/vp9_onyxd.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user