[FFmpeg-cvslog] avformat/flvenc: Avoid avio_write(pb, "", 0)
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 04:17:18 2024 +0100| [ee736ff80ed967999645147c974cd1941d5e6a21] | committer: Andreas Rheinhardt avformat/flvenc: Avoid avio_write(pb, "", 0) When the compiler chooses to inline put_amf_string(pb, ""), the avio_write(pb, "", 0) can be avoided. Happens with Clang-17 with -O1 and higher and GCC 13 with -O2 and higher here. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee736ff80ed967999645147c974cd1941d5e6a21 --- libavformat/flvenc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 7e410e627e..a7d4fa46a2 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -231,6 +231,9 @@ static void put_amf_string(AVIOContext *pb, const char *str) { size_t len = strlen(str); avio_wb16(pb, len); +// Avoid avio_write() if put_amf_string(pb, "") is inlined. +if (av_builtin_constant_p(len == 0) && len == 0) +return; avio_write(pb, str, len); } ___ 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/decode: log hwaccel name
ffmpeg | branch: master | Zhao Zhili | Thu Mar 14 11:40:03 2024 +0800| [c775163a8c032e20f25b79e63920f67e1b5b540d] | committer: Zhao Zhili avcodec/decode: log hwaccel name Many users mistakenly think that hwaccel is an instance of a decoder, and cannot find the corresponding decoder name in the logs. Log hwaccel name so user know hwaccel has taken effect. Signed-off-by: Zhao Zhili > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c775163a8c032e20f25b79e63920f67e1b5b540d --- libavcodec/decode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 4168cf6f2d..34bcb7cc64 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1326,8 +1326,8 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) goto try_again; } if (hw_config->hwaccel) { -av_log(avctx, AV_LOG_DEBUG, "Format %s requires hwaccel " - "initialisation.\n", desc->name); +av_log(avctx, AV_LOG_DEBUG, "Format %s requires hwaccel %s " + "initialisation.\n", desc->name, hw_config->hwaccel->p.name); err = hwaccel_init(avctx, hw_config->hwaccel); if (err < 0) goto try_again; ___ 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] Changelog: mention ffplay with hwaccel decoding support
ffmpeg | branch: master | Zhao Zhili | Mon Mar 18 23:26:14 2024 +0800| [4869171aa911fdfce67549bd56fdd0ff914d9380] | committer: Zhao Zhili Changelog: mention ffplay with hwaccel decoding support Signed-off-by: Zhao Zhili > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4869171aa911fdfce67549bd56fdd0ff914d9380 --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index e3ca52430c..c6e8f6bcaf 100644 --- a/Changelog +++ b/Changelog @@ -35,6 +35,7 @@ version : - AEA muxer - ffmpeg CLI loopback decoders - Support PacketTypeMetadata of PacketType in enhanced flv format +- ffplay with hwaccel decoding support (depends on vulkan renderer via libplacebo) version 6.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] avcodec/libx264: fix extradata when config annexb=0
ffmpeg | branch: master | Zhao Zhili | Sun Mar 17 11:34:57 2024 +0800| [5229778440bf81e8a929af2cde04dc1e2d2c65f5] | committer: Zhao Zhili avcodec/libx264: fix extradata when config annexb=0 AVCodecContext extradata should be an AVCDecoderConfigurationRecord when bitstream format is avcc. Simply concatenating the NALUs output by x264_encoder_headers does not form a standard AVCDecoderConfigurationRecord. The following cmd generates broken file before the patch: ffmpeg -i foo.mp4 -c:v libx264 -x264-params annexb=0 bar.mp4 Signed-off-by: Zhao Zhili > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5229778440bf81e8a929af2cde04dc1e2d2c65f5 --- configure| 2 +- libavcodec/libx264.c | 166 +++ 2 files changed, 143 insertions(+), 25 deletions(-) diff --git a/configure b/configure index 6d7b33b0ff..343edb38ab 100755 --- a/configure +++ b/configure @@ -3539,7 +3539,7 @@ libwebp_encoder_deps="libwebp" libwebp_anim_encoder_deps="libwebp" libx262_encoder_deps="libx262" libx264_encoder_deps="libx264" -libx264_encoder_select="atsc_a53" +libx264_encoder_select="atsc_a53 golomb" libx264rgb_encoder_deps="libx264" libx264rgb_encoder_select="libx264_encoder" libx265_encoder_deps="libx265" diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 4804dae6e9..2653941eb9 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -39,6 +39,7 @@ #include "packet_internal.h" #include "atsc_a53.h" #include "sei.h" +#include "golomb.h" #include #include @@ -848,6 +849,144 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) return 0; } +static int save_sei(AVCodecContext *avctx, x264_nal_t *nal) +{ +X264Context *x4 = avctx->priv_data; + +av_log(avctx, AV_LOG_INFO, "%s\n", nal->p_payload + 25); +x4->sei_size = nal->i_payload; +x4->sei = av_malloc(x4->sei_size); +if (!x4->sei) +return AVERROR(ENOMEM); + +memcpy(x4->sei, nal->p_payload, nal->i_payload); + +return 0; +} + +#if CONFIG_LIBX264_ENCODER +static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int nnal) +{ +X264Context *x4 = avctx->priv_data; +x264_nal_t *sps_nal = NULL; +x264_nal_t *pps_nal = NULL; +uint8_t *p, *sps; +int ret; + +/* We know it's in the order of SPS/PPS/SEI, but it's not documented in x264 API. + * The x264 param i_sps_id implies there is a single pair of SPS/PPS. + */ +for (int i = 0; i < nnal; i++) { +switch (nal[i].i_type) { +case NAL_SPS: +sps_nal = &nal[i]; +break; +case NAL_PPS: +pps_nal = &nal[i]; +break; +case NAL_SEI: +ret = save_sei(avctx, &nal[i]); +if (ret < 0) +return ret; +break; +} +} +if (!sps_nal || !pps_nal) +return AVERROR_EXTERNAL; + +avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 7; +avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); +if (!avctx->extradata) +return AVERROR(ENOMEM); + +// Now create AVCDecoderConfigurationRecord +p = avctx->extradata; +// Skip size part +sps = sps_nal->p_payload + 4; +*p++ = 1; // version +*p++ = sps[1]; // AVCProfileIndication +*p++ = sps[2]; // profile_compatibility +*p++ = sps[3]; // AVCLevelIndication +*p++ = 0xFF; +*p++ = 0xE0 | 0x01; // 3 bits reserved (111) + 5 bits number of sps +memcpy(p, sps_nal->p_payload + 2, sps_nal->i_payload - 2); +// Make sps has AV_INPUT_BUFFER_PADDING_SIZE padding, so it can be used +// with GetBitContext +sps = p + 2; +p += sps_nal->i_payload - 2; +*p++ = 1; +memcpy(p, pps_nal->p_payload + 2, pps_nal->i_payload - 2); +p += pps_nal->i_payload - 2; + +if (sps[3] != 66 && sps[3] != 77 && sps[3] != 88) { +GetBitContext gbc; +int chroma_format_idc; +int bit_depth_luma_minus8, bit_depth_chroma_minus8; + +/* It's not possible to have emulation prevention byte before + * bit_depth_chroma_minus8 due to the range of sps id, chroma_format_idc + * and so on. So we can read directly without need to escape emulation + * prevention byte. + * + * +4 to skip until sps id. + */ +init_get_bits8(&gbc, sps + 4, sps_nal->i_payload - 4 - 4); +// Skip sps id +get_ue_golomb_31(&gbc); +chroma_format_idc = get_ue_golomb_31(&gbc); +if (chroma_format_idc == 3) +skip_bits1(&gbc); +bit_depth_luma_minus8 = get_ue_golomb_31(&gbc); +bit_depth_chroma_minus8 = get_ue_golomb_31(&gbc); + +*p++ = 0xFC | chroma_format_idc; +*p++ = 0xF8 | bit_depth_luma_minus8; +*p++ = 0xF8 | bit_depth_chroma_minus8; +*p++ = 0; +} +av_assert2(avctx->extradata + avctx->extradata_size >= p); +avctx->extradata_size = p - avctx->extradat
[FFmpeg-cvslog] avcodec/dovi_rpu: use OR instead of addition
ffmpeg | branch: master | Niklas Haas | Thu Mar 21 13:50:45 2024 +0100| [d5648a806fda04eeb76e4c8ec9685e8ce19ecc44] | committer: Niklas Haas avcodec/dovi_rpu: use OR instead of addition > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5648a806fda04eeb76e4c8ec9685e8ce19ecc44 --- libavcodec/dovi_rpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/dovi_rpu.c b/libavcodec/dovi_rpu.c index 529062be30..6185fac230 100644 --- a/libavcodec/dovi_rpu.c +++ b/libavcodec/dovi_rpu.c @@ -145,7 +145,7 @@ static inline uint64_t get_ue_coef(GetBitContext *gb, const AVDOVIRpuDataHeader case RPU_COEFF_FIXED: ipart = get_ue_golomb_long(gb); fpart.u32 = get_bits_long(gb, hdr->coef_log2_denom); -return (ipart << hdr->coef_log2_denom) + fpart.u32; +return (ipart << hdr->coef_log2_denom) | fpart.u32; case RPU_COEFF_FLOAT: fpart.u32 = get_bits_long(gb, 32); @@ -164,7 +164,7 @@ static inline int64_t get_se_coef(GetBitContext *gb, const AVDOVIRpuDataHeader * case RPU_COEFF_FIXED: ipart = get_se_golomb_long(gb); fpart.u32 = get_bits_long(gb, hdr->coef_log2_denom); -return ipart * (1LL << hdr->coef_log2_denom) + fpart.u32; +return ipart * (1LL << hdr->coef_log2_denom) | fpart.u32; case RPU_COEFF_FLOAT: fpart.u32 = get_bits_long(gb, 32); ___ 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/dovi_rpu: fix off-by-one in loop
ffmpeg | branch: master | Niklas Haas | Thu Mar 21 13:32:21 2024 +0100| [f04a2ba30230d80201d7021780593625c5ba709e] | committer: Niklas Haas avcodec/dovi_rpu: fix off-by-one in loop Otherwise the last VDR would never get copied. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f04a2ba30230d80201d7021780593625c5ba709e --- libavcodec/dovi_rpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dovi_rpu.c b/libavcodec/dovi_rpu.c index 6185fac230..31c64fb060 100644 --- a/libavcodec/dovi_rpu.c +++ b/libavcodec/dovi_rpu.c @@ -68,7 +68,7 @@ void ff_dovi_ctx_replace(DOVIContext *s, const DOVIContext *s0) s->mapping = s0->mapping; s->color = s0->color; s->dv_profile = s0->dv_profile; -for (int i = 0; i < DOVI_MAX_DM_ID; i++) +for (int i = 0; i <= DOVI_MAX_DM_ID; i++) ff_refstruct_replace(&s->vdr[i], s0->vdr[i]); } ___ 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/libdav1d: Stop mangling AVPacket.opaque
ffmpeg | branch: master | Andreas Rheinhardt | Thu Mar 7 16:11:32 2024 +0100| [c89f6ae6899e0f3ffb4f51da1f1776ab16f5b3a0] | committer: Andreas Rheinhardt avcodec/libdav1d: Stop mangling AVPacket.opaque Unnecessary since 67e7f0b0537eee1357769038270fda08fe32 as there are no longer two opaque fields. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c89f6ae6899e0f3ffb4f51da1f1776ab16f5b3a0 --- libavcodec/libdav1d.c | 27 --- 1 file changed, 27 deletions(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 597944d88d..17b0743cf0 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -305,10 +305,6 @@ static void libdav1d_flush(AVCodecContext *c) dav1d_flush(dav1d->c); } -typedef struct OpaqueData { -void*pkt_orig_opaque; -} OpaqueData; - static void libdav1d_data_free(const uint8_t *data, void *opaque) { AVBufferRef *buf = opaque; @@ -318,7 +314,6 @@ static void libdav1d_data_free(const uint8_t *data, void *opaque) { static void libdav1d_user_data_free(const uint8_t *data, void *opaque) { AVPacket *pkt = opaque; av_assert0(data == opaque); -av_free(pkt->opaque); av_packet_free(&pkt); } @@ -341,8 +336,6 @@ static int libdav1d_receive_frame_internal(AVCodecContext *c, Dav1dPicture *p) } if (pkt->size) { -OpaqueData *od = NULL; - res = dav1d_data_wrap(data, pkt->data, pkt->size, libdav1d_data_free, pkt->buf); if (res < 0) { @@ -352,21 +345,9 @@ static int libdav1d_receive_frame_internal(AVCodecContext *c, Dav1dPicture *p) pkt->buf = NULL; -if (pkt->opaque && (c->flags & AV_CODEC_FLAG_COPY_OPAQUE)) { -od = av_mallocz(sizeof(*od)); -if (!od) { -av_packet_free(&pkt); -dav1d_data_unref(data); -return AVERROR(ENOMEM); -} -od->pkt_orig_opaque = pkt->opaque; -} -pkt->opaque = od; - res = dav1d_data_wrap_user_data(data, (const uint8_t *)pkt, libdav1d_user_data_free, pkt); if (res < 0) { -av_free(pkt->opaque); av_packet_free(&pkt); dav1d_data_unref(data); return res; @@ -405,7 +386,6 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) Libdav1dContext *dav1d = c->priv_data; Dav1dPicture pic = { 0 }, *p = &pic; AVPacket *pkt; -OpaqueData *od = NULL; #if FF_DAV1D_VERSION_AT_LEAST(5,1) enum Dav1dEventFlags event_flags = 0; #endif @@ -460,16 +440,9 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) ff_set_sar(c, frame->sample_aspect_ratio); pkt = (AVPacket *)p->m.user_data.data; -od = pkt->opaque; - -// restore the original user opaque value for -// ff_decode_frame_props_from_pkt() -pkt->opaque = od ? od->pkt_orig_opaque : NULL; -av_freep(&od); // match timestamps and packet size res = ff_decode_frame_props_from_pkt(c, frame, pkt); -pkt->opaque = NULL; if (res < 0) goto fail; ___ 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/librav1e: Don't unnecessarily create new references
ffmpeg | branch: master | Andreas Rheinhardt | Thu Mar 7 17:25:37 2024 +0100| [3fd047ee30574fd2dfd739cbb150f87c7225b81f] | committer: Andreas Rheinhardt avcodec/librav1e: Don't unnecessarily create new references Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3fd047ee30574fd2dfd739cbb150f87c7225b81f --- libavcodec/librav1e.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index dbd728a408..2a6d8bfbed 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -472,12 +472,8 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { fd->frame_opaque = frame->opaque; -ret = av_buffer_replace(&fd->frame_opaque_ref, frame->opaque_ref); -if (ret < 0) { -frame_data_free(fd); -av_frame_unref(frame); -return ret; -} +fd->frame_opaque_ref = frame->opaque_ref; +frame->opaque_ref= NULL; } rframe = rav1e_frame_new(ctx->ctx); ___ 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] fftools/ffmpeg_enc: Don't call frame_data twice
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 22 17:07:00 2024 +0100| [c77164390b6432626d970d197c2da44f408071bc] | committer: Andreas Rheinhardt fftools/ffmpeg_enc: Don't call frame_data twice Reviewed-by: Jan Ekström Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c77164390b6432626d970d197c2da44f408071bc --- fftools/ffmpeg_enc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index f01be1c22f..5f7fcf8a5f 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -646,7 +646,6 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, if (frame) { FrameData *fd = frame_data(frame); -fd = frame_data(frame); if (!fd) return AVERROR(ENOMEM); ___ 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/libx264: Remove unused variable
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 22 14:02:21 2024 +0100| [6ecc2f0f6f5011946b5dd9724eaeaf56b224b478] | committer: Andreas Rheinhardt avcodec/libx264: Remove unused variable Reviewed-by: Zhao Zhili Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6ecc2f0f6f5011946b5dd9724eaeaf56b224b478 --- libavcodec/libx264.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 2653941eb9..3d195fa6b6 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -867,7 +867,6 @@ static int save_sei(AVCodecContext *avctx, x264_nal_t *nal) #if CONFIG_LIBX264_ENCODER static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int nnal) { -X264Context *x4 = avctx->priv_data; x264_nal_t *sps_nal = NULL; x264_nal_t *pps_nal = NULL; uint8_t *p, *sps; ___ 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/libx265: Don't use AVBPrint unnecessarily
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 22 14:15:44 2024 +0100| [244db7103797df3f3f87e4c1bd8cf5224e6ebff9] | committer: Andreas Rheinhardt avcodec/libx265: Don't use AVBPrint unnecessarily This code uses the AVBPrint API for exactly one av_bprintf() in a scenario in which a good upper bound for the needed size of the buffer is available (with said upper bound being much smaller than sizeof(AVBPrint)). So one can simply use snprintf() instead. This also avoids the (always-false due to the current size of the internal AVBPrint buffer) check for whether the AVBPrint is complete. Furthermore, the old code used AV_BPRINT_SIZE_AUTOMATIC which implies that the AVBPrint buffer will never be (re)allocated and yet it used av_bprint_finalize(). This has of course also been removed. Reviewed-by: Jan Ekström Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=244db7103797df3f3f87e4c1bd8cf5224e6ebff9 --- libavcodec/libx265.c | 31 ++- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 70ec6d3539..d7620878b8 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -28,17 +28,14 @@ #include #include "libavutil/avassert.h" -#include "libavutil/bprint.h" #include "libavutil/buffer.h" #include "libavutil/internal.h" -#include "libavutil/common.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #include "packet_internal.h" #include "atsc_a53.h" #include "sei.h" @@ -182,13 +179,10 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api, x265_param *params, const AVMasteringDisplayMetadata *mdcv) { -int ret = AVERROR_BUG; -AVBPrint buf; -av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC); +char buf[10 /* # of PRId64s */ * 20 /* max strlen for %PRId64 */ + sizeof("G(,)B(,)R(,)WP(,)L(,)")]; // G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u) -av_bprintf( -&buf, +snprintf(buf, sizeof(buf), "G(%"PRId64",%"PRId64")B(%"PRId64",%"PRId64")R(%"PRId64",%"PRId64")" "WP(%"PRId64",%"PRId64")L(%"PRId64",%"PRId64")", av_rescale_q(1, mdcv->display_primaries[1][0], (AVRational){ 1, 5 }), @@ -202,28 +196,15 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api, av_rescale_q(1, mdcv->max_luminance, (AVRational){ 1, 1 }), av_rescale_q(1, mdcv->min_luminance, (AVRational){ 1, 1 })); -if (!av_bprint_is_complete(&buf)) { -av_log(avcl, AV_LOG_ERROR, - "MDCV string too long for its available space!\n"); -ret = AVERROR(ENOMEM); -goto end; -} - -if (api->param_parse(params, "master-display", buf.str) == +if (api->param_parse(params, "master-display", buf) == X265_PARAM_BAD_VALUE) { av_log(avcl, AV_LOG_ERROR, "Invalid value \"%s\" for param \"master-display\".\n", - buf.str); -ret = AVERROR(EINVAL); -goto end; + buf); +return AVERROR(EINVAL); } -ret = 0; - -end: -av_bprint_finalize(&buf, NULL); - -return ret; +return 0; } static int handle_side_data(AVCodecContext *avctx, const x265_api *api, ___ 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/libx265: Pass logctx as void*, not AVClass**
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 22 14:25:44 2024 +0100| [b9fcc135c570e254b8cb8d63c50877646bf97e40] | committer: Andreas Rheinhardt avcodec/libx265: Pass logctx as void*, not AVClass** The latter need not be save, because av_log() expects to get a pointer to an AVClass-enabled structure and not only a fake object. If this function were actually be called in the following way: const AVClass *avcl = avctx->av_class; handle_mdcv(&avcl, ); the AVClass's item_name would expect to point to an actual AVCodecContext, potentially leading to a segfault. Reviewed-by: Jan Ekström Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b9fcc135c570e254b8cb8d63c50877646bf97e40 --- libavcodec/libx265.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index d7620878b8..45349a85b9 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -175,7 +175,7 @@ static av_cold int libx265_param_parse_int(AVCodecContext *avctx, return 0; } -static int handle_mdcv(const AVClass **avcl, const x265_api *api, +static int handle_mdcv(void *logctx, const x265_api *api, x265_param *params, const AVMasteringDisplayMetadata *mdcv) { @@ -198,7 +198,7 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api, if (api->param_parse(params, "master-display", buf) == X265_PARAM_BAD_VALUE) { -av_log(avcl, AV_LOG_ERROR, +av_log(logctx, AV_LOG_ERROR, "Invalid value \"%s\" for param \"master-display\".\n", buf); return AVERROR(EINVAL); @@ -230,7 +230,7 @@ static int handle_side_data(AVCodecContext *avctx, const x265_api *api, if (mdcv_sd) { int ret = handle_mdcv( -&avctx->av_class, api, params, +avctx, api, params, (AVMasteringDisplayMetadata *)mdcv_sd->data); 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] avutil/frame: Constify av_frame_side_data_get()
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 22 14:37:15 2024 +0100| [26398da8f3001518e6d229e69f8dedd50ef7d5f9] | committer: Andreas Rheinhardt avutil/frame: Constify av_frame_side_data_get() Reviewed-by: Jan Ekström Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=26398da8f3001518e6d229e69f8dedd50ef7d5f9 --- doc/APIchanges | 3 +++ libavutil/frame.c | 2 +- libavutil/frame.h | 2 +- libavutil/version.h | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a025f1df14..9d25621e43 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-03-22 - xx - lavu 59.4.100 - frame.h + Constified the first-level pointee of av_frame_side_data_get(). + 2024-03-xx - xx - lavc 61.2.100 - avcodec.h Add AVCodecContext.[nb_]decoded_side_data. diff --git a/libavutil/frame.c b/libavutil/frame.c index 89db687d9c..8598aa98a2 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -813,7 +813,7 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, const int nb_sd, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index a7fc909ad8..cf9ffe1ba9 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1051,7 +1051,7 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, * @return a pointer to the side data of a given type on success, NULL if there * is no side data with such type in this set. */ -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, const int nb_sd, enum AVFrameSideDataType type); diff --git a/libavutil/version.h b/libavutil/version.h index 5027b025be..882003f719 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 3 +#define LIBAVUTIL_VERSION_MINOR 4 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ ___ 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] avutil/frame: Rename av_frame_side_data_get and add wrapper for it
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 22 14:44:21 2024 +0100| [b7bec5d3c9ec0d38175d3385b37d85de26c96470] | committer: Andreas Rheinhardt avutil/frame: Rename av_frame_side_data_get and add wrapper for it av_frame_side_data_get() has a const AVFrameSideData * const *sd parameter; so calling it with an AVFramesSideData **sd like AVCodecContext.decoded_side_data (or with a AVFramesSideData * const *sd) is safe, but the conversion is not performed automatically in C. All users of this function therefore resort to a cast. This commit changes this: av_frame_side_data_get() is renamed to av_frame_side_data_get_c(); furthermore, a static inline wrapper for it name av_frame_side_data_get() is added that accepts an AVFramesSideData * const * and converts this to const AVFramesSideData * const * in a Wcast-qual safe way. This also allows to remove the casts from the current users. Reviewed-by: Jan Ekström Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7bec5d3c9ec0d38175d3385b37d85de26c96470 --- doc/APIchanges | 5 - libavcodec/libsvtav1.c | 6 ++ libavcodec/libx264.c | 6 ++ libavcodec/libx265.c | 6 ++ libavutil/frame.c | 8 libavutil/frame.h | 19 +-- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 9d25621e43..9694947e63 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -3,7 +3,10 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: 2024-03-22 - xx - lavu 59.4.100 - frame.h - Constified the first-level pointee of av_frame_side_data_get(). + Constified the first-level pointee of av_frame_side_data_get() + and renamed it to av_frame_side_data_get_c(). From now on, + av_frame_side_data_get() is a wrapper around av_frame_side_data_get_c() + that accepts AVFrameSideData * const *sd. 2024-03-xx - xx - lavc 61.2.100 - avcodec.h Add AVCodecContext.[nb_]decoded_side_data. diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 6400a6507a..8fa42d590b 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -180,12 +180,10 @@ static void handle_side_data(AVCodecContext *avctx, EbSvtAv1EncConfiguration *param) { const AVFrameSideData *cll_sd = -av_frame_side_data_get( -(const AVFrameSideData **)avctx->decoded_side_data, +av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = -av_frame_side_data_get( -(const AVFrameSideData **)avctx->decoded_side_data, +av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 3d195fa6b6..eadb20d2b3 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -1044,12 +1044,10 @@ static void handle_side_data(AVCodecContext *avctx, x264_param_t *params) { #if CONFIG_LIBX264_HDR10 const AVFrameSideData *cll_sd = -av_frame_side_data_get( -(const AVFrameSideData **)avctx->decoded_side_data, +av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = -av_frame_side_data_get( -(const AVFrameSideData **)avctx->decoded_side_data, +av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 45349a85b9..d3e74eaacf 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -211,12 +211,10 @@ static int handle_side_data(AVCodecContext *avctx, const x265_api *api, x265_param *params) { const AVFrameSideData *cll_sd = -av_frame_side_data_get( -(const AVFrameSideData **)avctx->decoded_side_data, +av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = -av_frame_side_data_get( -(const AVFrameSideData **)avctx->decoded_side_data, +av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); diff --git a/libavutil/frame.c b/libavutil/frame.c index 8598aa98a2..7dd37e5490 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -813,9 +813,9 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, - const
[FFmpeg-cvslog] avutil/frame: Use av_realloc_array(), improve overflow check
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 22 15:24:47 2024 +0100| [d11b5e6096b888caa7e6c4d159f6c0c44d0ca83d] | committer: Andreas Rheinhardt avutil/frame: Use av_realloc_array(), improve overflow check Also use sizeof of the proper type, namely sizeof(**sd) and not sizeof(*sd). Reviewed-by: Jan Ekström Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d11b5e6096b888caa7e6c4d159f6c0c44d0ca83d --- libavutil/frame.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 7dd37e5490..d7a32cdc92 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -721,10 +721,11 @@ static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, if (!buf) return NULL; -if (*nb_sd > INT_MAX / sizeof(*sd) - 1) +// *nb_sd + 1 needs to fit into an int and a size_t. +if ((unsigned)*nb_sd >= FFMIN(INT_MAX, SIZE_MAX)) return NULL; -tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd)); +tmp = av_realloc_array(*sd, sizeof(**sd), *nb_sd + 1); if (!tmp) return NULL; *sd = tmp; ___ 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/mp3enc: Improve query_codec
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 05:00:26 2024 +0100| [eb3ee7f141d33e2133697919ee91352cfad388b0] | committer: Andreas Rheinhardt avformat/mp3enc: Improve query_codec Signal that anything except MP3 and the ID3V2 attached pic types are forbidden. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb3ee7f141d33e2133697919ee91352cfad388b0 --- libavformat/mp3enc.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index cb250a46ca..4a02a45069 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -495,12 +495,16 @@ static int mp3_write_trailer(struct AVFormatContext *s) static int query_codec(enum AVCodecID id, int std_compliance) { const CodecMime *cm= ff_id3v2_mime_tags; + +if (id == AV_CODEC_ID_MP3) +return 1; + while(cm->id != AV_CODEC_ID_NONE) { if(id == cm->id) return MKTAG('A', 'P', 'I', 'C'); cm++; } -return -1; +return 0; } static const AVOption options[] = { ___ 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] libavformat/westwood_audenc: Use proper logcontext
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 23:03:45 2024 +0100| [b8124fe35ef92512d9d4522c4ccc27fdc6436e39] | committer: Andreas Rheinhardt libavformat/westwood_audenc: Use proper logcontext (AVStream did not have an AVClass when this muxer was added.) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b8124fe35ef92512d9d4522c4ccc27fdc6436e39 --- libavformat/westwood_audenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/westwood_audenc.c b/libavformat/westwood_audenc.c index 84a871e478..46456e2ecb 100644 --- a/libavformat/westwood_audenc.c +++ b/libavformat/westwood_audenc.c @@ -48,19 +48,19 @@ static int wsaud_write_init(AVFormatContext *ctx) /* Stream must be seekable to correctly write the file. */ if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) { -av_log(ctx->streams[0], AV_LOG_ERROR, "Cannot write Westwood AUD to" +av_log(ctx, AV_LOG_ERROR, "Cannot write Westwood AUD to" " non-seekable stream.\n"); return AVERROR(EINVAL); } if (st->codecpar->codec_id != AV_CODEC_ID_ADPCM_IMA_WS) { -av_log(st, AV_LOG_ERROR, "%s codec not supported for Westwood AUD.\n", +av_log(ctx, AV_LOG_ERROR, "%s codec not supported for Westwood AUD.\n", avcodec_get_name(st->codecpar->codec_id)); return AVERROR(EINVAL); } if (ctx->nb_streams != 1) { -av_log(st, AV_LOG_ERROR, "AUD files have exactly one stream\n"); +av_log(ctx, AV_LOG_ERROR, "AUD files have exactly one stream\n"); return AVERROR(EINVAL); } ___ 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/amr: Move write_header closer to muxer definition
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 19:04:09 2024 +0100| [789c5b03db3b5e11387e40e774030ac316783ffb] | committer: Andreas Rheinhardt avformat/amr: Move write_header closer to muxer definition Avoids one #if. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=789c5b03db3b5e11387e40e774030ac316783ffb --- libavformat/amr.c | 32 +++- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/libavformat/amr.c b/libavformat/amr.c index 85815e8675..1b80810302 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -51,23 +51,6 @@ static const uint8_t amrwb_packed_size[16] = { 18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 1, 1, 1, 1, 1, 1 }; -#if CONFIG_AMR_MUXER -static int amr_write_header(AVFormatContext *s) -{ -AVIOContext*pb = s->pb; -AVCodecParameters *par = s->streams[0]->codecpar; - -if (par->codec_id == AV_CODEC_ID_AMR_NB) { -avio_write(pb, AMR_header, sizeof(AMR_header)); /* magic number */ -} else if (par->codec_id == AV_CODEC_ID_AMR_WB) { -avio_write(pb, AMRWB_header, sizeof(AMRWB_header)); /* magic number */ -} else { -return -1; -} -return 0; -} -#endif /* CONFIG_AMR_MUXER */ - #if CONFIG_AMR_DEMUXER static int amr_probe(const AVProbeData *p) { @@ -268,6 +251,21 @@ const FFInputFormat ff_amrwb_demuxer = { #endif #if CONFIG_AMR_MUXER +static int amr_write_header(AVFormatContext *s) +{ +AVIOContext*pb = s->pb; +AVCodecParameters *par = s->streams[0]->codecpar; + +if (par->codec_id == AV_CODEC_ID_AMR_NB) { +avio_write(pb, AMR_header, sizeof(AMR_header)); /* magic number */ +} else if (par->codec_id == AV_CODEC_ID_AMR_WB) { +avio_write(pb, AMRWB_header, sizeof(AMRWB_header)); /* magic number */ +} else { +return -1; +} +return 0; +} + const FFOutputFormat ff_amr_muxer = { .p.name= "amr", .p.long_name = NULL_IF_CONFIG_SMALL("3GPP AMR"), ___ 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/mux: Add flag for "not more than one stream of each type"
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 21:40:54 2024 +0100| [f4167842c12ad0e406a2bed4c2bb17084b184710] | committer: Andreas Rheinhardt avformat/mux: Add flag for "not more than one stream of each type" More exactly: Not more than one stream of each type for which a default codec (i.e. AVOutputFormat.(audio|video|subtitle)_codec) is set; for those types for which no such codec is set (or for which no designated default codec in AVOutputFormat exists at all) no streams are permitted. Given that with this flag set the default codecs become more important, they are now set explicitly to AV_CODEC_ID_NONE for "unset"; the earlier code relied on AV_CODEC_ID_NONE being equal to zero, so that default static initialization set it accordingly; but this is not how one is supposed to use an enum. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f4167842c12ad0e406a2bed4c2bb17084b184710 --- libavformat/ac4enc.c | 4 +- libavformat/aeaenc.c | 11 ++-- libavformat/alp.c | 7 +-- libavformat/apm.c | 11 +--- libavformat/apngenc.c | 6 +- libavformat/argo_asf.c| 11 +--- libavformat/argo_cvg.c| 11 +--- libavformat/assenc.c | 5 +- libavformat/astenc.c | 11 +--- libavformat/au.c | 7 +-- libavformat/cafenc.c | 7 +-- libavformat/chromaprint.c | 8 +-- libavformat/codec2.c | 4 +- libavformat/gif.c | 6 +- libavformat/ilbc.c| 11 ++-- libavformat/ircamenc.c| 7 +-- libavformat/ivfenc.c | 12 ++-- libavformat/kvag.c| 11 +--- libavformat/lrcenc.c | 9 +-- libavformat/microdvdenc.c | 5 +- libavformat/mux.c | 23 +++ libavformat/mux.h | 12 libavformat/mux_utils.c | 19 ++ libavformat/rawenc.c | 135 -- libavformat/rcwtenc.c | 9 +-- libavformat/sccenc.c | 9 +-- libavformat/segafilmenc.c | 10 +--- libavformat/srtenc.c | 9 +-- libavformat/supenc.c | 9 +-- libavformat/swfenc.c | 12 ++-- libavformat/ttaenc.c | 10 +--- libavformat/ttmlenc.c | 6 +- libavformat/wavenc.c | 20 ++- libavformat/webpenc.c | 7 +-- libavformat/webvttenc.c | 5 +- libavformat/westwood_audenc.c | 7 +-- libavformat/wvenc.c | 5 +- libavformat/yuv4mpegenc.c | 5 +- 38 files changed, 239 insertions(+), 237 deletions(-) diff --git a/libavformat/ac4enc.c b/libavformat/ac4enc.c index aefbfc2684..02b8d4d976 100644 --- a/libavformat/ac4enc.c +++ b/libavformat/ac4enc.c @@ -35,7 +35,7 @@ static int ac4_init(AVFormatContext *s) { AVCodecParameters *par = s->streams[0]->codecpar; -if (s->nb_streams != 1 || par->codec_id != AV_CODEC_ID_AC4) { +if (par->codec_id != AV_CODEC_ID_AC4) { av_log(s, AV_LOG_ERROR, "Only one AC-4 stream can be muxed by the AC-4 muxer\n"); return AVERROR(EINVAL); } @@ -95,6 +95,8 @@ const FFOutputFormat ff_ac4_muxer = { .priv_data_size= sizeof(AC4Context), .p.audio_codec = AV_CODEC_ID_AC4, .p.video_codec = AV_CODEC_ID_NONE, +.p.subtitle_codec = AV_CODEC_ID_NONE, +.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH, .init = ac4_init, .write_packet = ac4_write_packet, .p.priv_class = &ac4_muxer_class, diff --git a/libavformat/aeaenc.c b/libavformat/aeaenc.c index 495e98c6a2..3303d108a5 100644 --- a/libavformat/aeaenc.c +++ b/libavformat/aeaenc.c @@ -29,14 +29,8 @@ static int aea_write_header(AVFormatContext *s) { const AVDictionaryEntry *title_entry; size_t title_length = 0; -AVStream *st; - -if (s->nb_streams > 1) { -av_log(s, AV_LOG_ERROR, "Got more than one stream to encode. This is not supported.\n"); -return AVERROR(EINVAL); -} +AVStream *st = s->streams[0]; -st = s->streams[0]; if (st->codecpar->ch_layout.nb_channels != 1 && st->codecpar->ch_layout.nb_channels != 2) { av_log(s, AV_LOG_ERROR, "Only maximum 2 channels are supported in the audio" " stream, %d channels were found.\n", st->codecpar->ch_layout.nb_channels); @@ -108,7 +102,10 @@ const FFOutputFormat ff_aea_muxer = { .p.long_name = NULL_IF_CONFIG_SMALL("MD STUDIO audio"), .p.extensions = "aea", .p.audio_codec= AV_CODEC_ID_ATRAC1, +.p.video_codec= AV_CODEC_ID_NONE, +.p.subtitle_codec = AV_CODEC_ID_NONE, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, .write_header = aea_write_header, .write_packet = ff_raw_write_packet, .write_trailer= aea_write_trailer, diff --git a/libavformat/alp.c b/libavformat/alp.c index 3db256cd05..9d507cb310 100644 --- a/libavformat/alp.c +++ b/libavformat/alp.c @@ -189,11 +189
[FFmpeg-cvslog] avformat/mux_utils: Don't report that AV_CODEC_ID_NONE can be muxed
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 19:42:55 2024 +0100| [a48e839a221d8470071a367b6a7be1bc022ba6e7] | committer: Andreas Rheinhardt avformat/mux_utils: Don't report that AV_CODEC_ID_NONE can be muxed If AVOutputFormat.video_codec, audio_codec or subtitle_codec is AV_CODEC_ID_NONE, it means that there is no default codec for this format and not that it is supported to mux AV_CODEC_ID_NONE. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a48e839a221d8470071a367b6a7be1bc022ba6e7 --- libavformat/mux_utils.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c index 9d811c14e2..841a19a3a2 100644 --- a/libavformat/mux_utils.c +++ b/libavformat/mux_utils.c @@ -39,9 +39,10 @@ int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, return ffofmt(ofmt)->query_codec(codec_id, std_compliance); else if (ofmt->codec_tag) return !!av_codec_get_tag2(ofmt->codec_tag, codec_id, &codec_tag); -else if (codec_id == ofmt->video_codec || - codec_id == ofmt->audio_codec || - codec_id == ofmt->subtitle_codec) +else if (codec_id != AV_CODEC_ID_NONE && + (codec_id == ofmt->video_codec || + codec_id == ofmt->audio_codec || + codec_id == ofmt->subtitle_codec)) return 1; } return AVERROR_PATCHWELCOME; ___ 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/mux: Rename FF_FMT_ALLOW_FLUSH->FF_OFMT_FLAG_ALLOW_FLUSH
ffmpeg | branch: master | Andreas Rheinhardt | Fri Mar 15 18:18:23 2024 +0100| [233e13f285c9f0169b62fea38d6c09f15186fa5f] | committer: Andreas Rheinhardt avformat/mux: Rename FF_FMT_ALLOW_FLUSH->FF_OFMT_FLAG_ALLOW_FLUSH It better reflects that this is a muxer-only flag. Also document the flag. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=233e13f285c9f0169b62fea38d6c09f15186fa5f --- libavdevice/pulse_audio_enc.c | 2 +- libavformat/fifo.c | 2 +- libavformat/hlsenc.c | 2 +- libavformat/matroskaenc.c | 6 +++--- libavformat/movenc.c | 18 +- libavformat/mpegtsenc.c| 2 +- libavformat/mux.c | 4 ++-- libavformat/mux.h | 14 +++--- libavformat/oggenc.c | 10 +- libavformat/tee.c | 2 +- libavformat/tests/fifo_muxer.c | 2 +- 11 files changed, 36 insertions(+), 28 deletions(-) diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index 4955b3b884..3e2cc91f69 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -801,5 +801,5 @@ const FFOutputFormat ff_pulse_muxer = { .p.flags = AVFMT_NOFILE, #endif .p.priv_class = &pulse_muxer_class, -.flags_internal = FF_FMT_ALLOW_FLUSH, +.flags_internal = FF_OFMT_FLAG_ALLOW_FLUSH, }; diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 2a2673f4d8..23e4149ad6 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -728,5 +728,5 @@ const FFOutputFormat ff_fifo_muxer = { .write_packet = fifo_write_packet, .write_trailer = fifo_write_trailer, .deinit = fifo_deinit, -.flags_internal = FF_FMT_ALLOW_FLUSH, +.flags_internal = FF_OFMT_FLAG_ALLOW_FLUSH, }; diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e5350323b1..2202ce64e4 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -3205,7 +3205,7 @@ const FFOutputFormat ff_hls_muxer = { .p.flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_NODIMENSIONS, #endif .p.priv_class = &hls_class, -.flags_internal = FF_FMT_ALLOW_FLUSH, +.flags_internal = FF_OFMT_FLAG_ALLOW_FLUSH, .priv_data_size = sizeof(HLSContext), .init = hls_init, .write_header = hls_write_header, diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index db41d3d1c2..0de4ec1dc0 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -3569,7 +3569,7 @@ const FFOutputFormat ff_matroska_muxer = { .query_codec = mkv_query_codec, .check_bitstream = mkv_check_bitstream, .p.priv_class = &matroska_webm_class, -.flags_internal= FF_FMT_ALLOW_FLUSH, +.flags_internal= FF_OFMT_FLAG_ALLOW_FLUSH, }; #endif @@ -3606,7 +3606,7 @@ const FFOutputFormat ff_webm_muxer = { AVFMT_TS_NONSTRICT, #endif .p.priv_class = &matroska_webm_class, -.flags_internal= FF_FMT_ALLOW_FLUSH, +.flags_internal= FF_OFMT_FLAG_ALLOW_FLUSH, }; #endif @@ -3636,6 +3636,6 @@ const FFOutputFormat ff_matroska_audio_muxer = { ff_codec_wav_tags, additional_audio_tags, 0 }, .p.priv_class = &matroska_webm_class, -.flags_internal= FF_FMT_ALLOW_FLUSH, +.flags_internal= FF_OFMT_FLAG_ALLOW_FLUSH, }; #endif diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 029b08c0b0..ee6734995d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -8241,7 +8241,7 @@ const FFOutputFormat ff_mov_muxer = { }, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, -.flags_internal= FF_FMT_ALLOW_FLUSH, +.flags_internal= FF_OFMT_FLAG_ALLOW_FLUSH, }; #endif #if CONFIG_TGP_MUXER @@ -8265,7 +8265,7 @@ const FFOutputFormat ff_tgp_muxer = { .p.codec_tag = codec_3gp_tags_list, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, -.flags_internal= FF_FMT_ALLOW_FLUSH, +.flags_internal= FF_OFMT_FLAG_ALLOW_FLUSH, }; #endif #if CONFIG_MP4_MUXER @@ -8291,7 +8291,7 @@ const FFOutputFormat ff_mp4_muxer = { .p.codec_tag = mp4_codec_tags_list, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, -.flags_internal= FF_FMT_ALLOW_FLUSH, +.flags_internal= FF_OFMT_FLAG_ALLOW_FLUSH, }; #endif #if CONFIG_PSP_MUXER @@ -8316,7 +8316,7 @@ const FFOutputFormat ff_psp_muxer = { .p.codec_tag = mp4_codec_tags_list, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, -.flags_internal= FF_FMT_ALLOW_FLUSH, +.flags_internal= FF_OFMT_FLAG_ALLOW_FLUSH, }; #endif #if CONFIG_TG2_MUXER @@ -8340,7 +8340,7 @@ const FFOutputFormat ff_tg2_muxer = { .p.codec_tag = codec_3gp_tags_
[FFmpeg-cvslog] avformat: Enforce one-stream limit where appropriate
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 22:07:12 2024 +0100| [03b04eef72a5f23e30c2d7700b290d915c31d3a1] | committer: Andreas Rheinhardt avformat: Enforce one-stream limit where appropriate Several muxers (e.g. pcm muxers) did not check the number of streams even though the individual streams were not recoverable from the muxed files. This commit changes this by using the FF_OFMT_MAX_ONE_OF_EACH flag where appropriate. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=03b04eef72a5f23e30c2d7700b290d915c31d3a1 --- libavformat/a64.c | 3 +++ libavformat/adtsenc.c | 2 ++ libavformat/amr.c | 2 ++ libavformat/amvenc.c | 2 ++ libavformat/bit.c | 2 ++ libavformat/daudenc.c | 2 ++ libavformat/filmstripenc.c | 2 ++ libavformat/fitsenc.c | 2 ++ libavformat/idroqenc.c | 2 ++ libavformat/jacosubenc.c | 3 +++ libavformat/latmenc.c | 2 ++ libavformat/mmf.c | 2 ++ libavformat/omaenc.c | 3 +++ libavformat/pcmenc.c | 2 ++ libavformat/rsoenc.c | 2 ++ libavformat/smjpegenc.c| 6 ++ libavformat/soxenc.c | 2 ++ libavformat/spdifenc.c | 2 ++ libavformat/vc1testenc.c | 2 ++ 19 files changed, 41 insertions(+), 4 deletions(-) diff --git a/libavformat/a64.c b/libavformat/a64.c index 23b20fc8b7..6e722c7e9f 100644 --- a/libavformat/a64.c +++ b/libavformat/a64.c @@ -65,6 +65,9 @@ const FFOutputFormat ff_a64_muxer = { .p.long_name= NULL_IF_CONFIG_SMALL("a64 - video for Commodore 64"), .p.extensions = "a64, A64", .p.video_codec = AV_CODEC_ID_A64_MULTI, +.p.audio_codec= AV_CODEC_ID_NONE, +.p.subtitle_codec = AV_CODEC_ID_NONE, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, .write_header = a64_write_header, .write_packet = ff_raw_write_packet, }; diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c index c5765cc92e..7eaf91630c 100644 --- a/libavformat/adtsenc.c +++ b/libavformat/adtsenc.c @@ -241,6 +241,8 @@ const FFOutputFormat ff_adts_muxer = { .priv_data_size= sizeof(ADTSContext), .p.audio_codec = AV_CODEC_ID_AAC, .p.video_codec = AV_CODEC_ID_NONE, +.p.subtitle_codec = AV_CODEC_ID_NONE, +.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH, .init = adts_init, .write_header = adts_write_header, .write_packet = adts_write_packet, diff --git a/libavformat/amr.c b/libavformat/amr.c index 1b80810302..0db0a8d26a 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -273,7 +273,9 @@ const FFOutputFormat ff_amr_muxer = { .p.extensions = "amr", .p.audio_codec = AV_CODEC_ID_AMR_NB, .p.video_codec = AV_CODEC_ID_NONE, +.p.subtitle_codec = AV_CODEC_ID_NONE, .p.flags = AVFMT_NOTIMESTAMPS, +.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH, .write_header = amr_write_header, .write_packet = ff_raw_write_packet, }; diff --git a/libavformat/amvenc.c b/libavformat/amvenc.c index e1b1ffd42e..9fcc09add2 100644 --- a/libavformat/amvenc.c +++ b/libavformat/amvenc.c @@ -410,6 +410,8 @@ const FFOutputFormat ff_amv_muxer = { .priv_data_size = sizeof(AMVContext), .p.audio_codec = AV_CODEC_ID_ADPCM_IMA_AMV, .p.video_codec = AV_CODEC_ID_AMV, +.p.subtitle_codec = AV_CODEC_ID_NONE, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, .init = amv_init, .deinit = amv_deinit, .write_header = amv_write_header, diff --git a/libavformat/bit.c b/libavformat/bit.c index 8133b1f44d..81a954c392 100644 --- a/libavformat/bit.c +++ b/libavformat/bit.c @@ -167,6 +167,8 @@ const FFOutputFormat ff_bit_muxer = { .p.extensions = "bit", .p.audio_codec = AV_CODEC_ID_G729, .p.video_codec = AV_CODEC_ID_NONE, +.p.subtitle_codec = AV_CODEC_ID_NONE, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, .write_header = write_header, .write_packet = write_packet, }; diff --git a/libavformat/daudenc.c b/libavformat/daudenc.c index a995838351..f1e0da058b 100644 --- a/libavformat/daudenc.c +++ b/libavformat/daudenc.c @@ -62,7 +62,9 @@ const FFOutputFormat ff_daud_muxer = { .p.extensions = "302", .p.audio_codec = AV_CODEC_ID_PCM_S24DAUD, .p.video_codec = AV_CODEC_ID_NONE, +.p.subtitle_codec = AV_CODEC_ID_NONE, .p.flags = AVFMT_NOTIMESTAMPS, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, .init = daud_init, .write_packet = daud_write_packet, }; diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c index 9033dba692..b2a4cee8fa 100644 --- a/libavformat/filmstripenc.c +++ b/libavformat/filmstripenc.c @@ -66,6 +66,8 @@ const FFOutputFormat ff_filmstrip_muxer = { .p.extensions = "flm", .p.audio_codec = AV_CODEC_ID_NONE, .p.video_codec = AV_CODEC_ID_RAWVIDEO, +.p.subtitle_codec = AV_CODEC_ID_NONE, +.flags_int
[FFmpeg-cvslog] fate/filter-audio: Don't use pcm output for channelsplit test
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 21:08:28 2024 +0100| [c6bc2d4fea99bfc0ad125897f61d205d78d0a8c1] | committer: Andreas Rheinhardt fate/filter-audio: Don't use pcm output for channelsplit test This test muxes two streams into a single pcm file, although the two streams are of course not recoverable from the output (unless one has extra information). So use the streamhash muxer instead (which also provides coverage for it; it was surprisingly unused in FATE so far). This is in preparation for actually enforcing a limit of one stream for the PCM muxers. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c6bc2d4fea99bfc0ad125897f61d205d78d0a8c1 --- tests/fate/filter-audio.mak| 6 ++ tests/ref/fate/filter-channelsplit | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak index 308969c4ac..8d05e6bd77 100644 --- a/tests/fate/filter-audio.mak +++ b/tests/fate/filter-audio.mak @@ -306,12 +306,10 @@ fate-filter-channelmap-one-str: REF = 0ea3052e482c95d5d3bd9da6dac1b5fa FATE_AFILTER-$(call FILTERDEMDECENCMUX, CHANNELMAP ARESAMPLE, WAV, PCM_S16LE, PCM_S16LE, WAV) += $(FATE_FILTER_CHANNELMAP) -FATE_AFILTER-$(call FILTERDEMDECENCMUX, CHANNELSPLIT ASETNSAMPLES ARESAMPLE, WAV, PCM_S16LE, PCM_S16LE, PCM_S16LE) += fate-filter-channelsplit +FATE_AFILTER-$(call FILTERDEMDECENCMUX, CHANNELSPLIT ASETNSAMPLES ARESAMPLE, WAV, PCM_S16LE, PCM_S16LE, STREAMHASH) += fate-filter-channelsplit fate-filter-channelsplit: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav fate-filter-channelsplit: tests/data/asynth-44100-2.wav -fate-filter-channelsplit: CMD = md5 -auto_conversion_filters -i $(SRC) -filter_complex asetnsamples=n=1024:p=0,channelsplit -f s16le -fate-filter-channelsplit: CMP = oneline -fate-filter-channelsplit: REF = d92988d0fe2dd92236763f47b07ab597 +fate-filter-channelsplit: CMD = fmtstdout streamhash -auto_conversion_filters -i $(SRC) -filter_complex asetnsamples=n=1024:p=0,channelsplit FATE_AFILTER-$(call FILTERDEMDECENCMUX, JOIN ARESAMPLE, WAV, PCM_S16LE, PCM_S16LE, PCM_S16LE) += fate-filter-join fate-filter-join: SRC1 = $(TARGET_PATH)/tests/data/asynth-44100-2.wav diff --git a/tests/ref/fate/filter-channelsplit b/tests/ref/fate/filter-channelsplit new file mode 100644 index 00..892801d94d --- /dev/null +++ b/tests/ref/fate/filter-channelsplit @@ -0,0 +1,2 @@ +0,a,SHA256=a4f03d92f82d074d20bcc49ffcbb28911ae85b097142249a890af59422eb0da8 +1,a,SHA256=c2f021f2b2faa1629674e6126ce5f997ef2034ecd3a15df595a98aefa40614e9 ___ 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/mux: Add flag for "only default codecs allowed"
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 23:28:36 2024 +0100| [a24bccc23859b37e03cbf395b3349cb4f707b3e0] | committer: Andreas Rheinhardt avformat/mux: Add flag for "only default codecs allowed" AVOutputFormat has default codecs for audio, video and subtitle and often these are the only codecs of this type allowed. So add a flag to AVOutputFormat so that this can be checked generically. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a24bccc23859b37e03cbf395b3349cb4f707b3e0 --- libavformat/ac4enc.c | 17 ++--- libavformat/adtsenc.c | 7 ++- libavformat/aeaenc.c | 8 ++-- libavformat/alp.c | 9 ++--- libavformat/amvenc.c | 9 +++-- libavformat/apm.c | 9 ++--- libavformat/apngenc.c | 9 ++--- libavformat/argo_asf.c| 9 ++--- libavformat/argo_cvg.c| 9 ++--- libavformat/assenc.c | 7 ++- libavformat/bit.c | 5 +++-- libavformat/codec2.c | 12 +++- libavformat/gif.c | 9 ++--- libavformat/ilbc.c| 8 ++-- libavformat/kvag.c| 9 ++--- libavformat/microdvdenc.c | 8 ++-- libavformat/mux.c | 11 +-- libavformat/mux.h | 9 + libavformat/mux_utils.c | 2 ++ libavformat/rcwtenc.c | 8 ++-- libavformat/sccenc.c | 9 ++--- libavformat/ttmlenc.c | 8 ++-- libavformat/vc1testenc.c | 7 ++- libavformat/webpenc.c | 10 +++--- libavformat/webvttenc.c | 9 ++--- libavformat/westwood_audenc.c | 10 ++ libavformat/wvenc.c | 14 ++ 27 files changed, 72 insertions(+), 169 deletions(-) diff --git a/libavformat/ac4enc.c b/libavformat/ac4enc.c index 02b8d4d976..0505b05147 100644 --- a/libavformat/ac4enc.c +++ b/libavformat/ac4enc.c @@ -19,7 +19,6 @@ */ #include "libavcodec/codec_id.h" -#include "libavcodec/codec_par.h" #include "libavcodec/packet.h" #include "libavutil/crc.h" #include "libavutil/opt.h" @@ -31,18 +30,6 @@ typedef struct AC4Context { int write_crc; } AC4Context; -static int ac4_init(AVFormatContext *s) -{ -AVCodecParameters *par = s->streams[0]->codecpar; - -if (par->codec_id != AV_CODEC_ID_AC4) { -av_log(s, AV_LOG_ERROR, "Only one AC-4 stream can be muxed by the AC-4 muxer\n"); -return AVERROR(EINVAL); -} - -return 0; -} - static int ac4_write_packet(AVFormatContext *s, AVPacket *pkt) { AC4Context *ac4 = s->priv_data; @@ -96,8 +83,8 @@ const FFOutputFormat ff_ac4_muxer = { .p.audio_codec = AV_CODEC_ID_AC4, .p.video_codec = AV_CODEC_ID_NONE, .p.subtitle_codec = AV_CODEC_ID_NONE, -.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH, -.init = ac4_init, +.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH | + FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .write_packet = ac4_write_packet, .p.priv_class = &ac4_muxer_class, .p.flags = AVFMT_NOTIMESTAMPS, diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c index 7eaf91630c..0671224fc2 100644 --- a/libavformat/adtsenc.c +++ b/libavformat/adtsenc.c @@ -106,10 +106,6 @@ static int adts_init(AVFormatContext *s) ADTSContext *adts = s->priv_data; AVCodecParameters *par = s->streams[0]->codecpar; -if (par->codec_id != AV_CODEC_ID_AAC) { -av_log(s, AV_LOG_ERROR, "Only AAC streams can be muxed by the ADTS muxer\n"); -return AVERROR(EINVAL); -} if (par->extradata_size > 0) return adts_decode_extradata(s, adts, par->extradata, par->extradata_size); @@ -242,7 +238,8 @@ const FFOutputFormat ff_adts_muxer = { .p.audio_codec = AV_CODEC_ID_AAC, .p.video_codec = AV_CODEC_ID_NONE, .p.subtitle_codec = AV_CODEC_ID_NONE, -.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH, +.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH | + FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .init = adts_init, .write_header = adts_write_header, .write_packet = adts_write_packet, diff --git a/libavformat/aeaenc.c b/libavformat/aeaenc.c index 3303d108a5..f7969526f4 100644 --- a/libavformat/aeaenc.c +++ b/libavformat/aeaenc.c @@ -37,11 +37,6 @@ static int aea_write_header(AVFormatContext *s) return AVERROR(EINVAL); } -if (st->codecpar->codec_id != AV_CODEC_ID_ATRAC1) { -av_log(s, AV_LOG_ERROR, "AEA can only store ATRAC1 streams, %s was found.\n", avcodec_get_name(st->codecpar->codec_id)); -return AVERROR(EINVAL); -} - if (st->codecpar->sample_rate != 44100) { av_log(s, AV_LOG_ERROR, "Invalid sample rate (%d) AEA only supports 44.1kHz.\n", st->codecpar->sample_rate); return AVERRO
[FFmpeg-cvslog] avformat/ttmlenc: Avoid unnecessary block
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 23:37:11 2024 +0100| [2ccb45511fa9f1c7f57d171d3e7f41a604e07a71] | committer: Andreas Rheinhardt avformat/ttmlenc: Avoid unnecessary block Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2ccb45511fa9f1c7f57d171d3e7f41a604e07a71 --- libavformat/ttmlenc.c | 55 --- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/libavformat/ttmlenc.c b/libavformat/ttmlenc.c index af2e2b85a5..1ffbd66f80 100644 --- a/libavformat/ttmlenc.c +++ b/libavformat/ttmlenc.c @@ -124,38 +124,35 @@ static int ttml_set_header_values_from_extradata( static int ttml_write_header(AVFormatContext *ctx) { TTMLMuxContext *ttml_ctx = ctx->priv_data; +AVStream*st = ctx->streams[0]; +AVIOContext *pb = ctx->pb; + +const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, +0); +const char *printed_lang = (lang && lang->value) ? lang->value : ""; + ttml_ctx->document_written = 0; +ttml_ctx->input_type = ff_is_ttml_stream_paragraph_based(st->codecpar) ? + PACKET_TYPE_PARAGRAPH : + PACKET_TYPE_DOCUMENT; + +avpriv_set_pts_info(st, 64, 1, 1000); -{ -AVStream*st = ctx->streams[0]; -AVIOContext *pb = ctx->pb; - -AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, - 0); -const char *printed_lang = (lang && lang->value) ? lang->value : ""; - -ttml_ctx->input_type = ff_is_ttml_stream_paragraph_based(st->codecpar) ? - PACKET_TYPE_PARAGRAPH : - PACKET_TYPE_DOCUMENT; - -avpriv_set_pts_info(st, 64, 1, 1000); - -if (ttml_ctx->input_type == PACKET_TYPE_PARAGRAPH) { -struct TTMLHeaderParameters header_params; -int ret = ttml_set_header_values_from_extradata( -st->codecpar, &header_params); -if (ret < 0) { -av_log(ctx, AV_LOG_ERROR, - "Failed to parse TTML header values from extradata: " - "%s!\n", av_err2str(ret)); -return ret; -} - -avio_printf(pb, ttml_header_text, -header_params.tt_element_params, -printed_lang, -header_params.pre_body_elements); +if (ttml_ctx->input_type == PACKET_TYPE_PARAGRAPH) { +struct TTMLHeaderParameters header_params; +int ret = ttml_set_header_values_from_extradata( +st->codecpar, &header_params); +if (ret < 0) { +av_log(ctx, AV_LOG_ERROR, + "Failed to parse TTML header values from extradata: " + "%s!\n", av_err2str(ret)); +return ret; } + +avio_printf(pb, ttml_header_text, +header_params.tt_element_params, +printed_lang, +header_params.pre_body_elements); } 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] avformat: Enforce codec_id where appropriate
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 19 23:44:16 2024 +0100| [37f0dbbc3911d315e12478535dcc7ea138d000ad] | committer: Andreas Rheinhardt avformat: Enforce codec_id where appropriate E.g. chromaprint expects to be fed 16bit signed PCM in native endianness, yet there was no check for this. Similarly for other muxers. Use the new FF_OFMT_FLAG_ONLY_DEFAULT_CODECS to enfore this where appropriate, e.g. for pcm/raw muxers. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37f0dbbc3911d315e12478535dcc7ea138d000ad --- libavformat/chromaprint.c | 3 +- libavformat/daudenc.c | 3 +- libavformat/filmstripenc.c | 3 +- libavformat/fitsenc.c | 3 +- libavformat/idroqenc.c | 3 +- libavformat/jacosubenc.c | 3 +- libavformat/mmf.c | 3 +- libavformat/mpjpeg.c | 2 + libavformat/pcmenc.c | 3 +- libavformat/rawenc.c | 102 ++--- libavformat/ttaenc.c | 3 +- 11 files changed, 88 insertions(+), 43 deletions(-) diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c index 62264d6a4b..4beb75c7a9 100644 --- a/libavformat/chromaprint.c +++ b/libavformat/chromaprint.c @@ -179,7 +179,8 @@ const FFOutputFormat ff_chromaprint_muxer = { .p.audio_codec = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE), .p.video_codec = AV_CODEC_ID_NONE, .p.subtitle_codec = AV_CODEC_ID_NONE, -.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH, +.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH | + FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .write_header = write_header, .write_packet = write_packet, .write_trailer = write_trailer, diff --git a/libavformat/daudenc.c b/libavformat/daudenc.c index f1e0da058b..5c8db5104e 100644 --- a/libavformat/daudenc.c +++ b/libavformat/daudenc.c @@ -64,7 +64,8 @@ const FFOutputFormat ff_daud_muxer = { .p.video_codec = AV_CODEC_ID_NONE, .p.subtitle_codec = AV_CODEC_ID_NONE, .p.flags = AVFMT_NOTIMESTAMPS, -.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH | +FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .init = daud_init, .write_packet = daud_write_packet, }; diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c index b2a4cee8fa..ec9c814f8c 100644 --- a/libavformat/filmstripenc.c +++ b/libavformat/filmstripenc.c @@ -67,7 +67,8 @@ const FFOutputFormat ff_filmstrip_muxer = { .p.audio_codec = AV_CODEC_ID_NONE, .p.video_codec = AV_CODEC_ID_RAWVIDEO, .p.subtitle_codec = AV_CODEC_ID_NONE, -.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH, +.flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH | + FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .write_header = write_header, .write_packet = ff_raw_write_packet, .write_trailer = write_trailer, diff --git a/libavformat/fitsenc.c b/libavformat/fitsenc.c index 605056af59..a8efe93d3c 100644 --- a/libavformat/fitsenc.c +++ b/libavformat/fitsenc.c @@ -199,7 +199,8 @@ const FFOutputFormat ff_fits_muxer = { .p.audio_codec = AV_CODEC_ID_NONE, .p.video_codec = AV_CODEC_ID_FITS, .p.subtitle_codec = AV_CODEC_ID_NONE, -.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH | +FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .priv_data_size = sizeof(FITSContext), .write_header = fits_write_header, .write_packet = fits_write_packet, diff --git a/libavformat/idroqenc.c b/libavformat/idroqenc.c index 75a191189c..f3172692e0 100644 --- a/libavformat/idroqenc.c +++ b/libavformat/idroqenc.c @@ -67,7 +67,8 @@ const FFOutputFormat ff_roq_muxer = { .p.audio_codec = AV_CODEC_ID_ROQ_DPCM, .p.video_codec = AV_CODEC_ID_ROQ, .p.subtitle_codec = AV_CODEC_ID_NONE, -.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH | +FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .write_header = roq_write_header, .write_packet = ff_raw_write_packet, }; diff --git a/libavformat/jacosubenc.c b/libavformat/jacosubenc.c index a792fda42e..428505e51f 100644 --- a/libavformat/jacosubenc.c +++ b/libavformat/jacosubenc.c @@ -39,7 +39,8 @@ const FFOutputFormat ff_jacosub_muxer = { .p.video_codec= AV_CODEC_ID_NONE, .p.audio_codec= AV_CODEC_ID_NONE, .p.subtitle_codec = AV_CODEC_ID_JACOSUB, -.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, +.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH | +FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, .write_header = jacosub_write_header, .write_packet = ff_raw_write_packet, }; diff --git a/libavformat/mmf.c b/libavformat/mmf.c index fab4509711..42a88cff90 100644 --- a/libavformat/mmf.c +++ b/libavfo
[FFmpeg-cvslog] avformat: Make init function out of write_header functions if possible
ffmpeg | branch: master | Andreas Rheinhardt | Wed Mar 20 00:51:30 2024 +0100| [073251316e1b0e4174a5aea41e8a3ce25590b165] | committer: Andreas Rheinhardt avformat: Make init function out of write_header functions if possible Also mark them as av_cold while just at it. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=073251316e1b0e4174a5aea41e8a3ce25590b165 --- libavformat/bit.c | 4 ++-- libavformat/chromaprint.c | 4 ++-- libavformat/filmstripenc.c | 4 ++-- libavformat/gif.c | 4 ++-- libavformat/supenc.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavformat/bit.c b/libavformat/bit.c index cd088b87ff..5c3eb31c57 100644 --- a/libavformat/bit.c +++ b/libavformat/bit.c @@ -125,7 +125,7 @@ const FFInputFormat ff_bit_demuxer = { #endif #if CONFIG_BIT_MUXER -static int write_header(AVFormatContext *s) +static av_cold int init(AVFormatContext *s) { AVCodecParameters *par = s->streams[0]->codecpar; @@ -170,7 +170,7 @@ const FFOutputFormat ff_bit_muxer = { .p.subtitle_codec = AV_CODEC_ID_NONE, .flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, -.write_header = write_header, +.init = init, .write_packet = write_packet, }; #endif diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c index 4beb75c7a9..1cdca47ea5 100644 --- a/libavformat/chromaprint.c +++ b/libavformat/chromaprint.c @@ -58,7 +58,7 @@ static void deinit(AVFormatContext *s) } } -static int write_header(AVFormatContext *s) +static av_cold int init(AVFormatContext *s) { ChromaprintMuxContext *cpr = s->priv_data; AVStream *st; @@ -181,7 +181,7 @@ const FFOutputFormat ff_chromaprint_muxer = { .p.subtitle_codec = AV_CODEC_ID_NONE, .flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, -.write_header = write_header, +.init = init, .write_packet = write_packet, .write_trailer = write_trailer, .deinit= deinit, diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c index ec9c814f8c..b5d9179ff3 100644 --- a/libavformat/filmstripenc.c +++ b/libavformat/filmstripenc.c @@ -32,7 +32,7 @@ #define RAND_TAG MKBETAG('R','a','n','d') -static int write_header(AVFormatContext *s) +static av_cold int init(AVFormatContext *s) { if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) { av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n"); @@ -69,7 +69,7 @@ const FFOutputFormat ff_filmstrip_muxer = { .p.subtitle_codec = AV_CODEC_ID_NONE, .flags_internal= FF_OFMT_FLAG_MAX_ONE_OF_EACH | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, -.write_header = write_header, +.init = init, .write_packet = ff_raw_write_packet, .write_trailer = write_trailer, }; diff --git a/libavformat/gif.c b/libavformat/gif.c index 8264e118c6..211705facc 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -40,7 +40,7 @@ typedef struct GIFContext { AVPacket *prev_pkt; } GIFContext; -static int gif_write_header(AVFormatContext *s) +static av_cold int gif_init(AVFormatContext *s) { avpriv_set_pts_info(s->streams[0], 64, 1, 100); @@ -208,7 +208,7 @@ const FFOutputFormat ff_gif_muxer = { .p.subtitle_codec = AV_CODEC_ID_NONE, .flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS, -.write_header = gif_write_header, +.init = gif_init, .write_packet = gif_write_packet, .write_trailer = gif_write_trailer, .p.priv_class = &gif_muxer_class, diff --git a/libavformat/supenc.c b/libavformat/supenc.c index 9d5ca51894..ebdfc7c939 100644 --- a/libavformat/supenc.c +++ b/libavformat/supenc.c @@ -72,7 +72,7 @@ static int sup_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } -static int sup_write_header(AVFormatContext *s) +static av_cold int sup_init(AVFormatContext *s) { avpriv_set_pts_info(s->streams[0], 32, 1, 9); @@ -89,6 +89,6 @@ const FFOutputFormat ff_sup_muxer = { .p.subtitle_codec = AV_CODEC_ID_HDMV_PGS_SUBTITLE, .p.flags = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT, .flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH, -.write_header = sup_write_header, +.init = sup_init, .write_packet = sup_write_packet, }; ___ 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".