Skip to content

Commit

Permalink
Replace DLOG() with LOG() for progressive playback (#3025)
Browse files Browse the repository at this point in the history
Most of them are DLOG(ERROR) and DLOG(WARNING). Replace them with LOG()
so they will be included in QA build.

b/276483058

Change-Id: I71c5fa4cc1fa902ac08ba8dd4da9945541bc13bc
  • Loading branch information
xiaomings authored Apr 22, 2024
1 parent 5301c80 commit 3a25929
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 81 deletions.
8 changes: 4 additions & 4 deletions cobalt/media/progressive/avc_access_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using ::media::DemuxerStream;
bool ReadBytes(uint64 offset, size_t size, uint8* buffer,
DataSourceReader* reader) {
if (reader->BlockingRead(offset, size, buffer) != size) {
DLOG(ERROR) << "unable to download AU";
LOG(ERROR) << "unable to download AU";
return false;
}
return true;
Expand Down Expand Up @@ -125,7 +125,7 @@ bool AudioAU::Read(DataSourceReader* reader, DecoderBuffer* buffer) {
return false;

if (!parser_->Prepend(this, buffer)) {
DLOG(ERROR) << "prepend fail";
LOG(ERROR) << "prepend fail";
return false;
}

Expand Down Expand Up @@ -237,15 +237,15 @@ bool VideoAU::Read(DataSourceReader* reader, DecoderBuffer* buffer) {
}

if (au_left != 0) {
DLOG(ERROR) << "corrupted NALU";
LOG(ERROR) << "corrupted NALU";
return false;
}

size_ = decoder_buffer_offset;
buffer->shrink_to(size_);

if (!parser_->Prepend(this, buffer)) {
DLOG(ERROR) << "prepend fail";
LOG(ERROR) << "prepend fail";
return false;
}

Expand Down
48 changes: 24 additions & 24 deletions cobalt/media/progressive/avc_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
DCHECK(record_out) << "no output structure provided";
// first byte is NAL type id, check that it is SPS
if ((*sps & 0x1f) != kSPSNALType) {
DLOG(ERROR) << "bad NAL type on SPS";
LOG(ERROR) << "bad NAL type on SPS";
return false;
}
// convert SPS NALU to RBSP stream
RBSPStream sps_rbsp(sps + 1, sps_size - 1);
uint8 profile_idc = 0;
if (!sps_rbsp.ReadByte(&profile_idc)) {
DLOG(ERROR) << "failure reading profile_idc from sps RBSP";
LOG(ERROR) << "failure reading profile_idc from sps RBSP";
return false;
}
// skip 3 constraint flags, 5 reserved bits, and level_idc (16 bits)
Expand All @@ -143,7 +143,7 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
profile_idc == 83 || profile_idc == 86 || profile_idc == 118) {
uint32 chroma_format_idc = 0;
if (!sps_rbsp.ReadUEV(&chroma_format_idc)) {
DLOG(WARNING) << "failure reading chroma_format_idc from sps RBSP";
LOG(WARNING) << "failure reading chroma_format_idc from sps RBSP";
return false;
}
if (chroma_format_idc == 3) {
Expand All @@ -159,7 +159,7 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
// seq_scaling_matrix_present_flag
uint8 seq_scaling_matrix_present_flag = 0;
if (!sps_rbsp.ReadBit(&seq_scaling_matrix_present_flag)) {
DLOG(ERROR)
LOG(ERROR)
<< "failure reading seq_scaling_matrix_present_flag from sps RBSP";
return false;
}
Expand All @@ -173,7 +173,7 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
// pic_order_cnt_type
uint32 pic_order_cnt_type = 0;
if (!sps_rbsp.ReadUEV(&pic_order_cnt_type)) {
DLOG(ERROR) << "failure reading pic_order_cnt_type from sps RBSP";
LOG(ERROR) << "failure reading pic_order_cnt_type from sps RBSP";
return false;
}
if (pic_order_cnt_type == 0) {
Expand All @@ -189,7 +189,7 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
// num_ref_frames_in_pic_order_cnt_cycle
uint32 num_ref_frames_in_pic_order_cnt_cycle = 0;
if (!sps_rbsp.ReadUEV(&num_ref_frames_in_pic_order_cnt_cycle)) {
DLOG(ERROR)
LOG(ERROR)
<< "failure reading num_ref_frames_in_pic_order_cnt_cycle from sps";
return false;
}
Expand All @@ -200,29 +200,29 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
// number of reference frames used to decode
uint32 num_ref_frames = 0;
if (!sps_rbsp.ReadUEV(&num_ref_frames)) {
DLOG(ERROR) << "failure reading number of ref frames from sps RBSP";
LOG(ERROR) << "failure reading number of ref frames from sps RBSP";
return false;
}
// gaps_in_frame_num_value_allowed_flag
sps_rbsp.SkipBits(1);
// width is calculated from pic_width_in_mbs_minus1
uint32 pic_width_in_mbs_minus1 = 0;
if (!sps_rbsp.ReadUEV(&pic_width_in_mbs_minus1)) {
DLOG(WARNING) << "failure reading image width from sps RBSP";
LOG(WARNING) << "failure reading image width from sps RBSP";
return false;
}
// 16 pxs per macroblock
uint32 width = (pic_width_in_mbs_minus1 + 1) * 16;
// pic_height_in_map_units_minus1
uint32 pic_height_in_map_units_minus1 = 0;
if (!sps_rbsp.ReadUEV(&pic_height_in_map_units_minus1)) {
DLOG(ERROR)
LOG(ERROR)
<< "failure reading pic_height_in_map_uints_minus1 from sps RBSP";
return false;
}
uint8 frame_mbs_only_flag = 0;
if (!sps_rbsp.ReadBit(&frame_mbs_only_flag)) {
DLOG(ERROR) << "failure reading frame_mbs_only_flag from sps RBSP";
LOG(ERROR) << "failure reading frame_mbs_only_flag from sps RBSP";
return false;
}
uint32 height = (2 - static_cast<uint32>(frame_mbs_only_flag)) *
Expand All @@ -235,7 +235,7 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
// frame cropping flag
uint8 frame_cropping_flag = 0;
if (!sps_rbsp.ReadBit(&frame_cropping_flag)) {
DLOG(ERROR) << "failure reading frame_cropping_flag from sps RBSP";
LOG(ERROR) << "failure reading frame_cropping_flag from sps RBSP";
return false;
}
// distance in pixels from the associated edge of the media:
Expand Down Expand Up @@ -266,19 +266,19 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,
// cropping values are stored divided by two
if (frame_cropping_flag) {
if (!sps_rbsp.ReadUEV(&crop_left)) {
DLOG(ERROR) << "failure reading crop_left from sps RBSP";
LOG(ERROR) << "failure reading crop_left from sps RBSP";
return false;
}
if (!sps_rbsp.ReadUEV(&crop_right)) {
DLOG(ERROR) << "failure reading crop_right from sps RBSP";
LOG(ERROR) << "failure reading crop_right from sps RBSP";
return false;
}
if (!sps_rbsp.ReadUEV(&crop_top)) {
DLOG(ERROR) << "failure reading crop_top from sps RBSP";
LOG(ERROR) << "failure reading crop_top from sps RBSP";
return false;
}
if (!sps_rbsp.ReadUEV(&crop_bottom)) {
DLOG(ERROR) << "failure reading crop_bottom from sps RBSP";
LOG(ERROR) << "failure reading crop_bottom from sps RBSP";
return false;
}
crop_left *= 2;
Expand All @@ -300,7 +300,7 @@ bool AVCParser::ParseSPS(const uint8* sps, size_t sps_size,

bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
if (size < kAVCConfigMinSize) {
DLOG(ERROR) << base::StringPrintf("AVC config record bad size: %d", size);
LOG(ERROR) << base::StringPrintf("AVC config record bad size: %d", size);
return false;
}

Expand All @@ -316,7 +316,7 @@ bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
// That means we need at least 1 SPS NALU in this stream for extraction.
uint8 number_of_sps_nalus = buffer[5] & 0x1f;
if (number_of_sps_nalus == 0) {
DLOG(WARNING) << "got AVCConfigRecord without any SPS NALUs!";
LOG(WARNING) << "got AVCConfigRecord without any SPS NALUs!";
return false;
}
// iterate through SPS NALUs finding one of valid size for our purposes
Expand All @@ -330,7 +330,7 @@ bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
// make sure we haven't run out of record for the 2-byte size record
DCHECK_LE(size, static_cast<uint32>(std::numeric_limits<int32>::max()));
if (record_offset + 2 > static_cast<int>(size)) {
DLOG(WARNING) << "ran out of AVCConfig record while parsing SPS size.";
LOG(WARNING) << "ran out of AVCConfig record while parsing SPS size.";
return false;
}
// extract 2-byte size of this SPS
Expand All @@ -340,7 +340,7 @@ bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
record_offset += 2;
// see if we jumped over record size
if (record_offset + sps_size > size) {
DLOG(WARNING) << "ran out of AVCConfig record while parsing SPS blocks.";
LOG(WARNING) << "ran out of AVCConfig record while parsing SPS blocks.";
return false;
}
if (!have_valid_sps) {
Expand All @@ -353,7 +353,7 @@ bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
record_offset += sps_size;
}
if (!have_valid_sps) {
DLOG(WARNING)
LOG(WARNING)
<< "unable to parse a suitable SPS. Perhaps increase max size?";
return false;
}
Expand All @@ -374,7 +374,7 @@ bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
// make sure we don't run out of room for 2-byte size record
DCHECK_LE(size, static_cast<uint32>(std::numeric_limits<int32>::max()));
if (record_offset + 2 >= static_cast<int>(size)) {
DLOG(WARNING) << "ran out of AVCConfig record while parsing PPS size.";
LOG(WARNING) << "ran out of AVCConfig record while parsing PPS size.";
return false;
}
// extract 2-byte size of this PPS
Expand All @@ -383,7 +383,7 @@ bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
record_offset += 2;
// see if there's actually room for this record in the buffer
if (record_offset + pps_size > size) {
DLOG(WARNING)
LOG(WARNING)
<< "ran out of AVCConfig record while scanning PPS blocks.";
return false;
}
Expand All @@ -398,7 +398,7 @@ bool AVCParser::ParseAVCConfigRecord(uint8* buffer, uint32 size) {
// now we parse the valid SPS we extracted from byte stream earlier.
SPSRecord sps_record;
if (!ParseSPS(buffer + usable_sps_offset, usable_sps_size, &sps_record)) {
DLOG(WARNING) << "error parsing SPS";
LOG(WARNING) << "error parsing SPS";
return false;
}
// we can now initialize our video decoder config
Expand Down Expand Up @@ -462,7 +462,7 @@ void AVCParser::ParseAudioSpecificConfig(uint8 b0, uint8 b1) {
int adts_header_size;
if (!aac.Parse(aac_config, media_log_) ||
!aac.ConvertEsdsToADTS(&audio_prepend_, &adts_header_size)) {
DLOG(WARNING) << "Error in parsing AudioSpecificConfig.";
LOG(WARNING) << "Error in parsing AudioSpecificConfig.";
return;
}

Expand Down
2 changes: 1 addition & 1 deletion cobalt/media/progressive/mp4_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ bool MP4Map::ctts_AdvanceToSample(uint32 sample_number) {
// number is undefined. While not a fatal error it's kind of a weird
// state, we set the offset back to zero and extend the next_first_sample
// to infinity
DLOG(WARNING) << base::StringPrintf(
LOG(WARNING) << base::StringPrintf(
"out of range sample number %d in ctts, last valid sample number: %d",
sample_number, ctts_next_first_sample_);
ctts_sample_offset_ = 0;
Expand Down
Loading

0 comments on commit 3a25929

Please sign in to comment.