libeplayer3: Standardize comparison order and improve code readability

Origin commit data
------------------
Commit: b7d7f97ee4
Author: BPanther <bpanther_ts@hotmail.com>
Date: 2024-03-21 (Thu, 21 Mar 2024)

Origin message was:
------------------
small fix

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
BPanther
2024-03-24 22:23:52 +01:00
committed by Thilo Graf
parent 551e212a25
commit 73536563da
12 changed files with 65 additions and 69 deletions

View File

@@ -53,7 +53,7 @@ static int64_t update_max_injected_pts(int64_t pts)
{ {
if (pts > 0 && pts != INVALID_PTS_VALUE) if (pts > 0 && pts != INVALID_PTS_VALUE)
{ {
if (maxInjectedPTS == INVALID_PTS_VALUE || pts > maxInjectedPTS || 0 == PlaybackDieNow(0)) if (maxInjectedPTS == INVALID_PTS_VALUE || pts > maxInjectedPTS || PlaybackDieNow(0) == 0)
{ {
maxInjectedPTS = pts; maxInjectedPTS = pts;
} }
@@ -89,7 +89,7 @@ static int8_t is_finish_timeout()
static void update_finish_timeout() static void update_finish_timeout()
{ {
if (0 == pauseTimeout) if (pauseTimeout == 0)
{ {
int64_t maxInjectedPts = update_max_injected_pts(-1); int64_t maxInjectedPts = update_max_injected_pts(-1);
int64_t currPts = -1; int64_t currPts = -1;
@@ -106,14 +106,14 @@ static void update_finish_timeout()
/* On some STBs PTS readed from decoder is invalid after seek or at start /* On some STBs PTS readed from decoder is invalid after seek or at start
* this is the reason for additional validation when we what to close immediately * this is the reason for additional validation when we what to close immediately
*/ */
if (!progressive_playback && 0 == ret && currPts >= maxInjectedPts && if (!progressive_playback && ret == 0 && currPts >= maxInjectedPts &&
((currPts - maxInjectedPts) / 90000) < 2) ((currPts - maxInjectedPts) / 90000) < 2)
{ {
/* close immediately /* close immediately
*/ */
finishTimeout = TIMEOUT_MAX_ITERS + 1; finishTimeout = TIMEOUT_MAX_ITERS + 1;
} }
else if (0 == ret && (playPts != currPts && maxInjectedPts > currPts)) else if (ret == 0 && (playPts != currPts && maxInjectedPts > currPts))
{ {
playPts = currPts; playPts = currPts;
finishTimeout = 0; finishTimeout = 0;
@@ -124,10 +124,10 @@ static void update_finish_timeout()
static int32_t ffmpeg_read_wrapper_base(void *opaque, uint8_t *buf, int32_t buf_size, uint8_t type) static int32_t ffmpeg_read_wrapper_base(void *opaque, uint8_t *buf, int32_t buf_size, uint8_t type)
{ {
int32_t len = 0; int32_t len = 0;
if (0 == PlaybackDieNow(0)) if (PlaybackDieNow(0) == 0)
{ {
len = ffmpeg_real_read_org(opaque, buf, buf_size); len = ffmpeg_real_read_org(opaque, buf, buf_size);
while (len < buf_size && g_context && 0 == PlaybackDieNow(0)) while (len < buf_size && g_context && PlaybackDieNow(0) == 0)
{ {
if (type && len > 0) if (type && len > 0)
{ {
@@ -273,7 +273,7 @@ static void ffmpeg_filler(Context_t *context, int32_t id, int32_t *inpause, int3
while ((flag == 0 && avContextTab[0] != NULL && avContextTab[0]->pb != NULL && rwdiff > FILLBUFDIFF) || while ((flag == 0 && avContextTab[0] != NULL && avContextTab[0]->pb != NULL && rwdiff > FILLBUFDIFF) ||
(flag == 1 && hasfillerThreadStarted[id] == 1 && avContextTab[0] != NULL && avContextTab[0]->pb != NULL && rwdiff > FILLBUFDIFF)) (flag == 1 && hasfillerThreadStarted[id] == 1 && avContextTab[0] != NULL && avContextTab[0]->pb != NULL && rwdiff > FILLBUFDIFF))
{ {
if (0 == PlaybackDieNow(0)) if (PlaybackDieNow(0) == 0)
{ {
break; break;
} }
@@ -533,7 +533,7 @@ static int32_t ffmpeg_read(void *opaque, uint8_t *buf, int32_t buf_size)
int32_t len = 0; int32_t len = 0;
int32_t count = 2000; int32_t count = 2000;
while (sumlen < buf_size && (--count) > 0 && 0 == PlaybackDieNow(0)) while (sumlen < buf_size && (--count) > 0 && PlaybackDieNow(0) == 0)
{ {
len = ffmpeg_read_real(opaque, buf, buf_size - sumlen); len = ffmpeg_read_real(opaque, buf, buf_size - sumlen);
sumlen += len; sumlen += len;

View File

@@ -419,7 +419,7 @@ static char *Codec2Encoding(int32_t codec_id, int32_t media_type, uint8_t *extra
{ {
return "A_IPCM"; return "A_IPCM";
} }
else if (0 == m4ac.chan_config && STB_HISILICON != GetSTBType()) else if (m4ac.chan_config == 0 && STB_HISILICON != GetSTBType())
{ {
// according to https://wiki.multimedia.cx/index.php/ADTS // according to https://wiki.multimedia.cx/index.php/ADTS
// "MPEG-4 Channel Configuration - in the case of 0, the channel configuration is sent via an inband PCE" // "MPEG-4 Channel Configuration - in the case of 0, the channel configuration is sent via an inband PCE"
@@ -660,7 +660,7 @@ static void FFMPEGThread(Context_t *context)
/* ST DVB drivers skip data if they are written during pause /* ST DVB drivers skip data if they are written during pause
* so, we must wait here if there is not buffering queue * so, we must wait here if there is not buffering queue
*/ */
if (0 == bufferSize && context->playback->isPaused) if (bufferSize == 0 && context->playback->isPaused)
{ {
ffmpeg_printf(20, "paused\n"); ffmpeg_printf(20, "paused\n");
reset_finish_timeout(); reset_finish_timeout();
@@ -905,8 +905,7 @@ static void FFMPEGThread(Context_t *context)
else else
#endif #endif
#ifdef HAVE_FLV2MPEG4_CONVERTER #ifdef HAVE_FLV2MPEG4_CONVERTER
if (get_codecpar(avContextTab[cAVIdx]->streams[packet.stream_index])->codec_id == AV_CODEC_ID_FLV1 && if (get_codecpar(avContextTab[cAVIdx]->streams[packet.stream_index])->codec_id == AV_CODEC_ID_FLV1 && memcmp(videoTrack->Encoding, "V_MPEG4", 7) == 0)
0 == memcmp(videoTrack->Encoding, "V_MPEG4", 7))
{ {
flv2mpeg4_write_packet(context, &flv2mpeg4_context, videoTrack, cAVIdx, &currentVideoPts, &latestPts, &packet); flv2mpeg4_write_packet(context, &flv2mpeg4_context, videoTrack, cAVIdx, &currentVideoPts, &latestPts, &packet);
update_max_injected_pts(latestPts); update_max_injected_pts(latestPts);
@@ -1362,7 +1361,7 @@ static void FFMPEGThread(Context_t *context)
{ {
static char errbuf[256]; static char errbuf[256];
if (0 == av_strerror(ffmpegStatus, errbuf, sizeof(errbuf))) if (av_strerror(ffmpegStatus, errbuf, sizeof(errbuf)) == 0)
{ {
/* In this way we inform user about error within the core */ /* In this way we inform user about error within the core */
printf("{\"log\":\"Frame read error: '%s'\"}\n", errbuf); printf("{\"log\":\"Frame read error: '%s'\"}\n", errbuf);
@@ -1397,7 +1396,7 @@ static void FFMPEGThread(Context_t *context)
else if (1 == context->playback->isLoopMode) else if (1 == context->playback->isLoopMode)
{ {
int64_t tmpLength = 0; int64_t tmpLength = 0;
if (0 == container_ffmpeg_get_length(context, &tmpLength) && tmpLength > 0 && get_play_pts() > 0) if (container_ffmpeg_get_length(context, &tmpLength) == 0 && tmpLength > 0 && get_play_pts() > 0)
{ {
seek_target_seconds = 0; seek_target_seconds = 0;
do_seek_target_seconds = 1; do_seek_target_seconds = 1;
@@ -1532,7 +1531,7 @@ int64_t SAM_SeekFunc(void *ptr, int64_t pos, int whence)
if (AVSEEK_SIZE != whence) if (AVSEEK_SIZE != whence)
{ {
ret = (int64_t)fseeko(io->pFile, (off_t)pos, whence); ret = (int64_t)fseeko(io->pFile, (off_t)pos, whence);
if (0 == ret) if (ret == 0)
{ {
ret = (int64_t)ftello(io->pFile); ret = (int64_t)ftello(io->pFile);
} }
@@ -1635,8 +1634,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
avContextTab[AVIdx]->interrupt_callback.opaque = context->playback; avContextTab[AVIdx]->interrupt_callback.opaque = context->playback;
} }
#ifdef USE_CUSTOM_IO #ifdef USE_CUSTOM_IO
if (0 == strstr(filename, "://") || if (strstr(filename, "://") == 0 || strncmp(filename, "file://", 7) == 0)
0 == strncmp(filename, "file://", 7))
{ {
AVIOContext *avio_ctx = NULL; AVIOContext *avio_ctx = NULL;
custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t)); custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t));
@@ -1672,7 +1670,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
eRTMPProtoImplType rtmpProtoImplType = RTMP_NONE; eRTMPProtoImplType rtmpProtoImplType = RTMP_NONE;
uint8_t numOfRTMPImpl = 0; uint8_t numOfRTMPImpl = 0;
if (0 == strncmp(filename, "ffrtmp", 6)) if (strncmp(filename, "ffrtmp", 6) == 0)
{ {
filename = filename + 2; filename = filename + 2;
rtmpProtoImplType = RTMP_NATIVE; rtmpProtoImplType = RTMP_NATIVE;
@@ -1687,12 +1685,12 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
rtmpProtoImplType = RTMP_LIBRTMP; rtmpProtoImplType = RTMP_LIBRTMP;
} }
if (0 == strncmp(filename, "rtmp://", 7) || if (strncmp(filename, "rtmp://", 7) == 0 ||
0 == strncmp(filename, "rtmpe://", 8) || strncmp(filename, "rtmpe://", 8) == 0 ||
0 == strncmp(filename, "rtmps://", 8) || strncmp(filename, "rtmps://", 8) == 0 ||
0 == strncmp(filename, "rtmpt://", 8) || strncmp(filename, "rtmpt://", 8) == 0 ||
0 == strncmp(filename, "rtmpte://", 9) || strncmp(filename, "rtmpte://", 9) == 0 ||
0 == strncmp(filename, "rtmpts://", 9)) strncmp(filename, "rtmpts://", 9) == 0)
{ {
/* At first we need to check which protocol /* At first we need to check which protocol
* implementations we have * implementations we have
@@ -1703,17 +1701,17 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
while ((protoName = avio_enum_protocols(&opaque, 1))) while ((protoName = avio_enum_protocols(&opaque, 1)))
{ {
if (0 == strcmp("rtmp", protoName)) if (strcmp("rtmp", protoName) == 0)
{ {
++numOfRTMPImpl; ++numOfRTMPImpl;
} }
else if (0 == strcmp("ffrtmp", protoName)) else if (strcmp("ffrtmp", protoName) == 0)
{ {
// ffmpeg has patch to have both native and librtmp implementations // ffmpeg has patch to have both native and librtmp implementations
++numOfRTMPImpl; ++numOfRTMPImpl;
haveNativeProto = 2; haveNativeProto = 2;
} }
else if (0 == strncmp("rtmpts", protoName, 6)) else if (strncmp("rtmpts", protoName, 6) == 0)
{ {
// rtmpts is only available in native implementation // rtmpts is only available in native implementation
// rtmpts is listed after rtmp // rtmpts is listed after rtmp
@@ -1881,8 +1879,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
} }
} }
} }
else if (0 == strncmp(filename, "http://", 7) || else if (strncmp(filename, "http://", 7) == 0 || strncmp(filename, "https://", 8) == 0)
0 == strncmp(filename, "https://", 8))
{ {
char num[16]; char num[16];
@@ -1954,7 +1951,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
{ {
ffmpeg_real_read_org = avContextTab[AVIdx]->pb->read_packet; ffmpeg_real_read_org = avContextTab[AVIdx]->pb->read_packet;
if (0 == AVIdx && strstr(filename, "://") != 0 && strncmp(filename, "file://", 7) != 0) if (AVIdx == 0 && strstr(filename, "://") != 0 && strncmp(filename, "file://", 7) != 0)
{ {
if (ffmpeg_buf_size > 0 && ffmpeg_buf_size > FILLBUFDIFF + FILLBUFPAKET) if (ffmpeg_buf_size > 0 && ffmpeg_buf_size > FILLBUFDIFF + FILLBUFPAKET)
{ {
@@ -2127,7 +2124,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
{ {
uint32_t n = 0; uint32_t n = 0;
ffmpeg_printf(1, "cAVIdx[%d]: stream with multi programs: num of programs %d\n", cAVIdx, avContext->nb_programs); ffmpeg_printf(1, "cAVIdx[%d]: stream with multi programs: num of programs %d\n", cAVIdx, avContext->nb_programs);
for (n = 0; n < avContext->nb_programs && (0 == nb_stream_indexes || stream_index == NULL); n++) for (n = 0; n < avContext->nb_programs && (nb_stream_indexes == 0 || stream_index == NULL); n++)
{ {
AVProgram *p = avContext->programs[n]; AVProgram *p = avContext->programs[n];
if (p->nb_stream_indexes) if (p->nb_stream_indexes)
@@ -2251,7 +2248,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type); ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type);
// do not discard any stream from second context // do not discard any stream from second context
stream->discard = 0 == cAVIdx ? AVDISCARD_ALL : AVDISCARD_DEFAULT; /* by default we discard all video streams */ stream->discard = cAVIdx == 0 ? AVDISCARD_ALL : AVDISCARD_DEFAULT; /* by default we discard all video streams */
if (encoding != NULL) if (encoding != NULL)
{ {
@@ -2270,7 +2267,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
track.aspect_ratio_num = stream->sample_aspect_ratio.num; track.aspect_ratio_num = stream->sample_aspect_ratio.num;
track.aspect_ratio_den = stream->sample_aspect_ratio.den; track.aspect_ratio_den = stream->sample_aspect_ratio.den;
if (0 == track.aspect_ratio_num || 0 == track.aspect_ratio_den) if (track.aspect_ratio_num == 0 || track.aspect_ratio_den == 0)
{ {
track.aspect_ratio_num = get_codecpar(stream)->sample_aspect_ratio.num; track.aspect_ratio_num = get_codecpar(stream)->sample_aspect_ratio.num;
track.aspect_ratio_den = get_codecpar(stream)->sample_aspect_ratio.den; track.aspect_ratio_den = get_codecpar(stream)->sample_aspect_ratio.den;
@@ -2316,7 +2313,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
track.Id = ((AVStream *)(track.stream))->id; track.Id = ((AVStream *)(track.stream))->id;
track.duration = (int64_t)av_rescale(stream->duration, (int64_t)stream->time_base.num * 1000, stream->time_base.den); track.duration = (int64_t)av_rescale(stream->duration, (int64_t)stream->time_base.num * 1000, stream->time_base.den);
if (stream->duration == AV_NOPTS_VALUE || 0 == strncmp(avContext->iformat->name, "dash", 4)) if (stream->duration == AV_NOPTS_VALUE || strncmp(avContext->iformat->name, "dash", 4) == 0)
{ {
ffmpeg_printf(10, "Stream has no duration so we take the duration from context\n"); ffmpeg_printf(10, "Stream has no duration so we take the duration from context\n");
track.duration = (int64_t) avContext->duration / 1000; track.duration = (int64_t) avContext->duration / 1000;
@@ -2354,7 +2351,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n", get_codecpar(stream)->codec_type); ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n", get_codecpar(stream)->codec_type);
// do not discard any stream from second context // do not discard any stream from second context
stream->discard = 0 == cAVIdx ? AVDISCARD_ALL : AVDISCARD_DEFAULT; stream->discard = cAVIdx == 0 ? AVDISCARD_ALL : AVDISCARD_DEFAULT;
if (encoding != NULL) if (encoding != NULL)
{ {
@@ -2426,8 +2423,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
} }
else if (get_codecpar(stream)->codec_id == AV_CODEC_ID_AAC) else if (get_codecpar(stream)->codec_id == AV_CODEC_ID_AAC)
{ {
if (0 == strncmp(avContext->iformat->name, "mpegts", 6) || if (strncmp(avContext->iformat->name, "mpegts", 6) == 0 || strncmp(avContext->iformat->name, "hls,", 4) == 0)
0 == strncmp(avContext->iformat->name, "hls,", 4))
{ {
const char marker[] = "ADTS"; const char marker[] = "ADTS";
track.aacbuflen = sizeof(marker) / sizeof(char); track.aacbuflen = sizeof(marker) / sizeof(char);

View File

@@ -74,7 +74,7 @@ static AVCodecContext *get_codecpar(AVStream *stream)
static AVRational get_frame_rate(AVStream *stream) static AVRational get_frame_rate(AVStream *stream)
{ {
AVRational rateRational = stream->avg_frame_rate; AVRational rateRational = stream->avg_frame_rate;
if (0 == rateRational.den) if (rateRational.den == 0)
{ {
rateRational = stream->r_frame_rate; rateRational = stream->r_frame_rate;
} }

View File

@@ -44,7 +44,7 @@
#include "debug.h" #include "debug.h"
#define DUMP_BOOL(x) 0 == x ? "false" : "true" #define DUMP_BOOL(x) x == 0 ? "false" : "true"
#define IPTV_MAX_FILE_PATH 1024 #define IPTV_MAX_FILE_PATH 1024
extern int ffmpeg_av_dict_set(const char *key, const char *value, int flags); extern int ffmpeg_av_dict_set(const char *key, const char *value, int flags);
@@ -80,7 +80,7 @@ static void TerminateAllSockets(void)
int i; int i;
for (i = 0; i < 1024; ++i) for (i = 0; i < 1024; ++i)
{ {
if (0 == shutdown(i, SHUT_RDWR)) if (shutdown(i, SHUT_RDWR) == 0)
{ {
/* yes, I know that this is not good practice and I know what this could cause /* yes, I know that this is not good practice and I know what this could cause
* but in this use case it can be accepted. * but in this use case it can be accepted.
@@ -182,7 +182,7 @@ finish:
static void map_inter_file_path(char *filename) static void map_inter_file_path(char *filename)
{ {
if (0 == strncmp(filename, "iptv://", 7)) if (strncmp(filename, "iptv://", 7) == 0)
{ {
FILE *f = fopen(filename + 7, "r"); FILE *f = fopen(filename + 7, "r");
if (NULL != f) if (NULL != f)
@@ -587,7 +587,7 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int *
} }
} }
if (0 == ret && optind < argc) if (ret == 0 && optind < argc)
{ {
ret = 0; ret = 0;
playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH); playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH);
@@ -706,7 +706,7 @@ int main(int argc, char *argv[])
if (fcntl(g_pfd[1], F_SETFL, flags) == -1) if (fcntl(g_pfd[1], F_SETFL, flags) == -1)
break; break;
if (0 == pthread_create(&termThread, NULL, TermThreadFun, NULL)) if (pthread_create(&termThread, NULL, TermThreadFun, NULL) == 0)
isTermThreadStarted = 1; isTermThreadStarted = 1;
} }
while (0); while (0);
@@ -781,7 +781,7 @@ int main(int argc, char *argv[])
HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) -1, "sc"); HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) -1, "sc");
} }
while (g_player->playback->isPlaying && 0 == PlaybackDieNow(0)) while (g_player->playback->isPlaying && PlaybackDieNow(0) == 0)
{ {
/* we made fgets non blocking */ /* we made fgets non blocking */
if (NULL == fgets(argvBuff, sizeof(argvBuff) - 1, stdin)) if (NULL == fgets(argvBuff, sizeof(argvBuff) - 1, stdin))
@@ -791,7 +791,7 @@ int main(int argc, char *argv[])
continue; continue;
} }
if (0 == argvBuff[0]) if (argvBuff[0] == 0)
{ {
continue; continue;
} }
@@ -911,12 +911,12 @@ int main(int argc, char *argv[])
commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts); commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts);
CurrentSec = (int32_t)(pts / 90000); CurrentSec = (int32_t)(pts / 90000);
if (0 == commandRetVal) if (commandRetVal == 0)
{ {
E2iSendMsg("{\"J\":{\"ms\":%"PRId64"}}\n", pts / 90); E2iSendMsg("{\"J\":{\"ms\":%"PRId64"}}\n", pts / 90);
} }
if (0 == commandRetVal || force) if (commandRetVal == 0 || force)
{ {
commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length); commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length);
E2iSendMsg("{\"PLAYBACK_LENGTH\":{\"length\":%"PRId64", \"sts\":%d}}\n", length, commandRetVal); E2iSendMsg("{\"PLAYBACK_LENGTH\":{\"length\":%"PRId64", \"sts\":%d}}\n", length, commandRetVal);
@@ -958,7 +958,7 @@ int main(int argc, char *argv[])
{ {
int64_t pts = 0; int64_t pts = 0;
commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts); commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts);
if (0 == commandRetVal) if (commandRetVal == 0)
{ {
int64_t lastPts = 0; int64_t lastPts = 0;
commandRetVal = 1; commandRetVal = 1;
@@ -968,7 +968,7 @@ int main(int argc, char *argv[])
commandRetVal = g_player->container->selectedContainer->Command((Context_t *)g_player->container, CONTAINER_LAST_PTS, &lastPts); commandRetVal = g_player->container->selectedContainer->Command((Context_t *)g_player->container, CONTAINER_LAST_PTS, &lastPts);
} }
if (0 == commandRetVal && lastPts != INVALID_PTS_VALUE) if (commandRetVal == 0 && lastPts != INVALID_PTS_VALUE)
{ {
E2iSendMsg("{\"J\":{\"ms\":%"PRId64",\"lms\":%"PRId64"}}\n", pts / 90, lastPts / 90); E2iSendMsg("{\"J\":{\"ms\":%"PRId64",\"lms\":%"PRId64"}}\n", pts / 90, lastPts / 90);
} }

View File

@@ -87,7 +87,7 @@ static bool IsRegular(const char *pPath)
{ {
struct stat st = {0}; struct stat st = {0};
if (0 == lstat(pPath, &st) && S_ISREG(st.st_mode)) if (lstat(pPath, &st) == 0 && S_ISREG(st.st_mode))
{ {
return true; return true;
} }
@@ -100,7 +100,7 @@ static void RemoveAllRegularFiles(const char *mainDir, const char *filePattern)
return; return;
DIR *dirp = opendir(mainDir); DIR *dirp = opendir(mainDir);
if (0 == dirp) if (dirp == 0)
return; return;
struct dirent *pDir = 0; struct dirent *pDir = 0;
@@ -111,7 +111,7 @@ static void RemoveAllRegularFiles(const char *mainDir, const char *filePattern)
while (1) while (1)
{ {
pDir = readdir(dirp); pDir = readdir(dirp);
if (0 == pDir) if (pDir == 0)
break; break;
if (pDir->d_type != DT_REG && pDir->d_type != DT_UNKNOWN) if (pDir->d_type != DT_REG && pDir->d_type != DT_UNKNOWN)
@@ -121,7 +121,7 @@ static void RemoveAllRegularFiles(const char *mainDir, const char *filePattern)
if (pDir->d_type == DT_UNKNOWN && !IsRegular(fullpath)) if (pDir->d_type == DT_UNKNOWN && !IsRegular(fullpath))
continue; continue;
if (0 == fnmatch(filePattern, pDir->d_name, 0)) if (fnmatch(filePattern, pDir->d_name, 0) == 0)
remove(fullpath); remove(fullpath);
} }
} }
@@ -295,7 +295,7 @@ static int32_t Write(WriterSubCallData_t *subPacket)
g_sys->p_swctx = sws_getCachedContext(g_sys->p_swctx, rec->w, rec->h, AV_PIX_FMT_PAL8, desc_tab[j].w, desc_tab[j].h, AV_PIX_FMT_RGBA, SWS_BICUBIC, NULL, NULL, NULL); // SWS_FAST_BILINEAR g_sys->p_swctx = sws_getCachedContext(g_sys->p_swctx, rec->w, rec->h, AV_PIX_FMT_PAL8, desc_tab[j].w, desc_tab[j].h, AV_PIX_FMT_RGBA, SWS_BICUBIC, NULL, NULL, NULL); // SWS_FAST_BILINEAR
sws_scale(g_sys->p_swctx, (const uint8_t *const *)rec->data, rec->linesize, 0, rec->h, data, linesize); sws_scale(g_sys->p_swctx, (const uint8_t *const *)rec->data, rec->linesize, 0, rec->h, data, linesize);
if (0 == PNGPlugin_saveRGBAImage(filepath, &(data[0][0]), desc_tab[j].w, desc_tab[j].h)) if (PNGPlugin_saveRGBAImage(filepath, &(data[0][0]), desc_tab[j].w, desc_tab[j].h) == 0)
{ {
j += 1; j += 1;
} }

View File

@@ -151,7 +151,7 @@ static void LinuxDvbBuffThread(Context_t *context)
PlaybackDieNowRegisterCallback(WriteWakeUp); PlaybackDieNowRegisterCallback(WriteWakeUp);
while (0 == PlaybackDieNow(0)) while (PlaybackDieNow(0) == 0)
{ {
pthread_mutex_lock(&bufferingMtx); pthread_mutex_lock(&bufferingMtx);
g_bDuringWrite = false; g_bDuringWrite = false;
@@ -451,7 +451,7 @@ ssize_t BufferingWriteV(int fd, const struct iovec *iov, int ic)
} }
pthread_mutex_lock(&bufferingMtx); pthread_mutex_lock(&bufferingMtx);
while (0 == PlaybackDieNow(0)) while (PlaybackDieNow(0) == 0)
{ {
if (bufferingDataSize + chunkSize >= maxBufferingDataSize) if (bufferingDataSize + chunkSize >= maxBufferingDataSize)
{ {

View File

@@ -154,7 +154,7 @@ static int _writeData(WriterAVCallData_t *call, int type)
} }
/* simple validation */ /* simple validation */
if (0 == type) // check ADTS header if (type == 0) // check ADTS header
{ {
if (0xFF != call->data[0] || 0xF0 != (0xF0 & call->data[1])) if (0xFF != call->data[0] || 0xF0 != (0xF0 & call->data[1]))
{ {
@@ -163,7 +163,7 @@ static int _writeData(WriterAVCallData_t *call, int type)
} }
// STB can handle only AAC LC profile // STB can handle only AAC LC profile
if (0 == (call->data[2] & 0xC0)) if ((call->data[2] & 0xC0) == 0)
{ {
// change profile AAC Main -> AAC LC (Low Complexity) // change profile AAC Main -> AAC LC (Low Complexity)
aac_printf(1, "change profile AAC Main -> AAC LC (Low Complexity) in the ADTS header"); aac_printf(1, "change profile AAC Main -> AAC LC (Low Complexity) in the ADTS header");
@@ -204,7 +204,7 @@ static int writeDataADTS(WriterAVCallData_t *call)
return 0; return 0;
} }
if ((call->private_data && 0 == strncmp("ADTS", (const char *)call->private_data, call->private_size)) || if ((call->private_data && strncmp("ADTS", (const char *)call->private_data, call->private_size) == 0) ||
HasADTSHeader(call->data, call->len)) HasADTSHeader(call->data, call->len))
{ {
//printf("%hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx\n", call->data[0], call->data[1], call->data[2], call->data[3], call->data[4], call->data[5], call->data[6], call->data[7]); //printf("%hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx\n", call->data[0], call->data[1], call->data[2], call->data[3], call->data[4], call->data[5], call->data[6], call->data[7]);
@@ -269,7 +269,7 @@ static int writeDataLATM(WriterAVCallData_t *call)
return 0; return 0;
} }
if (call->private_data && 0 == strncmp("LATM", (const char *)call->private_data, call->private_size)) if (call->private_data && strncmp("LATM", (const char *)call->private_data, call->private_size) == 0)
{ {
return _writeData(call, 1); return _writeData(call, 1);
} }

View File

@@ -334,7 +334,7 @@ static int writeData(WriterAVCallData_t *call)
} }
/* AnnexA */ /* AnnexA */
if (!avc3 && ((1 < call->private_size && 0 == call->private_data[0]) || if (!avc3 && ((1 < call->private_size && call->private_data[0] == 0) ||
((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) || ((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->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))))
{ {

View File

@@ -111,7 +111,7 @@ ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, void *pDVBMtx __a
int retval = -1; int retval = -1;
int maxFd = pipefd > fd ? pipefd : fd; int maxFd = pipefd > fd ? pipefd : fd;
struct timeval tv; struct timeval tv;
while (size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking) while (size > 0 && PlaybackDieNow(0) == 0 && !context->playback->isSeeking)
{ {
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_ZERO(&wfds); FD_ZERO(&wfds);
@@ -194,7 +194,7 @@ ssize_t write_with_retry(int fd, const void *buf, int size)
{ {
ssize_t ret; ssize_t ret;
int retval = 0; int retval = 0;
while (size > 0 && 0 == PlaybackDieNow(0)) while (size > 0 && PlaybackDieNow(0) == 0)
{ {
ret = write(fd, buf, size); ret = write(fd, buf, size);
if (ret < 0) if (ret < 0)

View File

@@ -153,7 +153,7 @@ static int _writeData(void *_call, int type)
} }
/* simple validation */ /* simple validation */
if (0 == type) // check ADTS header if (type == 0) // check ADTS header
{ {
if (0xFF != call->data[0] || 0xF0 != (0xF0 & call->data[1])) if (0xFF != call->data[0] || 0xF0 != (0xF0 & call->data[1]))
{ {
@@ -162,7 +162,7 @@ static int _writeData(void *_call, int type)
} }
// STB can handle only AAC LC profile // STB can handle only AAC LC profile
if (0 == (call->data[2] & 0xC0)) if ((call->data[2] & 0xC0) == 0)
{ {
// change profile AAC Main -> AAC LC (Low Complexity) // change profile AAC Main -> AAC LC (Low Complexity)
aac_printf(1, "change profile AAC Main -> AAC LC (Low Complexity) in the ADTS header"); aac_printf(1, "change profile AAC Main -> AAC LC (Low Complexity) in the ADTS header");
@@ -217,7 +217,7 @@ static int writeDataADTS(void *_call)
return 0; return 0;
} }
if ((call->private_data && 0 == strncmp("ADTS", call->private_data, call->private_size)) || if ((call->private_data && strncmp("ADTS", call->private_data, call->private_size) == 0) ||
HasADTSHeader(call->data, call->len)) HasADTSHeader(call->data, call->len))
{ {
return _writeData(_call, 0); return _writeData(_call, 0);
@@ -281,7 +281,7 @@ static int writeDataLATM(void *_call)
return 0; return 0;
} }
if (call->private_data && 0 == strncmp("LATM", call->private_data, call->private_size)) if (call->private_data && strncmp("LATM", call->private_data, call->private_size) == 0)
{ {
return _writeData(_call, 1); return _writeData(_call, 1);
} }

View File

@@ -236,7 +236,7 @@ static int32_t writeData(void *_call)
} }
/* AnnexA */ /* AnnexA */
if (!avc3 && ((1 < call->private_size && 0 == call->private_data[0]) || if (!avc3 && ((1 < call->private_size && call->private_data[0] == 0) ||
(call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) || (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->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
{ {

View File

@@ -105,7 +105,7 @@ ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, void *pDVBMtx, co
int retval = -1; int retval = -1;
struct timeval tv; struct timeval tv;
while (size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking) while (size > 0 && PlaybackDieNow(0) == 0 && !context->playback->isSeeking)
{ {
if (context->playback->isPaused) if (context->playback->isPaused)
{ {