[FFmpeg-cvslog] avformat/mvdec: handle audio sample size
ffmpeg | branch: master | John-Paul Stewart | Sat Nov 27 16:45:51 2021 -0500| [6c76b6392348460472f0b6deac4d0a161109d498] | committer: Peter Ross avformat/mvdec: handle audio sample size Adds support for reading audio sample size from the data instead of assuming all audio is 16 bits per sample. Reviewed-by: Peter Ross > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c76b6392348460472f0b6deac4d0a161109d498 --- libavformat/mvdec.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index 8492928820..8b54a9ab04 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -299,6 +299,8 @@ static int mv_read_header(AVFormatContext *avctx) if (version == 2) { uint64_t timestamp; int v; +uint32_t bytes_per_sample; + avio_skip(pb, 22); /* allocate audio track first to prevent unnecessary seeking @@ -341,11 +343,21 @@ static int mv_read_header(AVFormatContext *avctx) } avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate); -avio_skip(pb, 4); +bytes_per_sample = avio_rb32(pb); v = avio_rb32(pb); if (v == AUDIO_FORMAT_SIGNED) { -ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; +switch (bytes_per_sample) { +case 1: +ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8; +break; +case 2: +ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; +break; +default: +avpriv_request_sample(avctx, "Audio sample size %i bytes", bytes_per_sample); +break; +} } else { avpriv_request_sample(avctx, "Audio compression (format %i)", v); } @@ -369,7 +381,7 @@ static int mv_read_header(AVFormatContext *avctx) avio_skip(pb, 8); av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME); av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME); -timestamp += asize / (ast->codecpar->channels * 2LL); +timestamp += asize / (ast->codecpar->channels * bytes_per_sample); } } else if (!version && avio_rb16(pb) == 3) { avio_skip(pb, 4); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/mvdec: fix reading number of audio channels
ffmpeg | branch: master | John-Paul Stewart | Sat Nov 27 16:45:50 2021 -0500| [4a90c039e7a17c913d2961f902f667d38490b6ab] | committer: Peter Ross avformat/mvdec: fix reading number of audio channels The number of audio channels is stored after the magic number identifying the audio format. Prior to this patch the code has been reading it earlier, causing files with only one audio channel to be handled incorrectly. Reviewed-by: Peter Ross > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4a90c039e7a17c913d2961f902f667d38490b6ab --- libavformat/mvdec.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index d58281c3a9..8492928820 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -340,8 +340,8 @@ static int mv_read_header(AVFormatContext *avctx) return AVERROR_INVALIDDATA; } avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate); -if (set_channels(avctx, ast, avio_rb32(pb)) < 0) -return AVERROR_INVALIDDATA; + +avio_skip(pb, 4); v = avio_rb32(pb); if (v == AUDIO_FORMAT_SIGNED) { @@ -350,7 +350,11 @@ static int mv_read_header(AVFormatContext *avctx) avpriv_request_sample(avctx, "Audio compression (format %i)", v); } -avio_skip(pb, 12); +if (set_channels(avctx, ast, avio_rb32(pb)) < 0) +return AVERROR_INVALIDDATA; + +avio_skip(pb, 8); + var_read_metadata(avctx, "title", 0x80); var_read_metadata(avctx, "comment", 0x100); avio_skip(pb, 0x80); ___ 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] swresample/swresample: Remove array size hint from swr_convert()
ffmpeg | branch: master | Andreas Rheinhardt | Tue Nov 30 12:24:10 2021 +0100| [77a37e0369b4b0adf06ccbda2f95828fb6afb2c3] | committer: Andreas Rheinhardt swresample/swresample: Remove array size hint from swr_convert() SWR_CH_MAX is internal only and the arrays are therefore not required to have that many elements (and they typically don't do it). So remove this potentially confusing hint. (Newer versions of GCC emit -Warray-parameter= warnings for this, because the definition with explicit size differs from the declaration (which leaves the size unspecified); this is IMO a false-positive, because definition and declaration didn't conflict, but anyway it is fixed by this commit.) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77a37e0369b4b0adf06ccbda2f95828fb6afb2c3 --- libswresample/swresample.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 22c2c33673..c03fe5528f 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -711,8 +711,10 @@ int swr_is_initialized(struct SwrContext *s) { return !!s->in_buffer.ch_count; } -int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, -const uint8_t *in_arg [SWR_CH_MAX], int in_count){ +int attribute_align_arg swr_convert(struct SwrContext *s, + uint8_t **out_arg, int out_count, +const uint8_t **in_arg, int in_count) +{ AudioData * in= &s->in; AudioData *out= &s->out; int av_unused max_output; ___ 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] avdevice/lavfi: Cleanup generically on read_header failure
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 16:00:16 2021 +0100| [05c924a86db04e05831876dd2720093dcc2dc8e1] | committer: Andreas Rheinhardt avdevice/lavfi: Cleanup generically on read_header failure Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=05c924a86db04e05831876dd2720093dcc2dc8e1 --- libavdevice/lavfi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 4eb1f56f7d..826dafbd00 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -356,8 +356,6 @@ end: av_free(pix_fmts); avfilter_inout_free(&input_links); avfilter_inout_free(&output_links); -if (ret < 0) -lavfi_read_close(avctx); return ret; } @@ -507,4 +505,5 @@ const AVInputFormat ff_lavfi_demuxer = { .read_close = lavfi_read_close, .flags = AVFMT_NOFILE, .priv_class = &lavfi_class, +.flags_internal = FF_FMT_INIT_CLEANUP, }; ___ 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] avdevice/lavfi: Properly free an AVDictionary
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 16:41:09 2021 +0100| [531d289cfd853567df69d5eb490425677e3759b9] | committer: Andreas Rheinhardt avdevice/lavfi: Properly free an AVDictionary It is not documented that freeing the last (and only) entry of an AVDictionary frees the dictionary. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=531d289cfd853567df69d5eb490425677e3759b9 --- libavdevice/lavfi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 826dafbd00..d9083ad984 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -150,7 +150,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) if (avctx->protocol_whitelist && (ret = av_dict_set(&options, "protocol_whitelist", avctx->protocol_whitelist, 0)) < 0) goto end; ret = avio_open2(&avio, lavfi->graph_filename, AVIO_FLAG_READ, &avctx->interrupt_callback, &options); -av_dict_set(&options, "protocol_whitelist", NULL, 0); +av_dict_free(&options); if (ret < 0) goto end; av_bprint_init(&graph_file_pb, 0, AV_BPRINT_SIZE_UNLIMITED); ___ 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_redundant_pps_bsf: Remove flush callback
ffmpeg | branch: master | Andreas Rheinhardt | Tue Nov 30 18:16:17 2021 +0100| [5e7bdbfff6b99ea61254b048605aca3cb349ddb1] | committer: Andreas Rheinhardt avcodec/h264_redundant_pps_bsf: Remove flush callback extradata_pic_init_qp is unset since fa75e438756f159a667080dcba58ea2e3b190001 (and resetting current_pic_init_qp to the value it had in extradata never made much sense). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e7bdbfff6b99ea61254b048605aca3cb349ddb1 --- libavcodec/h264_redundant_pps_bsf.c | 8 1 file changed, 8 deletions(-) diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index fb678beef3..4b2831fb04 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -33,7 +33,6 @@ typedef struct H264RedundantPPSContext { int global_pic_init_qp; int current_pic_init_qp; -int extradata_pic_init_qp; } H264RedundantPPSContext; @@ -111,12 +110,6 @@ static int h264_redundant_pps_update_fragment(AVBSFContext *bsf, return 0; } -static void h264_redundant_pps_flush(AVBSFContext *bsf) -{ -H264RedundantPPSContext *ctx = bsf->priv_data; -ctx->current_pic_init_qp = ctx->extradata_pic_init_qp; -} - static const CBSBSFType h264_redundant_pps_type = { .codec_id= AV_CODEC_ID_H264, .fragment_name = "access unit", @@ -141,7 +134,6 @@ const AVBitStreamFilter ff_h264_redundant_pps_bsf = { .name = "h264_redundant_pps", .priv_data_size = sizeof(H264RedundantPPSContext), .init = &h264_redundant_pps_init, -.flush = &h264_redundant_pps_flush, .close = &ff_cbs_bsf_generic_close, .filter = &ff_cbs_bsf_generic_filter, .codec_ids = h264_redundant_pps_codec_ids, ___ 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_redundant_pps_bsf: Inline constant
ffmpeg | branch: master | Andreas Rheinhardt | Tue Nov 30 19:19:06 2021 +0100| [b574fb472ed168f5a75cd981c98dd34cfe57ff3a] | committer: Andreas Rheinhardt avcodec/h264_redundant_pps_bsf: Inline constant Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b574fb472ed168f5a75cd981c98dd34cfe57ff3a --- libavcodec/h264_redundant_pps_bsf.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index 5efcf5ea5d..769946abfd 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -27,11 +27,10 @@ #include "cbs_h264.h" #include "h264.h" +#define NEW_GLOBAL_PIC_INIT_QP 26 typedef struct H264RedundantPPSContext { CBSBSFContext common; - -int global_pic_init_qp; } H264RedundantPPSContext; @@ -50,7 +49,7 @@ static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx, pps = unit->content; // Overwrite pic_init_qp with the global value. -pps->pic_init_qp_minus26 = ctx->global_pic_init_qp - 26; +pps->pic_init_qp_minus26 = NEW_GLOBAL_PIC_INIT_QP - 26; // Some PPSs have this set, so it must be set in all of them. // (Slices which do not use such a PPS on input will still have @@ -69,7 +68,7 @@ static int h264_redundant_pps_fixup_slice(H264RedundantPPSContext *ctx, // We modified the PPS's qp value, now offset this by applying // the negative offset to the slices. slice->slice_qp_delta += pps->pic_init_qp_minus26 - - (ctx->global_pic_init_qp - 26); + - (NEW_GLOBAL_PIC_INIT_QP - 26); return 0; } @@ -119,10 +118,6 @@ static const CBSBSFType h264_redundant_pps_type = { static int h264_redundant_pps_init(AVBSFContext *bsf) { -H264RedundantPPSContext *ctx = bsf->priv_data; - -ctx->global_pic_init_qp = 26; - return ff_cbs_bsf_generic_init(bsf, &h264_redundant_pps_type); } ___ 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_redundant_pps_bsf: Support multiple input PPS
ffmpeg | branch: master | Andreas Rheinhardt | Tue Nov 30 18:43:34 2021 +0100| [5892a55d55dcb17702eff35717ca7cafcd4dc658] | committer: Andreas Rheinhardt avcodec/h264_redundant_pps_bsf: Support multiple input PPS Up until now, the h264_redundant_pps_bsf stored the initial value of pic_init_qp_minus26 of the most recently encountered PPS; it also modified the slices based upon to assumption that the most recent PPS is the PPS the slice belongs to. Yet this assumption is flawed, as there can be several PPS with different IDs that are visible at any given time. If these have different pic_init_qp_minus26 values, the output can be invalid. Fix this by directly using the pic_init_qp_minus26 value of the input PPS. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5892a55d55dcb17702eff35717ca7cafcd4dc658 --- libavcodec/h264_redundant_pps_bsf.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index 4b2831fb04..5efcf5ea5d 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -32,7 +32,6 @@ typedef struct H264RedundantPPSContext { CBSBSFContext common; int global_pic_init_qp; -int current_pic_init_qp; } H264RedundantPPSContext; @@ -50,9 +49,7 @@ static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx, return err; pps = unit->content; -// Record the current value of pic_init_qp in order to fix up -// following slices, then overwrite with the global value. -ctx->current_pic_init_qp = pps->pic_init_qp_minus26 + 26; +// Overwrite pic_init_qp with the global value. pps->pic_init_qp_minus26 = ctx->global_pic_init_qp - 26; // Some PPSs have this set, so it must be set in all of them. @@ -66,10 +63,13 @@ static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx, static int h264_redundant_pps_fixup_slice(H264RedundantPPSContext *ctx, H264RawSliceHeader *slice) { -int qp; +const CodedBitstreamH264Context *const in = ctx->common.input->priv_data; +const H264RawPPS *const pps = in->pps[slice->pic_parameter_set_id]; -qp = ctx->current_pic_init_qp + slice->slice_qp_delta; -slice->slice_qp_delta = qp - ctx->global_pic_init_qp; +// We modified the PPS's qp value, now offset this by applying +// the negative offset to the slices. +slice->slice_qp_delta += pps->pic_init_qp_minus26 + - (ctx->global_pic_init_qp - 26); 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] swscale/yuv2rgb: Silence a set-but-unused-variable warning
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 1 16:02:23 2021 +0100| [3be6fe9a567038a77cebca275db99573ed9853ba] | committer: Andreas Rheinhardt swscale/yuv2rgb: Silence a set-but-unused-variable warning Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3be6fe9a567038a77cebca275db99573ed9853ba --- libswscale/yuv2rgb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 353de2f822..76232cb364 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -145,8 +145,8 @@ const int *sws_getCoefficients(int colorspace) dst_type av_unused *r, *g, *b; \ const uint8_t *py_1 = src[0] + y * srcStride[0]; \ const uint8_t *py_2 = py_1 +srcStride[0]; \ -const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \ -const uint8_t *pv = src[2] + (y >> 1) * srcStride[2]; \ +const uint8_t av_unused *pu = src[1] + (y >> 1) * srcStride[1]; \ +const uint8_t av_unused *pv = src[2] + (y >> 1) * srcStride[2]; \ const uint8_t av_unused *pa_1, *pa_2; \ unsigned int h_size = c->dstW >> 3; \ if (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] all: Use av_memdup() where appropriate
ffmpeg | branch: master | Andreas Rheinhardt | Sat Nov 27 10:50:47 2021 +0100| [a4798a5d5109cd9c1b5682efe19660e825da97e6] | committer: Andreas Rheinhardt all: Use av_memdup() where appropriate Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a4798a5d5109cd9c1b5682efe19660e825da97e6 --- libavcodec/decode.c | 4 +--- libavcodec/dvbsubdec.c | 8 ++-- libavcodec/g723_1enc.c | 3 +-- libavformat/hdsenc.c | 6 ++ libavformat/mpegts.c | 3 +-- libavformat/oggparsevorbis.c | 3 +-- libavformat/rtsp.c | 3 +-- libavutil/bprint.c | 6 ++ 8 files changed, 11 insertions(+), 25 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index c44724d150..52bf5dcd33 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1104,12 +1104,10 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) avctx->sw_pix_fmt = fmt[n - 1]; } -choices = av_malloc_array(n + 1, sizeof(*choices)); +choices = av_memdup(fmt, (n + 1) * sizeof(*choices)); if (!choices) return AV_PIX_FMT_NONE; -memcpy(choices, fmt, (n + 1) * sizeof(*choices)); - for (;;) { // Remove the previous hwaccel, if there was one. hwaccel_uninit(avctx); diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index d192f3251d..81ccaf4c57 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -823,14 +823,12 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou } memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(*clut_table)); -rect->data[0] = av_malloc(region->buf_size); +rect->data[0] = av_memdup(region->pbuf, region->buf_size); if (!rect->data[0]) { ret = AVERROR(ENOMEM); goto fail; } -memcpy(rect->data[0], region->pbuf, region->buf_size); - if ((clut == &default_clut && ctx->compute_clut < 0) || ctx->compute_clut == 1) { if (!region->has_computed_clut) { compute_default_clut(ctx, region->computed_clut, rect, rect->w, rect->h); @@ -1074,12 +1072,10 @@ static int dvbsub_parse_clut_segment(AVCodecContext *avctx, clut = get_clut(ctx, clut_id); if (!clut) { -clut = av_malloc(sizeof(*clut)); +clut = av_memdup(&default_clut, sizeof(*clut)); if (!clut) return AVERROR(ENOMEM); -memcpy(clut, &default_clut, sizeof(*clut)); - clut->id = clut_id; clut->version = -1; diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index 2b3cccee09..2a8149b4cd 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -1116,10 +1116,9 @@ static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, HFParam hf[4]; /* duplicate input */ -start = in = av_malloc(frame->nb_samples * sizeof(int16_t)); +start = in = av_memdup(frame->data[0], frame->nb_samples * sizeof(int16_t)); if (!in) return AVERROR(ENOMEM); -memcpy(in, frame->data[0], frame->nb_samples * sizeof(int16_t)); highpass_filter(in, &p->hpf_fir_mem, &p->hpf_iir_mem); diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index e5353bac65..64d9f1413d 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -93,19 +93,17 @@ static int parse_header(OutputStream *os, const uint8_t *buf, int buf_size) if (os->nb_extra_packets >= FF_ARRAY_ELEMS(os->extra_packets)) return AVERROR_INVALIDDATA; os->extra_packet_sizes[os->nb_extra_packets] = size; -os->extra_packets[os->nb_extra_packets] = av_malloc(size); +os->extra_packets[os->nb_extra_packets] = av_memdup(buf, size); if (!os->extra_packets[os->nb_extra_packets]) return AVERROR(ENOMEM); -memcpy(os->extra_packets[os->nb_extra_packets], buf, size); os->nb_extra_packets++; } else if (type == 0x12) { if (os->metadata) return AVERROR_INVALIDDATA; os->metadata_size = size - 11 - 4; -os->metadata = av_malloc(os->metadata_size); +os->metadata = av_memdup(buf + 11, os->metadata_size); if (!os->metadata) return AVERROR(ENOMEM); -memcpy(os->metadata, buf + 11, os->metadata_size); } buf += size; buf_size -= size; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 36ab7ab3af..2479cb6f7d 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -938,10 +938,9 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, // audio track - add a second stream for this AVStream *sub_st; // priv_data cannot be shared between
[FFmpeg-cvslog] all: Remove unused-but-set variables
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 1 15:22:05 2021 +0100| [01d158d1c8295474fa2034612487b36a47adfd1d] | committer: Andreas Rheinhardt all: Remove unused-but-set variables Newer versions of Clang detect this and emit warnings for it. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01d158d1c8295474fa2034612487b36a47adfd1d --- libavcodec/aaccoder.c| 3 +-- libavcodec/cinepakenc.c | 3 --- libavcodec/error_resilience.c| 3 --- libavcodec/imc.c | 5 ++--- libavcodec/j2kenc.c | 2 -- libavcodec/roqvideoenc.c | 2 -- libavfilter/af_astats.c | 4 libswresample/tests/swresample.c | 8 8 files changed, 3 insertions(+), 27 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 11b0559e1c..7bbd4d5b2e 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -414,11 +414,10 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, start = 0; for (g = 0; g < sce->ics.num_swb; g++) { int nz = 0; -float uplim = 0.0f, energy = 0.0f; +float uplim = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; uplim += band->threshold; -energy += band->energy; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; continue; diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c index edb553f0db..0574b125d7 100644 --- a/libavcodec/cinepakenc.c +++ b/libavcodec/cinepakenc.c @@ -705,7 +705,6 @@ static int quantize(CinepakEncContext *s, int h, uint8_t *data[4], int entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4; int *codebook = v1mode ? info->v1_codebook : info->v4_codebook; int size= v1mode ? info->v1_size : info->v4_size; -int64_t total_error = 0; uint8_t vq_pict_buf[(MB_AREA * 3) / 2]; uint8_t *sub_data[4], *vq_data[4]; int sub_linesize[4], vq_linesize[4]; @@ -795,7 +794,6 @@ static int quantize(CinepakEncContext *s, int h, uint8_t *data[4], mb->v1_error = compute_mb_distortion(s, sub_data, sub_linesize, vq_data, vq_linesize); -total_error += mb->v1_error; } else { for (k = 0; k < 4; k++) mb->v4_vector[k] = s->codebook_closest[i + k]; @@ -805,7 +803,6 @@ static int quantize(CinepakEncContext *s, int h, uint8_t *data[4], mb->v4_error = compute_mb_distortion(s, sub_data, sub_linesize, vq_data, vq_linesize); -total_error += mb->v4_error; } i += v1mode ? 1 : 4; } diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index f13be7b918..91cd8a 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -476,8 +476,6 @@ static void guess_mv(ERContext *s) none_left = 1; changed = 1; for (pass = 0; (changed || pass < 2) && pass < 10; pass++) { -int score_sum = 0; - changed = 0; for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) { const int mb_x = blocklist[blocklist_index][0]; @@ -668,7 +666,6 @@ skip_mean_and_median: best_pred = j; } } -score_sum += best_score; s->mv[0][0][0] = mv_predictor[best_pred][0]; s->mv[0][0][1] = mv_predictor[best_pred][1]; diff --git a/libavcodec/imc.c b/libavcodec/imc.c index cbe3edeeec..116c273ba0 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -829,7 +829,7 @@ static void imc_get_coeffs(AVCodecContext *avctx, static void imc_refine_bit_allocation(IMCContext *q, IMCChannel *chctx) { int i, j; -int bits, summer; +int summer; for (i = 0; i < BANDS; i++) { chctx->sumLenArr[i] = 0; @@ -853,7 +853,7 @@ static void imc_refine_bit_allocation(IMCContext *q, IMCChannel *chctx) } /* calculate bits left, bits needed and adjust bit allocation */ -bits = summer = 0; +summer = 0; for (i = 0; i < BANDS; i++) { if (chctx->bandFlagsBuf[i]) { @@ -863,7 +863,6 @@ static void imc_refine_bit_allocation(IMCContext *q, IMCChannel *chctx) chctx->CWlengthT[j] = 0; } } -bits += chctx->skipFlagBits[i]; summer -= chctx->skipFlagBits[i]; } } diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index fa6fc208f5..c06752f43a 100644 --- a/libavcodec/j2kenc.c ++
[FFmpeg-cvslog] fftools/ffmpeg_filter: Avoid DynBuf-API for writing strings
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 1 16:36:19 2021 +0100| [cf8925a0965a75f22cddb1cc42e11871ccf84c15] | committer: Andreas Rheinhardt fftools/ffmpeg_filter: Avoid DynBuf-API for writing strings It is not really natural, it requires internal allocations of its own and its error handling is horrible (i.e. the implicit (re)allocations here are unchecked). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cf8925a0965a75f22cddb1cc42e11871ccf84c15 --- fftools/ffmpeg_filter.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 452b689d62..47bbb67ce0 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -201,17 +201,15 @@ static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in) AVFilterContext *ctx = inout->filter_ctx; AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs; -AVIOContext *pb; -uint8_t *res = NULL; +char *res; -if (avio_open_dyn_buf(&pb) < 0) -exit_program(1); - -avio_printf(pb, "%s", ctx->filter->name); if (nb_pads > 1) -avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx)); -avio_w8(pb, 0); -avio_close_dyn_buf(pb, &res); +res = av_strdup(ctx->filter->name); +else +res = av_asprintf("%s:%s", ctx->filter->name, + avfilter_pad_get_name(pads, inout->pad_idx)); +if (!res) +exit_program(1); return res; } ___ 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_filter: Avoid DynBuf API to improve error checks
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 1 17:13:32 2021 +0100| [efc323062c20aaead8fb5805b7f69b4f071cb319] | committer: Andreas Rheinhardt fftools/ffmpeg_filter: Avoid DynBuf API to improve error checks choose_pix_fmts() used the dynamic buffer API to write strings; as is common among uses of this API, only opening the dynamic buffer was checked, but not the end result, leading to crashes in case of allocation failure. Furthermore, some static strings were duplicated; the allocations performed here were not properly checked: Allocation failure would be treated as "could not determine pixel format". The first issue is fixed by switching to the AVBPrint API which allows to easily perform checks at the end. Furthermore, the internal buffer avoids almost all allocations in case the AVBPrint is used. The AVBPrint also allows to solve the second issue in an elegant way, because it allows to return the static strings directly. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=efc323062c20aaead8fb5805b7f69b4f071cb319 --- fftools/ffmpeg_filter.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 47bbb67ce0..dab0f28819 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -83,7 +83,10 @@ static enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx return target; } -static char *choose_pix_fmts(OutputFilter *ofilter) +/* May return NULL (no pixel format found), a static string or a string + * backed by the bprint. Nothing has been written to the AVBPrint in case + * NULL is returned. The AVBPrint provided should be clean. */ +static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) { OutputStream *ost = ofilter->ost; const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); @@ -96,18 +99,12 @@ static char *choose_pix_fmts(OutputFilter *ofilter) AVFILTER_AUTO_CONVERT_NONE); if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE) return NULL; -return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt)); +return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt); } if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { -return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt))); +return av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)); } else if (ost->enc && ost->enc->pix_fmts) { const enum AVPixelFormat *p; -AVIOContext *s = NULL; -uint8_t *ret; -int len; - -if (avio_open_dyn_buf(&s) < 0) -exit_program(1); p = ost->enc->pix_fmts; if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { @@ -116,11 +113,11 @@ static char *choose_pix_fmts(OutputFilter *ofilter) for (; *p != AV_PIX_FMT_NONE; p++) { const char *name = av_get_pix_fmt_name(*p); -avio_printf(s, "%s|", name); +av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|'); } -len = avio_close_dyn_buf(s, &ret); -ret[len - 1] = 0; -return ret; +if (!av_bprint_is_complete(bprint)) +exit_program(1); +return bprint->str; } else return NULL; } @@ -416,12 +413,13 @@ static int insert_filter(AVFilterContext **last_filter, int *pad_idx, static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out) { -char *pix_fmts; OutputStream *ost = ofilter->ost; OutputFile*of = output_files[ost->file_index]; AVFilterContext *last_filter = out->filter_ctx; +AVBPrint bprint; int pad_idx = out->pad_idx; int ret; +const char *pix_fmts; char name[255]; snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index); @@ -457,13 +455,14 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, pad_idx = 0; } -if ((pix_fmts = choose_pix_fmts(ofilter))) { +av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); +if ((pix_fmts = choose_pix_fmts(ofilter, &bprint))) { AVFilterContext *filter; ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("format"), "format", pix_fmts, NULL, fg->graph); -av_freep(&pix_fmts); +av_bprint_finalize(&bprint, NULL); if (ret < 0) return ret; if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubs
[FFmpeg-cvslog] avdevice/lavfi: Use dedicated pointer to access st->codecpar
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 18:08:13 2021 +0100| [83ae589359203e83a7e9c1e96eb3f02f5a5bfa6b] | committer: Andreas Rheinhardt avdevice/lavfi: Use dedicated pointer to access st->codecpar Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83ae589359203e83a7e9c1e96eb3f02f5a5bfa6b --- libavdevice/lavfi.c | 25 + 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 2659c8508a..209ebed5fd 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -317,26 +317,27 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) AVFilterContext *sink = lavfi->sinks[lavfi->stream_sink_map[i]]; AVRational time_base = av_buffersink_get_time_base(sink); AVStream *st = avctx->streams[i]; -st->codecpar->codec_type = av_buffersink_get_type(sink); +AVCodecParameters *const par = st->codecpar; avpriv_set_pts_info(st, 64, time_base.num, time_base.den); +par->codec_type = av_buffersink_get_type(sink); if (av_buffersink_get_type(sink) == AVMEDIA_TYPE_VIDEO) { -st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; -st->codecpar->format = av_buffersink_get_format(sink); -st->codecpar->width = av_buffersink_get_w(sink); -st->codecpar->height = av_buffersink_get_h(sink); +par->codec_id = AV_CODEC_ID_RAWVIDEO; +par->format = av_buffersink_get_format(sink); +par->width = av_buffersink_get_w(sink); +par->height = av_buffersink_get_h(sink); st ->sample_aspect_ratio = -st->codecpar->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink); +par->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink); avctx->probesize = FFMAX(avctx->probesize, av_buffersink_get_w(sink) * av_buffersink_get_h(sink) * av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(av_buffersink_get_format(sink))) * 30); } else if (av_buffersink_get_type(sink) == AVMEDIA_TYPE_AUDIO) { -st->codecpar->codec_id= av_get_pcm_codec(av_buffersink_get_format(sink), -1); -st->codecpar->channels= av_buffersink_get_channels(sink); -st->codecpar->format = av_buffersink_get_format(sink); -st->codecpar->sample_rate = av_buffersink_get_sample_rate(sink); -st->codecpar->channel_layout = av_buffersink_get_channel_layout(sink); -if (st->codecpar->codec_id == AV_CODEC_ID_NONE) +par->channels= av_buffersink_get_channels(sink); +par->sample_rate = av_buffersink_get_sample_rate(sink); +par->channel_layout = av_buffersink_get_channel_layout(sink); +par->format = av_buffersink_get_format(sink); +par->codec_id= av_get_pcm_codec(av_buffersink_get_format(sink), -1); +if (par->codec_id == AV_CODEC_ID_NONE) av_log(avctx, AV_LOG_ERROR, "Could not find PCM codec for sample format %s.\n", av_get_sample_fmt_name(av_buffersink_get_format(sink))); ___ 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] avdevice/lavfi: Don't unnecessarily write '\0' to AVBPrint
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 16:51:17 2021 +0100| [84f037edc2065db348879a9312720a93e54a4942] | committer: Andreas Rheinhardt avdevice/lavfi: Don't unnecessarily write '\0' to AVBPrint An AVBPrint's internal string is always already zero-terminated; writing another '\0' is unnecessary as long as one treats the string only as a C-string. Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84f037edc2065db348879a9312720a93e54a4942 --- libavdevice/lavfi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index d9083ad984..2659c8508a 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -156,9 +156,6 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) av_bprint_init(&graph_file_pb, 0, AV_BPRINT_SIZE_UNLIMITED); ret = avio_read_to_bprint(avio, &graph_file_pb, INT_MAX); avio_closep(&avio); -av_bprint_chars(&graph_file_pb, '\0', 1); -if (!ret && !av_bprint_is_complete(&graph_file_pb)) -ret = AVERROR(ENOMEM); if (ret) { av_bprint_finalize(&graph_file_pb, NULL); goto end; ___ 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] avdevice/lavfi: Avoid calling av_buffersink_get_* multiple times
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 18:35:50 2021 +0100| [88af0962ef76582a1f4772ee81816512a6646edb] | committer: Andreas Rheinhardt avdevice/lavfi: Avoid calling av_buffersink_get_* multiple times Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=88af0962ef76582a1f4772ee81816512a6646edb --- libavdevice/lavfi.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 209ebed5fd..878bb193af 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -320,27 +320,27 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) AVCodecParameters *const par = st->codecpar; avpriv_set_pts_info(st, 64, time_base.num, time_base.den); par->codec_type = av_buffersink_get_type(sink); -if (av_buffersink_get_type(sink) == AVMEDIA_TYPE_VIDEO) { +if (par->codec_type == AVMEDIA_TYPE_VIDEO) { +int64_t probesize; par->codec_id = AV_CODEC_ID_RAWVIDEO; par->format = av_buffersink_get_format(sink); par->width = av_buffersink_get_w(sink); par->height = av_buffersink_get_h(sink); +probesize = par->width * par->height * 30 * + av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(par->format)); +avctx->probesize = FFMAX(avctx->probesize, probesize); st ->sample_aspect_ratio = par->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink); -avctx->probesize = FFMAX(avctx->probesize, - av_buffersink_get_w(sink) * av_buffersink_get_h(sink) * - av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(av_buffersink_get_format(sink))) * - 30); -} else if (av_buffersink_get_type(sink) == AVMEDIA_TYPE_AUDIO) { +} else if (par->codec_type == AVMEDIA_TYPE_AUDIO) { par->channels= av_buffersink_get_channels(sink); par->sample_rate = av_buffersink_get_sample_rate(sink); par->channel_layout = av_buffersink_get_channel_layout(sink); par->format = av_buffersink_get_format(sink); -par->codec_id= av_get_pcm_codec(av_buffersink_get_format(sink), -1); +par->codec_id= av_get_pcm_codec(par->format, -1); if (par->codec_id == AV_CODEC_ID_NONE) av_log(avctx, AV_LOG_ERROR, "Could not find PCM codec for sample format %s.\n", - av_get_sample_fmt_name(av_buffersink_get_format(sink))); + av_get_sample_fmt_name(par->format)); } } ___ 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] avdevice/lavfi: Make array static const
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 18:40:39 2021 +0100| [60a2c74a5eaf8d4ab16a68842be3b9cfbd45b467] | committer: Andreas Rheinhardt avdevice/lavfi: Make array static const Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=60a2c74a5eaf8d4ab16a68842be3b9cfbd45b467 --- libavdevice/lavfi.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 878bb193af..b208b1a928 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -269,11 +269,10 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) if (ret < 0) goto end; } else if (type == AVMEDIA_TYPE_AUDIO) { -enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8, - AV_SAMPLE_FMT_S16, - AV_SAMPLE_FMT_S32, - AV_SAMPLE_FMT_FLT, - AV_SAMPLE_FMT_DBL, -1 }; +static const enum AVSampleFormat sample_fmts[] = { +AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, +AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, -1 +}; ret = avfilter_graph_create_filter(&sink, abuffersink, inout->name, NULL, ___ 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] avdevice/lavfi: Simplify setting sample_fmts
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 19:19:19 2021 +0100| [b7e3ae19b8d3dc1b14c600220a47171e5e3ef746] | committer: Andreas Rheinhardt avdevice/lavfi: Simplify setting sample_fmts The length of this list is a compile-time constant, so there is no need to calculate it again at runtime. (This also avoids an implicit requirement of -1 == AV_SAMPLE_FMT_NONE.) Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7e3ae19b8d3dc1b14c600220a47171e5e3ef746 --- libavdevice/lavfi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index b208b1a928..d63a6f66b3 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -271,14 +271,15 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) } else if (type == AVMEDIA_TYPE_AUDIO) { static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, -AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, -1 +AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, }; ret = avfilter_graph_create_filter(&sink, abuffersink, inout->name, NULL, NULL, lavfi->graph); if (ret >= 0) -ret = av_opt_set_int_list(sink, "sample_fmts", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN); +ret = av_opt_set_bin(sink, "sample_fmts", (const uint8_t*)sample_fmts, + sizeof(sample_fmts), AV_OPT_SEARCH_CHILDREN); if (ret < 0) goto end; ret = av_opt_set_int(sink, "all_channel_counts", 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] avdevice/lavfi: Don't require AV_PIX_FMT_NONE == -1
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 20:57:23 2021 +0100| [61bbd0cf3c2ae1f8502243a5695d68cbd3b20758] | committer: Andreas Rheinhardt avdevice/lavfi: Don't require AV_PIX_FMT_NONE == -1 Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=61bbd0cf3c2ae1f8502243a5695d68cbd3b20758 --- libavdevice/lavfi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index d63a6f66b3..710ad7c530 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -76,7 +76,7 @@ static int *create_all_formats(int n) if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) fmts[j++] = i; } -fmts[j] = -1; +fmts[j] = AV_PIX_FMT_NONE; return fmts; } ___ 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] avfilter/buffersink: Remove outdated comments
ffmpeg | branch: master | Andreas Rheinhardt | Thu Dec 2 21:08:38 2021 +0100| [03ab1de429a43a99c6de0c0d6ec1d275349dc133] | committer: Andreas Rheinhardt avfilter/buffersink: Remove outdated comments These lists have size fields since e48ded8551172b58a78f30303a81dfce125344e0. Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=03ab1de429a43a99c6de0c0d6ec1d275349dc133 --- libavfilter/buffersink.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index b8ddafec35..c0215669e7 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -43,18 +43,18 @@ typedef struct BufferSinkContext { unsigned warning_limit; /* only used for video */ -enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats, must be terminated with -1 +enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats int pixel_fmts_size; /* only used for audio */ -enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE +enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats int sample_fmts_size; -int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1 +int64_t *channel_layouts; ///< list of accepted channel layouts int channel_layouts_size; -int *channel_counts;///< list of accepted channel counts, terminated by -1 +int *channel_counts;///< list of accepted channel counts int channel_counts_size; int all_channel_counts; -int *sample_rates; ///< list of accepted sample rates, terminated by -1 +int *sample_rates; ///< list of accepted sample rates int sample_rates_size; AVFrame *peeked_frame; ___ 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] lavu/avframe: add a time_base field
ffmpeg | branch: master | Lynne | Thu Nov 25 18:26:20 2021 +0100| [b236ef0a594e20038b4045e2fecd414f1886d212] | committer: Lynne lavu/avframe: add a time_base field This adds a time_base field to AVFrame, as an analogue to the AVPacket.time_base field. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b236ef0a594e20038b4045e2fecd414f1886d212 --- doc/APIchanges | 3 +++ libavutil/frame.c | 2 ++ libavutil/frame.h | 8 libavutil/version.h | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index bc9f4e38da..4788dd576d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-12-03 - xx - lavu 57.10.100 - frame.h + Add AVFrame.time_base + 2021-11-22 - xx - lavu 57.9.100 - pixfmt.h Add AV_PIX_FMT_P210, AV_PIX_FMT_P410, AV_PIX_FMT_P216, and AV_PIX_FMT_P416. diff --git a/libavutil/frame.c b/libavutil/frame.c index d4d3ad6988..64eed5b0dd 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -63,6 +63,7 @@ static void get_frame_defaults(AVFrame *frame) frame->pkt_duration= 0; frame->pkt_pos = -1; frame->pkt_size= -1; +frame->time_base = (AVRational){ 0, 1 }; frame->key_frame = 1; frame->sample_aspect_ratio = (AVRational){ 0, 1 }; frame->format = -1; /* unknown */ @@ -278,6 +279,7 @@ static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy) dst->pkt_pos= src->pkt_pos; dst->pkt_size = src->pkt_size; dst->pkt_duration = src->pkt_duration; +dst->time_base = src->time_base; dst->reordered_opaque = src->reordered_opaque; dst->quality= src->quality; dst->best_effort_timestamp = src->best_effort_timestamp; diff --git a/libavutil/frame.h b/libavutil/frame.h index 753234792e..882b5afbde 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -421,6 +421,14 @@ typedef struct AVFrame { */ int64_t pkt_dts; +/** + * Time base for the timestamps in this frame. + * In the future, this field may be set on frames output by decoders or + * filters, but its value will be by default ignored on input to encoders + * or filters. + */ +AVRational time_base; + /** * picture number in bitstream order */ diff --git a/libavutil/version.h b/libavutil/version.h index a2615cd299..017fc277a6 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 9 +#define LIBAVUTIL_VERSION_MINOR 10 #define LIBAVUTIL_VERSION_MICRO 101 #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] avformat/aviobuf: check if read_packet() exist before read_packet_wrapper()
ffmpeg | branch: master | Limin Wang | Fri Dec 3 12:07:34 2021 +0800| [3c74ffb01ac3aa567d166362237117a6ca7c0775] | committer: Limin Wang avformat/aviobuf: check if read_packet() exist before read_packet_wrapper() without it, read_packet_wrapper() will return AVERROR(EINVAL) and avio_read will be failed. Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3c74ffb01ac3aa567d166362237117a6ca7c0775 --- libavformat/aviobuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 5da4dea7b6..14688a2262 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -646,7 +646,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) while (size > 0) { len = FFMIN(s->buf_end - s->buf_ptr, size); if (len == 0 || s->write_flag) { -if((s->direct || size > s->buffer_size) && !s->update_checksum) { +if((s->direct || size > s->buffer_size) && !s->update_checksum && s->read_packet) { // bypass the buffer and read data directly into buf len = read_packet_wrapper(s, buf, size); if (len == AVERROR_EOF) { ___ 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/rtsp: load the sdp file with avio_read_to_bprint()
ffmpeg | branch: master | Limin Wang | Thu Dec 2 18:12:12 2021 +0800| [98054e4f018fefb83c1903de99cdd9e9c3394e85] | committer: Limin Wang avformat/rtsp: load the sdp file with avio_read_to_bprint() this allows getting rid of the hardcoded max size of SDP. Reviewed-by: Martin Storsjö Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98054e4f018fefb83c1903de99cdd9e9c3394e85 --- libavformat/rtsp.c | 25 + 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index cd3d284da6..deaed34db4 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2372,9 +2372,9 @@ static int sdp_read_header(AVFormatContext *s) { RTSPState *rt = s->priv_data; RTSPStream *rtsp_st; -int size, i, err; -char *content; +int i, err; char url[MAX_URL_SIZE]; +AVBPrint bp; if (!ff_network_init()) return AVERROR(EIO); @@ -2385,22 +2385,15 @@ static int sdp_read_header(AVFormatContext *s) rt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM; /* read the whole sdp file */ -/* XXX: better loading */ -content = av_malloc(SDP_MAX_SIZE); -if (!content) { +av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); +err = avio_read_to_bprint(s->pb, &bp, INT_MAX); +if (err < 0 ) { ff_network_close(); -return AVERROR(ENOMEM); +av_bprint_finalize(&bp, NULL); +return err; } -size = avio_read(s->pb, content, SDP_MAX_SIZE - 1); -if (size <= 0) { -av_free(content); -ff_network_close(); -return AVERROR_INVALIDDATA; -} -content[size] ='\0'; - -err = ff_sdp_parse(s, content); -av_freep(&content); +err = ff_sdp_parse(s, bp.str); +av_bprint_finalize(&bp, NULL); if (err) goto fail; /* open each RTP stream */ ___ 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/videotoolbox: fix use of unknown builtin '__builtin_available'
ffmpeg | branch: master | Limin Wang | Thu Dec 2 21:15:22 2021 +0800| [a7df966c82b991ea4f05c40ff5efab65ce56308e] | committer: Limin Wang avcodec/videotoolbox: fix use of unknown builtin '__builtin_available' Old system is: OSX version: 10.11.6 Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin15.6.0 Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a7df966c82b991ea4f05c40ff5efab65ce56308e --- libavcodec/videotoolbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 284da97541..519f55a9ab 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -895,7 +895,7 @@ static int videotoolbox_start(AVCodecContext *avctx) break; } -#if defined(MAC_OS_X_VERSION_10_9) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9) +#if defined(MAC_OS_X_VERSION_10_9) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9) && AV_HAS_BUILTIN(__builtin_available) if (avctx->codec_id == AV_CODEC_ID_PRORES) { if (__builtin_available(macOS 10.9, *)) { VTRegisterProfessionalVideoWorkflowVideoDecoders(); @@ -903,7 +903,7 @@ static int videotoolbox_start(AVCodecContext *avctx) } #endif -#if defined(MAC_OS_VERSION_11_0) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0) +#if defined(MAC_OS_VERSION_11_0) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0) && AV_HAS_BUILTIN(__builtin_available) if (__builtin_available(macOS 11.0, *)) { VTRegisterSupplementalVideoDecoderIfAvailable(videotoolbox->cm_codec_type); } ___ 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/rtspdec: get rid of the hardcoded max size for sdp
ffmpeg | branch: master | Limin Wang | Thu Dec 2 18:33:58 2021 +0800| [d782c746a0d31b48b4484421ab80a472db954bc7] | committer: Limin Wang avformat/rtspdec: get rid of the hardcoded max size for sdp Reviewed-by: Martin Storsjö Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d782c746a0d31b48b4484421ab80a472db954bc7 --- libavformat/rtspdec.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 0e91e3e315..2ada29a2d3 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -172,7 +172,7 @@ static int rtsp_read_announce(AVFormatContext *s) { RTSPState *rt = s->priv_data; RTSPMessageHeader request = { 0 }; -char sdp[SDP_MAX_SIZE]; +char *sdp; int ret; ret = rtsp_read_request(s, &request, "ANNOUNCE"); @@ -185,18 +185,24 @@ static int rtsp_read_announce(AVFormatContext *s) rtsp_send_reply(s, RTSP_STATUS_SERVICE, NULL, request.seq); return AVERROR_OPTION_NOT_FOUND; } -if (request.content_length && request.content_length < sizeof(sdp) - 1) { +if (request.content_length) { +sdp = av_malloc(request.content_length + 1); +if (!sdp) +return AVERROR(ENOMEM); + /* Read SDP */ if (ffurl_read_complete(rt->rtsp_hd, sdp, request.content_length) < request.content_length) { av_log(s, AV_LOG_ERROR, "Unable to get complete SDP Description in ANNOUNCE\n"); rtsp_send_reply(s, RTSP_STATUS_INTERNAL, NULL, request.seq); +av_free(sdp); return AVERROR(EIO); } sdp[request.content_length] = '\0'; av_log(s, AV_LOG_VERBOSE, "SDP: %s\n", sdp); ret = ff_sdp_parse(s, sdp); +av_free(sdp); if (ret) return ret; rtsp_send_reply(s, RTSP_STATUS_OK, NULL, request.seq); ___ 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".