avformat/mov: Cosmetics

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-06-14 21:26:16 +02:00
parent 9ce1eb5eb0
commit 7256c363a0
1 changed files with 54 additions and 60 deletions

View File

@ -1566,8 +1566,7 @@ static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
ret = ffio_read_size(pb, icc_profile, atom.size - 4);
if (ret < 0)
return ret;
}
else {
} else {
color_primaries = avio_rb16(pb);
color_trc = avio_rb16(pb);
color_matrix = avio_rb16(pb);
@ -1720,7 +1719,7 @@ static int mov_read_dpxe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int ret = mov_read_extradata(c, pb, atom, AV_CODEC_ID_AVUI);
if(ret == 0)
if (!ret)
ret = mov_read_extradata(c, pb, atom, AV_CODEC_ID_DNXHD);
return ret;
}
@ -2765,8 +2764,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_log(c->fc, AV_LOG_TRACE, "keyframe_count = %u\n", entries);
if (!entries)
{
if (!entries) {
sc->keyframe_absent = 1;
if (!st->need_parsing && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
@ -2947,8 +2945,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (duration > 0 &&
duration <= INT64_MAX - sc->duration_for_fps &&
total_sample_count <= INT_MAX - sc->nb_frames_for_fps
) {
total_sample_count <= INT_MAX - sc->nb_frames_for_fps) {
sc->duration_for_fps += duration;
sc->nb_frames_for_fps += total_sample_count;
}
@ -3278,7 +3275,7 @@ static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
FFMAX(min_size_needed, 2 * st->index_entries_allocated_size) :
min_size_needed;
if((unsigned)st->nb_index_entries + 1 >= UINT_MAX / sizeof(AVIndexEntry))
if (st->nb_index_entries + 1U >= UINT_MAX / sizeof(AVIndexEntry))
return -1;
entries = av_fast_realloc(st->index_entries,
@ -3347,7 +3344,8 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, uns
}
#define MAX_REORDER_DELAY 16
static void mov_estimate_video_delay(MOVContext *c, AVStream* st) {
static void mov_estimate_video_delay(MOVContext *c, AVStream* st)
{
MOVStreamContext *msc = st->priv_data;
int ind;
int ctts_ind = 0;
@ -4797,8 +4795,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb);
frag_stream_info = get_current_frag_stream_info(&c->frag_index);
if (frag_stream_info)
{
if (frag_stream_info) {
if (frag_stream_info->next_trun_dts != AV_NOPTS_VALUE) {
dts = frag_stream_info->next_trun_dts - sc->time_offset;
} else if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE &&
@ -6591,15 +6588,13 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s
av_aes_ctr_set_full_iv(sc->cenc.aes_ctr, sample->iv);
if (!sample->subsample_count)
{
if (!sample->subsample_count) {
/* decrypt the whole packet */
av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, size);
return 0;
}
for (i = 0; i < sample->subsample_count; i++)
{
for (i = 0; i < sample->subsample_count; i++) {
if (sample->subsamples[i].bytes_of_clear_data + sample->subsamples[i].bytes_of_protected_data > size) {
av_log(c->fc, AV_LOG_ERROR, "subsample size exceeds the packet size left\n");
return AVERROR_INVALIDDATA;
@ -6962,10 +6957,9 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
}
}
if (atom.type != MKTAG('r','o','o','t') &&
atom.type != MKTAG('m','o','o','v'))
{
if (a.type == MKTAG('t','r','a','k') || a.type == MKTAG('m','d','a','t'))
{
atom.type != MKTAG('m','o','o','v')) {
if (a.type == MKTAG('t','r','a','k') ||
a.type == MKTAG('m','d','a','t')) {
av_log(c->fc, AV_LOG_ERROR, "Broken file, trak/mdat not at top-level\n");
avio_skip(pb, -8);
c->atom_depth --;
@ -7121,11 +7115,12 @@ static int mov_probe(const AVProbeData *p)
* low score to force expanding the probe window until
* mpegps_probe finds what it needs */
return 5;
}else
} else {
/* Keep looking */
offset += 2;
}
}
}
return score;
}
@ -7600,7 +7595,8 @@ static int mov_read_header(AVFormatContext *s)
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
fix_timescale(mov, sc);
if(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id == AV_CODEC_ID_AAC) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codecpar->codec_id == AV_CODEC_ID_AAC) {
st->skip_samples = sc->start_pad;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sc->nb_frames_for_fps > 0 && sc->duration_for_fps > 0)
@ -7618,8 +7614,7 @@ static int mov_read_header(AVFormatContext *s)
}
if (mov->handbrake_version &&
mov->handbrake_version <= 1000000*0 + 1000*10 + 2 && // 0.10.2
st->codecpar->codec_id == AV_CODEC_ID_MP3
) {
st->codecpar->codec_id == AV_CODEC_ID_MP3) {
av_log(s, AV_LOG_VERBOSE, "Forcing full parsing for mp3 stream\n");
st->need_parsing = AVSTREAM_PARSE_FULL;
}
@ -7673,9 +7668,8 @@ static int mov_read_header(AVFormatContext *s)
switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
err = ff_replaygain_export(st, s->metadata);
if (err < 0) {
if (err < 0)
goto fail;
}
break;
case AVMEDIA_TYPE_VIDEO:
if (sc->display_matrix) {
@ -7889,7 +7883,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_INVALIDDATA;
}
if( st->discard == AVDISCARD_NONKEY && 0==(sample->flags & AVINDEX_KEYFRAME) ) {
if (st->discard == AVDISCARD_NONKEY && !(sample->flags & AVINDEX_KEYFRAME)) {
av_log(mov->fc, AV_LOG_DEBUG, "Nonkey frame from stream %d discarded due to AVDISCARD_NONKEY\n", sc->ffindex);
goto retry;
}