Commit 9f095dd9 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/dvbpsi.c: cleanup indentation

parent c0ca06c3
/*****************************************************************************
* dvbpsi.c: conversion from TS packets to PSI sections
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -177,6 +177,7 @@ dvbpsi_decoder_t *dvbpsi_NewDecoder(dvbpsi_t *handle, dvbpsi_callback *callback)
p_decoder->pf_callback = NULL;
p_decoder->p_current_section = NULL;
p_decoder->i_continuity_counter = 0xFF; /* invalid CC */
return p_decoder;
}
......@@ -224,9 +225,10 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
dvbpsi_decoder_t *p_decoder = (dvbpsi_decoder_t *)handle->p_private;
assert(p_decoder);
assert(p_decoder->pf_callback);
/* TS start code */
if(p_data[0] != 0x47)
if (p_data[0] != 0x47)
{
dvbpsi_error(handle, "PSI decoder", "not a TS packet");
return;
......@@ -236,7 +238,7 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
i_expected_counter = (p_decoder->i_continuity_counter + 1) & 0xf;
p_decoder->i_continuity_counter = p_data[3] & 0xf;
if(i_expected_counter == ((p_decoder->i_continuity_counter + 1) & 0xf)
if (i_expected_counter == ((p_decoder->i_continuity_counter + 1) & 0xf)
&& !p_decoder->b_discontinuity)
{
dvbpsi_error(handle, "PSI decoder",
......@@ -246,14 +248,14 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
return;
}
if(i_expected_counter != p_decoder->i_continuity_counter)
if (i_expected_counter != p_decoder->i_continuity_counter)
{
dvbpsi_error(handle, "PSI decoder",
"TS discontinuity (received %d, expected %d) for PID %d",
p_decoder->i_continuity_counter, i_expected_counter,
((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
p_decoder->b_discontinuity = true;
if(p_decoder->p_current_section)
if (p_decoder->p_current_section)
{
dvbpsi_DeletePSISections(p_decoder->p_current_section);
p_decoder->p_current_section = NULL;
......@@ -261,19 +263,17 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
}
/* Return if no payload in the TS packet */
if(!(p_data[3] & 0x10))
{
if (!(p_data[3] & 0x10))
return;
}
/* Skip the adaptation_field if present */
if(p_data[3] & 0x20)
if (p_data[3] & 0x20)
p_payload_pos = p_data + 5 + p_data[4];
else
p_payload_pos = p_data + 4;
/* Unit start -> skip the pointer_field and a new section begins */
if(p_data[1] & 0x40)
if (p_data[1] & 0x40)
{
p_new_pos = p_payload_pos + *p_payload_pos + 1;
p_payload_pos += 1;
......@@ -283,9 +283,9 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
/* If the psi decoder needs a begginning of section and a new section
begins in the packet then initialize the dvbpsi_psi_section_t structure */
if(p_section == NULL)
if (p_section == NULL)
{
if(p_new_pos)
if (p_new_pos)
{
/* Allocation of the structure */
p_decoder->p_current_section
......@@ -309,9 +309,9 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
/* Remaining bytes in the payload */
i_available = 188 + p_data - p_payload_pos;
while(i_available > 0)
while (i_available > 0)
{
if(i_available >= p_decoder->i_need)
if (i_available >= p_decoder->i_need)
{
/* There are enough bytes in this packet to complete the
header/section */
......@@ -320,7 +320,7 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
p_section->p_payload_end += p_decoder->i_need;
i_available -= p_decoder->i_need;
if(!p_decoder->b_complete_header)
if (!p_decoder->b_complete_header)
{
/* Header is complete */
p_decoder->b_complete_header = true;
......@@ -329,14 +329,14 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
= ((uint16_t)(p_section->p_data[1] & 0xf)) << 8
| p_section->p_data[2];
/* Check that the section isn't too long */
if(p_decoder->i_need > p_decoder->i_section_max_size - 3)
if (p_decoder->i_need > p_decoder->i_section_max_size - 3)
{
dvbpsi_error(handle, "PSI decoder", "PSI section too long");
dvbpsi_DeletePSISections(p_section);
p_decoder->p_current_section = NULL;
/* If there is a new section not being handled then go forward
in the packet */
if(p_new_pos)
if (p_new_pos)
{
p_decoder->p_current_section
= p_section
......@@ -359,14 +359,14 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
p_section->b_syntax_indicator = p_section->p_data[1] & 0x80;
p_section->b_private_indicator = p_section->p_data[1] & 0x40;
/* Update the end of the payload if CRC_32 is present */
if(p_section->b_syntax_indicator)
if (p_section->b_syntax_indicator)
p_section->p_payload_end -= 4;
if(p_section->p_data[0] != 0x72 && dvbpsi_ValidPSISection(p_section))
if (p_section->p_data[0] != 0x72 && dvbpsi_ValidPSISection(p_section))
{
/* PSI section is valid */
p_section->i_table_id = p_section->p_data[0];
if(p_section->b_syntax_indicator)
if (p_section->b_syntax_indicator)
{
p_section->i_extension = (p_section->p_data[3] << 8)
| p_section->p_data[4];
......@@ -401,12 +401,12 @@ void dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
/* A TS packet may contain any number of sections, only the first
* new one is flagged by the pointer_field. If the next payload
* byte isn't 0xff then a new section starts. */
if(p_new_pos == NULL && i_available && *p_payload_pos != 0xff)
if (p_new_pos == NULL && i_available && *p_payload_pos != 0xff)
p_new_pos = p_payload_pos;
/* If there is a new section not being handled then go forward
in the packet */
if(p_new_pos)
if (p_new_pos)
{
p_decoder->p_current_section
= p_section
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment