[FFmpeg-cvslog] avformat/mux: correct error msg for when BSF filtering fails
ffmpeg | branch: master | Gyan Doshi | Tue Jul 16 18:24:42 2019 +0530| [c104701b6c5db48481fa2fb32b6e3e40b70f1eb6] | committer: Gyan Doshi avformat/mux: correct error msg for when BSF filtering fails > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c104701b6c5db48481fa2fb32b6e3e40b70f1eb6 --- libavformat/mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index 21f10caf53..8ab5ea8c2b 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -865,7 +865,7 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) { if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) return 0; av_log(ctx, AV_LOG_ERROR, -"Failed to send packet to filter %s for stream %d\n", +"Failed to receive packet from filter %s for stream %d\n", ctx->filter->name, pkt->stream_index); if (s->error_recognition & AV_EF_EXPLODE) return ret; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h2645: Fix infinite loop in more_rbsp_data
ffmpeg | branch: master | Andreas Rheinhardt | Wed Jun 5 04:18:54 2019 +0200| [d4035ca849bdb90e95c87e2737a99ea657be0716] | committer: Mark Thompson cbs_h2645: Fix infinite loop in more_rbsp_data cbs_h2645_read_more_rbsp_data does not handle malformed input very well: 1. If there were <= 8 bits left in the bitreader, these bits were read via show_bits. But show_bits requires the number of bits to be read to be > 0 (internally it shifts by 32 - number of bits to be read which is undefined behaviour if said number is zero; there is also an assert for this, but it is only an av_assert2). Furthermore, in this case a shift by -1 was performed which is of course undefined behaviour, too. 2. If there were > 0 and <= 8 bits left and all of them were zero (this can only happen for defective input), it was reported that there was further RBSP data. This can lead to an infinite loop in H.265's cbs_h265_read_extension_data corresponding to the [vsp]ps_extension_data_flag syntax elements. If the relevant flag indicates the (potential) occurence of these syntax elements, while all bits after this flag are zero, cbs_h2645_read_more_rbsp_data always returns 1 on x86. Given that a checked bitstream reader is used, we are also not "saved" by an overflow in the bitstream reader's index. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d4035ca849bdb90e95c87e2737a99ea657be0716 --- libavcodec/cbs_h2645.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index da4927ca8e..b09845bfc1 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -327,9 +327,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) int bits_left = get_bits_left(gbc); if (bits_left > 8) return 1; -if (show_bits(gbc, bits_left) == 1 << (bits_left - 1)) +if (bits_left == 0) return 0; -return 1; +if (show_bits(gbc, bits_left) & MAX_UINT_BITS(bits_left - 1)) +return 1; +return 0; } #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw)) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/cbs_h265: add support for Alpha Channel Info SEI messages
ffmpeg | branch: master | James Almer | Thu Jun 20 22:21:26 2019 -0300| [e460dcc832e911982e5cf143ce7ff52c95547ab0] | committer: James Almer avcodec/cbs_h265: add support for Alpha Channel Info SEI messages As defined in sections F.14.2.8 and F.14.3.8 Reviewed-by: Mark Thompson Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e460dcc832e911982e5cf143ce7ff52c95547ab0 --- libavcodec/cbs_h2645.c| 1 + libavcodec/cbs_h265.h | 12 libavcodec/cbs_h265_syntax_template.c | 29 + libavcodec/hevc_sei.h | 1 + 4 files changed, 43 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index b09845bfc1..c95f1308e9 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -531,6 +531,7 @@ static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload) case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO: case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS: +case HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO: break; case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35: av_buffer_unref(&payload->payload.user_data_registered.data_ref); diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h index c9bc90187b..ad746bf35f 100644 --- a/libavcodec/cbs_h265.h +++ b/libavcodec/cbs_h265.h @@ -679,6 +679,17 @@ typedef struct H265RawSEIAlternativeTransferCharacteristics { uint8_t preferred_transfer_characteristics; } H265RawSEIAlternativeTransferCharacteristics; +typedef struct H265RawSEIAlphaChannelInfo { +uint8_t alpha_channel_cancel_flag; +uint8_t alpha_channel_use_idc; +uint8_t alpha_channel_bit_depth_minus8; +uint16_t alpha_transparent_value; +uint16_t alpha_opaque_value; +uint8_t alpha_channel_incr_flag; +uint8_t alpha_channel_clip_flag; +uint8_t alpha_channel_clip_type_flag; +} H265RawSEIAlphaChannelInfo; + typedef struct H265RawSEIPayload { uint32_t payload_type; uint32_t payload_size; @@ -697,6 +708,7 @@ typedef struct H265RawSEIPayload { H265RawSEIContentLightLevelInfo content_light_level; H265RawSEIAlternativeTransferCharacteristics alternative_transfer_characteristics; +H265RawSEIAlphaChannelInfo alpha_channel_info; struct { uint8_t *data; size_t data_length; diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index f279d283d9..54570929ec 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -2028,6 +2028,34 @@ static int FUNC(sei_alternative_transfer_characteristics)(CodedBitstreamContext return 0; } +static int FUNC(sei_alpha_channel_info)(CodedBitstreamContext *ctx, +RWContext *rw, +H265RawSEIAlphaChannelInfo *current) +{ +int err, length; + +HEADER("Alpha Channel Information"); + +flag(alpha_channel_cancel_flag); +if (!current->alpha_channel_cancel_flag) { +ub(3, alpha_channel_use_idc); +ub(3, alpha_channel_bit_depth_minus8); +length = current->alpha_channel_bit_depth_minus8 + 9; +ub(length, alpha_transparent_value); +ub(length, alpha_opaque_value); +flag(alpha_channel_incr_flag); +flag(alpha_channel_clip_flag); +if (current->alpha_channel_clip_flag) +flag(alpha_channel_clip_type_flag); +} else { + infer(alpha_channel_use_idc, 2); + infer(alpha_channel_incr_flag, 0); + infer(alpha_channel_clip_flag, 0); +} + +return 0; +} + static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIPayload *current, int prefix) { @@ -2080,6 +2108,7 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, SEI_TYPE_N(CONTENT_LIGHT_LEVEL_INFO, 1, 0, content_light_level); SEI_TYPE_N(ALTERNATIVE_TRANSFER_CHARACTERISTICS, 1, 0, alternative_transfer_characteristics); +SEI_TYPE_N(ALPHA_CHANNEL_INFO, 1, 0, alpha_channel_info); #undef SEI_TYPE default: diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h index 2fec00ace0..f6516ae982 100644 --- a/libavcodec/hevc_sei.h +++ b/libavcodec/hevc_sei.h @@ -56,6 +56,7 @@ typedef enum { HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO = 137, HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144, HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147, +HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO = 165, } HEVC_SEI_Type; typedef struct HEVCSEIPictureHash { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffm
[FFmpeg-cvslog] avcodec/tak_parser: don't return error values
ffmpeg | branch: master | James Almer | Wed Jul 17 19:22:00 2019 -0300| [23599834bd6f6c75fe6ec089c617185e215ef52c] | committer: James Almer avcodec/tak_parser: don't return error values The API does not allow it. Also set poutbuf and poutbuf_size to NULL/0 on error. Reviewed-by: Michael Niedermayer Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=23599834bd6f6c75fe6ec089c617185e215ef52c --- libavcodec/tak_parser.c | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libavcodec/tak_parser.c b/libavcodec/tak_parser.c index 835a47bd52..3604b35443 100644 --- a/libavcodec/tak_parser.c +++ b/libavcodec/tak_parser.c @@ -46,15 +46,16 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx, int needed = buf_size ? TAK_MAX_FRAME_HEADER_BYTES : 8; int ret; +*poutbuf = buf; +*poutbuf_size = buf_size; + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { TAKStreamInfo ti; if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) -return ret; +return buf_size; if (!ff_tak_decode_frame_header(avctx, &gb, &ti, 127)) s->duration = t->ti.last_frame_samples ? t->ti.last_frame_samples : t->ti.frame_samples; -*poutbuf = buf; -*poutbuf_size = buf_size; return buf_size; } @@ -65,7 +66,7 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *tmp_buf = buf; if (ff_combine_frame(pc, END_NOT_FOUND, &tmp_buf, &tmp_buf_size) != -1) -return AVERROR(ENOMEM); +goto fail; consumed += tmp_buf_size; buf += tmp_buf_size; buf_size -= tmp_buf_size; @@ -78,7 +79,7 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx, if ((ret = init_get_bits8(&gb, pc->buffer + t->index, pc->index - t->index)) < 0) -return ret; +goto fail; if (!ff_tak_decode_frame_header(avctx, &gb, pc->frame_start_found ? &ti : &t->ti, 127) && !ff_tak_check_crc(pc->buffer + t->index, @@ -103,9 +104,7 @@ found: if (consumed && !buf_size && next == END_NOT_FOUND || ff_combine_frame(pc, next, &buf, &buf_size) < 0) { -*poutbuf = NULL; -*poutbuf_size = 0; -return buf_size + consumed; +goto fail; } if (next != END_NOT_FOUND) { @@ -116,6 +115,11 @@ found: *poutbuf = buf; *poutbuf_size = buf_size; return next; + +fail: +*poutbuf = NULL; +*poutbuf_size = 0; +return buf_size + consumed; } AVCodecParser ff_tak_parser = { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ffwavesynth: Check if there is enough extradata before allocation
ffmpeg | branch: master | Michael Niedermayer | Mon Jul 15 00:35:49 2019 +0200| [65bac4a7825e1f2bbf4112569ffa363cc1fdbce5] | committer: Michael Niedermayer avcodec/ffwavesynth: Check if there is enough extradata before allocation Fixes: OOM Fixes: 15750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5702090367696896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=65bac4a7825e1f2bbf4112569ffa363cc1fdbce5 --- libavcodec/ffwavesynth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index 94a843e3ca..b319b3341a 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -247,7 +247,7 @@ static int wavesynth_parse_extradata(AVCodecContext *avc) edata_end = edata + avc->extradata_size; ws->nb_inter = AV_RL32(edata); edata += 4; -if (ws->nb_inter < 0) +if (ws->nb_inter < 0 || (edata_end - edata) / 24 < ws->nb_inter) return AVERROR(EINVAL); ws->inter = av_calloc(ws->nb_inter, sizeof(*ws->inter)); if (!ws->inter) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ffwavesynth: Check sample rate before use
ffmpeg | branch: master | Michael Niedermayer | Mon Jul 15 00:35:47 2019 +0200| [c95857a4237d7a0c55378a44f51d2d809f3bc8f5] | committer: Michael Niedermayer avcodec/ffwavesynth: Check sample rate before use Fixes: division by zero Fixes: 15725/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5641231956180992 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c95857a4237d7a0c55378a44f51d2d809f3bc8f5 --- libavcodec/ffwavesynth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index 793eada7a5..1dbfaa5847 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -270,7 +270,7 @@ static int wavesynth_parse_extradata(AVCodecContext *avc) dt = in->ts_end - in->ts_start; switch (in->type) { case WS_SINE: -if (edata_end - edata < 20) +if (edata_end - edata < 20 || avc->sample_rate <= 0) return AVERROR(EINVAL); f1 = AV_RL32(edata + 0); f2 = AV_RL32(edata + 4); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/dvbsubdec: Use ff_set_dimensions()
ffmpeg | branch: master | Michael Niedermayer | Sat Jul 20 00:07:59 2019 +0200| [5941b7f615b0c0cab0d8f8613b918de75d3c1222] | committer: Michael Niedermayer avcodec/dvbsubdec: Use ff_set_dimensions() Fixes: signed integer overflow: 65313 * 65313 cannot be represented in type 'int' Fixes: 15740/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVBSUB_fuzzer-5641749164195840 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5941b7f615b0c0cab0d8f8613b918de75d3c1222 --- libavcodec/dvbsubdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index bc4a17bde0..6e7e13b6eb 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -1578,8 +1578,9 @@ static int dvbsub_parse_display_definition_segment(AVCodecContext *avctx, display_def->width = bytestream_get_be16(&buf) + 1; display_def->height = bytestream_get_be16(&buf) + 1; if (!avctx->width || !avctx->height) { -avctx->width = display_def->width; -avctx->height = display_def->height; +int ret = ff_set_dimensions(avctx, display_def->width, display_def->height); +if (ret < 0) +return ret; } if (info_byte & 1<<3) { // display_window_flag ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ffwavesynth: More correct cast in wavesynth_seek()
ffmpeg | branch: master | Michael Niedermayer | Mon Jul 15 00:35:48 2019 +0200| [f4605770af712dd9d7b0136fe298f8aa52101011] | committer: Michael Niedermayer avcodec/ffwavesynth: More correct cast in wavesynth_seek() Fixes: signed integer overflow: 553590816 - -9223372036315799520 cannot be represented in type 'long' Fixes: 15743/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5705835377852416 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f4605770af712dd9d7b0136fe298f8aa52101011 --- libavcodec/ffwavesynth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index 1dbfaa5847..94a843e3ca 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -215,7 +215,7 @@ static void wavesynth_seek(struct wavesynth_context *ws, int64_t ts) ws->next_inter = i; ws->next_ts = i < ws->nb_inter ? ws->inter[i].ts_start : INF_TS; *last = -1; -lcg_seek(&ws->dither_state, (uint32_t)ts - ws->cur_ts); +lcg_seek(&ws->dither_state, (uint32_t)ts - (uint32_t)ws->cur_ts); if (ws->pink_need) { int64_t pink_ts_cur = (ws->cur_ts + PINK_UNIT - 1) & ~(PINK_UNIT - 1); int64_t pink_ts_next = ts & ~(PINK_UNIT - 1); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/aacdec: factorize the adts frame resync code
ffmpeg | branch: master | James Almer | Sat Jul 20 10:13:08 2019 -0300| [a38eab8b7501440f872ff1af8a0c5482b7b3e532] | committer: James Almer avformat/aacdec: factorize the adts frame resync code Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a38eab8b7501440f872ff1af8a0c5482b7b3e532 --- libavformat/aacdec.c | 37 + 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index 8a5450880b..262614fdd9 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -80,10 +80,31 @@ static int adts_aac_probe(const AVProbeData *p) return 0; } +static int adts_aac_resync(AVFormatContext *s) +{ +uint16_t state; + +// skip data until an ADTS frame is found +state = avio_r8(s->pb); +while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) { +state = (state << 8) | avio_r8(s->pb); +if ((state >> 4) != 0xFFF) +continue; +avio_seek(s->pb, -2, SEEK_CUR); +break; +} +if (s->pb->eof_reached) +return AVERROR_EOF; +if ((state >> 4) != 0xFFF) +return AVERROR_INVALIDDATA; + +return 0; +} + static int adts_aac_read_header(AVFormatContext *s) { AVStream *st; -uint16_t state; +int ret; st = avformat_new_stream(s, NULL); if (!st) @@ -101,17 +122,9 @@ static int adts_aac_read_header(AVFormatContext *s) avio_seek(s->pb, cur, SEEK_SET); } -// skip data until the first ADTS frame is found -state = avio_r8(s->pb); -while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) { -state = (state << 8) | avio_r8(s->pb); -if ((state >> 4) != 0xFFF) -continue; -avio_seek(s->pb, -2, SEEK_CUR); -break; -} -if ((state >> 4) != 0xFFF) -return AVERROR_INVALIDDATA; +ret = adts_aac_resync(s); +if (ret < 0) +return ret; // LCM of all possible ADTS sample rates avpriv_set_pts_info(st, 64, 1, 28224000); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/aacdec: resync to the next adts frame on invalid data instead of aborting
ffmpeg | branch: master | James Almer | Sat Jul 20 21:47:55 2019 -0300| [881e1f5a6227a6fbaf67083d4d4b6caf58ff9892] | committer: James Almer avformat/aacdec: resync to the next adts frame on invalid data instead of aborting Should fix ticket #6634 Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=881e1f5a6227a6fbaf67083d4d4b6caf58ff9892 --- libavformat/aacdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index 262614fdd9..00ca2319ca 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -190,9 +190,9 @@ retry: } if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) { av_packet_unref(pkt); -return AVERROR_INVALIDDATA; -} -ret = handle_id3(s, pkt); +ret = adts_aac_resync(s); +} else +ret = handle_id3(s, pkt); if (ret < 0) return ret; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/avio: remove ffio_open2_wrapper function
ffmpeg | branch: master | Jun Zhao | Sat Jul 13 10:45:18 2019 +0800| [4373bb411c1d238b8785eee0714075dc49d61980] | committer: Jun Zhao lavf/avio: remove ffio_open2_wrapper function Remove the function ffio_open2_wrapper, it's not being used anymore. Signed-off-by: Jun Zhao > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4373bb411c1d238b8785eee0714075dc49d61980 --- libavformat/aviobuf.c | 6 -- libavformat/internal.h | 3 --- 2 files changed, 9 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 6a5cd97b0a..2d011027c9 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1180,12 +1180,6 @@ int avio_open2(AVIOContext **s, const char *filename, int flags, return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL); } -int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, - const AVIOInterruptCB *int_cb, AVDictionary **options) -{ -return ffio_open_whitelist(pb, url, flags, int_cb, options, s->protocol_whitelist, s->protocol_blacklist); -} - int avio_close(AVIOContext *s) { AVIOInternal *internal; diff --git a/libavformat/internal.h b/libavformat/internal.h index 399d0a68be..cf8c16579c 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -650,9 +650,6 @@ enum AVWriteUncodedFrameFlags { */ int ff_copy_whiteblacklists(AVFormatContext *dst, const AVFormatContext *src); -int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, - const AVIOInterruptCB *int_cb, AVDictionary **options); - /** * Returned by demuxers to indicate that data was consumed but discarded * (ignored streams or junk data). The framework will re-call the demuxer. ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavfi/showinfo: support regions of interest sidedata
ffmpeg | branch: master | Jun Zhao | Sat Mar 9 15:55:38 2019 +0800| [7eec3d22fc5f8f93a14a58836c5ac9f7b243e992] | committer: Jun Zhao lavfi/showinfo: support regions of interest sidedata support regions of interest sidedata Signed-off-by: Jun Zhao > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7eec3d22fc5f8f93a14a58836c5ac9f7b243e992 --- libavfilter/vf_showinfo.c | 25 + 1 file changed, 25 insertions(+) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index e41c3309a0..f6f8f49778 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -111,6 +111,28 @@ static void dump_stereo3d(AVFilterContext *ctx, AVFrameSideData *sd) av_log(ctx, AV_LOG_INFO, " (inverted)"); } +static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd) +{ +int nb_rois; +const AVRegionOfInterest *roi; +uint32_t roi_size; + +roi = (const AVRegionOfInterest *)sd->data; +roi_size = roi->self_size; +if (!roi_size || sd->size % roi_size != 0) { +av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n"); +return; +} +nb_rois = sd->size / roi_size; + +av_log(ctx, AV_LOG_INFO, "Regions Of Interest(RoI) information: "); +for (int i = 0; i < nb_rois; i++) { +roi = (const AVRegionOfInterest *)(sd->data + roi_size * i); +av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d, %d)/(%d, %d), qp offset: %d/%d.\n", + i, roi->left, roi->top, roi->right, roi->bottom, roi->qoffset.num, roi->qoffset.den); +} +} + static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) { const char *color_range_str = av_color_range_name(frame->color_range); @@ -246,6 +268,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) case AV_FRAME_DATA_AFD: av_log(ctx, AV_LOG_INFO, "afd: value of %"PRIu8, sd->data[0]); break; +case AV_FRAME_DATA_REGIONS_OF_INTEREST: +dump_roi(ctx, sd); +break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", sd->type, sd->size); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_h264: Fix handling of auxiliary pictures
ffmpeg | branch: release/4.1 | Andreas Rheinhardt | Wed Nov 7 04:47:51 2018 +0100| [2ac6315c7c3a0049b02d1d79f7944507fdc4c456] | committer: James Almer cbs_h264: Fix handling of auxiliary pictures The earlier code used the most recent non-auxiliary slice to determine whether an auxiliary slice has the syntax of an IDR slice, even when the most recent slice was from a slice of a redundant frame. Now only slices of the primary coded picture are used, as the specifications mandate. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 8d1cf2d89481ca986af893425188d065c0f8f857) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2ac6315c7c3a0049b02d1d79f7944507fdc4c456 --- libavcodec/cbs_h264_syntax_template.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index dbf9ff1268..4da4c5da67 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -1190,11 +1190,10 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, "in the same access unit.\n"); return AVERROR_INVALIDDATA; } +idr_pic_flag = h264->last_slice_nal_unit_type == H264_NAL_IDR_SLICE; } else { -h264->last_slice_nal_unit_type = -current->nal_unit_header.nal_unit_type; +idr_pic_flag = current->nal_unit_header.nal_unit_type == H264_NAL_IDR_SLICE; } -idr_pic_flag = h264->last_slice_nal_unit_type == H264_NAL_IDR_SLICE; ue(first_mb_in_slice, 0, H264_MAX_MB_PIC_SIZE - 1); ue(slice_type, 0, 9); @@ -1272,6 +1271,13 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, if (pps->redundant_pic_cnt_present_flag) ue(redundant_pic_cnt, 0, 127); +else +infer(redundant_pic_cnt, 0); + +if (current->nal_unit_header.nal_unit_type != H264_NAL_AUXILIARY_SLICE +&& !current->redundant_pic_cnt) +h264->last_slice_nal_unit_type = +current->nal_unit_header.nal_unit_type; if (slice_type_b) flag(direct_spatial_mv_pred_flag); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/cbs: Do not use format specifier "z" on Windows.
ffmpeg | branch: release/4.1 | Carl Eugen Hoyos | Mon Dec 17 14:39:41 2018 +0100| [b3b5941ec7b4c1dbb059b0cd85db3c659d5c8039] | committer: James Almer lavc/cbs: Do not use format specifier "z" on Windows. (cherry picked from commit 0b7269e62d0345fec5f1ee9ee7b960e8d25c5dd1) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3b5941ec7b4c1dbb059b0cd85db3c659d5c8039 --- libavcodec/cbs_av1.c | 10 +- libavcodec/cbs_vp9.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index e4e3964118..80628c72ba 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -795,7 +795,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, if (INT_MAX / 8 < size) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid fragment: " - "too large (%zu bytes).\n", size); + "too large (%"SIZE_SPECIFIER" bytes).\n", size); err = AVERROR_INVALIDDATA; goto fail; } @@ -819,7 +819,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, if (get_bits_left(&gbc) < 8) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid OBU: fragment " - "too short (%zu bytes).\n", size); + "too short (%"SIZE_SPECIFIER" bytes).\n", size); err = AVERROR_INVALIDDATA; goto fail; } @@ -835,7 +835,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, if (size < obu_length) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid OBU length: " - "%"PRIu64", but only %zu bytes remaining in fragment.\n", + "%"PRIu64", but only %"SIZE_SPECIFIER" bytes remaining in fragment.\n", obu_length, size); err = AVERROR_INVALIDDATA; goto fail; @@ -950,7 +950,7 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx, } else { if (unit->data_size < 1 + obu->header.obu_extension_flag) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid OBU length: " - "unit too short (%zu).\n", unit->data_size); + "unit too short (%"SIZE_SPECIFIER").\n", unit->data_size); return AVERROR_INVALIDDATA; } obu->obu_size = unit->data_size - 1 - obu->header.obu_extension_flag; @@ -1256,7 +1256,7 @@ static int cbs_av1_write_unit(CodedBitstreamContext *ctx, if (err < 0) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Unable to allocate a " "sufficiently large write buffer (last attempt " - "%zu bytes).\n", priv->write_buffer_size); + "%"SIZE_SPECIFIER" bytes).\n", priv->write_buffer_size); return err; } } diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c index f145694e22..0b5f137ed8 100644 --- a/libavcodec/cbs_vp9.c +++ b/libavcodec/cbs_vp9.c @@ -457,7 +457,7 @@ static int cbs_vp9_split_fragment(CodedBitstreamContext *ctx, } if (pos + index_size != frag->data_size) { av_log(ctx->log_ctx, AV_LOG_WARNING, "Extra padding at " - "end of superframe: %zu bytes.\n", + "end of superframe: %"SIZE_SPECIFIER" bytes.\n", frag->data_size - (pos + index_size)); } @@ -538,7 +538,7 @@ static int cbs_vp9_write_unit(CodedBitstreamContext *ctx, if (err < 0) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Unable to allocate a " "sufficiently large write buffer (last attempt " - "%zu bytes).\n", priv->write_buffer_size); + "%"SIZE_SPECIFIER" bytes).\n", priv->write_buffer_size); return err; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/cbs_h2645: add helper macros for signed values
ffmpeg | branch: release/4.1 | James Almer | Mon Apr 15 17:48:55 2019 -0300| [94b1630b7ca34964aa873a59540ecd895a1bf9e6] | committer: James Almer avcodec/cbs_h2645: add helper macros for signed values Reviewed-by: Mark Thompson Signed-off-by: James Almer (cherry picked from commit 3dc6adf326c8cd6c7fc830ccb8def8772835c676) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=94b1630b7ca34964aa873a59540ecd895a1bf9e6 --- libavcodec/cbs_h2645.c | 20 1 file changed, 20 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index e55bd00183..64f1e5813a 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -255,6 +255,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, #define flag(name) u(1, name, 0, 1) #define ue(name, range_min, range_max) \ xue(name, current->name, range_min, range_max, 0) +#define i(width, name, range_min, range_max) \ +xi(width, name, current->name, range_min, range_max, 0) #define se(name, range_min, range_max) \ xse(name, current->name, range_min, range_max, 0) @@ -264,6 +266,8 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, xu(1, name, current->name, 0, 1, subs, __VA_ARGS__) #define ues(name, range_min, range_max, subs, ...) \ xue(name, current->name, range_min, range_max, subs, __VA_ARGS__) +#define is(width, name, range_min, range_max, subs, ...) \ +xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__) #define ses(name, range_min, range_max, subs, ...) \ xse(name, current->name, range_min, range_max, subs, __VA_ARGS__) @@ -291,6 +295,13 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, &value, range_min, range_max)); \ var = value; \ } while (0) +#define xi(width, name, var, range_min, range_max, subs, ...) do { \ +int32_t value = range_min; \ +CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \ + SUBSCRIPTS(subs, __VA_ARGS__), \ + &value, range_min, range_max)); \ +var = value; \ +} while (0) #define xse(name, var, range_min, range_max, subs, ...) do { \ int32_t value = range_min; \ CHECK(cbs_read_se_golomb(ctx, rw, #name, \ @@ -338,6 +349,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #undef READWRITE #undef RWContext #undef xu +#undef xi #undef xue #undef xse #undef infer @@ -362,6 +374,12 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) SUBSCRIPTS(subs, __VA_ARGS__), \ value, range_min, range_max)); \ } while (0) +#define xi(width, name, var, range_min, range_max, subs, ...) do { \ +int32_t value = var; \ +CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \ + SUBSCRIPTS(subs, __VA_ARGS__), \ + value, range_min, range_max)); \ +} while (0) #define xse(name, var, range_min, range_max, subs, ...) do { \ int32_t value = var; \ CHECK(cbs_write_se_golomb(ctx, rw, #name, \ @@ -402,9 +420,11 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc) #undef READWRITE #undef RWContext #undef xu +#undef xi #undef xue #undef xse #undef u +#undef i #undef flag #undef ue #undef se ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/cbs_mpeg2: fix leak of extra_information_slice buffer in cbs_mpeg2_read_slice_header()
ffmpeg | branch: release/4.1 | James Almer | Wed May 22 03:04:38 2019 +0200| [ae5c80b9cae8716085eaacd887c28378ae99233b] | committer: James Almer avcodec/cbs_mpeg2: fix leak of extra_information_slice buffer in cbs_mpeg2_read_slice_header() cbs_mpeg2_free_slice() calls av_buffer_unref() on extra_information_ref, meaning allocating with av_malloc() was not the intention. Signed-off-by: James Almer (cherry picked from commit d903c09d9a5c641223f0810d24161520e977544a) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae5c80b9cae8716085eaacd887c28378ae99233b --- libavcodec/cbs_mpeg2_syntax_template.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/cbs_mpeg2_syntax_template.c b/libavcodec/cbs_mpeg2_syntax_template.c index 88cf453b17..672ff66141 100644 --- a/libavcodec/cbs_mpeg2_syntax_template.c +++ b/libavcodec/cbs_mpeg2_syntax_template.c @@ -361,10 +361,11 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, current->extra_information_length = k; if (k > 0) { *rw = start; -current->extra_information = -av_malloc(current->extra_information_length); -if (!current->extra_information) +current->extra_information_ref = +av_buffer_alloc(current->extra_information_length); +if (!current->extra_information_ref) return AVERROR(ENOMEM); +current->extra_information = current->extra_information_ref->data; for (k = 0; k < current->extra_information_length; k++) { xui(1, extra_bit_slice, bit, 0); xui(8, extra_information_slice[k], ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/cbs_h264: fix storage type for time_offset in Pic Timing SEI
ffmpeg | branch: release/4.1 | James Almer | Mon Apr 15 17:50:01 2019 -0300| [a2132139852c57e71c731d10e5dc20e97342c289] | committer: James Almer avcodec/cbs_h264: fix storage type for time_offset in Pic Timing SEI The spec defines it as a signed value. Reviewed-by: Mark Thompson Signed-off-by: James Almer (cherry picked from commit 9bf520d04d6137d0772e019356356614bbf7ca82) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2132139852c57e71c731d10e5dc20e97342c289 --- libavcodec/cbs_h264.h | 2 +- libavcodec/cbs_h264_syntax_template.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h index 92277e4750..b5eee7c370 100644 --- a/libavcodec/cbs_h264.h +++ b/libavcodec/cbs_h264.h @@ -253,7 +253,7 @@ typedef struct H264RawSEIPicTimestamp { uint8_t minutes_value; uint8_t hours_flag; uint8_t hours_value; -uint32_t time_offset; +int32_t time_offset; } H264RawSEIPicTimestamp; typedef struct H264RawSEIPicTiming { diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 4da4c5da67..07b4cddb5e 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -592,8 +592,9 @@ static int FUNC(sei_pic_timestamp)(CodedBitstreamContext *ctx, RWContext *rw, time_offset_length = 24; if (time_offset_length > 0) -u(time_offset_length, time_offset, - 0, MAX_UINT_BITS(time_offset_length)); +i(time_offset_length, time_offset, + MIN_INT_BITS(time_offset_length), + MAX_INT_BITS(time_offset_length)); else infer(time_offset, 0); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/cbs: add helper functions and macros to read and write signed values
ffmpeg | branch: release/4.1 | James Almer | Mon Apr 15 17:46:53 2019 -0300| [7dc2366533d63df9d46be5ea3ec066e1977898d4] | committer: James Almer avcodec/cbs: add helper functions and macros to read and write signed values Reviewed-by: Mark Thompson Signed-off-by: James Almer (cherry picked from commit 5006dcdf9af177444e3e0185640d7d84629e4215) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7dc2366533d63df9d46be5ea3ec066e1977898d4 --- libavcodec/cbs.c | 79 +++ libavcodec/cbs_internal.h | 20 +++- 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index ecbf57c293..3152b13b1a 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -502,6 +502,85 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, return 0; } +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, + int width, const char *name, + const int *subscripts, int32_t *write_to, + int32_t range_min, int32_t range_max) +{ +int32_t value; +int position; + +av_assert0(width > 0 && width <= 32); + +if (get_bits_left(gbc) < width) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid value at " + "%s: bitstream ended.\n", name); +return AVERROR_INVALIDDATA; +} + +if (ctx->trace_enable) +position = get_bits_count(gbc); + +value = get_sbits_long(gbc, width); + +if (ctx->trace_enable) { +char bits[33]; +int i; +for (i = 0; i < width; i++) +bits[i] = value & (1U << (width - i - 1)) ? '1' : '0'; +bits[i] = 0; + +ff_cbs_trace_syntax_element(ctx, position, name, subscripts, +bits, value); +} + +if (value < range_min || value > range_max) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: " + "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n", + name, value, range_min, range_max); +return AVERROR_INVALIDDATA; +} + +*write_to = value; +return 0; +} + +int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, +int width, const char *name, +const int *subscripts, int32_t value, +int32_t range_min, int32_t range_max) +{ +av_assert0(width > 0 && width <= 32); + +if (value < range_min || value > range_max) { +av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: " + "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n", + name, value, range_min, range_max); +return AVERROR_INVALIDDATA; +} + +if (put_bits_left(pbc) < width) +return AVERROR(ENOSPC); + +if (ctx->trace_enable) { +char bits[33]; +int i; +for (i = 0; i < width; i++) +bits[i] = value & (1U << (width - i - 1)) ? '1' : '0'; +bits[i] = 0; + +ff_cbs_trace_syntax_element(ctx, put_bits_count(pbc), +name, subscripts, bits, value); +} + +if (width < 32) +put_sbits(pbc, width, value); +else +put_bits32(pbc, value); + +return 0; +} + int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index 53f2e5d187..dd4babf092 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -81,10 +81,28 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, const int *subscripts, uint32_t value, uint32_t range_min, uint32_t range_max); -// The largest value representable in N bits, suitable for use as +int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, + int width, const char *name, + const int *subscripts, int32_t *write_to, + int32_t range_min, int32_t range_max); + +int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, +int width, const char *name, +const int *subscripts, int32_t value, +int32_t range_min, int32_t range_max); + +// The largest unsigned value representable in N bits, suitable for use as // range_max in the above functions. #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1) +// The largest signed value representable in N bits, suitable for use as +// range_max in the above functions. +#define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1) + +// The smallest signed value representable in N bits, suitable for use as +// range_min in the above functions. +#define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1))) + extern const CodedBitstreamType ff_cbs_type_av1;
[FFmpeg-cvslog] avformat/aacdec: factorize the adts frame resync code
ffmpeg | branch: release/4.1 | James Almer | Sat Jul 20 10:13:08 2019 -0300| [1fbe0286e4091dd4cdc0694965d92c42b98cacf1] | committer: James Almer avformat/aacdec: factorize the adts frame resync code Signed-off-by: James Almer (cherry picked from commit a38eab8b7501440f872ff1af8a0c5482b7b3e532) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1fbe0286e4091dd4cdc0694965d92c42b98cacf1 --- libavformat/aacdec.c | 37 + 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index e23abd0abf..66fa49ac26 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -80,10 +80,31 @@ static int adts_aac_probe(AVProbeData *p) return 0; } +static int adts_aac_resync(AVFormatContext *s) +{ +uint16_t state; + +// skip data until an ADTS frame is found +state = avio_r8(s->pb); +while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) { +state = (state << 8) | avio_r8(s->pb); +if ((state >> 4) != 0xFFF) +continue; +avio_seek(s->pb, -2, SEEK_CUR); +break; +} +if (s->pb->eof_reached) +return AVERROR_EOF; +if ((state >> 4) != 0xFFF) +return AVERROR_INVALIDDATA; + +return 0; +} + static int adts_aac_read_header(AVFormatContext *s) { AVStream *st; -uint16_t state; +int ret; st = avformat_new_stream(s, NULL); if (!st) @@ -101,17 +122,9 @@ static int adts_aac_read_header(AVFormatContext *s) avio_seek(s->pb, cur, SEEK_SET); } -// skip data until the first ADTS frame is found -state = avio_r8(s->pb); -while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) { -state = (state << 8) | avio_r8(s->pb); -if ((state >> 4) != 0xFFF) -continue; -avio_seek(s->pb, -2, SEEK_CUR); -break; -} -if ((state >> 4) != 0xFFF) -return AVERROR_INVALIDDATA; +ret = adts_aac_resync(s); +if (ret < 0) +return ret; // LCM of all possible ADTS sample rates avpriv_set_pts_info(st, 64, 1, 28224000); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/cbs_vp9: Make variable prob unsigned.
ffmpeg | branch: release/4.1 | Carl Eugen Hoyos | Mon Dec 10 02:18:56 2018 +0100| [84b94fdd05d24f161f6559bfef63a8db049e0cc7] | committer: James Almer lavc/cbs_vp9: Make variable prob unsigned. Silences a warning with clang: libavcodec/cbs_vp9_syntax_template.c:220:17: warning: implicit conversion from 'int' to 'int8_t' (aka 'signed char') changes value from 255 to -1 (cherry picked from commit de441ad52a4d9791d93c278b4cf6867815c28b92) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84b94fdd05d24f161f6559bfef63a8db049e0cc7 --- libavcodec/cbs_vp9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c index c03ce986c0..f145694e22 100644 --- a/libavcodec/cbs_vp9.c +++ b/libavcodec/cbs_vp9.c @@ -305,7 +305,7 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, PutBitContext *pbc, #define prob(name, subs, ...) do { \ uint8_t prob_coded; \ -int8_t prob; \ +uint8_t prob; \ xf(1, name.prob_coded, prob_coded, subs, __VA_ARGS__); \ if (prob_coded) \ xf(8, name.prob, prob, subs, __VA_ARGS__); \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/aacdec: resync to the next adts frame on invalid data instead of aborting
ffmpeg | branch: release/4.1 | James Almer | Sat Jul 20 21:47:55 2019 -0300| [a21a9c78637ac1d86dd272214b6fc2008aef4db1] | committer: James Almer avformat/aacdec: resync to the next adts frame on invalid data instead of aborting Should fix ticket #6634 Signed-off-by: James Almer (cherry picked from commit 881e1f5a6227a6fbaf67083d4d4b6caf58ff9892) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a21a9c78637ac1d86dd272214b6fc2008aef4db1 --- libavformat/aacdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index 66fa49ac26..09fbab2766 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -190,9 +190,9 @@ retry: } if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) { av_packet_unref(pkt); -return AVERROR_INVALIDDATA; -} -ret = handle_id3(s, pkt); +ret = adts_aac_resync(s); +} else +ret = handle_id3(s, pkt); if (ret < 0) return ret; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_mpeg2: Fix storage type for frame_centre_*_offset
ffmpeg | branch: release/4.1 | Andreas Rheinhardt | Wed May 22 03:04:34 2019 +0200| [1b6bcee9fe6f59a2d8c11c18711d65d744b0b5aa] | committer: James Almer cbs_mpeg2: Fix storage type for frame_centre_*_offset The frame_centre_horizontal/vertical_offset values contained in picture display extensions are actually signed values (i.e. it is possible to indicate that the display device should add black bars/pillars). The files sony-ct3.bs and tcela-6.bits (which are both used in fate tests for mpeg2_metadata) contain picture display extensions; the former even contains a negative frame_centre_vertical_offset. Fortunately, the old code did not damage the picture display extensions when one did a cycle of reading and writing. For the same reason the fate tests needn't be updated either. Furthermore these fields now use the trace output for matrices. Signed-off-by: Andreas Rheinhardt (cherry picked from commit de5880383967f44927c599ab16fa0f4f96b38365) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b6bcee9fe6f59a2d8c11c18711d65d744b0b5aa --- libavcodec/cbs_mpeg2.c | 20 libavcodec/cbs_mpeg2.h | 4 ++-- libavcodec/cbs_mpeg2_syntax_template.c | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 3e7bfb4610..5e0757e8ee 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -48,6 +48,8 @@ xui(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__) #define uirs(width, name, subs, ...) \ xui(width, name, current->name, 1, MAX_UINT_BITS(width), subs, __VA_ARGS__) +#define sis(width, name, subs, ...) \ +xsi(width, name, current->name, subs, __VA_ARGS__) #define READ @@ -62,6 +64,15 @@ var = value; \ } while (0) +#define xsi(width, name, var, subs, ...) do { \ +int32_t value; \ +CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \ + SUBSCRIPTS(subs, __VA_ARGS__), &value, \ + MIN_INT_BITS(width), \ + MAX_INT_BITS(width))); \ +var = value; \ +} while (0) + #define marker_bit() do { \ av_unused uint32_t one; \ CHECK(ff_cbs_read_unsigned(ctx, rw, 1, "marker_bit", NULL, &one, 1, 1)); \ @@ -77,6 +88,7 @@ #undef READWRITE #undef RWContext #undef xui +#undef xsi #undef marker_bit #undef nextbits @@ -91,6 +103,13 @@ var, range_min, range_max)); \ } while (0) +#define xsi(width, name, var, subs, ...) do { \ +CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \ + SUBSCRIPTS(subs, __VA_ARGS__), var, \ + MIN_INT_BITS(width), \ + MAX_INT_BITS(width))); \ +} while (0) + #define marker_bit() do { \ CHECK(ff_cbs_write_unsigned(ctx, rw, 1, "marker_bit", NULL, 1, 1, 1)); \ } while (0) @@ -103,6 +122,7 @@ #undef READWRITE #undef RWContext #undef xui +#undef xsi #undef marker_bit #undef nextbits diff --git a/libavcodec/cbs_mpeg2.h b/libavcodec/cbs_mpeg2.h index 92caa99dc1..69eb10fc08 100644 --- a/libavcodec/cbs_mpeg2.h +++ b/libavcodec/cbs_mpeg2.h @@ -164,8 +164,8 @@ typedef struct MPEG2RawQuantMatrixExtension { } MPEG2RawQuantMatrixExtension; typedef struct MPEG2RawPictureDisplayExtension { -uint16_t frame_centre_horizontal_offset[3]; -uint16_t frame_centre_vertical_offset[3]; +int16_t frame_centre_horizontal_offset[3]; +int16_t frame_centre_vertical_offset[3]; } MPEG2RawPictureDisplayExtension; typedef struct MPEG2RawExtensionData { diff --git a/libavcodec/cbs_mpeg2_syntax_template.c b/libavcodec/cbs_mpeg2_syntax_template.c index 98c44dd048..1b5419d7c5 100644 --- a/libavcodec/cbs_mpeg2_syntax_template.c +++ b/libavcodec/cbs_mpeg2_syntax_template.c @@ -299,9 +299,9 @@ static int FUNC(picture_display_extension)(CodedBitstreamContext *ctx, RWContext HEADER("Picture Display Extension"); for (i = 0; i < mpeg2->number_of_frame_centre_offsets; i++) { -ui(16, frame_centre_horizontal_offset[i]); +sis(16, frame_centre_horizontal_offset[i], 1, i); marker_bit(); -ui(16, frame_centre_vertical_offset[i]); +sis(16, frame_centre_vertical_offset[i], 1, i); marker_bit(); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] cbs_mpeg2: Improve checks for invalid values
ffmpeg | branch: release/4.1 | Andreas Rheinhardt | Wed May 22 03:04:32 2019 +0200| [b010caa6c9e85657c2032046773cb1a816a5b1da] | committer: James Almer cbs_mpeg2: Improve checks for invalid values MPEG-2 contains several elements that mustn't be zero according to the specifications: horizontal/vertical_size_value, aspect_ratio_information, frame_rate_code, the quantiser matrices, the colour_description elements, picture_coding_type, the f_code[r][s] values and quantiser_scale_code. It is now checked that the invalid values don't occur. The colour_description elements are treated specially in this regard: Given that there are files in the wild which use illegal values for the colour_description elements (some of them created by mpeg2_metadata), they will be corrected to the value meaning "unknown" (namely 2) during reading. This has been done in such a way that trace_headers will nevertheless report the original value, together with a message about the fixup. Furthermore, the trace_headers output of user_data has been beautified. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 9c3f2a8894a66d6b5b9285caa25f91fbfca7b3bc) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b010caa6c9e85657c2032046773cb1a816a5b1da --- libavcodec/cbs_mpeg2.c | 16 + libavcodec/cbs_mpeg2_syntax_template.c | 64 +- 2 files changed, 50 insertions(+), 30 deletions(-) diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 0df4234b12..3e7bfb4610 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -41,20 +41,24 @@ #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) #define ui(width, name) \ -xui(width, name, current->name, 0) +xui(width, name, current->name, 0, MAX_UINT_BITS(width), 0) +#define uir(width, name) \ +xui(width, name, current->name, 1, MAX_UINT_BITS(width), 0) #define uis(width, name, subs, ...) \ -xui(width, name, current->name, subs, __VA_ARGS__) +xui(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__) +#define uirs(width, name, subs, ...) \ +xui(width, name, current->name, 1, MAX_UINT_BITS(width), subs, __VA_ARGS__) #define READ #define READWRITE read #define RWContext GetBitContext -#define xui(width, name, var, subs, ...) do { \ +#define xui(width, name, var, range_min, range_max, subs, ...) do { \ uint32_t value = 0; \ CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \ SUBSCRIPTS(subs, __VA_ARGS__), \ - &value, 0, (1 << width) - 1)); \ + &value, range_min, range_max)); \ var = value; \ } while (0) @@ -81,10 +85,10 @@ #define READWRITE write #define RWContext PutBitContext -#define xui(width, name, var, subs, ...) do { \ +#define xui(width, name, var, range_min, range_max, subs, ...) do { \ CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \ SUBSCRIPTS(subs, __VA_ARGS__), \ -var, 0, (1 << width) - 1)); \ +var, range_min, range_max)); \ } while (0) #define marker_bit() do { \ diff --git a/libavcodec/cbs_mpeg2_syntax_template.c b/libavcodec/cbs_mpeg2_syntax_template.c index 672ff66141..98c44dd048 100644 --- a/libavcodec/cbs_mpeg2_syntax_template.c +++ b/libavcodec/cbs_mpeg2_syntax_template.c @@ -26,14 +26,14 @@ static int FUNC(sequence_header)(CodedBitstreamContext *ctx, RWContext *rw, ui(8, sequence_header_code); -ui(12, horizontal_size_value); -ui(12, vertical_size_value); +uir(12, horizontal_size_value); +uir(12, vertical_size_value); mpeg2->horizontal_size = current->horizontal_size_value; mpeg2->vertical_size = current->vertical_size_value; -ui(4, aspect_ratio_information); -ui(4, frame_rate_code); +uir(4, aspect_ratio_information); +uir(4, frame_rate_code); ui(18, bit_rate_value); marker_bit(); @@ -44,13 +44,13 @@ static int FUNC(sequence_header)(CodedBitstreamContext *ctx, RWContext *rw, ui(1, load_intra_quantiser_matrix); if (current->load_intra_quantiser_matrix) { for (i = 0; i < 64; i++) -uis(8, intra_quantiser_matrix[i], 1, i); +uirs(8, intra_quantiser_matrix[i], 1, i); } ui(1, load_non_intra_quantiser_matrix); if (current->load_non_intra_quantiser_matrix) { for (i = 0; i < 64; i++) -uis(8, non_intra_quantiser_matrix[i], 1, i); +uirs(8, non_intra_quantiser_matrix[i], 1, i); } return 0; @@ -79,7 +79,7 @@ static int FUNC(user_data)(CodedBitstreamContext *ctx, RWContext *rw, #endif for (k = 0; k < current->user_data_length; k++) -xui(8, user_data, current->user_data[k], 0); +uis(8, user_data[k], 1, k); re