mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
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:
@@ -53,7 +53,7 @@ static int64_t update_max_injected_pts(int64_t pts)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ static int8_t is_finish_timeout()
|
||||
|
||||
static void update_finish_timeout()
|
||||
{
|
||||
if (0 == pauseTimeout)
|
||||
if (pauseTimeout == 0)
|
||||
{
|
||||
int64_t maxInjectedPts = update_max_injected_pts(-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
|
||||
* 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)
|
||||
{
|
||||
/* close immediately
|
||||
*/
|
||||
finishTimeout = TIMEOUT_MAX_ITERS + 1;
|
||||
}
|
||||
else if (0 == ret && (playPts != currPts && maxInjectedPts > currPts))
|
||||
else if (ret == 0 && (playPts != currPts && maxInjectedPts > currPts))
|
||||
{
|
||||
playPts = currPts;
|
||||
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)
|
||||
{
|
||||
int32_t len = 0;
|
||||
if (0 == PlaybackDieNow(0))
|
||||
if (PlaybackDieNow(0) == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -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) ||
|
||||
(flag == 1 && hasfillerThreadStarted[id] == 1 && avContextTab[0] != NULL && avContextTab[0]->pb != NULL && rwdiff > FILLBUFDIFF))
|
||||
{
|
||||
if (0 == PlaybackDieNow(0))
|
||||
if (PlaybackDieNow(0) == 0)
|
||||
{
|
||||
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 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);
|
||||
sumlen += len;
|
||||
|
@@ -419,7 +419,7 @@ static char *Codec2Encoding(int32_t codec_id, int32_t media_type, uint8_t *extra
|
||||
{
|
||||
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
|
||||
// "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
|
||||
* 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");
|
||||
reset_finish_timeout();
|
||||
@@ -905,8 +905,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
else
|
||||
#endif
|
||||
#ifdef HAVE_FLV2MPEG4_CONVERTER
|
||||
if (get_codecpar(avContextTab[cAVIdx]->streams[packet.stream_index])->codec_id == AV_CODEC_ID_FLV1 &&
|
||||
0 == memcmp(videoTrack->Encoding, "V_MPEG4", 7))
|
||||
if (get_codecpar(avContextTab[cAVIdx]->streams[packet.stream_index])->codec_id == AV_CODEC_ID_FLV1 && memcmp(videoTrack->Encoding, "V_MPEG4", 7) == 0)
|
||||
{
|
||||
flv2mpeg4_write_packet(context, &flv2mpeg4_context, videoTrack, cAVIdx, ¤tVideoPts, &latestPts, &packet);
|
||||
update_max_injected_pts(latestPts);
|
||||
@@ -1362,7 +1361,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
{
|
||||
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 */
|
||||
printf("{\"log\":\"Frame read error: '%s'\"}\n", errbuf);
|
||||
@@ -1397,7 +1396,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
else if (1 == context->playback->isLoopMode)
|
||||
{
|
||||
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;
|
||||
do_seek_target_seconds = 1;
|
||||
@@ -1532,7 +1531,7 @@ int64_t SAM_SeekFunc(void *ptr, int64_t pos, int whence)
|
||||
if (AVSEEK_SIZE != whence)
|
||||
{
|
||||
ret = (int64_t)fseeko(io->pFile, (off_t)pos, whence);
|
||||
if (0 == ret)
|
||||
if (ret == 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
#ifdef USE_CUSTOM_IO
|
||||
if (0 == strstr(filename, "://") ||
|
||||
0 == strncmp(filename, "file://", 7))
|
||||
if (strstr(filename, "://") == 0 || strncmp(filename, "file://", 7) == 0)
|
||||
{
|
||||
AVIOContext *avio_ctx = NULL;
|
||||
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;
|
||||
uint8_t numOfRTMPImpl = 0;
|
||||
if (0 == strncmp(filename, "ffrtmp", 6))
|
||||
if (strncmp(filename, "ffrtmp", 6) == 0)
|
||||
{
|
||||
filename = filename + 2;
|
||||
rtmpProtoImplType = RTMP_NATIVE;
|
||||
@@ -1687,12 +1685,12 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
|
||||
rtmpProtoImplType = RTMP_LIBRTMP;
|
||||
}
|
||||
|
||||
if (0 == strncmp(filename, "rtmp://", 7) ||
|
||||
0 == strncmp(filename, "rtmpe://", 8) ||
|
||||
0 == strncmp(filename, "rtmps://", 8) ||
|
||||
0 == strncmp(filename, "rtmpt://", 8) ||
|
||||
0 == strncmp(filename, "rtmpte://", 9) ||
|
||||
0 == strncmp(filename, "rtmpts://", 9))
|
||||
if (strncmp(filename, "rtmp://", 7) == 0 ||
|
||||
strncmp(filename, "rtmpe://", 8) == 0 ||
|
||||
strncmp(filename, "rtmps://", 8) == 0 ||
|
||||
strncmp(filename, "rtmpt://", 8) == 0 ||
|
||||
strncmp(filename, "rtmpte://", 9) == 0 ||
|
||||
strncmp(filename, "rtmpts://", 9) == 0)
|
||||
{
|
||||
/* At first we need to check which protocol
|
||||
* 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)))
|
||||
{
|
||||
if (0 == strcmp("rtmp", protoName))
|
||||
if (strcmp("rtmp", protoName) == 0)
|
||||
{
|
||||
++numOfRTMPImpl;
|
||||
}
|
||||
else if (0 == strcmp("ffrtmp", protoName))
|
||||
else if (strcmp("ffrtmp", protoName) == 0)
|
||||
{
|
||||
// ffmpeg has patch to have both native and librtmp implementations
|
||||
++numOfRTMPImpl;
|
||||
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 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) ||
|
||||
0 == strncmp(filename, "https://", 8))
|
||||
else if (strncmp(filename, "http://", 7) == 0 || strncmp(filename, "https://", 8) == 0)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -2127,7 +2124,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
|
||||
{
|
||||
uint32_t n = 0;
|
||||
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];
|
||||
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:
|
||||
ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type);
|
||||
// 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)
|
||||
{
|
||||
@@ -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_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_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.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");
|
||||
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:
|
||||
ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n", get_codecpar(stream)->codec_type);
|
||||
// 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)
|
||||
{
|
||||
@@ -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)
|
||||
{
|
||||
if (0 == strncmp(avContext->iformat->name, "mpegts", 6) ||
|
||||
0 == strncmp(avContext->iformat->name, "hls,", 4))
|
||||
if (strncmp(avContext->iformat->name, "mpegts", 6) == 0 || strncmp(avContext->iformat->name, "hls,", 4) == 0)
|
||||
{
|
||||
const char marker[] = "ADTS";
|
||||
track.aacbuflen = sizeof(marker) / sizeof(char);
|
||||
|
@@ -74,7 +74,7 @@ static AVCodecContext *get_codecpar(AVStream *stream)
|
||||
static AVRational get_frame_rate(AVStream *stream)
|
||||
{
|
||||
AVRational rateRational = stream->avg_frame_rate;
|
||||
if (0 == rateRational.den)
|
||||
if (rateRational.den == 0)
|
||||
{
|
||||
rateRational = stream->r_frame_rate;
|
||||
}
|
||||
|
Reference in New Issue
Block a user