Renamed H264BitReader to H26xBitReader.

Change-Id: I960a636541a5cadcce5f41e1a75c3ddfbbfaa803
This commit is contained in:
Jacob Trimble 2016-03-14 12:02:21 -07:00
parent 144cdc5e59
commit 43dc6248a3
6 changed files with 54 additions and 54 deletions

View File

@ -19,12 +19,12 @@
'decoder_configuration.h', 'decoder_configuration.h',
'ec3_audio_util.cc', 'ec3_audio_util.cc',
'ec3_audio_util.h', 'ec3_audio_util.h',
'h264_bit_reader.cc',
'h264_bit_reader.h',
'h264_byte_to_unit_stream_converter.cc', 'h264_byte_to_unit_stream_converter.cc',
'h264_byte_to_unit_stream_converter.h', 'h264_byte_to_unit_stream_converter.h',
'h264_parser.cc', 'h264_parser.cc',
'h264_parser.h', 'h264_parser.h',
'h26x_bit_reader.cc',
'h26x_bit_reader.h',
'hevc_decoder_configuration.cc', 'hevc_decoder_configuration.cc',
'hevc_decoder_configuration.h', 'hevc_decoder_configuration.h',
'nal_unit_to_byte_stream_converter.cc', 'nal_unit_to_byte_stream_converter.cc',
@ -49,9 +49,9 @@
'sources': [ 'sources': [
'avc_decoder_configuration_unittest.cc', 'avc_decoder_configuration_unittest.cc',
'ec3_audio_util_unittest.cc', 'ec3_audio_util_unittest.cc',
'h264_bit_reader_unittest.cc',
'h264_byte_to_unit_stream_converter_unittest.cc', 'h264_byte_to_unit_stream_converter_unittest.cc',
'h264_parser_unittest.cc', 'h264_parser_unittest.cc',
'h26x_bit_reader_unittest.cc',
'hevc_decoder_configuration_unittest.cc', 'hevc_decoder_configuration_unittest.cc',
'nal_unit_to_byte_stream_converter_unittest.cc', 'nal_unit_to_byte_stream_converter_unittest.cc',
'nalu_reader_unittest.cc', 'nalu_reader_unittest.cc',

View File

@ -320,7 +320,7 @@ static void FallbackScalingList8x8(
} }
} }
H264Parser::Result H264Parser::ParseScalingList(H264BitReader* br, H264Parser::Result H264Parser::ParseScalingList(H26xBitReader* br,
int size, int size,
int* scaling_list, int* scaling_list,
bool* use_default) { bool* use_default) {
@ -350,7 +350,7 @@ H264Parser::Result H264Parser::ParseScalingList(H264BitReader* br,
return kOk; return kOk;
} }
H264Parser::Result H264Parser::ParseSPSScalingLists(H264BitReader* br, H264Parser::Result H264Parser::ParseSPSScalingLists(H26xBitReader* br,
H264SPS* sps) { H264SPS* sps) {
// See 7.4.2.1.1. // See 7.4.2.1.1.
bool seq_scaling_list_present_flag; bool seq_scaling_list_present_flag;
@ -402,7 +402,7 @@ H264Parser::Result H264Parser::ParseSPSScalingLists(H264BitReader* br,
return kOk; return kOk;
} }
H264Parser::Result H264Parser::ParsePPSScalingLists(H264BitReader* br, H264Parser::Result H264Parser::ParsePPSScalingLists(H26xBitReader* br,
const H264SPS& sps, const H264SPS& sps,
H264PPS* pps) { H264PPS* pps) {
// See 7.4.2.2. // See 7.4.2.2.
@ -473,7 +473,7 @@ H264Parser::Result H264Parser::ParsePPSScalingLists(H264BitReader* br,
} }
H264Parser::Result H264Parser::ParseAndIgnoreHRDParameters( H264Parser::Result H264Parser::ParseAndIgnoreHRDParameters(
H264BitReader* br, bool* hrd_parameters_present) { H26xBitReader* br, bool* hrd_parameters_present) {
int data; int data;
READ_BOOL_OR_RETURN(&data); // {nal,vcl}_hrd_parameters_present_flag READ_BOOL_OR_RETURN(&data); // {nal,vcl}_hrd_parameters_present_flag
if (!data) if (!data)
@ -495,7 +495,7 @@ H264Parser::Result H264Parser::ParseAndIgnoreHRDParameters(
return kOk; return kOk;
} }
H264Parser::Result H264Parser::ParseVUIParameters(H264BitReader* br, H264Parser::Result H264Parser::ParseVUIParameters(H26xBitReader* br,
H264SPS* sps) { H264SPS* sps) {
bool aspect_ratio_info_present_flag; bool aspect_ratio_info_present_flag;
READ_BOOL_OR_RETURN(&aspect_ratio_info_present_flag); READ_BOOL_OR_RETURN(&aspect_ratio_info_present_flag);
@ -590,9 +590,9 @@ H264Parser::Result H264Parser::ParseSPS(const Nalu& nalu, int* sps_id) {
// See 7.4.2.1. // See 7.4.2.1.
int data; int data;
Result res; Result res;
H264BitReader reader; H26xBitReader reader;
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size()); reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
H264BitReader* br = &reader; H26xBitReader* br = &reader;
*sps_id = -1; *sps_id = -1;
@ -715,9 +715,9 @@ H264Parser::Result H264Parser::ParsePPS(const Nalu& nalu, int* pps_id) {
// See 7.4.2.2. // See 7.4.2.2.
const H264SPS* sps; const H264SPS* sps;
Result res; Result res;
H264BitReader reader; H26xBitReader reader;
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size()); reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
H264BitReader* br = &reader; H26xBitReader* br = &reader;
*pps_id = -1; *pps_id = -1;
@ -786,7 +786,7 @@ H264Parser::Result H264Parser::ParsePPS(const Nalu& nalu, int* pps_id) {
} }
H264Parser::Result H264Parser::ParseRefPicListModification( H264Parser::Result H264Parser::ParseRefPicListModification(
H264BitReader* br, H26xBitReader* br,
int num_ref_idx_active_minus1, int num_ref_idx_active_minus1,
H264ModificationOfPicNum* ref_list_mods) { H264ModificationOfPicNum* ref_list_mods) {
H264ModificationOfPicNum* pic_num_mod; H264ModificationOfPicNum* pic_num_mod;
@ -830,7 +830,7 @@ H264Parser::Result H264Parser::ParseRefPicListModification(
} }
H264Parser::Result H264Parser::ParseRefPicListModifications( H264Parser::Result H264Parser::ParseRefPicListModifications(
H264BitReader* br, H264SliceHeader* shdr) { H26xBitReader* br, H264SliceHeader* shdr) {
Result res; Result res;
if (!shdr->IsISlice() && !shdr->IsSISlice()) { if (!shdr->IsISlice() && !shdr->IsSISlice()) {
@ -857,7 +857,7 @@ H264Parser::Result H264Parser::ParseRefPicListModifications(
} }
H264Parser::Result H264Parser::ParseWeightingFactors( H264Parser::Result H264Parser::ParseWeightingFactors(
H264BitReader* br, H26xBitReader* br,
int num_ref_idx_active_minus1, int num_ref_idx_active_minus1,
int chroma_array_type, int chroma_array_type,
int luma_log2_weight_denom, int luma_log2_weight_denom,
@ -901,7 +901,7 @@ H264Parser::Result H264Parser::ParseWeightingFactors(
return kOk; return kOk;
} }
H264Parser::Result H264Parser::ParsePredWeightTable(H264BitReader* br, H264Parser::Result H264Parser::ParsePredWeightTable(H26xBitReader* br,
const H264SPS& sps, const H264SPS& sps,
H264SliceHeader* shdr) { H264SliceHeader* shdr) {
READ_UE_OR_RETURN(&shdr->luma_log2_weight_denom); READ_UE_OR_RETURN(&shdr->luma_log2_weight_denom);
@ -934,7 +934,7 @@ H264Parser::Result H264Parser::ParsePredWeightTable(H264BitReader* br,
return kOk; return kOk;
} }
H264Parser::Result H264Parser::ParseDecRefPicMarking(H264BitReader* br, H264Parser::Result H264Parser::ParseDecRefPicMarking(H26xBitReader* br,
H264SliceHeader* shdr) { H264SliceHeader* shdr) {
if (shdr->idr_pic_flag) { if (shdr->idr_pic_flag) {
READ_BOOL_OR_RETURN(&shdr->no_output_of_prior_pics_flag); READ_BOOL_OR_RETURN(&shdr->no_output_of_prior_pics_flag);
@ -986,9 +986,9 @@ H264Parser::Result H264Parser::ParseSliceHeader(const Nalu& nalu,
const H264SPS* sps; const H264SPS* sps;
const H264PPS* pps; const H264PPS* pps;
Result res; Result res;
H264BitReader reader; H26xBitReader reader;
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size()); reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
H264BitReader* br = &reader; H26xBitReader* br = &reader;
memset(shdr, 0, sizeof(*shdr)); memset(shdr, 0, sizeof(*shdr));
@ -1134,9 +1134,9 @@ H264Parser::Result H264Parser::ParseSliceHeader(const Nalu& nalu,
H264Parser::Result H264Parser::ParseSEI(const Nalu& nalu, H264Parser::Result H264Parser::ParseSEI(const Nalu& nalu,
H264SEIMessage* sei_msg) { H264SEIMessage* sei_msg) {
int byte; int byte;
H264BitReader reader; H26xBitReader reader;
reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size()); reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size());
H264BitReader* br = &reader; H26xBitReader* br = &reader;
memset(sei_msg, 0, sizeof(*sei_msg)); memset(sei_msg, 0, sizeof(*sei_msg));

View File

@ -12,7 +12,7 @@
#include <map> #include <map>
#include "packager/media/filters/h264_bit_reader.h" #include "packager/media/filters/h26x_bit_reader.h"
#include "packager/media/filters/nalu_reader.h" #include "packager/media/filters/nalu_reader.h"
namespace edash_packager { namespace edash_packager {
@ -286,34 +286,34 @@ class H264Parser {
private: private:
// Parse scaling lists (see spec). // Parse scaling lists (see spec).
Result ParseScalingList(H264BitReader* br, Result ParseScalingList(H26xBitReader* br,
int size, int size,
int* scaling_list, int* scaling_list,
bool* use_default); bool* use_default);
Result ParseSPSScalingLists(H264BitReader* br, H264SPS* sps); Result ParseSPSScalingLists(H26xBitReader* br, H264SPS* sps);
Result ParsePPSScalingLists(H264BitReader* br, Result ParsePPSScalingLists(H26xBitReader* br,
const H264SPS& sps, const H264SPS& sps,
H264PPS* pps); H264PPS* pps);
// Parse optional VUI parameters in SPS (see spec). // Parse optional VUI parameters in SPS (see spec).
Result ParseVUIParameters(H264BitReader* br, H264SPS* sps); Result ParseVUIParameters(H26xBitReader* br, H264SPS* sps);
// Set |hrd_parameters_present| to true only if they are present. // Set |hrd_parameters_present| to true only if they are present.
Result ParseAndIgnoreHRDParameters(H264BitReader* br, Result ParseAndIgnoreHRDParameters(H26xBitReader* br,
bool* hrd_parameters_present); bool* hrd_parameters_present);
// Parse reference picture lists' modifications (see spec). // Parse reference picture lists' modifications (see spec).
Result ParseRefPicListModifications(H264BitReader* br, H264SliceHeader* shdr); Result ParseRefPicListModifications(H26xBitReader* br, H264SliceHeader* shdr);
Result ParseRefPicListModification(H264BitReader* br, Result ParseRefPicListModification(H26xBitReader* br,
int num_ref_idx_active_minus1, int num_ref_idx_active_minus1,
H264ModificationOfPicNum* ref_list_mods); H264ModificationOfPicNum* ref_list_mods);
// Parse prediction weight table (see spec). // Parse prediction weight table (see spec).
Result ParsePredWeightTable(H264BitReader* br, Result ParsePredWeightTable(H26xBitReader* br,
const H264SPS& sps, const H264SPS& sps,
H264SliceHeader* shdr); H264SliceHeader* shdr);
// Parse weighting factors (see spec). // Parse weighting factors (see spec).
Result ParseWeightingFactors(H264BitReader* br, Result ParseWeightingFactors(H26xBitReader* br,
int num_ref_idx_active_minus1, int num_ref_idx_active_minus1,
int chroma_array_type, int chroma_array_type,
int luma_log2_weight_denom, int luma_log2_weight_denom,
@ -321,7 +321,7 @@ class H264Parser {
H264WeightingFactors* w_facts); H264WeightingFactors* w_facts);
// Parse decoded reference picture marking information (see spec). // Parse decoded reference picture marking information (see spec).
Result ParseDecRefPicMarking(H264BitReader* br, H264SliceHeader* shdr); Result ParseDecRefPicMarking(H26xBitReader* br, H264SliceHeader* shdr);
// PPSes and SPSes stored for future reference. // PPSes and SPSes stored for future reference.
typedef std::map<int, H264SPS*> SPSById; typedef std::map<int, H264SPS*> SPSById;

View File

@ -3,12 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "packager/base/logging.h" #include "packager/base/logging.h"
#include "packager/media/filters/h264_bit_reader.h" #include "packager/media/filters/h26x_bit_reader.h"
namespace edash_packager { namespace edash_packager {
namespace media { namespace media {
H264BitReader::H264BitReader() H26xBitReader::H26xBitReader()
: data_(NULL), : data_(NULL),
bytes_left_(0), bytes_left_(0),
curr_byte_(0), curr_byte_(0),
@ -16,9 +16,9 @@ H264BitReader::H264BitReader()
prev_two_bytes_(0), prev_two_bytes_(0),
emulation_prevention_bytes_(0) {} emulation_prevention_bytes_(0) {}
H264BitReader::~H264BitReader() {} H26xBitReader::~H26xBitReader() {}
bool H264BitReader::Initialize(const uint8_t* data, off_t size) { bool H26xBitReader::Initialize(const uint8_t* data, off_t size) {
DCHECK(data); DCHECK(data);
if (size < 1) if (size < 1)
@ -34,7 +34,7 @@ bool H264BitReader::Initialize(const uint8_t* data, off_t size) {
return true; return true;
} }
bool H264BitReader::UpdateCurrByte() { bool H26xBitReader::UpdateCurrByte() {
if (bytes_left_ < 1) if (bytes_left_ < 1)
return false; return false;
@ -65,7 +65,7 @@ bool H264BitReader::UpdateCurrByte() {
// Read |num_bits| (1 to 31 inclusive) from the stream and return them // Read |num_bits| (1 to 31 inclusive) from the stream and return them
// in |out|, with first bit in the stream as MSB in |out| at position // in |out|, with first bit in the stream as MSB in |out| at position
// (|num_bits| - 1). // (|num_bits| - 1).
bool H264BitReader::ReadBits(int num_bits, int* out) { bool H26xBitReader::ReadBits(int num_bits, int* out) {
int bits_left = num_bits; int bits_left = num_bits;
*out = 0; *out = 0;
DCHECK(num_bits <= 31); DCHECK(num_bits <= 31);
@ -86,7 +86,7 @@ bool H264BitReader::ReadBits(int num_bits, int* out) {
return true; return true;
} }
bool H264BitReader::ReadUE(int* val) { bool H26xBitReader::ReadUE(int* val) {
int num_bits = -1; int num_bits = -1;
int bit; int bit;
int rest; int rest;
@ -113,7 +113,7 @@ bool H264BitReader::ReadUE(int* val) {
return true; return true;
} }
bool H264BitReader::ReadSE(int* val) { bool H26xBitReader::ReadSE(int* val) {
int ue; int ue;
// See Chapter 9 in the spec. // See Chapter 9 in the spec.
@ -128,11 +128,11 @@ bool H264BitReader::ReadSE(int* val) {
return true; return true;
} }
off_t H264BitReader::NumBitsLeft() { off_t H26xBitReader::NumBitsLeft() {
return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8); return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8);
} }
bool H264BitReader::HasMoreRBSPData() { bool H26xBitReader::HasMoreRBSPData() {
// Make sure we have more bits, if we are at 0 bits in current byte // Make sure we have more bits, if we are at 0 bits in current byte
// and updating current byte fails, we don't have more data anyway. // and updating current byte fails, we don't have more data anyway.
if (num_remaining_bits_in_curr_byte_ == 0 && !UpdateCurrByte()) if (num_remaining_bits_in_curr_byte_ == 0 && !UpdateCurrByte())
@ -149,7 +149,7 @@ bool H264BitReader::HasMoreRBSPData() {
((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0; ((1 << (num_remaining_bits_in_curr_byte_ - 1)) - 1)) != 0;
} }
size_t H264BitReader::NumEmulationPreventionBytesRead() { size_t H26xBitReader::NumEmulationPreventionBytesRead() {
return emulation_prevention_bytes_; return emulation_prevention_bytes_;
} }

View File

@ -19,10 +19,10 @@ namespace media {
// This is not a generic bit reader class, as it takes into account // This is not a generic bit reader class, as it takes into account
// H.264 stream-specific constraints, such as skipping emulation-prevention // H.264 stream-specific constraints, such as skipping emulation-prevention
// bytes and stop bits. See spec for more details. // bytes and stop bits. See spec for more details.
class H264BitReader { class H26xBitReader {
public: public:
H264BitReader(); H26xBitReader();
~H264BitReader(); ~H26xBitReader();
// Initialize the reader to start reading at |data|, |size| being size // Initialize the reader to start reading at |data|, |size| being size
// of |data| in bytes. // of |data| in bytes.
@ -77,7 +77,7 @@ class H264BitReader {
// Number of emulation preventation bytes (0x000003) we met. // Number of emulation preventation bytes (0x000003) we met.
size_t emulation_prevention_bytes_; size_t emulation_prevention_bytes_;
DISALLOW_COPY_AND_ASSIGN(H264BitReader); DISALLOW_COPY_AND_ASSIGN(H26xBitReader);
}; };
} // namespace media } // namespace media

View File

@ -4,13 +4,13 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "packager/media/filters/h264_bit_reader.h" #include "packager/media/filters/h26x_bit_reader.h"
namespace edash_packager { namespace edash_packager {
namespace media { namespace media {
TEST(H264BitReaderTest, ReadStreamWithoutEscapeAndTrailingZeroBytes) { TEST(H26xBitReaderTest, ReadStreamWithoutEscapeAndTrailingZeroBytes) {
H264BitReader reader; H26xBitReader reader;
const unsigned char rbsp[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xa0}; const unsigned char rbsp[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xa0};
int dummy = 0; int dummy = 0;
@ -42,8 +42,8 @@ TEST(H264BitReaderTest, ReadStreamWithoutEscapeAndTrailingZeroBytes) {
EXPECT_FALSE(reader.HasMoreRBSPData()); EXPECT_FALSE(reader.HasMoreRBSPData());
} }
TEST(H264BitReaderTest, SingleByteStream) { TEST(H26xBitReaderTest, SingleByteStream) {
H264BitReader reader; H26xBitReader reader;
const unsigned char rbsp[] = {0x18}; const unsigned char rbsp[] = {0x18};
int dummy = 0; int dummy = 0;
@ -57,8 +57,8 @@ TEST(H264BitReaderTest, SingleByteStream) {
EXPECT_FALSE(reader.HasMoreRBSPData()); EXPECT_FALSE(reader.HasMoreRBSPData());
} }
TEST(H264BitReaderTest, StopBitOccupyFullByte) { TEST(H26xBitReaderTest, StopBitOccupyFullByte) {
H264BitReader reader; H26xBitReader reader;
const unsigned char rbsp[] = {0xab, 0x80}; const unsigned char rbsp[] = {0xab, 0x80};
int dummy = 0; int dummy = 0;