mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-31 01:11:13 +02:00
libeplayer3-arm: Code formatting
This commit is contained in:
@@ -182,7 +182,7 @@ static int _writeData(void *_call, int type)
|
||||
else // check LOAS header
|
||||
{
|
||||
if (!(call->len > 2 && call->data[0] == 0x56 && (call->data[1] >> 4) == 0xe &&
|
||||
(AV_RB16(call->data + 1) & 0x1FFF) + 3 == call->len))
|
||||
(AV_RB16(call->data + 1) & 0x1FFF) + 3 == call->len))
|
||||
{
|
||||
aac_err("parsing Data with wrong latm header. ignoring...\n");
|
||||
return 0;
|
||||
@@ -193,9 +193,9 @@ static int _writeData(void *_call, int type)
|
||||
unsigned int HeaderLength = InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
|
||||
struct iovec iov[2];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = HeaderLength;
|
||||
iov[0].iov_len = HeaderLength;
|
||||
iov[1].iov_base = call->data;
|
||||
iov[1].iov_len = call->len;
|
||||
iov[1].iov_len = call->len;
|
||||
return writev_with_retry(call->fd, iov, 2);
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ static int writeDataADTS(void *_call)
|
||||
return 0;
|
||||
}
|
||||
if ((call->private_data && 0 == strncmp("ADTS", call->private_data, call->private_size)) ||
|
||||
HasADTSHeader(call->data, call->len))
|
||||
HasADTSHeader(call->data, call->len))
|
||||
{
|
||||
return _writeData(_call, 0);
|
||||
}
|
||||
@@ -294,7 +294,7 @@ static int writeDataLATM(void *_call)
|
||||
if (ret)
|
||||
{
|
||||
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", (int)call->data[0], (int)call->data[1], (int)call->data[2], (int)call->data[3], \
|
||||
(int)call->data[4], (int)call->data[5], (int)call->data[6], (int)call->data[7]);
|
||||
(int)call->data[4], (int)call->data[5], (int)call->data[6], (int)call->data[7]);
|
||||
aac_err("latm_decode_extradata failed. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ static int writeData(void *_call)
|
||||
{
|
||||
WriterAVCallData_t *call = (WriterAVCallData_t *) _call;
|
||||
ac3_printf(10, "\n");
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
if (call == NULL)
|
||||
{
|
||||
ac3_err("call data is NULL...\n");
|
||||
@@ -118,7 +118,7 @@ static int writeData(void *_call)
|
||||
}
|
||||
struct iovec iov[3];
|
||||
iov[0].iov_base = PesHeader;
|
||||
iov[0].iov_len = InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0); //+ sizeof(AC3_SYNC_HEADER)
|
||||
iov[0].iov_len = InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0); //+ sizeof(AC3_SYNC_HEADER)
|
||||
//PesHeader[6] = 0x81;
|
||||
//PesHeader[7] = 0x80;
|
||||
//PesHeader[8] = 0x09;
|
||||
|
@@ -106,6 +106,7 @@ static uint8_t brcm_divx311_sequence_header[] =
|
||||
/* ***************************** */
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int reset()
|
||||
{
|
||||
initialHeader = 1;
|
||||
@@ -146,11 +147,11 @@ static int writeData(void *_call)
|
||||
data += 38;
|
||||
data[0] = B_GET_BITS(width, 11, 4);
|
||||
data[1] = B_SET_BITS("width [3..0]", B_GET_BITS(width, 3, 0), 7, 4) |
|
||||
B_SET_BITS("'10'", 0x02, 3, 2) |
|
||||
B_SET_BITS("height [11..10]", B_GET_BITS(height, 11, 10), 1, 0);
|
||||
B_SET_BITS("'10'", 0x02, 3, 2) |
|
||||
B_SET_BITS("height [11..10]", B_GET_BITS(height, 11, 10), 1, 0);
|
||||
data[2] = B_GET_BITS(height, 9, 2);
|
||||
data[3] = B_SET_BITS("height [1.0]", B_GET_BITS(height, 1, 0), 7, 6) |
|
||||
B_SET_BITS("'100000'", 0x20, 5, 0);
|
||||
B_SET_BITS("'100000'", 0x20, 5, 0);
|
||||
iov[ic].iov_base = brcm_divx311_sequence_header;
|
||||
iov[ic++].iov_len = sizeof(brcm_divx311_sequence_header);
|
||||
}
|
||||
|
@@ -69,6 +69,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
#else
|
||||
#define h263_err(fmt, x...)
|
||||
#endif
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
@@ -72,7 +72,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
#define h264_err(fmt, x...)
|
||||
#endif
|
||||
|
||||
#define IOVEC_SIZE 128
|
||||
#define IOVEC_SIZE 128
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
@@ -314,8 +314,8 @@ static int writeData(void *_call)
|
||||
}
|
||||
/* AnnexA */
|
||||
if (!avc3 && ((1 < call->private_size && 0 == call->private_data[0]) ||
|
||||
(call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
|
||||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
|
||||
(call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
|
||||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
|
||||
{
|
||||
uint32_t PacketLength = 0;
|
||||
uint32_t FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||
|
@@ -198,7 +198,7 @@ static int writeData(void *_call)
|
||||
h264_err("file pointer < 0. ignoring ...\n");
|
||||
return 0;
|
||||
}
|
||||
if (call->InfoFlags & 0x1) // TS container
|
||||
if (call->InfoFlags & 0x1) // TS container
|
||||
{
|
||||
h264_printf(10, "H265 simple inject method!\n");
|
||||
uint32_t PacketLength = 0;
|
||||
|
@@ -266,8 +266,7 @@ static int32_t writeData(void *_call)
|
||||
iov[1].iov_len = fixed_buffersize;
|
||||
writev_with_retry(call->fd, iov, 2);
|
||||
fixed_buffertimestamp += fixed_bufferduration;
|
||||
int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT |
|
||||
O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
|
||||
int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT | O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
|
||||
writev_with_retry(g_fd_dump, iov, 2);
|
||||
close(g_fd_dump);
|
||||
}
|
||||
|
@@ -100,6 +100,7 @@ static video_codec_data_t videocodecdata = {0, 0};
|
||||
/* ***************************** */
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int reset()
|
||||
{
|
||||
initialHeader = 1;
|
||||
@@ -153,8 +154,8 @@ static int writeData(void *_call)
|
||||
}
|
||||
}
|
||||
uint8_t needFrameStartCode = 0;
|
||||
if (sizeof(Vc1FrameStartCode) >= call->len
|
||||
|| memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
|
||||
if (sizeof(Vc1FrameStartCode) >= call->len ||
|
||||
memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
|
||||
{
|
||||
needFrameStartCode = 1;
|
||||
PacketLength += sizeof(Vc1FrameStartCode);
|
||||
|
@@ -98,6 +98,7 @@ static video_codec_data_t videocodecdata = {0, 0};
|
||||
/* ***************************** */
|
||||
/* MISC Functions */
|
||||
/* ***************************** */
|
||||
|
||||
static int reset()
|
||||
{
|
||||
initialHeader = 1;
|
||||
@@ -159,8 +160,8 @@ static int writeData(void *_call)
|
||||
}
|
||||
}
|
||||
uint8_t needFrameStartCode = 0;
|
||||
if (sizeof(Vc1FrameStartCode) >= call->len
|
||||
|| memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
|
||||
if (sizeof(Vc1FrameStartCode) >= call->len ||
|
||||
memcmp(call->data, Vc1FrameStartCode, sizeof(Vc1FrameStartCode)) != 0)
|
||||
{
|
||||
needFrameStartCode = 1;
|
||||
PacketLength += sizeof(Vc1FrameStartCode);
|
||||
|
@@ -99,6 +99,7 @@ static Writer_t *AvailableWriter[] =
|
||||
/* ***************************** */
|
||||
/* Functions */
|
||||
/* ***************************** */
|
||||
|
||||
ssize_t write_with_retry(int fd, const void *buf, size_t size)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
@@ -180,7 +180,7 @@ static int _writeData(void *_call, int type)
|
||||
else // check LOAS header
|
||||
{
|
||||
if (!(call->len > 2 && call->data[0] == 0x56 && (call->data[1] >> 4) == 0xe &&
|
||||
(AV_RB16(call->data + 1) & 0x1FFF) + 3 == call->len))
|
||||
(AV_RB16(call->data + 1) & 0x1FFF) + 3 == call->len))
|
||||
{
|
||||
aac_err("parsing Data with wrong latm header. ignoring...\n");
|
||||
return 0;
|
||||
@@ -217,7 +217,7 @@ static int writeDataADTS(void *_call)
|
||||
return 0;
|
||||
}
|
||||
if ((call->private_data && 0 == strncmp("ADTS", call->private_data, call->private_size)) ||
|
||||
HasADTSHeader(call->data, call->len))
|
||||
HasADTSHeader(call->data, call->len))
|
||||
{
|
||||
return _writeData(_call, 0);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ static int writeDataLATM(void *_call)
|
||||
if (ret)
|
||||
{
|
||||
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", (int)call->data[0], (int)call->data[1], (int)call->data[2], (int)call->data[3], \
|
||||
(int)call->data[4], (int)call->data[5], (int)call->data[6], (int)call->data[7]);
|
||||
(int)call->data[4], (int)call->data[5], (int)call->data[6], (int)call->data[7]);
|
||||
aac_err("latm_decode_extradata failed. ignoring...\n");
|
||||
return 0;
|
||||
}
|
||||
|
@@ -52,6 +52,7 @@
|
||||
/* ***************************** */
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#ifdef SAM_WITH_DEBUG
|
||||
#define H264_DEBUG
|
||||
#else
|
||||
@@ -232,8 +233,8 @@ static int32_t writeData(void *_call)
|
||||
}
|
||||
/* AnnexA */
|
||||
if (!avc3 && ((1 < call->private_size && 0 == call->private_data[0]) ||
|
||||
(call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
|
||||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
|
||||
(call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
|
||||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
|
||||
{
|
||||
uint32_t PacketLength = 0;
|
||||
uint32_t FakeStartCode = /*(call->Version << 8) | */PES_VERSION_FAKE_START_CODE;
|
||||
@@ -401,7 +402,7 @@ static int32_t writeData(void *_call)
|
||||
if (NalStart + NalLength > SampleSize)
|
||||
{
|
||||
h264_printf(20, "nal length past end of buffer - size %u frame offset %u left %u\n",
|
||||
NalLength, NalStart, SampleSize - NalStart);
|
||||
NalLength, NalStart, SampleSize - NalStart);
|
||||
NalStart = SampleSize;
|
||||
}
|
||||
else
|
||||
|
@@ -120,7 +120,7 @@ static int writeData(void *_call)
|
||||
while (Position < call->len)
|
||||
{
|
||||
int32_t PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
int32_t Remaining = call->len - Position - PacketLength;
|
||||
mpeg2_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
|
||||
struct iovec iov[2];
|
||||
|
@@ -119,11 +119,11 @@ static uint32_t breakBufferFillSize = 0;
|
||||
static int32_t prepareClipPlay(int32_t uNoOfChannels, int32_t uSampleRate, int32_t uBitsPerSample, uint8_t bLittleEndian __attribute__((unused)))
|
||||
{
|
||||
printf("rate: %d ch: %d bits: %d (%d bps)\n",
|
||||
uSampleRate/*Format->dwSamplesPerSec*/,
|
||||
uNoOfChannels/*Format->wChannels*/,
|
||||
uBitsPerSample/*Format->wBitsPerSample*/,
|
||||
(uBitsPerSample/*Format->wBitsPerSample*/ / 8)
|
||||
);
|
||||
uSampleRate/*Format->dwSamplesPerSec*/,
|
||||
uNoOfChannels/*Format->wChannels*/,
|
||||
uBitsPerSample/*Format->wBitsPerSample*/,
|
||||
(uBitsPerSample/*Format->wBitsPerSample*/ / 8)
|
||||
);
|
||||
SubFrameLen = 0;
|
||||
SubFramesPerPES = 0;
|
||||
breakBufferFillSize = 0;
|
||||
|
@@ -51,15 +51,15 @@
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#define WMV3_PRIVATE_DATA_LENGTH 4
|
||||
#define WMV3_PRIVATE_DATA_LENGTH 4
|
||||
|
||||
#define METADATA_STRUCT_A_START 12
|
||||
#define METADATA_STRUCT_B_START 24
|
||||
#define METADATA_STRUCT_B_FRAMERATE_START 32
|
||||
#define METADATA_STRUCT_C_START 8
|
||||
#define METADATA_STRUCT_A_START 12
|
||||
#define METADATA_STRUCT_B_START 24
|
||||
#define METADATA_STRUCT_B_FRAMERATE_START 32
|
||||
#define METADATA_STRUCT_C_START 8
|
||||
|
||||
#define VC1_SEQUENCE_LAYER_METADATA_START_CODE 0x80
|
||||
#define VC1_FRAME_START_CODE 0x0d
|
||||
#define VC1_SEQUENCE_LAYER_METADATA_START_CODE 0x80
|
||||
#define VC1_FRAME_START_CODE 0x0d
|
||||
|
||||
#ifdef SAM_WITH_DEBUG
|
||||
#define VC1_DEBUG
|
||||
@@ -87,9 +87,9 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
/* Types */
|
||||
/* ***************************** */
|
||||
|
||||
static const unsigned char SequenceLayerStartCode[] = {0x00, 0x00, 0x01, VC1_SEQUENCE_LAYER_METADATA_START_CODE};
|
||||
static const unsigned char SequenceLayerStartCode[] = {0x00, 0x00, 0x01, VC1_SEQUENCE_LAYER_METADATA_START_CODE};
|
||||
|
||||
static const unsigned char Metadata[] =
|
||||
static const unsigned char Metadata[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0xc5,
|
||||
0x04, 0x00, 0x00, 0x00,
|
||||
@@ -103,7 +103,7 @@ static const unsigned char Metadata[] =
|
||||
};
|
||||
|
||||
/* ***************************** */
|
||||
/* Varaibles */
|
||||
/* Variables */
|
||||
/* ***************************** */
|
||||
|
||||
static int initialHeader = 1;
|
||||
@@ -199,7 +199,7 @@ static int writeData(void *_call)
|
||||
while (Position < call->len)
|
||||
{
|
||||
int32_t PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
int32_t Remaining = call->len - Position - PacketLength;
|
||||
vc1_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
|
||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||
|
@@ -51,7 +51,7 @@
|
||||
/* Makros/Constants */
|
||||
/* ***************************** */
|
||||
|
||||
#define WMV3_PRIVATE_DATA_LENGTH 4
|
||||
#define WMV3_PRIVATE_DATA_LENGTH 4
|
||||
|
||||
#define METADATA_STRUCT_A_START 12
|
||||
#define METADATA_STRUCT_B_START 24
|
||||
@@ -149,7 +149,7 @@ static int writeData(void *_call)
|
||||
wmv_printf(10, "VideoPts %lld\n", call->Pts);
|
||||
wmv_printf(10, "Got Private Size %d\n", call->private_size);
|
||||
memcpy(private_data.privateData, call->private_data,
|
||||
call->private_size > WMV3_PRIVATE_DATA_LENGTH ? WMV3_PRIVATE_DATA_LENGTH : call->private_size);
|
||||
call->private_size > WMV3_PRIVATE_DATA_LENGTH ? WMV3_PRIVATE_DATA_LENGTH : call->private_size);
|
||||
private_data.width = call->Width;
|
||||
private_data.height = call->Height;
|
||||
private_data.framerate = call->FrameRate;
|
||||
@@ -185,7 +185,7 @@ static int writeData(void *_call)
|
||||
*PesPtr++ = (crazyFramerate >> 16) & 0xff;
|
||||
*PesPtr++ = crazyFramerate >> 24;
|
||||
MetadataLength = PesPtr - &PesPacket[PES_MIN_HEADER_SIZE];
|
||||
int HeaderLength = InsertPesHeader(PesPacket, MetadataLength, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
|
||||
int HeaderLength = InsertPesHeader(PesPacket, MetadataLength, VC1_VIDEO_PES_START_CODE, INVALID_PTS_VALUE, 0);
|
||||
len = write(call->fd, PesPacket, HeaderLength + MetadataLength);
|
||||
initialHeader = 0;
|
||||
}
|
||||
@@ -196,7 +196,7 @@ static int writeData(void *_call)
|
||||
while (Position < call->len)
|
||||
{
|
||||
int PacketLength = (call->len - Position) <= MAX_PES_PACKET_SIZE ?
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
(call->len - Position) : MAX_PES_PACKET_SIZE;
|
||||
int Remaining = call->len - Position - PacketLength;
|
||||
wmv_printf(20, "PacketLength=%d, Remaining=%d, Position=%d\n", PacketLength, Remaining, Position);
|
||||
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
|
||||
@@ -207,11 +207,10 @@ static int writeData(void *_call)
|
||||
{
|
||||
unsigned int PesLength;
|
||||
unsigned int PrivateHeaderLength;
|
||||
PrivateHeaderLength = InsertVideoPrivateDataHeader(&PesHeader[HeaderLength],
|
||||
call->len);
|
||||
PrivateHeaderLength = InsertVideoPrivateDataHeader(&PesHeader[HeaderLength], call->len);
|
||||
/* Update PesLength */
|
||||
PesLength = PesHeader[PES_LENGTH_BYTE_0] +
|
||||
(PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
|
||||
(PesHeader[PES_LENGTH_BYTE_1] << 8) + PrivateHeaderLength;
|
||||
PesHeader[PES_LENGTH_BYTE_0] = PesLength & 0xff;
|
||||
PesHeader[PES_LENGTH_BYTE_1] = (PesLength >> 8) & 0xff;
|
||||
PesHeader[PES_HEADER_DATA_LENGTH_BYTE] += PrivateHeaderLength;
|
||||
|
Reference in New Issue
Block a user