[FFmpeg-cvslog] avcodec/librav1e: Require a bitrate to be set when using 2-pass mode
ffmpeg | branch: master | Derek Buitenhuis | Sat May 2 14:10:48 2020 +0100| [422f1e32ead99a758375c713447b341c8ac3b20d] | committer: Derek Buitenhuis avcodec/librav1e: Require a bitrate to be set when using 2-pass mode Not requiring this leads to unexpected result, since Rav1e's current two pass API has no way to fail in such a case. Signed-off-by: Derek Buitenhuis > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=422f1e32ead99a758375c713447b341c8ac3b20d --- libavcodec/librav1e.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index b0ff60d8c7..6f9b4cce4c 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -202,6 +202,12 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx) }); } +if ((avctx->flags & AV_CODEC_FLAG_PASS1 || avctx->flags & AV_CODEC_FLAG_PASS2) && !avctx->bit_rate) { +av_log(avctx, AV_LOG_ERROR, "A bitrate must be set to use two pass mode.\n"); +ret = AVERROR_INVALIDDATA; +goto end; +} + if (avctx->flags & AV_CODEC_FLAG_PASS2) { if (!avctx->stats_in) { av_log(avctx, AV_LOG_ERROR, "No stats file provided for second pass.\n"); ___ 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/h265_metadata: filter parameter sets in packet side data
ffmpeg | branch: master | James Almer | Wed Apr 22 12:09:47 2020 -0300| [1a9684c08a631b600353e946d67188a715243abe] | committer: James Almer avcodec/h265_metadata: filter parameter sets in packet side data Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1a9684c08a631b600353e946d67188a715243abe --- libavcodec/h265_metadata_bsf.c | 55 ++ 1 file changed, 55 insertions(+) diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c index 730f7ac28f..0fe350e053 100644 --- a/libavcodec/h265_metadata_bsf.c +++ b/libavcodec/h265_metadata_bsf.c @@ -336,6 +336,57 @@ static int h265_metadata_update_sps(AVBSFContext *bsf, return 0; } +static int h265_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +{ +H265MetadataContext *ctx = bsf->priv_data; +CodedBitstreamFragment *au = >access_unit; +uint8_t *side_data; +int side_data_size; +int err, i; + +side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +_data_size); +if (!side_data_size) +return 0; + +err = ff_cbs_read(ctx->cbc, au, side_data, side_data_size); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); +return err; +} + +if (ctx->level == LEVEL_AUTO && !ctx->level_guess) +h265_metadata_guess_level(bsf, au); + +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == HEVC_NAL_VPS) { +err = h265_metadata_update_vps(bsf, au->units[i].content); +if (err < 0) +return err; +} +if (au->units[i].type == HEVC_NAL_SPS) { +err = h265_metadata_update_sps(bsf, au->units[i].content); +if (err < 0) +return err; +} +} + +err = ff_cbs_write_fragment_data(ctx->cbc, au); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); +return err; +} + +side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size); +if (!side_data) +return AVERROR(ENOMEM); +memcpy(side_data, au->data, au->data_size); + +ff_cbs_fragment_reset(ctx->cbc, au); + +return 0; +} + static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) { H265MetadataContext *ctx = bsf->priv_data; @@ -346,6 +397,10 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (err < 0) return err; +err = h265_metadata_update_side_data(bsf, pkt); +if (err < 0) +goto fail; + err = ff_cbs_read_packet(ctx->cbc, au, pkt); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); ___ 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/av1_metadata: filter parameter sets in packet side data
ffmpeg | branch: master | James Almer | Wed Apr 22 12:09:45 2020 -0300| [3921eed398c9ac01e9923e51d1bf9086556e03d1] | committer: James Almer avcodec/av1_metadata: filter parameter sets in packet side data Extradata included in packet side data is meant to replace the codec context extradata. So when muxing for example to MP4 without this change and if extradata is present in a packet side data, the result will be that the parameter sets present in keyframes will be filtered, but the parameter sets ultimately included in the av1C box will not. This is especially important for AV1 as both currently supported encoders don't export the Sequence Header in the codec context extradata, but as packet side data instead. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3921eed398c9ac01e9923e51d1bf9086556e03d1 --- libavcodec/av1_metadata_bsf.c | 48 +++ 1 file changed, 48 insertions(+) diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c index dd0c9b6148..e5dde6754f 100644 --- a/libavcodec/av1_metadata_bsf.c +++ b/libavcodec/av1_metadata_bsf.c @@ -111,6 +111,50 @@ static int av1_metadata_update_sequence_header(AVBSFContext *bsf, return 0; } +static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +{ +AV1MetadataContext *ctx = bsf->priv_data; +CodedBitstreamFragment *frag = >access_unit; +uint8_t *side_data; +int side_data_size; +int err, i; + +side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +_data_size); +if (!side_data_size) +return 0; + +err = ff_cbs_read(ctx->cbc, frag, side_data, side_data_size); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); +return err; +} + +for (i = 0; i < frag->nb_units; i++) { +if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) { +AV1RawOBU *obu = frag->units[i].content; +err = av1_metadata_update_sequence_header(bsf, >obu.sequence_header); +if (err < 0) +return err; +} +} + +err = ff_cbs_write_fragment_data(ctx->cbc, frag); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); +return err; +} + +side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, frag->data_size); +if (!side_data) +return AVERROR(ENOMEM); +memcpy(side_data, frag->data, frag->data_size); + +ff_cbs_fragment_reset(ctx->cbc, frag); + +return 0; +} + static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) { AV1MetadataContext *ctx = bsf->priv_data; @@ -122,6 +166,10 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (err < 0) return err; +err = av1_metadata_update_side_data(bsf, pkt); +if (err < 0) +goto fail; + err = ff_cbs_read_packet(ctx->cbc, frag, pkt); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); ___ 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/h264_metadata: filter parameter sets in packet side data
ffmpeg | branch: master | James Almer | Wed Apr 22 12:09:46 2020 -0300| [502dacdc50e204947f7a32bf5c31bc4fbcba80d6] | committer: James Almer avcodec/h264_metadata: filter parameter sets in packet side data Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=502dacdc50e204947f7a32bf5c31bc4fbcba80d6 --- libavcodec/h264_metadata_bsf.c | 47 ++ 1 file changed, 47 insertions(+) diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index d96a50dbf7..451eaa0b67 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -275,6 +275,49 @@ static int h264_metadata_update_sps(AVBSFContext *bsf, return 0; } +static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) +{ +H264MetadataContext *ctx = bsf->priv_data; +CodedBitstreamFragment *au = >access_unit; +uint8_t *side_data; +int side_data_size; +int err, i; + +side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +_data_size); +if (!side_data_size) +return 0; + +err = ff_cbs_read(ctx->cbc, au, side_data, side_data_size); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); +return err; +} + +for (i = 0; i < au->nb_units; i++) { +if (au->units[i].type == H264_NAL_SPS) { +err = h264_metadata_update_sps(bsf, au->units[i].content); +if (err < 0) +return err; +} +} + +err = ff_cbs_write_fragment_data(ctx->cbc, au); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); +return err; +} + +side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size); +if (!side_data) +return AVERROR(ENOMEM); +memcpy(side_data, au->data, au->data_size); + +ff_cbs_fragment_reset(ctx->cbc, au); + +return 0; +} + static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) { H264MetadataContext *ctx = bsf->priv_data; @@ -286,6 +329,10 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (err < 0) return err; +err = h264_metadata_update_side_data(bsf, pkt); +if (err < 0) +goto fail; + err = ff_cbs_read_packet(ctx->cbc, au, pkt); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); ___ 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] ffmpeg: Don't require a known device to pass a frames context to an encoder
ffmpeg | branch: master | Mark Thompson | Tue Apr 28 23:56:42 2020 +0100| [706ed34ce7aca7be4adab69a55dab02f4573591a] | committer: Mark Thompson ffmpeg: Don't require a known device to pass a frames context to an encoder The previous code here did not handle passing a frames context when ffmpeg itself did not know about the device it came from (for example, because it was created by device derivation inside a filter graph), which would break encoders requiring that input. Fix that by checking for HW frames and device context methods independently, and prefer to use a frames context method if possible. At the same time, revert the encoding additions to the device matching function because the additional complexity was not relevant to decoding. Also fixes #8637, which is the same case but with the device creation hidden in the ad-hoc libmfx setup code. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=706ed34ce7aca7be4adab69a55dab02f4573591a --- fftools/ffmpeg_hw.c | 75 ++--- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index c5c8aa97ef..fc4a5d31d6 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -19,6 +19,7 @@ #include #include "libavutil/avstring.h" +#include "libavutil/pixdesc.h" #include "libavfilter/buffersink.h" #include "ffmpeg.h" @@ -282,10 +283,7 @@ void hw_device_free_all(void) nb_hw_devices = 0; } -static HWDevice *hw_device_match_by_codec(const AVCodec *codec, - enum AVPixelFormat format, - int possible_methods, - int *matched_methods) +static HWDevice *hw_device_match_by_codec(const AVCodec *codec) { const AVCodecHWConfig *config; HWDevice *dev; @@ -294,18 +292,11 @@ static HWDevice *hw_device_match_by_codec(const AVCodec *codec, config = avcodec_get_hw_config(codec, i); if (!config) return NULL; -if (format != AV_PIX_FMT_NONE && -config->pix_fmt != AV_PIX_FMT_NONE && -config->pix_fmt != format) -continue; -if (!(config->methods & possible_methods)) +if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) continue; dev = hw_device_get_by_type(config->device_type); -if (dev) { -if (matched_methods) -*matched_methods = config->methods & possible_methods; +if (dev) return dev; -} } } @@ -351,9 +342,7 @@ int hw_device_setup_for_decode(InputStream *ist) if (!dev) err = hw_device_init_from_type(type, NULL, ); } else { -dev = hw_device_match_by_codec(ist->dec, AV_PIX_FMT_NONE, - AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, - NULL); +dev = hw_device_match_by_codec(ist->dec); if (!dev) { // No device for this codec, but not using generic hwaccel // and therefore may well not need one - ignore. @@ -429,37 +418,57 @@ int hw_device_setup_for_decode(InputStream *ist) int hw_device_setup_for_encode(OutputStream *ost) { -HWDevice *dev; -AVBufferRef *frames_ref; -int methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX; -int matched_methods; +const AVCodecHWConfig *config; +HWDevice *dev = NULL; +AVBufferRef *frames_ref = NULL; +int i; if (ost->filter) { frames_ref = av_buffersink_get_hw_frames_ctx(ost->filter->filter); if (frames_ref && ((AVHWFramesContext*)frames_ref->data)->format == -ost->enc_ctx->pix_fmt) -methods |= AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX; +ost->enc_ctx->pix_fmt) { +// Matching format, will try to use hw_frames_ctx. +} else { +frames_ref = NULL; +} } -dev = hw_device_match_by_codec(ost->enc, ost->enc_ctx->pix_fmt, - methods, _methods); -if (dev) { -if (matched_methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) { -ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); -if (!ost->enc_ctx->hw_device_ctx) -return AVERROR(ENOMEM); -} -if (matched_methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) { +for (i = 0;; i++) { +config = avcodec_get_hw_config(ost->enc, i); +if (!config) +break; + +if (frames_ref && +config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX && +(config->pix_fmt == AV_PIX_FMT_NONE || + config->pix_fmt == ost->enc_ctx->pix_fmt)) { +av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using input " + "frames context (format %s) with %s encoder.\n", +
[FFmpeg-cvslog] Revert "avcodec/proresenc_anatoliy: support for more color matrix for proresenc"
ffmpeg | branch: master | Limin Wang | Mon May 4 05:22:51 2020 +0800| [aa6d32ae43dbd7ec43e4c86ca05ad2137ec6a4bc] | committer: Limin Wang Revert "avcodec/proresenc_anatoliy: support for more color matrix for proresenc" This reverts commit e0eed1fd523ec5d0cc390a08c468dbc57316378a. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa6d32ae43dbd7ec43e4c86ca05ad2137ec6a4bc --- libavcodec/proresenc_anatoliy.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index afc6eea7be..11d05022dc 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -55,8 +55,7 @@ static const int bitrate_table[6] = { 1000, 2100, 3500, 5400, 7000, 1}; static const int valid_primaries[9] = { AVCOL_PRI_RESERVED0, AVCOL_PRI_BT709, AVCOL_PRI_UNSPECIFIED, AVCOL_PRI_BT470BG, AVCOL_PRI_SMPTE170M, AVCOL_PRI_BT2020, AVCOL_PRI_SMPTE431, AVCOL_PRI_SMPTE432,INT_MAX }; -static const int valid_trc[6]= { AVCOL_TRC_RESERVED0, AVCOL_TRC_BT709, AVCOL_TRC_UNSPECIFIED, AVCOL_TRC_SMPTE2084, - AVCOL_TRC_ARIB_STD_B67, INT_MAX }; +static const int valid_trc[4]= { AVCOL_TRC_RESERVED0, AVCOL_TRC_BT709, AVCOL_TRC_UNSPECIFIED, INT_MAX }; static const int valid_colorspace[5] = { AVCOL_SPC_BT709, AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_SMPTE170M, AVCOL_SPC_BT2020_NCL, INT_MAX }; @@ -758,9 +757,9 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt, *buf++ = frame_flags; *buf++ = 0; /* reserved */ /* only write color properties, if valid value. set to unspecified otherwise */ -*buf++ = ff_int_from_list_or_default(avctx, "frame color primaries", avctx->color_primaries, valid_primaries, 0); -*buf++ = ff_int_from_list_or_default(avctx, "frame color trc", avctx->color_trc, valid_trc, 0); -*buf++ = ff_int_from_list_or_default(avctx, "frame colorspace", avctx->colorspace, valid_colorspace, 0); +*buf++ = ff_int_from_list_or_default(avctx, "frame color primaries", pict->color_primaries, valid_primaries, 0); +*buf++ = ff_int_from_list_or_default(avctx, "frame color trc", pict->color_trc, valid_trc, 0); +*buf++ = ff_int_from_list_or_default(avctx, "frame colorspace", pict->colorspace, valid_colorspace, 0); if (avctx->profile >= FF_PROFILE_PRORES_) { if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10) { *buf++ = 0xA0;/* src b64a and no alpha */ ___ 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 missing support for reserved_payload_extension_data SEI bits
ffmpeg | branch: master | James Almer | Fri Apr 24 17:41:47 2020 -0300| [3d51d3b42d0eee10301b06aaa814454c5e38eed6] | committer: James Almer avcodec/cbs_h265: add missing support for reserved_payload_extension_data SEI bits Fixes ticket #8622 Reviewed-by: Andreas Rheinhardt Reviewed-by: Mark Thompson Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d51d3b42d0eee10301b06aaa814454c5e38eed6 --- libavcodec/cbs_h2645.c| 1 + libavcodec/cbs_h265.h | 1 + libavcodec/cbs_h265_syntax_template.c | 85 --- 3 files changed, 70 insertions(+), 17 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 095e449ddc..b432921ecc 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -553,6 +553,7 @@ static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload) av_buffer_unref(>payload.other.data_ref); break; } +av_buffer_unref(>extension_data.data_ref); } static void cbs_h265_free_sei(void *opaque, uint8_t *content) diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h index 2c1e153ad9..73897f77a4 100644 --- a/libavcodec/cbs_h265.h +++ b/libavcodec/cbs_h265.h @@ -715,6 +715,7 @@ typedef struct H265RawSEIPayload { AVBufferRef *data_ref; } other; } payload; +H265RawExtensionData extension_data; } H265RawSEIPayload; typedef struct H265RawSEI { diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index ed08b06e9c..d3ac618db6 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -1564,7 +1564,8 @@ static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw, static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIBufferingPeriod *current, - uint32_t *payload_size) + uint32_t *payload_size, + int *more_data) { CodedBitstreamH265Context *h265 = ctx->priv_data; const H265RawSPS *sps; @@ -1658,8 +1659,15 @@ static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw, else infer(use_alt_cpb_params_flag, 0); #else -if (current->use_alt_cpb_params_flag) +// If unknown extension data exists, then use_alt_cpb_params_flag is +// coded in the bitstream and must be written even if it's 0. +if (current->use_alt_cpb_params_flag || *more_data) { flag(use_alt_cpb_params_flag); +// Ensure this bit is not the last in the payload by making the +// more_data_in_payload() check evaluate to true, so it may not +// be mistaken as something else by decoders. +*more_data = 1; +} #endif return 0; @@ -2057,11 +2065,48 @@ static int FUNC(sei_alpha_channel_info)(CodedBitstreamContext *ctx, return 0; } +static int FUNC(payload_extension)(CodedBitstreamContext *ctx, RWContext *rw, + H265RawExtensionData *current, uint32_t payload_size, + int cur_pos) +{ +int err; +size_t byte_length, k; + +#ifdef READ +GetBitContext tmp; +int bits_left, payload_zero_bits; + +if (!cbs_h265_payload_extension_present(rw, payload_size, cur_pos)) +return 0; + +bits_left = 8 * payload_size - cur_pos; +tmp = *rw; +if (bits_left > 8) +skip_bits_long(, bits_left - 8); +payload_zero_bits = get_bits(, FFMIN(bits_left, 8)); +if (!payload_zero_bits) +return AVERROR_INVALIDDATA; +payload_zero_bits = ff_ctz(payload_zero_bits); +current->bit_length = bits_left - payload_zero_bits - 1; +allocate(current->data, (current->bit_length + 7) / 8); +#endif + +byte_length = (current->bit_length + 7) / 8; +for (k = 0; k < byte_length; k++) { +int length = FFMIN(current->bit_length - k * 8, 8); +xu(length, reserved_payload_extension_data, current->data[k], + 0, MAX_UINT_BITS(length), 0); +} + +return 0; +} + static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEIPayload *current, int prefix) { int err, i; -int start_position, end_position; +int start_position, current_position; +int more_data = !!current->extension_data.bit_length; #ifdef READ start_position = get_bits_count(rw); @@ -2093,8 +2138,15 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, CHECK(FUNC(sei_ ## name)(ctx, rw, >payload.name, \ >payload_size)); \ break +#define SEI_TYPE_E(type, prefix_valid, suffix_valid, name) \ +case HEVC_SEI_TYPE_ ## type: \ +SEI_TYPE_CHECK_VALID(name, prefix_valid, suffix_valid); \ +CHECK(FUNC(sei_ ## name)(ctx,
[FFmpeg-cvslog] avcodec/cbs_h265: fix writing extension_data bits
ffmpeg | branch: release/4.2 | James Almer | Mon Apr 20 15:25:58 2020 -0300| [31c523469a290c6a9b6d5c1d9279b4d74e9518f2] | committer: James Almer avcodec/cbs_h265: fix writing extension_data bits We only care about the right most bit. Signed-off-by: James Almer (cherry picked from commit 38d1815cc65dd447de80760895ee008cfc9a0091) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31c523469a290c6a9b6d5c1d9279b4d74e9518f2 --- libavcodec/cbs_h265_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 15114548c6..836bb6db58 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -80,7 +80,7 @@ static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw, } #else for (k = 0; k < current->bit_length; k++) -xu(1, extension_data, current->data[k / 8] >> (7 - k % 8), 0, 1, 0); +xu(1, extension_data, current->data[k / 8] >> (7 - k % 8) & 1, 0, 1, 0); #endif return 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_h265: fix writing extension_data bits
ffmpeg | branch: release/4.0 | James Almer | Mon Apr 20 15:25:58 2020 -0300| [e4c8d7d5da38e2a8bafb8064413c4027a258f688] | committer: James Almer avcodec/cbs_h265: fix writing extension_data bits We only care about the right most bit. Signed-off-by: James Almer (cherry picked from commit 38d1815cc65dd447de80760895ee008cfc9a0091) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e4c8d7d5da38e2a8bafb8064413c4027a258f688 --- libavcodec/cbs_h265_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 140c827c9d..d1ccebcf99 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -80,7 +80,7 @@ static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw, } #else for (k = 0; k < current->bit_length; k++) -xu(1, extension_data, current->data[k / 8] >> (7 - k % 8), 0, 1); +xu(1, extension_data, current->data[k / 8] >> (7 - k % 8) & 1, 0, 1); #endif return 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_h265: fix writing extension_data bits
ffmpeg | branch: release/4.1 | James Almer | Mon Apr 20 15:25:58 2020 -0300| [6376b6b00ba3d4705de077a0b6f6de3aefe33ff4] | committer: James Almer avcodec/cbs_h265: fix writing extension_data bits We only care about the right most bit. Signed-off-by: James Almer (cherry picked from commit 38d1815cc65dd447de80760895ee008cfc9a0091) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6376b6b00ba3d4705de077a0b6f6de3aefe33ff4 --- libavcodec/cbs_h265_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index e43f3caf99..52e45aa6db 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -80,7 +80,7 @@ static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw, } #else for (k = 0; k < current->bit_length; k++) -xu(1, extension_data, current->data[k / 8] >> (7 - k % 8), 0, 1, 0); +xu(1, extension_data, current->data[k / 8] >> (7 - k % 8) & 1, 0, 1, 0); #endif return 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_h265: move the payload_extension_present check into its own function
ffmpeg | branch: master | James Almer | Mon Apr 20 17:33:55 2020 -0300| [3a41bac4e2d0891dcfc19b73a3dfae0e70237084] | committer: James Almer avcodec/cbs_h265: move the payload_extension_present check into its own function Will be reused in the following patch. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3a41bac4e2d0891dcfc19b73a3dfae0e70237084 --- libavcodec/cbs_h2645.c| 10 ++ libavcodec/cbs_h265_syntax_template.c | 9 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index d42073cc5a..095e449ddc 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -233,6 +233,16 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, return 0; } +// payload_extension_present() - true if we are before the last 1-bit +// in the payload structure, which must be in the last byte. +static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t payload_size, + int cur_pos) +{ +int bits_left = payload_size * 8 - cur_pos; +return (bits_left > 0 && +(bits_left > 7 || show_bits(gbc, bits_left) & MAX_UINT_BITS(bits_left - 1))); +} + #define HEADER(name) do { \ ff_cbs_trace_header(ctx, name); \ } while (0) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index a51b12cfc6..ed08b06e9c 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -1572,7 +1572,7 @@ static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw, int err, i, length; #ifdef READ -int start_pos, end_pos, bits_left; +int start_pos, end_pos; start_pos = get_bits_count(rw); #endif @@ -1651,12 +1651,9 @@ static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw, } #ifdef READ -// payload_extension_present() - true if we are before the last 1-bit -// in the payload structure, which must be in the last byte. end_pos = get_bits_count(rw); -bits_left = *payload_size * 8 - (end_pos - start_pos); -if (bits_left > 0 && -(bits_left > 7 || ff_ctz(show_bits(rw, bits_left)) < bits_left - 1)) +if (cbs_h265_payload_extension_present(rw, *payload_size, + end_pos - start_pos)) flag(use_alt_cpb_params_flag); else infer(use_alt_cpb_params_flag, 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_h265: rename H265RawPSExtensionData to H265RawExtensionData
ffmpeg | branch: master | James Almer | Mon Apr 20 15:33:18 2020 -0300| [bdfc1d3cd33079b44dcb1f2ba02bfc69b811a3ca] | committer: James Almer avcodec/cbs_h265: rename H265RawPSExtensionData to H265RawExtensionData So that NAL types other than Parameter Set ones may use it. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bdfc1d3cd33079b44dcb1f2ba02bfc69b811a3ca --- libavcodec/cbs_h265.h | 10 +- libavcodec/cbs_h265_syntax_template.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h index ad746bf35f..2c1e153ad9 100644 --- a/libavcodec/cbs_h265.h +++ b/libavcodec/cbs_h265.h @@ -182,11 +182,11 @@ typedef struct H265RawVUI { uint8_t log2_max_mv_length_vertical; } H265RawVUI; -typedef struct H265RawPSExtensionData { +typedef struct H265RawExtensionData { uint8_t *data; size_t bit_length; AVBufferRef *data_ref; -} H265RawPSExtensionData; +} H265RawExtensionData; typedef struct H265RawVPS { H265RawNALUnitHeader nal_unit_header; @@ -221,7 +221,7 @@ typedef struct H265RawVPS { H265RawHRDParameters hrd_parameters[HEVC_MAX_LAYER_SETS]; uint8_t vps_extension_flag; -H265RawPSExtensionData extension_data; +H265RawExtensionData extension_data; } H265RawVPS; typedef struct H265RawSTRefPicSet { @@ -325,7 +325,7 @@ typedef struct H265RawSPS { uint8_t sps_scc_extension_flag; uint8_t sps_extension_4bits; -H265RawPSExtensionData extension_data; +H265RawExtensionData extension_data; // Range extension. uint8_t transform_skip_rotation_enabled_flag; @@ -413,7 +413,7 @@ typedef struct H265RawPPS { uint8_t pps_scc_extension_flag; uint8_t pps_extension_4bits; -H265RawPSExtensionData extension_data; +H265RawExtensionData extension_data; // Range extension. uint8_t log2_max_transform_skip_block_size_minus2; diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 0696eeeb9e..a51b12cfc6 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -59,7 +59,7 @@ static int FUNC(byte_alignment)(CodedBitstreamContext *ctx, RWContext *rw) } static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw, -H265RawPSExtensionData *current) +H265RawExtensionData *current) { int err; size_t 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] avformat/matroskadec: Free right buffer on error
ffmpeg | branch: master | Andreas Rheinhardt | Sun May 3 08:35:25 2020 +0200| [5767a2ed74078385a5ff70a7a487c1d4c367d729] | committer: Andreas Rheinhardt avformat/matroskadec: Free right buffer on error Since commit 979b5b89594c7628bd846c63198cb64ef9d81d16, reverting the Matroska ContentCompression is no longer done inside matroska_parse_frame() (the function that creates AVPackets out of the parsed data (unless we are dealing with certain codecs that need special handling)), but instead in matroska_parse_block(). As a consequence, the data that matroska_parse_frame() receives is no longer always owned by an AVBuffer; it is owned by an AVBuffer iff no ContentCompression needed to be reversed; otherwise the data is independently allocated and needs to be freed on error. Whether the data is owned by an AVBuffer or not is indicated by a variable buf of type AVBufferRef *: If it is NULL, the data is independently allocated, if not it is owned by the underlying AVBuffer (and is used to avoid copying the data when creating the AVPackets). Because the allocation of the buffer holding the uncompressed data happens outside of matroska_parse_frame() (if a ContentCompression needs to be reversed), the data is passed as uint8_t ** in order to not leave any dangling pointers behind in matroska_parse_block() should the data need to be freed: In case of errors, said uint8_t ** would be av_freep()'ed in case buf indicated the data to be independently allocated. Yet there is a problem with this: Some codecs (namely WavPack and ProRes) need special handling: Their packets are only stored in Matroska in a stripped form to save space and the demuxer reconstructs full packets. This involved allocating a new, enlarged buffer. And if an error happens when trying to wrap this new buffer into an AVBuffer, this buffer needs to be freed; yet instead the given uint8_t ** (holding the uncompressed, yet still stripped form of the data) would be freed (av_freep()'ed) which certainly leads to a memleak of the new buffer; even worse, in case the track does not use ContentCompression the given uint8_t ** must not be freed as the actual data is owned by an AVBuffer and the data given to matroska_parse_frame() is not the start of the actual allocated buffer at all. Both of these issues are fixed by always freeing the current data in case it is independently allocated. Furthermore, while it would be possible to track whether the pointer from matroska_parse_block() needs to be reset or not, there is no gain in doing so, as the pointer is not used at all afterwards and the sematics are clear: If the data passed to matroska_parse_frame() is independently allocated, then ownership of the data passes to matroska_parse_frame(). So don't pass the data via uint8_t **. Fixes Coverity ID 1462661 (the issue as described by Coverity is btw a false positive: It thinks that this error can be triggered by ProRes with a size of zero after reconstructing the original packets, but the reconstructed packets can't have a size of zero). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5767a2ed74078385a5ff70a7a487c1d4c367d729 --- libavformat/matroskadec.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 917c106258..981fb4bc20 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3414,13 +3414,13 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, static int matroska_parse_frame(MatroskaDemuxContext *matroska, MatroskaTrack *track, AVStream *st, -AVBufferRef *buf, uint8_t **data, int pkt_size, +AVBufferRef *buf, uint8_t *data, int pkt_size, uint64_t timecode, uint64_t lace_duration, int64_t pos, int is_keyframe, uint8_t *additional, uint64_t additional_id, int additional_size, int64_t discard_padding) { -uint8_t *pkt_data = *data; +uint8_t *pkt_data = data; int res = 0; AVPacket pktl, *pkt = @@ -3432,7 +3432,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, goto fail; } if (!buf) -av_freep(data); +av_freep(); buf = NULL; } @@ -3445,7 +3445,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, goto fail; } if (!buf) -av_freep(data); +av_freep(); buf = NULL; } @@ -3525,7 +3525,7 @@ FF_ENABLE_DEPRECATION_WARNINGS no_output: fail: if (!buf) -av_freep(data); +av_free(pkt_data); return res; } @@ -3659,7 +3659,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf if (res)
[FFmpeg-cvslog] doc/muxers: remove hls_fmp4_init_resend parameter
ffmpeg | branch: master | Steven Liu | Mon May 4 13:39:44 2020 +0800| [0b0a36b4f1e8fcc1cb74d74d4f240bbb42d5f4d4] | committer: Steven Liu doc/muxers: remove hls_fmp4_init_resend parameter the parameter should boolean > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b0a36b4f1e8fcc1cb74d74d4f240bbb42d5f4d4 --- doc/muxers.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 536433b1d3..abdeaf2b22 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -847,7 +847,7 @@ fmp4 files may be used in HLS version 7 and above. @item hls_fmp4_init_filename @var{filename} Set filename to the fragment files header file, default filename is @file{init.mp4}. -@item hls_fmp4_init_resend @var{filename} +@item hls_fmp4_init_resend Resend init file after m3u8 file refresh every time, default is @var{0}. When @code{var_stream_map} is set with two or more variant streams, the ___ 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/matroskaenc: Fix memleak upon encountering bogus chapter
ffmpeg | branch: master | Andreas Rheinhardt | Mon Apr 27 05:42:09 2020 +0200| [cb255b616cf1ebc6bc89b3538b6b7465dc2c526b] | committer: Andreas Rheinhardt avformat/matroskaenc: Fix memleak upon encountering bogus chapter Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cb255b616cf1ebc6bc89b3538b6b7465dc2c526b --- libavformat/matroskaenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index cccfdb41b6..36b29e2d8d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1463,6 +1463,7 @@ static int mkv_write_chapters(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Invalid chapter start (%"PRId64") or end (%"PRId64").\n", chapterstart, chapterend); +ffio_free_dyn_buf(_cp); return AVERROR_INVALIDDATA; } ___ 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/matroskaenc: Check mimetypes earlier
ffmpeg | branch: master | Andreas Rheinhardt | Sun Nov 3 13:25:08 2019 +0100| [449eaeb7a72a9fca437923660bfcdb6af844b353] | committer: Andreas Rheinhardt avformat/matroskaenc: Check mimetypes earlier This avoids errors lateron after the file header has already been partially written. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=449eaeb7a72a9fca437923660bfcdb6af844b353 --- libavformat/matroskaenc.c | 39 --- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 36b29e2d8d..7cf7724f89 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1687,6 +1687,23 @@ static int mkv_write_tags(AVFormatContext *s) return 0; } +static const char *get_mimetype(const AVStream *st) +{ +const AVDictionaryEntry *t; + +if (t = av_dict_get(st->metadata, "mimetype", NULL, 0)) +return t->value; +if (st->codecpar->codec_id != AV_CODEC_ID_NONE) { +const AVCodecDescriptor *desc = avcodec_descriptor_get(st->codecpar->codec_id); +if (desc && desc->mime_types) { +return desc->mime_types[0]; +} else if (st->codecpar->codec_id == AV_CODEC_ID_TEXT) +return "text/plain"; +} + +return NULL; +} + static int mkv_write_attachments(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; @@ -1707,7 +1724,7 @@ static int mkv_write_attachments(AVFormatContext *s) mkv_track *track = >tracks[i]; ebml_master attached_file; const AVDictionaryEntry *t; -const char *mimetype = NULL; +const char *mimetype; if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT) continue; @@ -1721,21 +1738,9 @@ static int mkv_write_attachments(AVFormatContext *s) return AVERROR(EINVAL); } put_ebml_string(dyn_cp, MATROSKA_ID_FILENAME, t->value); -if (t = av_dict_get(st->metadata, "mimetype", NULL, 0)) -mimetype = t->value; -else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) { -const AVCodecDescriptor *desc = avcodec_descriptor_get(st->codecpar->codec_id); -if (desc && desc->mime_types) { -mimetype = desc->mime_types[0]; -} else if (st->codecpar->codec_id == AV_CODEC_ID_TEXT) -mimetype = "text/plain"; -} -if (!mimetype) { -av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype tag and " -"it cannot be deduced from the codec id.\n", i); -return AVERROR(EINVAL); -} +mimetype = get_mimetype(st); +av_assert0(mimetype); put_ebml_string(dyn_cp, MATROSKA_ID_FILEMIMETYPE, mimetype); put_ebml_binary(dyn_cp, MATROSKA_ID_FILEDATA, st->codecpar->extradata, st->codecpar->extradata_size); put_ebml_uid(dyn_cp, MATROSKA_ID_FILEUID, track->uid); @@ -2672,6 +2677,10 @@ static int mkv_init(struct AVFormatContext *s) if (mkv->mode == MODE_WEBM) { av_log(s, AV_LOG_WARNING, "Stream %d will be ignored " "as WebM doesn't support attachments.\n", i); +} else if (!get_mimetype(st)) { +av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype " + "tag and it cannot be deduced from the codec id.\n", i); +return AVERROR(EINVAL); } mkv->nb_attachments++; continue; ___ 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/matroskaenc: Write SeekHead when livestreaming
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 26 10:39:27 2020 +0200| [d13feae0f85bebdd35e44ccbadf974b10dc3cef1] | committer: Andreas Rheinhardt avformat/matroskaenc: Write SeekHead when livestreaming Commit 6fd300ac6c2c3871736ce0e6df95603255004dc6 added support for WebM Chunk livestreaming; in this case, both the header as well as each Cluster is written to a file of its own, so that even if the AVIOContext seems seekable, the muxer has to behave as if it were not. Yet one of the added checks makes no sense: It ensures that no SeekHead is written preliminarily (and hence no SeekHead is written at all) if the option for livestreaming is set, although one should write the SeekHead in this case when writing the Header. E.g. the WebM-DASH specification [1] never forbids writing a SeekHead and in some instances (that don't apply here) even requires it (if Cues are written after the Clusters). [1]: https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d13feae0f85bebdd35e44ccbadf974b10dc3cef1 --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index e1528a9162..f69b3c39da 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1896,7 +1896,7 @@ static int mkv_write_header(AVFormatContext *s) if (ret < 0) return ret; -if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) { +if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) || mkv->is_live) { ret = mkv_write_seekhead(pb, mkv, 0, avio_tell(pb)); 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] avformat/matroskaenc: Only write Cluster if it has in fact been opened
ffmpeg | branch: master | Andreas Rheinhardt | Sat May 2 02:18:44 2020 +0200| [68c7186d94a08a3c993116530f5b66b243407a48] | committer: Andreas Rheinhardt avformat/matroskaenc: Only write Cluster if it has in fact been opened Since commit 4aa0665f393847c35387a1c673e62346d0acfc95, the dynamic buffer destined for the contents of the current Cluster is no longer constantly allocated, reallocated and then freed after writing the content; instead it is reset and reused when closing a Cluster. Yet the code in mkv_write_trailer() still checked for whether a Cluster is open by checking whether the pointer to the dynamic buffer is NULL or not (instead of checking whether the position of the current Cluster is -1 or not). If a Cluster was not open, an empty Cluster would be output. One usually does not run into this issue, because unless there are errors, there are only three possibilities to not have an opened Cluster at the end of writing a packet: The first is if one sent an audio packet to the muxer. It might trigger closing and outputting the old Cluster, but because the muxer caches audio packets internally, it would not be output immediately and therefore no new Cluster would be opened. The second is an audio packet that does not contain data (such packets are sometimes sent for side-data only, e.g. by the FLAC encoder). The only difference to the first scenario is that such packets are not cached. The third is if one explicitly flushes the muxer by sending a NULL packet via av_write_frame(). If one also allows for errors, then there is also another possibility: Caching the audio packet may fail in the first scenario. If one calls av_write_trailer() after the first scenario, the cached audio packet will be output when writing the trailer, for which a Cluster is opened and everything is fine; because flushing the muxer does currently not output the cached audio packet (if one is cached), the issue also does not exist if an audio packet has been cached before flushing. The issue only exists in one of the other scenarios. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68c7186d94a08a3c993116530f5b66b243407a48 --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 784973a951..e1528a9162 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2451,7 +2451,7 @@ static int mkv_write_trailer(AVFormatContext *s) } } -if (mkv->cluster_bc) { +if (mkv->cluster_pos != -1) { end_ebml_master_crc32(pb, >cluster_bc, mkv, MATROSKA_ID_CLUSTER, 0, 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] avformat/matroskaenc: Replace impossible condition with assert
ffmpeg | branch: master | Andreas Rheinhardt | Tue Apr 28 02:24:16 2020 +0200| [ca0a38f2f7803ab8fa12913d0385d4c70f8d6345] | committer: Andreas Rheinhardt avformat/matroskaenc: Replace impossible condition with assert If a FLAC track uses an unconventional channel layout, the Matroska muxer adds a WAVEFORMATEXTENSIBLE_CHANNEL_MASK VorbisComment to the CodecPrivate to preserve this information. And given that FLAC uses 24bit length fields, the muxer checks if the length is more than this and errors out if it is. Yet this can never happen, because we create the AVDictionary that is the source for the VorbisComment. It only contains exactly one entry that can't grow infinitely large (in fact, the length of the VorbisComment is <= 4 + 33 + 1 + 18 + strlen(LIBAVFORMAT_IDENT)). So we can simply assert the size to be < (1 << 24) - 4. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca0a38f2f7803ab8fa12913d0385d4c70f8d6345 --- libavformat/matroskaenc.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index f69b3c39da..87dff6ab7d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -631,10 +631,7 @@ static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, av_dict_set(, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0); len = ff_vorbiscomment_length(dict, vendor, NULL, 0); -if (len >= (1 << 24) - 4) { -av_dict_free(); -return AVERROR(EINVAL); -} +av_assert1(len < (1 << 24) - 4); data = av_malloc(len + 4); if (!data) { ___ 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/vorbiscomment: Replace AVDictionary ** by const AVDictionary *
ffmpeg | branch: master | Andreas Rheinhardt | Tue Apr 28 03:03:36 2020 +0200| [704d7c9f4616d71db1a1baa0a1726c77a9957521] | committer: Andreas Rheinhardt avformat/vorbiscomment: Replace AVDictionary ** by const AVDictionary * ff_vorbiscomment_write() used an AVDictionary ** parameter for a dictionary whose contents ought to be written; yet this can be replaced by AVDictionary * since commit 042ca05f0fdc5f4d56a3e9b94bc9cd67bca9a4bc; and this in turn can be replaced by const AVDictionary * to indicate that the dictionary isn't modified; the latter also applies to ff_vorbiscomment_length(). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=704d7c9f4616d71db1a1baa0a1726c77a9957521 --- libavformat/flacenc.c | 2 +- libavformat/matroskaenc.c | 2 +- libavformat/oggenc.c| 2 +- libavformat/vorbiscomment.c | 10 +- libavformat/vorbiscomment.h | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index a043274df6..0e88e18355 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -76,7 +76,7 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m, bytestream_put_byte(, last_block ? 0x84 : 0x04); bytestream_put_be24(, len); -ff_vorbiscomment_write(, m, vendor, NULL, 0); +ff_vorbiscomment_write(, *m, vendor, NULL, 0); avio_write(pb, p0, len+4); av_freep(); diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 87dff6ab7d..80ff341a90 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -643,7 +643,7 @@ static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, AV_WB24(data + 1, len); p = data + 4; -ff_vorbiscomment_write(, , vendor, NULL, 0); +ff_vorbiscomment_write(, dict, vendor, NULL, 0); avio_write(pb, data, len + 4); diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index fbd14fedf9..cc9a899a4c 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -308,7 +308,7 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact, p0 = p; p += offset; -ff_vorbiscomment_write(, m, vendor, chapters, nb_chapters); +ff_vorbiscomment_write(, *m, vendor, chapters, nb_chapters); if (framing_bit) bytestream_put_byte(, 1); diff --git a/libavformat/vorbiscomment.c b/libavformat/vorbiscomment.c index fb5c655a23..edaeae2772 100644 --- a/libavformat/vorbiscomment.c +++ b/libavformat/vorbiscomment.c @@ -38,7 +38,7 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = { { 0 } }; -int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string, +int64_t ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters) { int64_t len = 8; @@ -62,7 +62,7 @@ int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string, return len; } -int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m, +int ff_vorbiscomment_write(uint8_t **p, const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters) { @@ -74,11 +74,11 @@ int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m, cm_count += av_dict_count(chapters[i]->metadata) + 1; } } -if (*m) { -int count = av_dict_count(*m) + cm_count; +if (m) { +int count = av_dict_count(m) + cm_count; AVDictionaryEntry *tag = NULL; bytestream_put_le32(p, count); -while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) { +while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) { int64_t len1 = strlen(tag->key); int64_t len2 = strlen(tag->value); if (len1+1+len2 > UINT32_MAX) diff --git a/libavformat/vorbiscomment.h b/libavformat/vorbiscomment.h index 4ff3dd6c27..af9bd75cd7 100644 --- a/libavformat/vorbiscomment.h +++ b/libavformat/vorbiscomment.h @@ -34,7 +34,7 @@ * For no string, set to an empty string. * @return The length in bytes. */ -int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string, +int64_t ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters); /** @@ -49,7 +49,7 @@ int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string, * @param chapters The chapters to write. * @param nb_chapters The number of chapters to write. */ -int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m, +int ff_vorbiscomment_write(uint8_t **p, const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters);
[FFmpeg-cvslog] avformat/vorbiscomment: Switch to AVIOContext from bytestream API
ffmpeg | branch: master | Andreas Rheinhardt | Tue Apr 28 04:54:05 2020 +0200| [6397b4d6a241692a1c7bb611a3fd42b0de2d32b5] | committer: Andreas Rheinhardt avformat/vorbiscomment: Switch to AVIOContext from bytestream API Up until now ff_vorbiscomment_write() used the bytestream API to write VorbisComments. Therefore the caller had to provide a sufficiently large buffer to write the output. Yet two of the three callers (namely the FLAC and the Matroska muxer) actually want the output to be written via an AVIOContext; therefore they allocated buffers of the right size just for this purpose (i.e. they get freed immediately afterwards). Only the Ogg muxer actually wants a buffer. But given that it is easy to wrap a buffer into an AVIOContext this commit changes ff_vorbiscomment_write() to use an AVIOContext for its output. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6397b4d6a241692a1c7bb611a3fd42b0de2d32b5 --- libavformat/flacenc.c | 18 -- libavformat/matroskaenc.c | 18 -- libavformat/oggenc.c| 12 ++-- libavformat/vorbiscomment.c | 44 ++-- libavformat/vorbiscomment.h | 9 - 5 files changed, 40 insertions(+), 61 deletions(-) diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index 0e88e18355..b947a3b067 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -29,7 +29,6 @@ #include "id3v2.h" #include "internal.h" #include "vorbiscomment.h" -#include "libavcodec/bytestream.h" typedef struct FlacMuxerContext { @@ -62,25 +61,16 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m, { const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT; int64_t len; -uint8_t *p, *p0; ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL); len = ff_vorbiscomment_length(*m, vendor, NULL, 0); if (len >= ((1<<24) - 4)) return AVERROR(EINVAL); -p0 = av_malloc(len+4); -if (!p0) -return AVERROR(ENOMEM); -p = p0; - -bytestream_put_byte(, last_block ? 0x84 : 0x04); -bytestream_put_be24(, len); -ff_vorbiscomment_write(, *m, vendor, NULL, 0); - -avio_write(pb, p0, len+4); -av_freep(); -p = NULL; + +avio_w8(pb, last_block ? 0x84 : 0x04); +avio_wb24(pb, len); +ff_vorbiscomment_write(pb, *m, vendor, NULL, 0); return 0; } diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 80ff341a90..c07aa4f7e4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -624,7 +624,7 @@ static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, const char *vendor = (s->flags & AVFMT_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT; AVDictionary *dict = NULL; -uint8_t buf[32], *data, *p; +uint8_t buf[32]; int64_t len; snprintf(buf, sizeof(buf), "0x%"PRIx64, par->channel_layout); @@ -633,21 +633,11 @@ static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, len = ff_vorbiscomment_length(dict, vendor, NULL, 0); av_assert1(len < (1 << 24) - 4); -data = av_malloc(len + 4); -if (!data) { -av_dict_free(); -return AVERROR(ENOMEM); -} - -data[0] = 0x84; -AV_WB24(data + 1, len); - -p = data + 4; -ff_vorbiscomment_write(, dict, vendor, NULL, 0); +avio_w8(pb, 0x84); +avio_wb24(pb, len); -avio_write(pb, data, len + 4); +ff_vorbiscomment_write(pb, dict, vendor, NULL, 0); -av_freep(); av_dict_free(); } diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index cc9a899a4c..3aff3c7a08 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -294,8 +294,9 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact, AVChapter **chapters, unsigned int nb_chapters) { const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT; +AVIOContext pb; int64_t size; -uint8_t *p, *p0; +uint8_t *p; ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL); @@ -305,15 +306,14 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact, p = av_mallocz(size); if (!p) return NULL; -p0 = p; -p += offset; -ff_vorbiscomment_write(, *m, vendor, chapters, nb_chapters); +ffio_init_context(, p + offset, size - offset, 1, NULL, NULL, NULL, NULL); +ff_vorbiscomment_write(, *m, vendor, chapters, nb_chapters); if (framing_bit) -bytestream_put_byte(, 1); +avio_w8(, 1); *header_len = size; -return p0; +return p; } static int ogg_build_flac_headers(AVCodecParameters *par, diff --git a/libavformat/vorbiscomment.c b/libavformat/vorbiscomment.c index edaeae2772..a929634cc0 100644 ---
[FFmpeg-cvslog] avformat/matroskaenc: Make sure UIDs of delayed chapters are != 0
ffmpeg | branch: master | Andreas Rheinhardt | Mon Apr 27 03:12:24 2020 +0200| [0aed3002ad3104489d0e378dc9893271d14e0e5b] | committer: Andreas Rheinhardt avformat/matroskaenc: Make sure UIDs of delayed chapters are != 0 This has previously only been checked if the chapters were initially available, but not if they were only written in the trailer. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0aed3002ad3104489d0e378dc9893271d14e0e5b --- libavformat/matroskaenc.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c07aa4f7e4..cccfdb41b6 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1437,6 +1437,12 @@ static int mkv_write_chapters(AVFormatContext *s) if (!s->nb_chapters || mkv->wrote_chapters) return 0; +for (i = 0; i < s->nb_chapters; i++) +if (!s->chapters[i]->id) { +mkv->chapter_id_offset = 1; +break; +} + mkv_add_seekhead_entry(mkv, MATROSKA_ID_CHAPTERS, avio_tell(pb)); ret = start_ebml_master_crc32(_cp, mkv); @@ -1863,12 +1869,6 @@ static int mkv_write_header(AVFormatContext *s) if (ret < 0) return ret; -for (i = 0; i < s->nb_chapters; i++) -if (!s->chapters[i]->id) { -mkv->chapter_id_offset = 1; -break; -} - ret = mkv_write_chapters(s); if (ret < 0) return ret; @@ -1879,6 +1879,7 @@ static int mkv_write_header(AVFormatContext *s) return ret; } +/* Must come after mkv_write_chapters() because of chapter_id_offset */ ret = mkv_write_tags(s); 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".