[FFmpeg-devel] [PATCH 1/2] avcodec/diracdec: Use int64 in global mv to prevent overflow
Fixes: runtime error: signed integer overflow: 361 * -6295541 cannot be represented in type 'int' Fixes: 5911/clusterfuzz-testcase-minimized-6450382197751808 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer--- libavcodec/diracdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index 530e1c6ffd..e3afbf14be 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -1399,8 +1399,8 @@ static void global_mv(DiracContext *s, DiracBlock *block, int x, int y, int ref) int *c = s->globalmc[ref].perspective; int m = (1< u.mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep); block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep); -- 2.16.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dwt: Fix integer overflows in sr_1d53()
Fixes: 5918/clusterfuzz-testcase-minimized-5120505435652096 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer--- libavcodec/jpeg2000dwt.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c index 55dd5e89b5..ce1678a3d7 100644 --- a/libavcodec/jpeg2000dwt.c +++ b/libavcodec/jpeg2000dwt.c @@ -305,22 +305,22 @@ static void dwt_encode97_int(DWTContext *s, int *t) t[i] = (t[i] + ((1< >1)) >> I_PRESHIFT; } -static void sr_1d53(int *p, int i0, int i1) +static void sr_1d53(unsigned *p, int i0, int i1) { int i; if (i1 <= i0 + 1) { if (i0 == 1) -p[1] >>= 1; +p[1] = (int)p[1] >> 1; return; } extend53(p, i0, i1); for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++) -p[2 * i] -= (p[2 * i - 1] + p[2 * i + 1] + 2) >> 2; +p[2 * i] -= (int)(p[2 * i - 1] + p[2 * i + 1] + 2) >> 2; for (i = (i0 >> 1); i < (i1 >> 1); i++) -p[2 * i + 1] += (p[2 * i] + p[2 * i + 2]) >> 1; +p[2 * i + 1] += (int)(p[2 * i] + p[2 * i + 2]) >> 1; } static void dwt_decode53(DWTContext *s, int *t) -- 2.16.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 08/10] avformat/mxfdec: use body_offset of the partitions in mxf_absolute_bodysid_offset
Use body_offset of the partitions to search for the partition with the given offset in the essence. This makes the function find the correct partition for non frame-wrapped essences as well, where only the essence data is part of the the edit unit byte count, not the KLV-s. Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 23 +++ 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 64f607a491..497a97d3ef 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -91,6 +91,7 @@ typedef struct MXFPartition { int64_t index_byte_count; int pack_length; int64_t pack_ofs; ///< absolute offset of pack in file, including run-in +int64_t body_offset; } MXFPartition; typedef struct MXFCryptoContext { @@ -612,7 +613,7 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size partition->header_byte_count = avio_rb64(pb); partition->index_byte_count = avio_rb64(pb); partition->index_sid = avio_rb32(pb); -avio_skip(pb, 8); +partition->body_offset = avio_rb64(pb); partition->body_sid = avio_rb32(pb); if (avio_read(pb, op, sizeof(UID)) != sizeof(UID)) { av_log(mxf->fc, AV_LOG_ERROR, "Failed reading UID\n"); @@ -1347,7 +1348,10 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t offset, int64_t *offset_out) { int x; -int64_t offset_in = offset; /* for logging */ +MXFPartition *last_p = NULL; + +if (offset < 0) +return AVERROR(EINVAL); for (x = 0; x < mxf->partitions_count; x++) { MXFPartition *p = >partitions[x]; @@ -1355,17 +1359,20 @@ static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t of if (p->body_sid != body_sid) continue; -if (offset < p->essence_length || !p->essence_length) { -*offset_out = p->essence_offset + offset; -return 0; -} +if (p->body_offset > offset) +break; + +last_p = p; +} -offset -= p->essence_length; +if (last_p && (!last_p->essence_length || last_p->essence_length > (offset - last_p->body_offset))) { +*offset_out = last_p->essence_offset + (offset - last_p->body_offset); +return 0; } av_log(mxf->fc, AV_LOG_ERROR, "failed to find absolute offset of %"PRIX64" in BodySID %i - partial file?\n", - offset_in, body_sid); + offset, body_sid); return AVERROR_INVALIDDATA; } -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 09/10] avformat/mxfdec: compute sample_count after seek from index for audio streams
This fixes audio timestamps if the audio streams are not frame wrapped with the video. Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 54 ++-- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 497a97d3ef..21fd2a876b 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3055,6 +3055,42 @@ fail: return ret; } +static MXFIndexTable *mxf_find_index_table(MXFContext *mxf, int index_sid) +{ +int i; +for (i = 0; i < mxf->nb_index_tables; i++) +if (mxf->index_tables[i].index_sid == index_sid) +return >index_tables[i]; +return NULL; +} + +/* Get the edit unit of the next packet from current_offset in a track. The returned edit unit can be original_duration as well! */ +static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_t current_offset, int64_t *edit_unit_out) +{ +int64_t a, b, m, offset; +MXFIndexTable *t = mxf_find_index_table(mxf, track->index_sid); + +if (!t || track->original_duration <= 0) +return -1; + +a = -1; +b = track->original_duration; + +while (b - a > 1) { +m = (a + b) >> 1; +if (mxf_edit_unit_absolute_offset(mxf, t, m, NULL, , 0) < 0) +return -1; +if (offset < current_offset) +a = m; +else +b = m; +} + +*edit_unit_out = b; + +return 0; +} + /** * Sets mxf->current_edit_unit based on what offset we're currently at. * @return next_ofs if OK, <0 on error @@ -3454,13 +3490,19 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti for (i = 0; i < s->nb_streams; i++) { AVStream *cur_st = s->streams[i]; MXFTrack *cur_track = cur_st->priv_data; -uint64_t current_sample_count = 0; if (cur_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { -ret = mxf_compute_sample_count(mxf, i, _sample_count); -if (ret < 0) -return ret; - -cur_track->sample_count = current_sample_count; +int64_t track_edit_unit; +if (st != cur_st && mxf_get_next_track_edit_unit(mxf, cur_track, seekpos, _edit_unit) >= 0) { +cur_track->sample_count = av_rescale_q(track_edit_unit, + av_inv_q(cur_track->edit_rate), + cur_st->time_base); +} else { +uint64_t current_sample_count = 0; +ret = mxf_compute_sample_count(mxf, i, _sample_count); +if (ret < 0) +return ret; +cur_track->sample_count = current_sample_count; +} } } return 0; -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 07/10] avformat/mxfdec: set index_duration from the track using the index
Also use original_duration as index_duration is in edit units. Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 7abb047117..64f607a491 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1564,14 +1564,6 @@ static int mxf_compute_index_tables(MXFContext *mxf) { int i, j, k, ret, nb_sorted_segments; MXFIndexTableSegment **sorted_segments = NULL; -AVStream *st = NULL; - -for (i = 0; i < mxf->fc->nb_streams; i++) { -if (mxf->fc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_DATA) -continue; -st = mxf->fc->streams[i]; -break; -} if ((ret = mxf_get_sorted_table_segments(mxf, _sorted_segments, _segments)) || nb_sorted_segments <= 0) { @@ -1610,6 +1602,7 @@ static int mxf_compute_index_tables(MXFContext *mxf) for (i = j = 0; j < mxf->nb_index_tables; i += mxf->index_tables[j++].nb_segments) { MXFIndexTable *t = >index_tables[j]; +MXFTrack *mxf_track = NULL; t->segments = av_mallocz_array(t->nb_segments, sizeof(*t->segments)); @@ -1632,6 +1625,14 @@ static int mxf_compute_index_tables(MXFContext *mxf) if ((ret = mxf_compute_ptses_fake_index(mxf, t)) < 0) goto finish_decoding_index; +for (k = 0; k < mxf->fc->nb_streams; k++) { +MXFTrack *track = mxf->fc->streams[k]->priv_data; +if (track && track->index_sid == t->index_sid) { +mxf_track = track; +break; +} +} + /* fix zero IndexDurations */ for (k = 0; k < t->nb_segments; k++) { if (t->segments[k]->index_duration) @@ -1641,7 +1642,7 @@ static int mxf_compute_index_tables(MXFContext *mxf) av_log(mxf->fc, AV_LOG_WARNING, "IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n", t->index_sid, k); -if (!st) { +if (!mxf_track) { av_log(mxf->fc, AV_LOG_WARNING, "no streams?\n"); break; } @@ -1649,7 +1650,7 @@ static int mxf_compute_index_tables(MXFContext *mxf) /* assume the first stream's duration is reasonable * leave index_duration = 0 on further segments in case we have any (unlikely) */ -t->segments[k]->index_duration = st->duration; +t->segments[k]->index_duration = mxf_track->original_duration; break; } } -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 06/10] avformat/mxfdec: fix sorting of index segments
Fixes ticket #5320. Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4f30877f6d..7abb047117 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1309,9 +1309,15 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment * We want the smallest values for the keys than what we currently have, unless this is the first such entry this time around. * If we come across an entry with the same IndexStartPosition but larger IndexDuration, then we'll prefer it over the one we currently have. */ -if ((i == 0 || s->body_sid > last_body_sid || s->index_sid > last_index_sid || s->index_start_position > last_index_start) && -(best == -1 || s->body_sid < best_body_sid || s->index_sid < best_index_sid || s->index_start_position < best_index_start || -(s->index_start_position == best_index_start && s->index_duration > best_index_duration))) { +if ((i == 0 || + s->body_sid > last_body_sid || + s->body_sid == last_body_sid && s->index_sid > last_index_sid || + s->body_sid == last_body_sid && s->index_sid == last_index_sid && s->index_start_position > last_index_start) && +(best == -1 || + s->body_sid < best_body_sid || + s->body_sid == best_body_sid && s->index_sid < best_index_sid || + s->body_sid == best_body_sid && s->index_sid == best_index_sid && s->index_start_position < best_index_start || + s->body_sid == best_body_sid && s->index_sid == best_index_sid && s->index_start_position == best_index_start && s->index_duration > best_index_duration)) { best = j; best_body_sid= s->body_sid; best_index_sid = s->index_sid; -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 10/10] avformat/mxfdec: always use a stream which matches the first index table when seeking
Obviously this is still not perfect, but better then it was. Using the first index table and mxf->current_edit_unit is still hardcoded in many places, so this change has hopefully the less chance of breaking anything that works now. Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 21fd2a876b..e0a4b5bd11 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3451,6 +3451,20 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti mxf->current_edit_unit = sample_time; } else { t = >index_tables[0]; +if (t->index_sid != source_track->index_sid) { +/* If the first index table does not belong to the stream, then find a stream which does belong to the index table */ +for (i = 0; i < s->nb_streams; i++) { +MXFTrack *new_source_track = s->streams[i]->priv_data; +if (new_source_track && new_source_track->index_sid == t->index_sid) { +sample_time = av_rescale_q(sample_time, new_source_track->edit_rate, source_track->edit_rate); +source_track = new_source_track; +st = s->streams[i]; +break; +} +} +if (i == s->nb_streams) +return AVERROR_INVALIDDATA; +} /* clamp above zero, else ff_index_search_timestamp() returns negative * this also means we allow seeking before the start */ -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 02/10] avformat/mxfdec: fix essence_offset calculation
The reference point for a KAG is the first byte of the key of a Partition Pack. Fixes ticket #2817. Fixes ticket #5317. Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index fcae863ef4..95767ccba4 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2875,8 +2875,8 @@ static int mxf_read_header(AVFormatContext *s) * for OPAtom we still need the actual essence_offset though (the KL's length can vary) */ int64_t op1a_essence_offset = -round_to_kag(mxf->current_partition->this_partition + - mxf->current_partition->pack_length, mxf->current_partition->kag_size) + +mxf->current_partition->this_partition + +round_to_kag(mxf->current_partition->pack_length, mxf->current_partition->kag_size) + round_to_kag(mxf->current_partition->header_byte_count, mxf->current_partition->kag_size) + round_to_kag(mxf->current_partition->index_byte_count, mxf->current_partition->kag_size); -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 01/10] avformat/mxfdec: fix indentation
Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 3b8d423906..fcae863ef4 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3303,18 +3303,18 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti av_inv_q(source_track->edit_rate)); if (mxf->nb_index_tables <= 0) { -if (!s->bit_rate) -return AVERROR_INVALIDDATA; -if (sample_time < 0) -sample_time = 0; -seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den); +if (!s->bit_rate) +return AVERROR_INVALIDDATA; +if (sample_time < 0) +sample_time = 0; +seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den); -seekpos = avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET); -if (seekpos < 0) -return seekpos; +seekpos = avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET); +if (seekpos < 0) +return seekpos; -ff_update_cur_dts(s, st, sample_time); -mxf->current_edit_unit = sample_time; +ff_update_cur_dts(s, st, sample_time); +mxf->current_edit_unit = sample_time; } else { t = >index_tables[0]; -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 05/10] avformat/mxfdec: use both body_sid and track_number to find the track of a packet
In order to do that we have to parse the EssenceContainerData and assign the proper body_sid and index_sid to the tracks from the corresponding source packages. This fixes packets returned in the wrong stream for some OP1-b files. Based on a patch by Alex Mogurenko from https://github.com/da8eat/FFmpeg Reference: http://mogurenko.com/2018/01/02/mxf-op1b-ffmpeg-part1/ Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 87 +--- 1 file changed, 83 insertions(+), 4 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4c3f2a64cb..4f30877f6d 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -162,6 +162,8 @@ typedef struct { int intra_only; uint64_t sample_count; int64_t original_duration; /* st->duration in SampleRate/EditRate units */ +int index_sid; +int body_sid; } MXFTrack; typedef struct MXFDescriptor { @@ -223,6 +225,15 @@ typedef struct MXFPackage { int comment_count; } MXFPackage; +typedef struct MXFEssenceContainerData { +UID uid; +enum MXFMetadataSetType type; +UID package_uid; +UID package_ul; +int index_sid; +int body_sid; +} MXFEssenceContainerData; + typedef struct MXFMetadataSet { UID uid; enum MXFMetadataSetType type; @@ -247,6 +258,8 @@ typedef struct MXFContext { MXFOP op; UID *packages_refs; int packages_count; +UID *essence_container_data_refs; +int essence_container_data_count; MXFMetadataSet **metadata_sets; int metadata_sets_count; AVFormatContext *fc; @@ -385,20 +398,43 @@ static int klv_read_packet(KLVPacket *klv, AVIOContext *pb) return klv->length == -1 ? -1 : 0; } -static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv) +static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv, int body_sid) { int i; for (i = 0; i < s->nb_streams; i++) { MXFTrack *track = s->streams[i]->priv_data; /* SMPTE 379M 7.3 */ -if (track && !memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number))) +if (track && (!body_sid || !track->body_sid || track->body_sid == body_sid) && !memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number))) return i; } /* return 0 if only one stream, for OP Atom files with 0 as track number */ return s->nb_streams == 1 ? 0 : -1; } +static int find_body_sid_by_offset(MXFContext *mxf, int64_t offset) +{ +// we look for partition where the offset is placed +int a, b, m; +int64_t this_partition; + +a = -1; +b = mxf->partitions_count; + +while (b - a > 1) { +m = (a + b) >> 1; +this_partition = mxf->partitions[m].this_partition; +if (this_partition <= offset) +a = m; +else +b = m; +} + +if (a == -1) +return 0; +return mxf->partitions[a].body_sid; +} + /* XXX: use AVBitStreamFilter */ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length) { @@ -440,6 +476,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv uint8_t ivec[16]; uint8_t tmpbuf[16]; int index; +int body_sid; if (!mxf->aesc && s->key && s->keylen == 16) { mxf->aesc = av_aes_alloc(); @@ -457,7 +494,9 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv avio_read(pb, klv->key, 16); if (!IS_KLV_KEY(klv, mxf_essence_element_key)) return AVERROR_INVALIDDATA; -index = mxf_get_stream_index(s, klv); + +body_sid = find_body_sid_by_offset(mxf, klv->offset); +index = mxf_get_stream_index(s, klv, body_sid); if (index < 0) return AVERROR_INVALIDDATA; // source size @@ -757,6 +796,9 @@ static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int siz av_log(mxf->fc, AV_LOG_VERBOSE, "Multiple packages_refs\n"); av_free(mxf->packages_refs); return mxf_read_strong_ref_array(pb, >packages_refs, >packages_count); +case 0x1902: +av_free(mxf->essence_container_data_refs); +return mxf_read_strong_ref_array(pb, >essence_container_data_refs, >essence_container_data_count); } return 0; } @@ -893,6 +935,25 @@ static int mxf_read_package(void *arg, AVIOContext *pb, int tag, int size, UID u return 0; } +static int mxf_read_essence_container_data(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset) +{ +MXFEssenceContainerData *essence_data = arg; +switch(tag) { +case 0x2701: +/* linked package umid UMID */ +avio_read(pb, essence_data->package_ul, 16); +avio_read(pb, essence_data->package_uid, 16); +break; +case 0x3f06: +essence_data->index_sid =
[FFmpeg-devel] [PATCH 04/10] avformat/mxfdec: use full UMID to resolve source package
Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 43a0220c87..4c3f2a64cb 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1681,7 +1681,7 @@ static MXFTimecodeComponent* mxf_resolve_timecode_component(MXFContext *mxf, UID return NULL; } -static MXFPackage* mxf_resolve_source_package(MXFContext *mxf, UID package_uid) +static MXFPackage* mxf_resolve_source_package(MXFContext *mxf, UID package_ul, UID package_uid) { MXFPackage *package = NULL; int i; @@ -1691,7 +1691,7 @@ static MXFPackage* mxf_resolve_source_package(MXFContext *mxf, UID package_uid) if (!package) continue; -if (!memcmp(package->package_uid, package_uid, 16)) +if (!memcmp(package->package_ul, package_ul, 16) && !memcmp(package->package_uid, package_uid, 16)) return package; } return NULL; @@ -1740,7 +1740,7 @@ static MXFStructuralComponent* mxf_resolve_essence_group_choice(MXFContext *mxf, if (!component) continue; -if (!(package = mxf_resolve_source_package(mxf, component->source_package_uid))) +if (!(package = mxf_resolve_source_package(mxf, component->source_package_ul, component->source_package_uid))) continue; descriptor = mxf_resolve_strong_ref(mxf, >descriptor_ref, Descriptor); @@ -1806,7 +1806,7 @@ static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_t if (!sourceclip) continue; -if (!(physical_package = mxf_resolve_source_package(mxf, sourceclip->source_package_uid))) +if (!(physical_package = mxf_resolve_source_package(mxf, sourceclip->source_package_ul, sourceclip->source_package_uid))) break; mxf_add_umid_metadata(>metadata, "reel_umid", physical_package); @@ -1976,7 +1976,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) if (!component) continue; -source_package = mxf_resolve_source_package(mxf, component->source_package_uid); +source_package = mxf_resolve_source_package(mxf, component->source_package_ul, component->source_package_uid); if (!source_package) { av_log(mxf->fc, AV_LOG_TRACE, "material track %d: no corresponding source package found\n", material_track->track_id); continue; -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 03/10] avformat/mxfdec: use the first system item if available for calculating essence_offset
Also add an additional system item key. Fixes parsing of ffmpeg-bugs/trac/ticket2817/warehouse.mxf Signed-off-by: Marton Balint--- libavformat/mxfdec.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 95767ccba4..43a0220c87 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -289,7 +289,8 @@ static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 }; static const uint8_t mxf_avid_essence_element_key[]= { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 }; static const uint8_t mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x0a,0x0e,0x0f,0x03,0x01 }; -static const uint8_t mxf_system_item_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 }; +static const uint8_t mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 }; +static const uint8_t mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 }; static const uint8_t mxf_klv_key[] = { 0x06,0x0e,0x2b,0x34 }; /* complete keys to match */ static const uint8_t mxf_crypto_source_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 }; @@ -2861,7 +2862,8 @@ static int mxf_read_header(AVFormatContext *s) if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) || IS_KLV_KEY(klv.key, mxf_essence_element_key) || IS_KLV_KEY(klv.key, mxf_avid_essence_element_key) || -IS_KLV_KEY(klv.key, mxf_system_item_key)) { +IS_KLV_KEY(klv.key, mxf_system_item_key_cp) || +IS_KLV_KEY(klv.key, mxf_system_item_key_gc)) { if (!mxf->current_partition) { av_log(mxf->fc, AV_LOG_ERROR, "found essence prior to first PartitionPack\n"); @@ -2888,7 +2890,10 @@ static int mxf_read_header(AVFormatContext *s) mxf->current_partition->essence_length = klv.length; } else { /* NOTE: op1a_essence_offset may be less than to klv.offset (C0023S01.mxf) */ -mxf->current_partition->essence_offset = op1a_essence_offset; +if (IS_KLV_KEY(klv.key, mxf_system_item_key_cp) || IS_KLV_KEY(klv.key, mxf_system_item_key_gc)) +mxf->current_partition->essence_offset = klv.offset; +else +mxf->current_partition->essence_offset = op1a_essence_offset; } } -- 2.13.6 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] avcodec/dxtory: Remove code that corrupts dimensions
Fixes: Timeout Fixes: 5796/clusterfuzz-testcase-minimized-5206729085157376 Does someone have a valid sample that triggers this path ? Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer--- libavcodec/dxtory.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c index e736cec8db..285ca38efb 100644 --- a/libavcodec/dxtory.c +++ b/libavcodec/dxtory.c @@ -305,11 +305,7 @@ static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic, } if (avctx->height - line) { -av_log(avctx, AV_LOG_VERBOSE, - "Not enough slice data available, " - "cropping the frame by %d pixels\n", -avctx->height - line); -avctx->height = line; +avpriv_request_sample(avctx, "Not enough slice data available"); } return 0; -- 2.16.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/3] avcodec/dirac_dwt_template: Fix Integer overflow in horizontal_compose_dd137i()
Fixes: 5894/clusterfuzz-testcase-minimized-5315325420634112 Fixes: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer--- libavcodec/dirac_dwt_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c index e68cc4d530..19c008b988 100644 --- a/libavcodec/dirac_dwt_template.c +++ b/libavcodec/dirac_dwt_template.c @@ -118,8 +118,8 @@ static void RENAME(horizontal_compose_dd137i)(uint8_t *_b, uint8_t *_tmp, int w) tmp[w2+1] = tmp[w2] = tmp[w2-1]; for (x = 0; x < w2; x++) { -b[2*x ] = (tmp[x] + 1)>>1; -b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1; +b[2*x ] = (tmp[x] + 1U)>>1; +b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1U)>>1; } } -- 2.16.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/3] avcodec/hevcdec: Check luma/chroma_log2_weight_denom
Fixes: signed integer overflow: 3 + 2147483647 cannot be represented in type 'int' Fixes: 5888/clusterfuzz-testcase-minimized-5634701067812864 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer--- libavcodec/hevcdec.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 8f1c1f1953..fc4eb781dc 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -151,12 +151,18 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) int luma_log2_weight_denom; luma_log2_weight_denom = get_ue_golomb_long(gb); -if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) +if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) { av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom); +return AVERROR_INVALIDDATA; +} s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); if (s->ps.sps->chroma_format_idc != 0) { -int delta = get_se_golomb(gb); -s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3); +int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb); +if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) { +av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom); +return AVERROR_INVALIDDATA; +} +s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom; } for (i = 0; i < s->sh.nb_refs[L0]; i++) { -- 2.16.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] avfilter/vf/blend : add 16 bits SIMD version for basic mode (v2)
Hello, New patchs in attach Limit the asm version to x86_64 tested on osx X86_64 and osx X86_32 Martin 0001-checkasm-vf_blend-add-depth-param-in-order-to-add-te.patch Description: Binary data 0002-avfilter-x86-vf_blend-reorganize-init-in-order-to-ad.patch Description: Binary data 0003-avfilter-x86-vf_blend-indent.patch Description: Binary data 0004-avfilter-x86-vf_blend-add-16-bit-version-for.patch Description: Binary data 0005-checkasm-vf_blend-add-test-for-blend_simple_16-phoen.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] docs/codecs: remove dead codec debug options
On Mon, Jan 15, 2018, at 5:59 AM, Gyan Doshi wrote: > Email had 1 attachment: > + 0001-docs-codecs-remove-dead-codec-debug-options.patch > 2k (text/plain) LGTM. Sorry for the delay. I'll push by Monday unless someone else wants to do so earlier. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH]lavc/exr: Ignore long names flag
2018-02-08 21:45 GMT+01:00 Martin Vignali: > > >> Until now, two types of files are supported: >> Files with flags==0 and files with flags&0x02. >> The specification requires that (flags&0x02) >> implies flags==2 or possibly flags==6: "if bit >> 9 is 1, bits 11 and 12 must be 0" >> >> After my patch, the following values are >> accepted for flags: 0, 2, 4, 6 >> >> > Hello, > > Don't have a strong opinion about this. > But like deep data is not supported, and multipart file output is not > correct > Maybe we can be more explicit about unsupported features, and ignore long > name bit > > Like in patch in attach > > Martin > Hello, If no one is against, i will apply the patch in attach in few days (change since previous patch (mention ticket in commit msg)) Martin 0001-avcodec-exr-add-support-for-long-name-flag-and-be-mo.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] libavfilter/vf_fps: Add more fate tests
On Fri, Feb 16, 2018 at 03:02:02PM -0500, Calvin Walton wrote: > These tests cover specific rounding behaviour, to ensure that I don't > introduce any regressions with the rewritten "activate" callback based > fps filter. > --- > tests/fate/filter-video.mak | 10 +- > tests/ref/fate/filter-fps-down| 15 +++ > tests/ref/fate/filter-fps-down-eof-pass | 16 > tests/ref/fate/filter-fps-down-round-down | 15 +++ > tests/ref/fate/filter-fps-down-round-up | 16 > tests/ref/fate/filter-fps-up | 17 + > tests/ref/fate/filter-fps-up-round-down | 16 > tests/ref/fate/filter-fps-up-round-up | 17 + > 8 files changed, 121 insertions(+), 1 deletion(-) > create mode 100644 tests/ref/fate/filter-fps-down > create mode 100644 tests/ref/fate/filter-fps-down-eof-pass > create mode 100644 tests/ref/fate/filter-fps-down-round-down > create mode 100644 tests/ref/fate/filter-fps-down-round-up > create mode 100644 tests/ref/fate/filter-fps-up > create mode 100644 tests/ref/fate/filter-fps-up-round-down > create mode 100644 tests/ref/fate/filter-fps-up-round-up more tests are good, will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] libavfilter/vf_delogo: add options start and stop frame number
On 2/17/2018 6:23 PM, qq2225936589 wrote: +{ "f1", "set delogo start frame number",OFFSET(f1),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, +{ "f2", "set delogo stop frame number", OFFSET(f2),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS }, This filter has timeline support - doesn't that work? Regards, Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] libavfilter/vf_delogo: add options start and stop frame number
libavfilter/vf_delogo: add options start and stop frame number vf_delogo_add_options_start_and_stop_frame_number.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/flvdec: Set broken_sizes for FlixEngine.
fre 2018-02-16 klockan 15:25 -0800 skrev Nikolas Bowe: > --- > libavformat/flvdec.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > index 0217cef842..b86451fcbf 100644 > --- a/libavformat/flvdec.c > +++ b/libavformat/flvdec.c > @@ -598,7 +598,9 @@ static int amf_parse_object(AVFormatContext *s, > AVStream *astream, > if (version > 0 && version <= 655) > flv->broken_sizes = 1; > } > -} else if (!strcmp(key, "metadatacreator") && > !strcmp(str_val, "MEGA")) { > +} else if (!strcmp(key, "metadatacreator") > +&& (!strcmp(str_val, "MEGA") > +|| !strncmp(str_val, "FlixEngine", 10))) { Nit: please align the inner str(n)cmp:s FlixEngine is the VP6 thing, right? Awful, awful tool. Patch probably OK though /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] build: restore using dlltool/lib.exe for creating Win32 .lib files
On Fri, Feb 16, 2018 at 10:21 PM, Hendrik Leppkeswrote: > The GCC generated import libraries don't work properly when being imported > by MSVC, resulting in missing symbols at runtime. > > This reverts 5b5365fe9 and partially reverts changes from 98a9b1f0d For the record, Martin Storsjö, the original author of the change this is reverting, could reproduce the failure and also send a revert to Libav. So unless someone objects, I'll push this in a day or so, since without it using mingw-build libraries with MSVC is impossible right now (without manual steps to re-generate the .lib file, anyway) - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel