[FFmpeg-cvslog] avformat/mov: Propagate errors in mov_switch_root.
ffmpeg | branch: master | Jacob Trimble | Mon Nov 20 12:05:02 2017 -0800| [2d9cf3bf16b94cd9db10dabad695c69c5cff4f58] | committer: Michael Niedermayer avformat/mov: Propagate errors in mov_switch_root. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d9cf3bf16b94cd9db10dabad695c69c5cff4f58 --- libavformat/mov.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 0b8f8ad24b..b6cdf3a52a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6753,6 +6753,7 @@ static int should_retry(AVIOContext *pb, int error_code) { static int mov_switch_root(AVFormatContext *s, int64_t target, int index) { +int ret; MOVContext *mov = s->priv_data; if (index >= 0 && index < mov->frag_index.nb_items) @@ -6775,8 +6776,10 @@ static int mov_switch_root(AVFormatContext *s, int64_t target, int index) mov->found_mdat = 0; -if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || -avio_feof(s->pb)) +ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }); +if (ret < 0) +return ret; +if (avio_feof(s->pb)) return AVERROR_EOF; av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] configure: Fix dependencies of aac_at decoder.
ffmpeg | branch: master | Jacob Trimble | Thu Nov 30 14:58:59 2017 -0800| [83ecdc9a920d7f0b69d1a25d63757adb887a1f25] | committer: James Almer configure: Fix dependencies of aac_at decoder. Signed-off-by: Jacob Trimble Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83ecdc9a920d7f0b69d1a25d63757adb887a1f25 --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 1fa16e9dba..d05388638d 100755 --- a/configure +++ b/configure @@ -2890,6 +2890,7 @@ trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2" # external libraries aac_at_decoder_deps="audiotoolbox" +aac_at_decoder_select="aac_adtstoasc_bsf" ac3_at_decoder_deps="audiotoolbox" ac3_at_decoder_select="ac3_parser" adpcm_ima_qt_at_decoder_deps="audiotoolbox" ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] configure: Fix dependencies of aac_at decoder.
ffmpeg | branch: release/3.4 | Jacob Trimble | Thu Nov 30 14:58:59 2017 -0800| [5ab992cd3875a5a34d4c30a9d08f2eec95a3fd80] | committer: James Almer configure: Fix dependencies of aac_at decoder. Signed-off-by: Jacob Trimble Signed-off-by: James Almer (cherry picked from commit 83ecdc9a920d7f0b69d1a25d63757adb887a1f25) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ab992cd3875a5a34d4c30a9d08f2eec95a3fd80 --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 18d80ee87a..1797c5dd4f 100755 --- a/configure +++ b/configure @@ -2903,6 +2903,7 @@ mjpeg2jpeg_bsf_select="jpegtables" # external libraries aac_at_decoder_deps="audiotoolbox" +aac_at_decoder_select="aac_adtstoasc_bsf" ac3_at_decoder_deps="audiotoolbox" ac3_at_decoder_select="ac3_parser" adpcm_ima_qt_at_decoder_deps="audiotoolbox" ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Propagate errors in mov_switch_root.
ffmpeg | branch: release/3.0 | Jacob Trimble | Mon Nov 20 12:05:02 2017 -0800| [20e78d53394fa56eb4bcb3be06ff70375a86dd94] | committer: Michael Niedermayer avformat/mov: Propagate errors in mov_switch_root. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer (cherry picked from commit 2d9cf3bf16b94cd9db10dabad695c69c5cff4f58) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=20e78d53394fa56eb4bcb3be06ff70375a86dd94 --- libavformat/mov.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 85bf2e5211..d41778cbed 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4975,6 +4975,7 @@ static int should_retry(AVIOContext *pb, int error_code) { static int mov_switch_root(AVFormatContext *s, int64_t target) { +int ret; MOVContext *mov = s->priv_data; int i, j; int already_read = 0; @@ -5011,8 +5012,10 @@ static int mov_switch_root(AVFormatContext *s, int64_t target) mov->found_mdat = 0; -if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || -avio_feof(s->pb)) +ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }); +if (ret < 0) +return ret; +if (avio_feof(s->pb)) return AVERROR_EOF; av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Propagate errors in mov_switch_root.
ffmpeg | branch: release/3.4 | Jacob Trimble | Mon Nov 20 12:05:02 2017 -0800| [8aabc4fdb56cdd10ddc61dca8a995795721182f0] | committer: Michael Niedermayer avformat/mov: Propagate errors in mov_switch_root. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer (cherry picked from commit 2d9cf3bf16b94cd9db10dabad695c69c5cff4f58) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8aabc4fdb56cdd10ddc61dca8a995795721182f0 --- libavformat/mov.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index fc2d59b51a..5acac07d22 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6418,6 +6418,7 @@ static int should_retry(AVIOContext *pb, int error_code) { static int mov_switch_root(AVFormatContext *s, int64_t target) { +int ret; MOVContext *mov = s->priv_data; int i, j; int already_read = 0; @@ -6454,8 +6455,10 @@ static int mov_switch_root(AVFormatContext *s, int64_t target) mov->found_mdat = 0; -if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || -avio_feof(s->pb)) +ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }); +if (ret < 0) +return ret; +if (avio_feof(s->pb)) return AVERROR_EOF; av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/nvdec: Fix capability check with old drivers.
ffmpeg | branch: master | Jacob Trimble | Thu Nov 30 12:35:50 2017 -0800| [2fdc9f7c4939f83a6c9d1f9d85b6d37ce0bab714] | committer: Timo Rothenpieler avcodec/nvdec: Fix capability check with old drivers. Copied the check from cuviddec.c (*_cuvid decoders) to allow the capability check to be optional for older drivers. Signed-off-by: Jacob Trimble Signed-off-by: Timo Rothenpieler > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2fdc9f7c4939f83a6c9d1f9d85b6d37ce0bab714 --- libavcodec/nvdec.c | 12 1 file changed, 12 insertions(+) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index c7a02ff40f..e9e6ea0f8b 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -91,6 +91,18 @@ static int nvdec_test_capabilities(NVDECDecoder *decoder, caps.eChromaFormat = params->ChromaFormat; caps.nBitDepthMinus8 = params->bitDepthMinus8; +if (!decoder->cvdl->cuvidGetDecoderCaps) { +av_log(logctx, AV_LOG_WARNING, "Used Nvidia driver is too old to perform a capability check.\n"); +av_log(logctx, AV_LOG_WARNING, "The minimum required version is " +#if defined(_WIN32) || defined(__CYGWIN__) +"378.66" +#else +"378.13" +#endif +". Continuing blind.\n"); +return 0; +} + err = decoder->cvdl->cuvidGetDecoderCaps(&caps); if (err != CUDA_SUCCESS) { av_log(logctx, AV_LOG_ERROR, "Failed querying decoder capabilities\n"); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/Makefile: Fix opus parser dependency.
ffmpeg | branch: master | Jacob Trimble | Thu Dec 7 11:05:46 2017 -0800| [b38f222165f97af19f5bfc2c3e9217b5d1b25cfb] | committer: Michael Niedermayer avcodec/Makefile: Fix opus parser dependency. The opus.c file uses ff_celt_freq_range and ff_celt_freq_bands which are defined in opustab.c. The opus parser needs to include that file to avoid linker errors when not including the opus encoder/decoder. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b38f222165f97af19f5bfc2c3e9217b5d1b25cfb --- libavcodec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ab7893f560..ca72138c02 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1005,7 +1005,7 @@ OBJS-$(CONFIG_PNG_PARSER) += png_parser.o OBJS-$(CONFIG_MPEGAUDIO_PARSER)+= mpegaudio_parser.o OBJS-$(CONFIG_MPEGVIDEO_PARSER)+= mpegvideo_parser.o\ mpeg12.o mpeg12data.o -OBJS-$(CONFIG_OPUS_PARSER) += opus_parser.o opus.o vorbis_data.o +OBJS-$(CONFIG_OPUS_PARSER) += opus_parser.o opus.o opustab.o vorbis_data.o OBJS-$(CONFIG_PNG_PARSER) += png_parser.o OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Propagate errors in mov_switch_root.
ffmpeg | branch: release/3.3 | Jacob Trimble | Mon Nov 20 12:05:02 2017 -0800| [a0eccf673cda83697e8e42d13e10d31a60a45346] | committer: Michael Niedermayer avformat/mov: Propagate errors in mov_switch_root. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer (cherry picked from commit 2d9cf3bf16b94cd9db10dabad695c69c5cff4f58) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0eccf673cda83697e8e42d13e10d31a60a45346 --- libavformat/mov.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 6ebdf8a4b7..2f6965eabb 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6171,6 +6171,7 @@ static int should_retry(AVIOContext *pb, int error_code) { static int mov_switch_root(AVFormatContext *s, int64_t target) { +int ret; MOVContext *mov = s->priv_data; int i, j; int already_read = 0; @@ -6207,8 +6208,10 @@ static int mov_switch_root(AVFormatContext *s, int64_t target) mov->found_mdat = 0; -if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || -avio_feof(s->pb)) +ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }); +if (ret < 0) +return ret; +if (avio_feof(s->pb)) return AVERROR_EOF; av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Propagate errors in mov_switch_root.
ffmpeg | branch: release/3.2 | Jacob Trimble | Mon Nov 20 12:05:02 2017 -0800| [a03d488ae2e444847b64863ec3e3813465beaecc] | committer: Michael Niedermayer avformat/mov: Propagate errors in mov_switch_root. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer (cherry picked from commit 2d9cf3bf16b94cd9db10dabad695c69c5cff4f58) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a03d488ae2e444847b64863ec3e3813465beaecc --- libavformat/mov.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 7547c78957..7c245d14ee 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5670,6 +5670,7 @@ static int should_retry(AVIOContext *pb, int error_code) { static int mov_switch_root(AVFormatContext *s, int64_t target) { +int ret; MOVContext *mov = s->priv_data; int i, j; int already_read = 0; @@ -5706,8 +5707,10 @@ static int mov_switch_root(AVFormatContext *s, int64_t target) mov->found_mdat = 0; -if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || -avio_feof(s->pb)) +ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }); +if (ret < 0) +return ret; +if (avio_feof(s->pb)) return AVERROR_EOF; av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avutil/aes_ctr: Add method to set 16-byte IV.
ffmpeg | branch: master | Jacob Trimble | Mon Jan 8 14:12:43 2018 -0800| [9f07cf7c00f3a87669c27aec947daf0f3d33b01f] | committer: Michael Niedermayer avutil/aes_ctr: Add method to set 16-byte IV. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f07cf7c00f3a87669c27aec947daf0f3d33b01f --- doc/APIchanges| 3 +++ libavutil/aes_ctr.c | 6 ++ libavutil/aes_ctr.h | 7 ++- libavutil/tests/aes_ctr.c | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7699365879..c27f104c95 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-xx-xx - xxx - lavu 56.9.100 - aes_ctr.h + Add method to set the 16-byte IV. + 2018-01-xx - xxx - lavf 58.5.100 - avformat.h Explicitly make avformat_network_init() and avformat_network_deinit() optional. If these are not called, network initialization and deinitialization is diff --git a/libavutil/aes_ctr.c b/libavutil/aes_ctr.c index e9c568fe0d..0c2e86785f 100644 --- a/libavutil/aes_ctr.c +++ b/libavutil/aes_ctr.c @@ -45,6 +45,12 @@ void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv) a->block_offset = 0; } +void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv) +{ +memcpy(a->counter, iv, sizeof(a->counter)); +a->block_offset = 0; +} + const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a) { return a->counter; diff --git a/libavutil/aes_ctr.h b/libavutil/aes_ctr.h index f596fa6a46..e4aae126a7 100644 --- a/libavutil/aes_ctr.h +++ b/libavutil/aes_ctr.h @@ -67,11 +67,16 @@ const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a); void av_aes_ctr_set_random_iv(struct AVAESCTR *a); /** - * Forcefully change the iv + * Forcefully change the 8-byte iv */ void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv); /** + * Forcefully change the "full" 16-byte iv, including the counter + */ +void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv); + +/** * Increment the top 64 bit of the iv (performed after each frame) */ void av_aes_ctr_increment_iv(struct AVAESCTR *a); diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c index c5ebeda7ac..00fdb05d13 100644 --- a/libavutil/tests/aes_ctr.c +++ b/libavutil/tests/aes_ctr.c @@ -45,7 +45,7 @@ int main (void) av_aes_ctr_set_random_iv(ae); iv = av_aes_ctr_get_iv(ae); -av_aes_ctr_set_iv(ad, iv); +av_aes_ctr_set_full_iv(ad, iv); av_aes_ctr_crypt(ae, tmp, plain, sizeof(tmp)); av_aes_ctr_crypt(ad, tmp, tmp, sizeof(tmp)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Propagate errors in mov_switch_root.
ffmpeg | branch: release/2.8 | Jacob Trimble | Mon Nov 20 12:05:02 2017 -0800| [514bdaafb439441f1ad665215e9032bf17673b64] | committer: Michael Niedermayer avformat/mov: Propagate errors in mov_switch_root. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer (cherry picked from commit 2d9cf3bf16b94cd9db10dabad695c69c5cff4f58) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=514bdaafb439441f1ad665215e9032bf17673b64 --- libavformat/mov.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 4d4c1a4df9..4ed4af3923 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4674,6 +4674,7 @@ static int should_retry(AVIOContext *pb, int error_code) { static int mov_switch_root(AVFormatContext *s, int64_t target) { +int ret; MOVContext *mov = s->priv_data; int i, j; int already_read = 0; @@ -4710,8 +4711,10 @@ static int mov_switch_root(AVFormatContext *s, int64_t target) mov->found_mdat = 0; -if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || -avio_feof(s->pb)) +ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }); +if (ret < 0) +return ret; +if (avio_feof(s->pb)) return AVERROR_EOF; av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libavformat/mov: Fix inserting frames before current_frame.
ffmpeg | branch: master | Jacob Trimble | Thu Jul 27 10:34:32 2017 -0700| [f4544163b27615ecfff1b42d6acdb3672ac92399] | committer: Michael Niedermayer libavformat/mov: Fix inserting frames before current_frame. When using streaming input, it may be possible to see frames that appear before the current_frame. When these frames are inserted into the index, the current_frame needs to be updated so it is still pointing at the same frame. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f4544163b27615ecfff1b42d6acdb3672ac92399 --- libavformat/mov.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index c02caf6719..522ce60c2d 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4262,7 +4262,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; -int flags, distance, i, err; +int flags, distance, i, err, old_nb_index_entries; for (i = 0; i < c->fc->nb_streams; i++) { if (c->fc->streams[i]->id == frag->track_id) { @@ -4355,13 +4355,19 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES)); if (keyframe) distance = 0; +old_nb_index_entries = st->nb_index_entries; err = av_add_index_entry(st, offset, dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); if (err < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n"); +} else if (err <= sc->current_sample && err + 1 != st->nb_index_entries && +st->nb_index_entries != old_nb_index_entries) { +// if we inserted a new item before the current sample, move the +// counter ahead so it is still pointing to the same sample. +sc->current_sample++; } -av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset %"PRIx64", dts %"PRId64", " -"size %u, distance %d, keyframe %d\n", st->index, sc->sample_count+i, +av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", " +"size %u, distance %d, keyframe %d\n", st->index, err, offset, dts, sample_size, distance, keyframe); distance++; dts += sample_duration; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libavformat/mov: Fix NULL-dereference read for some encrypted content.
ffmpeg | branch: master | Jacob Trimble | Wed Dec 19 16:00:22 2018 -0800| [555f332e7adbd492ca74fa7329c492819b52e2ed] | committer: Michael Niedermayer libavformat/mov: Fix NULL-dereference read for some encrypted content. When reading frames, we need to use the fragment for the correct stream. Sometimes the "current" fragment is not the same as the one the frame is for. Found by Chromium's ClusterFuzz: https://crbug.com/906392 and https://crbug.com/915524 Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=555f332e7adbd492ca74fa7329c492819b52e2ed --- libavformat/mov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ec839ed5e3..825738127b 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6557,14 +6557,14 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s return 0; } -static int cenc_filter(MOVContext *mov, MOVStreamContext *sc, AVPacket *pkt, int current_index) +static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPacket *pkt, int current_index) { MOVFragmentStreamInfo *frag_stream_info; MOVEncryptionIndex *encryption_index; AVEncryptionInfo *encrypted_sample; int encrypted_index, ret; -frag_stream_info = get_current_frag_stream_info(&mov->frag_index); +frag_stream_info = get_frag_stream_info(&mov->frag_index, mov->frag_index.current, st->id); encrypted_index = current_index; encryption_index = NULL; if (frag_stream_info) { @@ -7794,7 +7794,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) if (mov->aax_mode) aax_filter(pkt->data, pkt->size, mov); -ret = cenc_filter(mov, sc, pkt, current_index); +ret = cenc_filter(mov, st, sc, pkt, current_index); if (ret < 0) return ret; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libavformat/mov: Fix NULL-dereference read for some encrypted content.
ffmpeg | branch: release/4.1 | Jacob Trimble | Wed Dec 19 16:00:22 2018 -0800| [73c90818b116e3783e6479172a565cfb9fa36036] | committer: Michael Niedermayer libavformat/mov: Fix NULL-dereference read for some encrypted content. When reading frames, we need to use the fragment for the correct stream. Sometimes the "current" fragment is not the same as the one the frame is for. Found by Chromium's ClusterFuzz: https://crbug.com/906392 and https://crbug.com/915524 Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer (cherry picked from commit 555f332e7adbd492ca74fa7329c492819b52e2ed) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73c90818b116e3783e6479172a565cfb9fa36036 --- libavformat/mov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 6f92742e23..ff7fdd48e2 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6556,14 +6556,14 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s return 0; } -static int cenc_filter(MOVContext *mov, MOVStreamContext *sc, AVPacket *pkt, int current_index) +static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPacket *pkt, int current_index) { MOVFragmentStreamInfo *frag_stream_info; MOVEncryptionIndex *encryption_index; AVEncryptionInfo *encrypted_sample; int encrypted_index, ret; -frag_stream_info = get_current_frag_stream_info(&mov->frag_index); +frag_stream_info = get_frag_stream_info(&mov->frag_index, mov->frag_index.current, st->id); encrypted_index = current_index; encryption_index = NULL; if (frag_stream_info) { @@ -7793,7 +7793,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) if (mov->aax_mode) aax_filter(pkt->data, pkt->size, mov); -ret = cenc_filter(mov, sc, pkt, current_index); +ret = cenc_filter(mov, st, sc, pkt, current_index); if (ret < 0) return ret; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/avcodec.h: Add encryption info side data.
ffmpeg | branch: master | Jacob Trimble | Tue Dec 5 14:52:22 2017 -0800| [db2a7c947ec28b0a04a4e5193c9b0d33de823fbb] | committer: Michael Niedermayer avcodec/avcodec.h: Add encryption info side data. This new side-data will contain info on how a packet is encrypted. This allows the app to handle packet decryption. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db2a7c947ec28b0a04a4e5193c9b0d33de823fbb --- doc/APIchanges | 4 + libavcodec/avcodec.h| 13 ++ libavutil/Makefile | 2 + libavutil/encryption_info.c | 295 libavutil/encryption_info.h | 200 ++ libavutil/version.h | 2 +- 6 files changed, 515 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index d410bcdd75..a099afd9bc 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-xx-xx - xxx - lavu 56.8.100 - encryption_info.h + Add AVEncryptionInitInfo and AVEncryptionInfo structures to hold new side-data + for encryption info. + 2018-03-21 - xxx - lavc 58.15.100 - avcodec.h Add av_packet_make_writable(). diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a78017f1fb..495242faf0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1345,6 +1345,19 @@ enum AVPacketSideDataType { AV_PKT_DATA_A53_CC, /** + * This side data is encryption initialization data. + * The format is not part of ABI, use av_encryption_init_info_* methods to + * access. + */ +AV_PKT_DATA_ENCRYPTION_INIT_INFO, + +/** + * This side data contains encryption info for how to decrypt the packet. + * The format is not part of ABI, use av_encryption_info_* methods to access. + */ +AV_PKT_DATA_ENCRYPTION_INFO, + +/** * The number of side data types. * This is not part of the public API/ABI in the sense that it may * change when new side data types are added. diff --git a/libavutil/Makefile b/libavutil/Makefile index 17ec1f1aa9..a63ba523c9 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -24,6 +24,7 @@ HEADERS = adler32.h \ dict.h\ display.h \ downmix_info.h\ + encryption_info.h \ error.h \ eval.h\ fifo.h\ @@ -107,6 +108,7 @@ OBJS = adler32.o \ dict.o \ display.o\ downmix_info.o \ + encryption_info.o\ error.o \ eval.o \ fifo.o \ diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c new file mode 100644 index 00..20a752d6b4 --- /dev/null +++ b/libavutil/encryption_info.c @@ -0,0 +1,295 @@ +/** + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "encryption_info.h" +#include "mem.h" +#include "intreadwrite.h" + +#define FF_ENCRYPTION_INFO_EXTRA 24 + +// The format of the AVEncryptionInfo side data: +// u32be scheme +// u32be crypt_byte_block +// u32be skip_byte_block +// u32be key_id_size +// u32be iv_size +// u32be subsample_count +// u8[key_id_size] key_id +// u8[iv_size] iv +// { +// u32be bytes_of_clear_data +// u32be bytes_of_protected_data +// }[subsample_count] + +AVEncryptionInfo *av_encryption_in
[FFmpeg-cvslog] avformat/mov: Fix parsing of tfdt when using sample descriptors.
ffmpeg | branch: master | Jacob Trimble | Wed Apr 4 12:30:56 2018 -0700| [b08c132a9c590cf5c3905a48b12527765fc91647] | committer: Michael Niedermayer avformat/mov: Fix parsing of tfdt when using sample descriptors. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b08c132a9c590cf5c3905a48b12527765fc91647 --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index e7c32e6148..97b1462aab 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4601,7 +4601,7 @@ static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR_INVALIDDATA; } sc = st->priv_data; -if (sc->pseudo_stream_id + 1 != frag->stsd_id) +if (sc->pseudo_stream_id + 1 != frag->stsd_id && sc->pseudo_stream_id != -1) return 0; version = avio_r8(pb); avio_rb24(pb); /* flags */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Increase support for common encryption.
ffmpeg | branch: master | Jacob Trimble | Wed Dec 6 16:17:54 2017 -0800| [f7221d8e670ec05471a16cc4cc1cc8e0040b5b5f] | committer: Michael Niedermayer avformat/mov: Increase support for common encryption. - Parse schm atom to get different encryption schemes. - Allow senc atom to appear in track fragments. - Allow 16-byte IVs. - Allow constant IVs (specified in tenc). - Allow only tenc to specify encryption (i.e. no senc/saiz/saio). - Use sample descriptor to detect clear fragments. This doesn't support: - Different sample descriptor holding different encryption info. - Only first sample descriptor can be encrypted. - Encrypted sample groups (i.e. seig). - Non-'cenc' encryption scheme when using -decryption_key. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f7221d8e670ec05471a16cc4cc1cc8e0040b5b5f --- libavformat/isom.h | 14 ++ libavformat/mov.c | 394 ++--- libavutil/encryption_info.h| 2 +- tests/fate/mov.mak | 8 + tests/ref/fate/mov-frag-encrypted | 57 + tests/ref/fate/mov-tenc-only-encrypted | 57 + 6 files changed, 450 insertions(+), 82 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 4da34142f0..eb942cf882 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -27,6 +27,7 @@ #include #include +#include "libavutil/encryption_info.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/spherical.h" #include "libavutil/stereo3d.h" @@ -108,12 +109,20 @@ typedef struct MOVSbgp { unsigned int index; } MOVSbgp; +typedef struct MOVEncryptionIndex { +// Individual encrypted samples. If there are no elements, then the default +// settings will be used. +unsigned int nb_encrypted_samples; +AVEncryptionInfo **encrypted_samples; +} MOVEncryptionIndex; + typedef struct MOVFragmentStreamInfo { int id; int64_t sidx_pts; int64_t first_tfra_pts; int64_t tfdt_dts; int index_entry; +MOVEncryptionIndex *encryption_index; } MOVFragmentStreamInfo; typedef struct MOVFragmentIndexItem { @@ -215,6 +224,7 @@ typedef struct MOVStreamContext { int has_sidx; // If there is an sidx entry for this stream. struct { +// TODO: Remove once old methods are removed from mov.c int use_subsamples; uint8_t* auxiliary_info; uint8_t* auxiliary_info_end; @@ -223,7 +233,11 @@ typedef struct MOVStreamContext { uint8_t* auxiliary_info_sizes; size_t auxiliary_info_sizes_count; int64_t auxiliary_info_index; + struct AVAESCTR* aes_ctr; +unsigned int per_sample_iv_size; // Either 0, 8, or 16. +AVEncryptionInfo *default_encrypted_sample; +MOVEncryptionIndex *encryption_index; } cenc; } MOVStreamContext; diff --git a/libavformat/mov.c b/libavformat/mov.c index 1340bf3913..fc512b8d72 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1330,6 +1330,7 @@ static int update_frag_index(MOVContext *c, int64_t offset) frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE; frag_stream_info[i].first_tfra_pts = AV_NOPTS_VALUE; frag_stream_info[i].index_entry = -1; +frag_stream_info[i].encryption_index = NULL; } if (index < c->frag_index.nb_items) @@ -5761,57 +5762,250 @@ static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom) +/** + * Gets the current encryption info and associated current stream context. If + * we are parsing a track fragment, this will return the specific encryption + * info for this fragment; otherwise this will return the global encryption + * info for the current stream. + */ +static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encryption_index, MOVStreamContext **sc) { +MOVFragmentStreamInfo *frag_stream_info; AVStream *st; +int i; + +frag_stream_info = get_current_frag_stream_info(&c->frag_index); +if (frag_stream_info) { +for (i = 0; i < c->fc->nb_streams; i++) { +if (c->fc->streams[i]->id == frag_stream_info->id) { + st = c->fc->streams[i]; + break; +} +} +if (i == c->fc->nb_streams) +return 0; +*sc = st->priv_data; + +if (!frag_stream_info->encryption_index) { +frag_stream_info->encryption_index = av_mallocz(sizeof(*frag_stream_info->encryption_index)); +if (!frag_stream_info->encryption_index) +return AVERROR(ENOMEM); +} +*encryption_index = frag_stream_info->encryption_index; +return 1; +} else { +//
[FFmpeg-cvslog] avformat/mov: Remove old encryption info methods.
ffmpeg | branch: master | Jacob Trimble | Tue Jan 30 11:14:35 2018 -0800| [baf9c0bd99d91ec501b020632ca72babc455139c] | committer: Michael Niedermayer avformat/mov: Remove old encryption info methods. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=baf9c0bd99d91ec501b020632ca72babc455139c --- libavformat/isom.h | 10 -- libavformat/mov.c | 91 -- 2 files changed, 101 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index eb942cf882..4245d37767 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -224,16 +224,6 @@ typedef struct MOVStreamContext { int has_sidx; // If there is an sidx entry for this stream. struct { -// TODO: Remove once old methods are removed from mov.c -int use_subsamples; -uint8_t* auxiliary_info; -uint8_t* auxiliary_info_end; -uint8_t* auxiliary_info_pos; -uint8_t auxiliary_info_default_size; -uint8_t* auxiliary_info_sizes; -size_t auxiliary_info_sizes_count; -int64_t auxiliary_info_index; - struct AVAESCTR* aes_ctr; unsigned int per_sample_iv_size; // Either 0, 8, or 16. AVEncryptionInfo *default_encrypted_sample; diff --git a/libavformat/mov.c b/libavformat/mov.c index 4eda48d617..45d8e1dce7 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6009,67 +6009,6 @@ static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom) -{ -AVStream *st; -MOVStreamContext *sc; -size_t data_size; -int atom_header_size; -int flags; - -if (c->decryption_key_len == 0 || c->fc->nb_streams < 1) -return 0; - -st = c->fc->streams[c->fc->nb_streams - 1]; -sc = st->priv_data; - -if (sc->cenc.auxiliary_info_sizes || sc->cenc.auxiliary_info_default_size) { -av_log(c->fc, AV_LOG_ERROR, "duplicate saiz atom\n"); -return AVERROR_INVALIDDATA; -} - -atom_header_size = 9; - -avio_r8(pb); /* version */ -flags = avio_rb24(pb); - -if ((flags & 0x01) != 0) { -atom_header_size += 8; - -avio_rb32(pb);/* info type */ -avio_rb32(pb);/* info type param */ -} - -sc->cenc.auxiliary_info_default_size = avio_r8(pb); -avio_rb32(pb);/* entries */ - -if (atom.size <= atom_header_size) { -return 0; -} - -if (atom.size > FFMIN(INT_MAX, SIZE_MAX)) { -av_log(c->fc, AV_LOG_ERROR, "saiz atom auxiliary_info_sizes size %"PRId64" invalid\n", atom.size); -return AVERROR_INVALIDDATA; -} - -/* save the auxiliary info sizes as is */ -data_size = atom.size - atom_header_size; - -sc->cenc.auxiliary_info_sizes = av_malloc(data_size); -if (!sc->cenc.auxiliary_info_sizes) { -return AVERROR(ENOMEM); -} - -sc->cenc.auxiliary_info_sizes_count = data_size; - -if (avio_read(pb, sc->cenc.auxiliary_info_sizes, data_size) != data_size) { -av_log(c->fc, AV_LOG_ERROR, "failed to read the auxiliary info sizes"); -return AVERROR_INVALIDDATA; -} - -return 0; -} - static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -6107,36 +6046,6 @@ static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -static int mov_seek_auxiliary_info(MOVContext *c, MOVStreamContext *sc, int64_t index) -{ -size_t auxiliary_info_seek_offset = 0; -int i; - -if (sc->cenc.auxiliary_info_default_size) { -auxiliary_info_seek_offset = (size_t)sc->cenc.auxiliary_info_default_size * index; -} else if (sc->cenc.auxiliary_info_sizes) { -if (index > sc->cenc.auxiliary_info_sizes_count) { -av_log(c, AV_LOG_ERROR, "current sample %"PRId64" greater than the number of auxiliary info sample sizes %"SIZE_SPECIFIER"\n", -index, sc->cenc.auxiliary_info_sizes_count); -return AVERROR_INVALIDDATA; -} - -for (i = 0; i < index; i++) { -auxiliary_info_seek_offset += sc->cenc.auxiliary_info_sizes[i]; -} -} - -if (auxiliary_info_seek_offset > sc->cenc.auxiliary_info_end - sc->cenc.auxiliary_info) { -av_log(c, AV_LOG_ERROR, "auxiliary info offset %"SIZE_SPECIFIER" greater than auxiliary info size %"SIZE_SPECIFIER"\n", -auxiliary_info_seek_offset, (size_t)(sc->cenc.auxiliary_info_end - sc->cenc.auxiliary_info)); -return AVERROR_INVALIDDATA; -} - -sc->cenc.auxiliary_info_pos = sc->cenc.auxiliary_info + auxiliary_
[FFmpeg-cvslog] avformat/mov: Fix memory leak in encryption info.
ffmpeg | branch: master | Jacob Trimble | Thu Apr 19 09:35:22 2018 -0700| [606c5c7f3ad1d289ef745b9053024ad318646c7e] | committer: Michael Niedermayer avformat/mov: Fix memory leak in encryption info. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=606c5c7f3ad1d289ef745b9053024ad318646c7e --- libavformat/mov.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index fc512b8d72..4eda48d617 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5833,6 +5833,7 @@ static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVSt if (use_subsamples) { subsample_count = avio_rb16(pb); +av_free((*sample)->subsamples); (*sample)->subsamples = av_mallocz_array(subsample_count, sizeof(*subsamples)); if (!(*sample)->subsamples) { av_encryption_info_free(*sample); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Fix parsing of saio/siaz atoms in encrypted content.
ffmpeg | branch: master | Jacob Trimble | Wed Dec 6 16:17:54 2017 -0800| [e5ba5fab493bd2edb24da47940626b024ebd0371] | committer: Michael Niedermayer avformat/mov: Fix parsing of saio/siaz atoms in encrypted content. This doesn't support saio atoms with more than one offset. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e5ba5fab493bd2edb24da47940626b024ebd0371 --- libavformat/isom.h | 6 ++ libavformat/mov.c | 237 + 2 files changed, 243 insertions(+) diff --git a/libavformat/isom.h b/libavformat/isom.h index 4245d37767..fb361125c9 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -114,6 +114,12 @@ typedef struct MOVEncryptionIndex { // settings will be used. unsigned int nb_encrypted_samples; AVEncryptionInfo **encrypted_samples; + +uint8_t* auxiliary_info_sizes; +size_t auxiliary_info_sample_count; +uint8_t auxiliary_info_default_size; +size_t* auxiliary_offsets; ///< Absolute seek position +size_t auxiliary_offsets_count; } MOVEncryptionIndex; typedef struct MOVFragmentStreamInfo { diff --git a/libavformat/mov.c b/libavformat/mov.c index 45d8e1dce7..8fea6700c3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5912,6 +5912,228 @@ static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOContext *pb, MOVEncryptionIndex *encryption_index) +{ +AVEncryptionInfo **sample, **encrypted_samples; +int64_t prev_pos; +size_t sample_count, sample_info_size, i; +int ret = 0; +unsigned int alloc_size = 0; + +if (encryption_index->nb_encrypted_samples) +return 0; +sample_count = encryption_index->auxiliary_info_sample_count; +if (encryption_index->auxiliary_offsets_count != 1) { +av_log(c->fc, AV_LOG_ERROR, "Multiple auxiliary info chunks are not supported\n"); +return AVERROR_PATCHWELCOME; +} +if (sample_count >= INT_MAX / sizeof(*encrypted_samples)) +return AVERROR(ENOMEM); + +prev_pos = avio_tell(pb); +if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || +avio_seek(pb, encryption_index->auxiliary_offsets[0], SEEK_SET) != encryption_index->auxiliary_offsets[0]) { +av_log(c->fc, AV_LOG_INFO, "Failed to seek for auxiliary info, will only parse senc atoms for encryption info\n"); +goto finish; +} + +for (i = 0; i < sample_count && !pb->eof_reached; i++) { +unsigned int min_samples = FFMIN(FFMAX(i, 1024 * 1024), sample_count); +encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size, +min_samples * sizeof(*encrypted_samples)); +if (!encrypted_samples) { +ret = AVERROR(ENOMEM); +goto finish; +} +encryption_index->encrypted_samples = encrypted_samples; + +sample = &encryption_index->encrypted_samples[i]; +sample_info_size = encryption_index->auxiliary_info_default_size + ? encryption_index->auxiliary_info_default_size + : encryption_index->auxiliary_info_sizes[i]; + +ret = mov_read_sample_encryption_info(c, pb, sc, sample, sample_info_size > sc->cenc.per_sample_iv_size); +if (ret < 0) +goto finish; +} +if (pb->eof_reached) { +av_log(c->fc, AV_LOG_ERROR, "Hit EOF while reading auxiliary info\n"); +ret = AVERROR_INVALIDDATA; +} else { +encryption_index->nb_encrypted_samples = sample_count; +} + +finish: +avio_seek(pb, prev_pos, SEEK_SET); +if (ret < 0) { +for (; i > 0; i--) { +av_encryption_info_free(encryption_index->encrypted_samples[i - 1]); +} +av_freep(&encryption_index->encrypted_samples); +} +return ret; +} + +/** + * Tries to read the given number of bytes from the stream and puts it in a + * newly allocated buffer. This reads in small chunks to avoid allocating large + * memory if the file contains an invalid/malicious size value. + */ +static int mov_try_read_block(AVIOContext *pb, size_t size, uint8_t **data) +{ +const unsigned int block_size = 1024 * 1024; +uint8_t *buffer = NULL; +unsigned int alloc_size = 0, offset = 0; +while (offset < size) { +unsigned int new_size = +alloc_size >= INT_MAX - block_size ? INT_MAX : alloc_size + block_size; +uint8_t *new_buffer = av_fast_realloc(buffer, &alloc_size, new_size); +unsigned int to_read = FFMIN(size, alloc_size) - offset; +if (!new_buffer) { +av_free(buffer); +retur
[FFmpeg-cvslog] libavformat/mov: Fix heap buffer overflow.
ffmpeg | branch: master | Jacob Trimble | Thu May 31 10:41:29 2018 -0700| [9827bb88e7dc55d5aaeddfaa3d1ba80a7489566c] | committer: Michael Niedermayer libavformat/mov: Fix heap buffer overflow. Found by Chrome's ClusterFuzz: https://crbug.com/847060 Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9827bb88e7dc55d5aaeddfaa3d1ba80a7489566c --- libavformat/mov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index f2a540ad50..08cc382a68 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5895,7 +5895,7 @@ static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); for (i = 0; i < sample_count; i++) { -unsigned int min_samples = FFMIN(FFMAX(i, 1024 * 1024), sample_count); +unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), sample_count); encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size, min_samples * sizeof(*encrypted_samples)); if (encrypted_samples) { @@ -5949,7 +5949,7 @@ static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOCon } for (i = 0; i < sample_count && !pb->eof_reached; i++) { -unsigned int min_samples = FFMIN(FFMAX(i, 1024 * 1024), sample_count); +unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), sample_count); encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size, min_samples * sizeof(*encrypted_samples)); if (!encrypted_samples) { @@ -6110,7 +6110,7 @@ static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); for (i = 0; i < entry_count && !pb->eof_reached; i++) { -unsigned int min_offsets = FFMIN(FFMAX(i, 1024), entry_count); +unsigned int min_offsets = FFMIN(FFMAX(i + 1, 1024), entry_count); auxiliary_offsets = av_fast_realloc( encryption_index->auxiliary_offsets, &alloc_size, min_offsets * sizeof(*auxiliary_offsets)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Fix reading saio/saiz for clear content.
ffmpeg | branch: master | Jacob Trimble | Thu Jun 7 10:29:33 2018 -0700| [cf81a9c07891966cca6d3bb31ed6931fae1f77ea] | committer: Michael Niedermayer avformat/mov: Fix reading saio/saiz for clear content. This validates that the common encryption saio/saiz atoms only appear when the data is actually encrypted. This also ignores those atoms in clear content. Found by Chrome's ClusterFuzz: http://crbug.com/850389 Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cf81a9c07891966cca6d3bb31ed6931fae1f77ea --- libavformat/mov.c | 71 ++- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 4ad19122b3..2fca025889 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6035,7 +6035,7 @@ static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOVEncryptionIndex *encryption_index; MOVStreamContext *sc; int ret; -unsigned int sample_count; +unsigned int sample_count, aux_info_type, aux_info_param; ret = get_current_encryption_info(c, &encryption_index, &sc); if (ret != 1) @@ -6054,14 +6054,33 @@ static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_r8(pb); /* version */ if (avio_rb24(pb) & 0x01) { /* flags */ -if (avio_rb32(pb) != sc->cenc.default_encrypted_sample->scheme) { -av_log(c->fc, AV_LOG_DEBUG, "Ignoring saiz box with non-zero aux_info_type\n"); -return 0; -} -if (avio_rb32(pb) != 0) { -av_log(c->fc, AV_LOG_DEBUG, "Ignoring saiz box with non-zero aux_info_type_parameter\n"); -return 0; +aux_info_type = avio_rb32(pb); +aux_info_param = avio_rb32(pb); +if (sc->cenc.default_encrypted_sample) { +if (aux_info_type != sc->cenc.default_encrypted_sample->scheme) { +av_log(c->fc, AV_LOG_DEBUG, "Ignoring saiz box with non-zero aux_info_type\n"); +return 0; +} +if (aux_info_param != 0) { +av_log(c->fc, AV_LOG_DEBUG, "Ignoring saiz box with non-zero aux_info_type_parameter\n"); +return 0; +} +} else { +// Didn't see 'schm' or 'tenc', so this isn't encrypted. +if ((aux_info_type == MKBETAG('c','e','n','c') || + aux_info_type == MKBETAG('c','e','n','s') || + aux_info_type == MKBETAG('c','b','c','1') || + aux_info_type == MKBETAG('c','b','c','s')) && +aux_info_param == 0) { +av_log(c->fc, AV_LOG_ERROR, "Saw encrypted saiz without schm/tenc\n"); +return AVERROR_INVALIDDATA; +} else { +return 0; +} } +} else if (!sc->cenc.default_encrypted_sample) { +// Didn't see 'schm' or 'tenc', so this isn't encrypted. +return 0; } encryption_index->auxiliary_info_default_size = avio_r8(pb); @@ -6089,7 +6108,8 @@ static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOVEncryptionIndex *encryption_index; MOVStreamContext *sc; int i, ret; -unsigned int version, entry_count, alloc_size = 0; +unsigned int version, entry_count, aux_info_type, aux_info_param; +unsigned int alloc_size = 0; ret = get_current_encryption_info(c, &encryption_index, &sc); if (ret != 1) @@ -6108,14 +6128,33 @@ static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom) version = avio_r8(pb); /* version */ if (avio_rb24(pb) & 0x01) { /* flags */ -if (avio_rb32(pb) != sc->cenc.default_encrypted_sample->scheme) { -av_log(c->fc, AV_LOG_DEBUG, "Ignoring saio box with non-zero aux_info_type\n"); -return 0; -} -if (avio_rb32(pb) != 0) { -av_log(c->fc, AV_LOG_DEBUG, "Ignoring saio box with non-zero aux_info_type_parameter\n"); -return 0; +aux_info_type = avio_rb32(pb); +aux_info_param = avio_rb32(pb); +if (sc->cenc.default_encrypted_sample) { +if (aux_info_type != sc->cenc.default_encrypted_sample->scheme) { +av_log(c->fc, AV_LOG_DEBUG, "Ignoring saio box with non-zero aux_info_type\n"); +return 0; +} +if (aux_info_param != 0) { +av_log(c->fc, AV_LOG_DEBUG, "Ignoring saio box with non-zer
[FFmpeg-cvslog] avformat/mov: Add check for per-sample IV size.
ffmpeg | branch: master | Jacob Trimble | Tue Jun 12 14:26:20 2018 -0700| [4aba45ca1fece6be425d168c05aa3a7f9f05da36] | committer: Michael Niedermayer avformat/mov: Add check for per-sample IV size. Found by Chrome's ClusterFuzz: http://crbug.com/849062. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4aba45ca1fece6be425d168c05aa3a7f9f05da36 --- libavformat/mov.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2fca025889..5d9ffa69a3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6273,8 +6273,13 @@ static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); } sc->cenc.per_sample_iv_size = avio_r8(pb); +if (sc->cenc.per_sample_iv_size != 0 && sc->cenc.per_sample_iv_size != 8 && +sc->cenc.per_sample_iv_size != 16) { +av_log(c->fc, AV_LOG_ERROR, "invalid per-sample IV size value\n"); +return AVERROR_INVALIDDATA; +} if (avio_read(pb, sc->cenc.default_encrypted_sample->key_id, 16) != 16) { -av_log(c->fc, AV_LOG_ERROR, "failed to read the default key ID"); +av_log(c->fc, AV_LOG_ERROR, "failed to read the default key ID\n"); return AVERROR_INVALIDDATA; } @@ -6286,7 +6291,7 @@ static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom) } if (avio_read(pb, sc->cenc.default_encrypted_sample->iv, iv_size) != iv_size) { -av_log(c->fc, AV_LOG_ERROR, "failed to read the default IV"); +av_log(c->fc, AV_LOG_ERROR, "failed to read the default IV\n"); return AVERROR_INVALIDDATA; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libavutil/encryption_info: Allow multiple init info.
ffmpeg | branch: master | Jacob Trimble | Mon Apr 23 10:33:58 2018 -0700| [b86c5757a2bf2a589b3982d6b85401165deb4958] | committer: Michael Niedermayer libavutil/encryption_info: Allow multiple init info. It is possible for there to be multiple encryption init info structure. For example, to support multiple key systems or in key rotation. This changes the AVEncryptionInitInfo struct to be a linked list so there can be multiple structs without breaking ABI. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b86c5757a2bf2a589b3982d6b85401165deb4958 --- libavutil/encryption_info.c | 146 libavutil/encryption_info.h | 5 ++ 2 files changed, 100 insertions(+), 51 deletions(-) diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c index 20a752d6b4..3b7e16cd0c 100644 --- a/libavutil/encryption_info.c +++ b/libavutil/encryption_info.c @@ -160,13 +160,16 @@ uint8_t *av_encryption_info_add_side_data(const AVEncryptionInfo *info, size_t * } // The format of the AVEncryptionInitInfo side data: -// u32be system_id_size -// u32be num_key_ids -// u32be key_id_size -// u32be data_size -// u8[system_id_size] system_id -// u8[key_id_size][num_key_id] key_ids -// u8[data_size] data +// u32be init_info_count +// { +// u32be system_id_size +// u32be num_key_ids +// u32be key_id_size +// u32be data_size +// u8[system_id_size] system_id +// u8[key_id_size][num_key_id] key_ids +// u8[data_size] data +// }[init_info_count] #define FF_ENCRYPTION_INIT_INFO_EXTRA 16 @@ -215,6 +218,7 @@ void av_encryption_init_info_free(AVEncryptionInitInfo *info) for (i = 0; i < info->num_key_ids; i++) { av_free(info->key_ids[i]); } +av_encryption_init_info_free(info->next); av_free(info->system_id); av_free(info->key_ids); av_free(info->data); @@ -225,71 +229,111 @@ void av_encryption_init_info_free(AVEncryptionInitInfo *info) AVEncryptionInitInfo *av_encryption_init_info_get_side_data( const uint8_t *side_data, size_t side_data_size) { -AVEncryptionInitInfo *info; -uint64_t system_id_size, num_key_ids, key_id_size, data_size, i; +// |ret| tracks the front of the list, |info| tracks the back. +AVEncryptionInitInfo *ret = NULL, *info, *temp_info; +uint64_t system_id_size, num_key_ids, key_id_size, data_size, i, j; +uint64_t init_info_count; -if (!side_data || side_data_size < FF_ENCRYPTION_INIT_INFO_EXTRA) +if (!side_data || side_data_size < 4) return NULL; -system_id_size = AV_RB32(side_data); -num_key_ids = AV_RB32(side_data + 4); -key_id_size = AV_RB32(side_data + 8); -data_size = AV_RB32(side_data + 12); +init_info_count = AV_RB32(side_data); +side_data += 4; +side_data_size -= 4; +for (i = 0; i < init_info_count; i++) { +if (side_data_size < FF_ENCRYPTION_INIT_INFO_EXTRA) { +av_encryption_init_info_free(ret); +return NULL; +} -// UINT32_MAX + UINT32_MAX + UINT32_MAX * UINT32_MAX == UINT64_MAX -if (side_data_size - FF_ENCRYPTION_INIT_INFO_EXTRA < system_id_size + data_size + num_key_ids * key_id_size) -return NULL; +system_id_size = AV_RB32(side_data); +num_key_ids = AV_RB32(side_data + 4); +key_id_size = AV_RB32(side_data + 8); +data_size = AV_RB32(side_data + 12); -info = av_encryption_init_info_alloc(system_id_size, num_key_ids, key_id_size, data_size); -if (!info) -return NULL; +// UINT32_MAX + UINT32_MAX + UINT32_MAX * UINT32_MAX == UINT64_MAX +if (side_data_size - FF_ENCRYPTION_INIT_INFO_EXTRA < system_id_size + data_size + num_key_ids * key_id_size) { +av_encryption_init_info_free(ret); +return NULL; +} +side_data += FF_ENCRYPTION_INIT_INFO_EXTRA; +side_data_size -= FF_ENCRYPTION_INIT_INFO_EXTRA; + +temp_info = av_encryption_init_info_alloc(system_id_size, num_key_ids, key_id_size, data_size); +if (!temp_info) { +av_encryption_init_info_free(ret); +return NULL; +} +if (i == 0) { +info = ret = temp_info; +} else { +info->next = temp_info; +info = temp_info; +} -memcpy(info->system_id, side_data + 16, system_id_size); -side_data += system_id_size + 16; -for (i = 0; i < num_key_ids; i++) { - memcpy(info->key_ids[i], side_data, key_id_size); - side_data += key_id_size; +memcpy(info->system_id, side_data, system_id_size); +side_data += system_id_size; +side_data_size -= system_id_size; +for (j = 0; j < num_key_ids; j++) { +memcpy(info->key_ids[j], side_data, key_id_size); +side_data += key_id_size; +
[FFmpeg-cvslog] avutil/gitignore: Ignore integer test binary.
ffmpeg | branch: master | Jacob Trimble | Tue Jun 26 09:35:05 2018 -0700| [96281ed689043519ee9f28501921bacece59d790] | committer: Michael Niedermayer avutil/gitignore: Ignore integer test binary. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96281ed689043519ee9f28501921bacece59d790 --- libavutil/tests/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore index 71f75a8ee9..bf07c57b75 100644 --- a/libavutil/tests/.gitignore +++ b/libavutil/tests/.gitignore @@ -24,6 +24,7 @@ /hmac /hwdevice /imgutils +/integer /lfg /lls /log ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libavutil/encryption_info: Add unit tests.
ffmpeg | branch: master | Jacob Trimble | Fri Jun 1 11:38:05 2018 -0700| [69bd73b3ff873abb43de9db062b04425de153643] | committer: Michael Niedermayer libavutil/encryption_info: Add unit tests. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=69bd73b3ff873abb43de9db062b04425de153643 --- libavutil/Makefile| 1 + libavutil/tests/.gitignore| 1 + libavutil/tests/encryption_info.c | 176 ++ tests/fate/libavutil.mak | 4 + tests/ref/fate/encryption-info| 0 5 files changed, 182 insertions(+) diff --git a/libavutil/Makefile b/libavutil/Makefile index d0632f16a6..9ed24cfc82 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -200,6 +200,7 @@ TESTPROGS = adler32 \ des \ dict\ display \ +encryption_info \ error \ eval\ file\ diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore index bf07c57b75..9d90827954 100644 --- a/libavutil/tests/.gitignore +++ b/libavutil/tests/.gitignore @@ -17,6 +17,7 @@ /dict /display /error +/encryption_info /eval /fifo /file diff --git a/libavutil/tests/encryption_info.c b/libavutil/tests/encryption_info.c new file mode 100644 index 00..d489612b7d --- /dev/null +++ b/libavutil/tests/encryption_info.c @@ -0,0 +1,176 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/encryption_info.h" + +#include +#include + +#include "libavutil/avassert.h" + +static const AVSubsampleEncryptionInfo test_subsamples[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}}; +static const size_t test_subsample_count = sizeof(test_subsamples) / sizeof(test_subsamples[0]); +static const uint8_t test_iv[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}; +static const uint8_t test_key_id[] = {0x21, 0x22, 0x23, 0x24}; +static const uint8_t test_key_id_2[] = {0x31, 0x32, 0x33, 0x34}; +static const uint8_t test_system_id[] = {0x41, 0x42, 0x43}; +static const uint8_t test_data[] = {0x51, 0x52}; + +static int compare_encryption_info(const AVEncryptionInfo *a, const AVEncryptionInfo *b) { +if (!a || !b || a->scheme != b->scheme || a->crypt_byte_block != b->crypt_byte_block || +a->skip_byte_block != b->skip_byte_block || a->key_id_size != b->key_id_size || +a->iv_size != b->iv_size || a->subsample_count != b->subsample_count) +return 1; + +if (memcmp(a->key_id, b->key_id, a->key_id_size) != 0 || +memcmp(a->iv, b->iv, a->iv_size) != 0 || +memcmp(a->subsamples, b->subsamples, a->subsample_count * sizeof(a->subsamples[0]))) +return 1; + +return 0; +} + +static int compare_encryption_init_info(const AVEncryptionInitInfo *a, const AVEncryptionInitInfo *b) { +if (!a || !b || a->system_id_size != b->system_id_size || +a->num_key_ids != b->num_key_ids || a->key_id_size != b->key_id_size || +a->data_size != b->data_size) +return 1; + +if (memcmp(a->system_id, b->system_id, a->system_id_size) != 0 || +memcmp(a->data, b->data, a->data_size) != 0) +return 1; + +for (uint32_t i = 0; i < a->num_key_ids; i++) { +if (memcmp(a->key_ids[i], b->key_ids[i], a->key_id_size) != 0) +return 1; +} + +if (a->next || b->next) { +if (!a->next || !b->next) +return 1; +if (compare_encryption_init_info(a->next, b->next) != 0) +return 1; +} + +return 0; +} + +static void run_encryption_info_test(void) +{ +AVEncryptionInfo *info, *copy; +uint8
[FFmpeg-cvslog] avutil/encryption_info: Fix documentation problem.
ffmpeg | branch: master | Jacob Trimble | Tue Jun 26 09:32:14 2018 -0700| [ad2ae21010c4f8dcd64c3fee5b21e07f16c0ae97] | committer: Michael Niedermayer avutil/encryption_info: Fix documentation problem. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad2ae21010c4f8dcd64c3fee5b21e07f16c0ae97 --- libavutil/encryption_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/encryption_info.h b/libavutil/encryption_info.h index 9140968fde..8fe7ebfe43 100644 --- a/libavutil/encryption_info.h +++ b/libavutil/encryption_info.h @@ -129,7 +129,7 @@ typedef struct AVEncryptionInitInfo { * * @param subsample_count The number of subsamples. * @param key_id_size The number of bytes in the key ID, should be 16. - * @param key_id_size The number of bytes in the IV, should be 16. + * @param iv_size The number of bytes in the IV, should be 16. * * @return The new AVEncryptionInfo structure, or NULL on error. */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Expose encryption info to the app.
ffmpeg | branch: master | Jacob Trimble | Wed Dec 6 16:17:54 2017 -0800| [7e22f5d457fa042292741c1f5c38232ba10dbea2] | committer: Michael Niedermayer avformat/mov: Expose encryption info to the app. This exposes encryption info from the container to the app. This includes key ID, IV, and subsample byte ranges. The info is passed using the new side-data AV_PKT_DATA_ENCRYPTION_DATA and AV_PKT_DATA_ENCRYPTION_INIT_DATA. Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e22f5d457fa042292741c1f5c38232ba10dbea2 --- libavformat/mov.c | 120 +- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 1011763641..1346ffe480 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6198,6 +6198,114 @@ static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +AVEncryptionInitInfo *info, *old_init_info; +uint8_t **key_ids; +AVStream *st; +uint8_t *side_data, *extra_data, *old_side_data; +size_t side_data_size; +int ret = 0, old_side_data_size; +unsigned int version, kid_count, extra_data_size, alloc_size = 0; + +if (c->fc->nb_streams < 1) +return 0; +st = c->fc->streams[c->fc->nb_streams-1]; + +version = avio_r8(pb); /* version */ +avio_rb24(pb); /* flags */ + +info = av_encryption_init_info_alloc(/* system_id_size */ 16, /* num_key_ids */ 0, + /* key_id_size */ 16, /* data_size */ 0); +if (!info) +return AVERROR(ENOMEM); + +if (avio_read(pb, info->system_id, 16) != 16) { +av_log(c->fc, AV_LOG_ERROR, "Failed to read the system id\n"); +ret = AVERROR_INVALIDDATA; +goto finish; +} + +if (version > 0) { +kid_count = avio_rb32(pb); +if (kid_count >= INT_MAX / sizeof(*key_ids)) +return AVERROR(ENOMEM); + +for (unsigned int i = 0; i < kid_count && !pb->eof_reached; i++) { +unsigned int min_kid_count = FFMIN(FFMAX(i + 1, 1024), kid_count); +key_ids = av_fast_realloc(info->key_ids, &alloc_size, + min_kid_count * sizeof(*key_ids)); +if (!key_ids) { +ret = AVERROR(ENOMEM); +goto finish; +} +info->key_ids = key_ids; + +info->key_ids[i] = av_mallocz(16); +if (!info->key_ids[i]) { +ret = AVERROR(ENOMEM); +goto finish; +} +info->num_key_ids = i + 1; + +if (avio_read(pb, info->key_ids[i], 16) != 16) { +av_log(c->fc, AV_LOG_ERROR, "Failed to read the key id\n"); +ret = AVERROR_INVALIDDATA; +goto finish; +} +} + +if (pb->eof_reached) { +av_log(c->fc, AV_LOG_ERROR, "Hit EOF while reading pssh\n"); +ret = AVERROR_INVALIDDATA; +goto finish; +} +} + +extra_data_size = avio_rb32(pb); +ret = mov_try_read_block(pb, extra_data_size, &extra_data); +if (ret < 0) +goto finish; + +av_freep(&info->data); // malloc(0) may still allocate something. +info->data = extra_data; +info->data_size = extra_data_size; + +// If there is existing initialization data, append to the list. +old_side_data = av_stream_get_side_data(st, AV_PKT_DATA_ENCRYPTION_INIT_INFO, &old_side_data_size); +if (old_side_data) { +old_init_info = av_encryption_init_info_get_side_data(old_side_data, old_side_data_size); +if (old_init_info) { +// Append to the end of the list. +for (AVEncryptionInitInfo *cur = old_init_info;; cur = cur->next) { +if (!cur->next) { +cur->next = info; +break; +} +} +info = old_init_info; +} else { +// Assume existing side-data will be valid, so the only error we could get is OOM. +ret = AVERROR(ENOMEM); +goto finish; +} +} + +side_data = av_encryption_init_info_add_side_data(info, &side_data_size); +if (!side_data) { +ret = AVERROR(ENOMEM); +goto finish; +} +ret = av_stream_add_side_data(st, AV_PKT_DATA_ENCRYPTION_INIT_INFO, + side_data, side_data_size); +if (ret < 0) +av_free(side_data); + +finish: +av_encryption_init_info_free(info); +return ret; +} + static int mov_read_schm(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -6398,7 +6506,7 @@
[FFmpeg-cvslog] avutil/encryption_info: Fix size calculation.
ffmpeg | branch: master | Jacob Trimble | Mon Aug 13 15:17:11 2018 -0700| [67599812a36a5cc727522760b56930868f93ba0d] | committer: Michael Niedermayer avutil/encryption_info: Fix size calculation. Found by Chrome's ClusterFuzz: https://crbug.com/873693 Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67599812a36a5cc727522760b56930868f93ba0d --- libavutil/encryption_info.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c index 3b7e16cd0c..812c704776 100644 --- a/libavutil/encryption_info.c +++ b/libavutil/encryption_info.c @@ -297,14 +297,14 @@ uint8_t *av_encryption_init_info_add_side_data(const AVEncryptionInitInfo *info, temp_side_data_size = 4; init_info_count = 0; for (cur_info = info; cur_info; cur_info = cur_info->next) { -temp_side_data_size += (uint64_t)FF_ENCRYPTION_INIT_INFO_EXTRA + info->system_id_size + info->data_size; +temp_side_data_size += (uint64_t)FF_ENCRYPTION_INIT_INFO_EXTRA + cur_info->system_id_size + cur_info->data_size; if (init_info_count == UINT32_MAX || temp_side_data_size > UINT32_MAX) { return NULL; } init_info_count++; -if (info->num_key_ids) { -temp_side_data_size += (uint64_t)info->num_key_ids * info->key_id_size; +if (cur_info->num_key_ids) { +temp_side_data_size += (uint64_t)cur_info->num_key_ids * cur_info->key_id_size; if (temp_side_data_size > UINT32_MAX) { return NULL; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/opus_parser: Handle complete frames flag.
ffmpeg | branch: master | Jacob Trimble | Mon Aug 20 11:25:27 2018 -0700| [7e0df5910ec0f107cd0700d6b9359d29177f1933] | committer: James Almer avcodec/opus_parser: Handle complete frames flag. Signed-off-by: Jacob Trimble Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e0df5910ec0f107cd0700d6b9359d29177f1933 --- libavcodec/opus_parser.c | 29 + 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/libavcodec/opus_parser.c b/libavcodec/opus_parser.c index 28b0933900..a145fe7793 100644 --- a/libavcodec/opus_parser.c +++ b/libavcodec/opus_parser.c @@ -170,19 +170,24 @@ static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx, ParseContext *pc= &s->pc; int next, header_len; -next = opus_find_frame_end(ctx, avctx, buf, buf_size, &header_len); - -if (s->ts_framing && next != AVERROR_INVALIDDATA && -ff_combine_frame(pc, next, &buf, &buf_size) < 0) { -*poutbuf = NULL; -*poutbuf_size = 0; -return buf_size; -} +if (ctx->flags & PARSER_FLAG_COMPLETE_FRAMES) { +next = buf_size; +header_len = 0; +} else { +next = opus_find_frame_end(ctx, avctx, buf, buf_size, &header_len); + +if (s->ts_framing && next != AVERROR_INVALIDDATA && +ff_combine_frame(pc, next, &buf, &buf_size) < 0) { +*poutbuf = NULL; +*poutbuf_size = 0; +return buf_size; +} -if (next == AVERROR_INVALIDDATA){ -*poutbuf = NULL; -*poutbuf_size = 0; -return buf_size; +if (next == AVERROR_INVALIDDATA){ +*poutbuf = NULL; +*poutbuf_size = 0; +return buf_size; +} } *poutbuf = buf + header_len; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/mov: Allow saio/saiz in clear content.
ffmpeg | branch: master | Jacob Trimble | Tue Aug 14 10:18:55 2018 -0700| [eb350ab738e7e2590b26d97c465da1138fe54598] | committer: Michael Niedermayer avformat/mov: Allow saio/saiz in clear content. If there is a saio/saiz in clear content, we shouldn't create the encryption index if we don't already have one. Otherwise it will confuse the cenc_filter. The changed method is also used for senc atoms, but they should not appear in clear content. Found by Chromium's ClusterFuzz: https://crbug.com/873432 Signed-off-by: Jacob Trimble Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb350ab738e7e2590b26d97c465da1138fe54598 --- libavformat/mov.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 1bd7d7e483..f36820995d 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5845,6 +5845,9 @@ static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encry *sc = st->priv_data; if (!frag_stream_info->encryption_index) { +// If this stream isn't encrypted, don't create the index. +if (!(*sc)->cenc.default_encrypted_sample) +return 0; frag_stream_info->encryption_index = av_mallocz(sizeof(*frag_stream_info->encryption_index)); if (!frag_stream_info->encryption_index) return AVERROR(ENOMEM); @@ -5860,6 +5863,9 @@ static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encry *sc = st->priv_data; if (!(*sc)->cenc.encryption_index) { +// If this stream isn't encrypted, don't create the index. +if (!(*sc)->cenc.default_encrypted_sample) +return 0; (*sc)->cenc.encryption_index = av_mallocz(sizeof(*frag_stream_info->encryption_index)); if (!(*sc)->cenc.encryption_index) return AVERROR(ENOMEM); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog