提交 8c2ba441 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

codecs cpp: add proper curly braces always

上级 64e4d89b
......@@ -17,7 +17,9 @@ namespace RTC
MS_TRACE();
if (len < 2)
{
return nullptr;
}
std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor());
......@@ -48,7 +50,9 @@ namespace RTC
// Detect key frame.
if (frameMarking->start && frameMarking->independent)
{
payloadDescriptor->isKeyFrame = true;
}
}
// NOTE: Unfortunately libwebrtc produces wrong Frame-Marking (without i=1 in
......@@ -95,7 +99,9 @@ namespace RTC
// Check if there is room for the indicated NAL unit size.
if (len < (naluSize + sizeof(naluSize)))
{
break;
}
offset += naluSize + sizeof(naluSize);
len -= naluSize + sizeof(naluSize);
......@@ -113,7 +119,9 @@ namespace RTC
uint8_t startBit = *(data + 1) & 0x80;
if (subnal == 7 && startBit == 128)
{
payloadDescriptor->isKeyFrame = true;
}
break;
}
......@@ -138,7 +146,9 @@ namespace RTC
PayloadDescriptor* payloadDescriptor = H264::Parse(data, len, frameMarking, frameMarkingLen);
if (!payloadDescriptor)
{
return;
}
auto* payloadDescriptorHandler = new PayloadDescriptorHandler(payloadDescriptor);
......@@ -231,7 +241,9 @@ namespace RTC
}
if (context->GetCurrentTemporalLayer() > context->GetTargetTemporalLayer())
{
context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer());
}
return true;
}
......
......@@ -20,7 +20,9 @@ namespace RTC
MS_TRACE();
if (len < 1)
{
return nullptr;
}
std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor());
......@@ -39,7 +41,9 @@ namespace RTC
else
{
if (len < ++offset + 1)
{
return nullptr;
}
byte = data[offset];
......@@ -52,14 +56,18 @@ namespace RTC
if (payloadDescriptor->i)
{
if (len < ++offset + 1)
{
return nullptr;
}
byte = data[offset];
if ((byte >> 7) & 0x01)
{
if (len < ++offset + 1)
{
return nullptr;
}
payloadDescriptor->hasTwoBytesPictureId = true;
payloadDescriptor->pictureId = (byte & 0x7F) << 8;
......@@ -77,7 +85,9 @@ namespace RTC
if (payloadDescriptor->l)
{
if (len < ++offset + 1)
{
return nullptr;
}
payloadDescriptor->hasTl0PictureIndex = true;
payloadDescriptor->tl0PictureIndex = data[offset];
......@@ -86,7 +96,9 @@ namespace RTC
if (payloadDescriptor->t || payloadDescriptor->k)
{
if (len < ++offset + 1)
{
return nullptr;
}
byte = data[offset];
......@@ -126,7 +138,9 @@ namespace RTC
PayloadDescriptor* payloadDescriptor = VP8::Parse(data, len, frameMarking, frameMarkingLen);
if (!payloadDescriptor)
{
return;
}
auto* payloadDescriptorHandler = new PayloadDescriptorHandler(payloadDescriptor);
......@@ -180,7 +194,9 @@ namespace RTC
// Nothing to do.
if (!this->extended)
{
return;
}
data += 2;
......@@ -200,12 +216,16 @@ namespace RTC
data++;
if (pictureId > 127)
{
MS_DEBUG_TAG(rtp, "casting pictureId value to one byte");
}
}
}
if (this->l)
{
*data = tl0PictureIndex;
}
}
void VP8::PayloadDescriptor::Restore(uint8_t* data) const
......@@ -337,7 +357,9 @@ namespace RTC
}
if (context->GetCurrentTemporalLayer() > context->GetTargetTemporalLayer())
{
context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer());
}
// clang-format off
if (
......
......@@ -19,7 +19,9 @@ namespace RTC
MS_TRACE();
if (len < 1)
{
return nullptr;
}
std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor());
......@@ -37,14 +39,18 @@ namespace RTC
if (payloadDescriptor->i)
{
if (len < ++offset + 1)
{
return nullptr;
}
byte = data[offset];
if (byte >> 7 & 0x01)
{
if (len < ++offset + 1)
{
return nullptr;
}
payloadDescriptor->pictureId = (byte & 0x7F) << 8;
payloadDescriptor->pictureId += data[offset];
......@@ -62,7 +68,9 @@ namespace RTC
if (payloadDescriptor->l)
{
if (len < ++offset + 1)
{
return nullptr;
}
byte = data[offset];
......@@ -74,7 +82,9 @@ namespace RTC
payloadDescriptor->hasTlIndex = true;
if (len < ++offset + 1)
{
return nullptr;
}
// Read TL0PICIDX if flexible mode is unset.
if (!payloadDescriptor->f)
......@@ -113,7 +123,9 @@ namespace RTC
PayloadDescriptor* payloadDescriptor = VP9::Parse(data, len, frameMarking, frameMarkingLen);
if (!payloadDescriptor)
{
return;
}
if (payloadDescriptor->isKeyFrame)
{
......@@ -285,10 +297,15 @@ namespace RTC
// * higher than current one
// * different than the current one when KSVC is enabled and this is not a keyframe
// (interframe p bit = 1)
// clang-format off
if (
!isOldPacket &&
(packetSpatialLayer > tmpSpatialLayer ||
(context->IsKSvc() && this->payloadDescriptor->p && packetSpatialLayer != tmpSpatialLayer)))
(
packetSpatialLayer > tmpSpatialLayer ||
(context->IsKSvc() && this->payloadDescriptor->p && packetSpatialLayer != tmpSpatialLayer)
)
)
// clang-format on
{
return false;
}
......@@ -345,12 +362,16 @@ namespace RTC
// Filter temporal layers higher than current one.
if (packetTemporalLayer > tmpTemporalLayer)
{
return false;
}
}
// Set marker bit if needed.
if (packetSpatialLayer == tmpSpatialLayer && this->payloadDescriptor->e)
{
marker = true;
}
// Update the pictureId manager.
if (this->payloadDescriptor->hasPictureId)
......@@ -362,11 +383,15 @@ namespace RTC
// Update current spatial layer if needed.
if (tmpSpatialLayer != context->GetCurrentSpatialLayer())
{
context->SetCurrentSpatialLayer(tmpSpatialLayer);
}
// Update current temporal layer if needed.
if (tmpTemporalLayer != context->GetCurrentTemporalLayer())
{
context->SetCurrentTemporalLayer(tmpTemporalLayer);
}
return true;
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论