[FFmpeg-cvslog] doc/encoders: update default coder for aac
ffmpeg | branch: master | Gyan Doshi | Sun May 23 13:48:44 2021 +0530| [4c0d6c91f61a754f605c2e82b3cf6a81e8ff29cb] | committer: Gyan Doshi doc/encoders: update default coder for aac Changed in 660d1d8e3b. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4c0d6c91f61a754f605c2e82b3cf6a81e8ff29cb --- doc/encoders.texi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 2ba9938da2..4c38996372 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -53,7 +53,7 @@ Set AAC encoder coding method. Possible values: @table @samp @item twoloop -Two loop searching (TLS) method. +Two loop searching (TLS) method. This is the default method. This method first sets quantizers depending on band thresholds and then tries to find an optimal combination by adding or subtracting a specific value from @@ -75,7 +75,6 @@ Constant quantizer method. Uses a cheaper version of twoloop algorithm that doesn't try to do as many clever adjustments. Worse with low bitrates (less than 64kbps), but is better and much faster at higher bitrates. -This is the default choice for a coder @end table ___ 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/vf_guided: Don't free frame we don't own
ffmpeg | branch: master | Andreas Rheinhardt | Fri May 14 10:34:41 2021 +0200| [618d186b8c2bdb42cdbc722be42ab9efb1f7cdd1] | committer: Andreas Rheinhardt avfilter/vf_guided: Don't free frame we don't own Reviewed-by: Steven Liu Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=618d186b8c2bdb42cdbc722be42ab9efb1f7cdd1 --- libavfilter/vf_guided.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index 95b2c52f3a..b0adf75886 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -319,7 +319,6 @@ static int process_frame(FFFrameSync *fs) out_frame = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out_frame) { av_frame_free(&main_frame); -av_frame_free(&ref_frame); return AVERROR(ENOMEM); } av_frame_copy_props(out_frame, main_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] avfilter/vf_guided: Fix leak of frames
ffmpeg | branch: master | Andreas Rheinhardt | Fri May 14 10:37:00 2021 +0200| [376e80ad7440cbb6e857ea1b48deb0b8cdf3ae90] | committer: Andreas Rheinhardt avfilter/vf_guided: Fix leak of frames Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=376e80ad7440cbb6e857ea1b48deb0b8cdf3ae90 --- libavfilter/vf_guided.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index b0adf75886..6ded4c7c59 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -343,6 +343,7 @@ static int process_frame(FFFrameSync *fs) s->planewidth[plane], s->planeheight[plane], main_frame->linesize[plane] / 2, ref_frame->linesize[plane] / 2, out_frame->linesize[plane] / 2, (1 << s->depth) - 1.f); } +av_frame_free(&main_frame); return ff_filter_frame(outlink, out_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] avfilter/vf_guided: Don't needlessly copy properties, fix potential NPD
ffmpeg | branch: master | Andreas Rheinhardt | Fri May 14 11:22:31 2021 +0200| [a0ab83bf93c546c215be1f34becb90263c11632d] | committer: Andreas Rheinhardt avfilter/vf_guided: Don't needlessly copy properties, fix potential NPD ref_frame is owned by the framesync structure and should therefore not be modified; furthermore, these properties that are copied don't seem to be used at all, so copying is unnecessary. Finally copying when the destination frame is NULL gives a guaranteed segfault. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0ab83bf93c546c215be1f34becb90263c11632d --- libavfilter/vf_guided.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index 6ded4c7c59..ea537e40c6 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -323,10 +323,6 @@ static int process_frame(FFFrameSync *fs) } av_frame_copy_props(out_frame, main_frame); -if (ctx->is_disabled || !ref_frame) { -av_frame_copy_props(ref_frame, main_frame); -} - for (int plane = 0; plane < s->nb_planes; plane++) { if (!(s->planes & (1 << plane))) { av_image_copy_plane(out_frame->data[plane], out_frame->linesize[plane], ___ 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/libaomenc: Avoid copying data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [044daa7c450b132f4f5cdecb738089b3dd7db3f7] | committer: Andreas Rheinhardt avcodec/libaomenc: Avoid copying data, allow user-supplied buffers Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one can use this information to avoid the implicit use of another intermediate buffer for the packet data; and by switching to ff_get_encode_buffer() one can also allow user-supplied buffers. Reviewed-by: James Almer Reviewed-by: James Zern Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=044daa7c450b132f4f5cdecb738089b3dd7db3f7 --- libavcodec/libaomenc.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index fcf75e835d..779714fdaa 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -36,6 +36,7 @@ #include "av1.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "packet_internal.h" #include "profiles.h" @@ -970,7 +971,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, { AOMContext *ctx = avctx->priv_data; int av_unused pict_type; -int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); +int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %"SIZE_SPECIFIER".\n", cx_frame->sz); @@ -1344,11 +1345,12 @@ AVCodec ff_libaom_av1_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libaom AV1"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AV1, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(AOMContext), .init = av1_init, .encode2= aom_encode, .close = aom_free, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), .priv_class = &class_aom, ___ 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/audiotoolboxenc: Remove AV_CODEC_CAP_DR1
ffmpeg | branch: master | Andreas Rheinhardt | Sat May 15 13:02:25 2021 +0200| [c685249ff8596f215fbac1afdf654bef540c5113] | committer: Andreas Rheinhardt avcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1 It has been added in 2016 when this flag made no sense for encoders at all; now that it makes sense, audiotoolboxenc doesn't support it, despite claiming to do so. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c685249ff8596f215fbac1afdf654bef540c5113 --- libavcodec/audiotoolboxenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c index e3d056a79d..e0e00ba2b0 100644 --- a/libavcodec/audiotoolboxenc.c +++ b/libavcodec/audiotoolboxenc.c @@ -627,7 +627,7 @@ static const AVOption options[] = { .encode2= ffat_encode, \ .flush = ffat_encode_flush, \ .priv_class = &ffat_##NAME##_enc_class, \ -.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | \ +.capabilities = AV_CODEC_CAP_DELAY | \ AV_CODEC_CAP_ENCODER_FLUSH __VA_ARGS__, \ .sample_fmts= (const enum AVSampleFormat[]) { \ AV_SAMPLE_FMT_S16, \ ___ 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/libcodec2: Avoid copying packet data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [398822a70edf860cd47514e34e15c80c2dfca584] | committer: Andreas Rheinhardt avcodec/libcodec2: Avoid copying packet data, allow user-supplied buffers When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=398822a70edf860cd47514e34e15c80c2dfca584 --- libavcodec/libcodec2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index 562a616f59..2996dc42f5 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -22,6 +22,7 @@ #include #include "avcodec.h" #include "libavutil/opt.h" +#include "encode.h" #include "internal.h" #include "codec2utils.h" @@ -169,7 +170,7 @@ static int libcodec2_encode(AVCodecContext *avctx, AVPacket *avpkt, LibCodec2Context *c2 = avctx->priv_data; int16_t *samples = (int16_t *)frame->data[0]; -int ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align, 0); +int ret = ff_get_encode_buffer(avctx, avpkt, avctx->block_align, 0); if (ret < 0) { return ret; } @@ -201,11 +202,11 @@ const AVCodec ff_libcodec2_encoder = { .long_name = NULL_IF_CONFIG_SMALL("codec2 encoder using libcodec2"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_CODEC2, +.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(LibCodec2Context), .init = libcodec2_init_encoder, .close = libcodec2_close, .encode2= libcodec2_encode, -.capabilities = 0, .supported_samplerates = (const int[]){ 8000, 0 }, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .channel_layouts= (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/libkvazaar: Allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [95c8a859d97e9902388f5acf5c735b16417a2609] | committer: Andreas Rheinhardt avcodec/libkvazaar: Allow user-supplied buffers Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=95c8a859d97e9902388f5acf5c735b16417a2609 --- libavcodec/libkvazaar.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index 14eabe4e05..aabe446a28 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -36,6 +36,7 @@ #include "libavutil/opt.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "packet_internal.h" @@ -237,7 +238,7 @@ static int libkvazaar_encode(AVCodecContext *avctx, kvz_data_chunk *chunk = NULL; uint64_t written = 0; -retval = ff_alloc_packet2(avctx, avpkt, len_out, len_out); +retval = ff_get_encode_buffer(avctx, avpkt, len_out, 0); if (retval < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n"); goto done; @@ -316,7 +317,8 @@ const AVCodec ff_libkvazaar_encoder = { .long_name= NULL_IF_CONFIG_SMALL("libkvazaar H.265 / HEVC"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_HEVC, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | +AV_CODEC_CAP_OTHER_THREADS, .pix_fmts = pix_fmts, .priv_class = &class, ___ 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/libgsmenc: Avoid copying packet data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [91567c28fc178d8f3c226b66dd40572f4eadd35c] | committer: Andreas Rheinhardt avcodec/libgsmenc: Avoid copying packet data, allow user-supplied buffers When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91567c28fc178d8f3c226b66dd40572f4eadd35c --- libavcodec/libgsmenc.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c index 850963e8f6..97ba789046 100644 --- a/libavcodec/libgsmenc.c +++ b/libavcodec/libgsmenc.c @@ -37,6 +37,7 @@ #include "libavutil/common.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "gsm.h" @@ -98,7 +99,7 @@ static int libgsm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, gsm_signal *samples = (gsm_signal *)frame->data[0]; struct gsm_state *state = avctx->priv_data; -if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align, 0)) < 0) +if ((ret = ff_get_encode_buffer(avctx, avpkt, avctx->block_align, 0)) < 0) return ret; switch(avctx->codec_id) { @@ -125,6 +126,7 @@ const AVCodec ff_libgsm_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_GSM, +.capabilities = AV_CODEC_CAP_DR1, .init = libgsm_encode_init, .encode2= libgsm_encode_frame, .close = libgsm_encode_close, @@ -141,6 +143,7 @@ const AVCodec ff_libgsm_ms_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_GSM_MS, +.capabilities = AV_CODEC_CAP_DR1, .init = libgsm_encode_init, .encode2= libgsm_encode_frame, .close = libgsm_encode_close, ___ 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/libmp3lame: Avoid copying data, allow user-supplied buffer
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [c59398970bff5ee6c0305a0228eb562ec5901b08] | committer: Andreas Rheinhardt avcodec/libmp3lame: Avoid copying data, allow user-supplied buffer The libmp3lame encoder already uses an internal buffer, so that the packet size is already known before allocating the packet; therefore one can avoid another (implicit) intermediate buffer by switching to ff_get_encode_buffer(), thereby also supporting user-supplied buffers. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c59398970bff5ee6c0305a0228eb562ec5901b08 --- libavcodec/libmp3lame.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index fe4b50257f..5675864bb2 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -34,6 +34,7 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "audio_frame_queue.h" +#include "encode.h" #include "internal.h" #include "mpegaudio.h" #include "mpegaudiodecheader.h" @@ -264,7 +265,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ff_dlog(avctx, "in:%d packet-len:%d index:%d\n", avctx->frame_size, len, s->buffer_index); if (len <= s->buffer_index) { -if ((ret = ff_alloc_packet2(avctx, avpkt, len, 0)) < 0) +if ((ret = ff_get_encode_buffer(avctx, avpkt, len, 0)) < 0) return ret; memcpy(avpkt->data, s->buffer, len); s->buffer_index -= len; @@ -296,7 +297,6 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, AV_WL32(side_data + 4, discard_padding); } -avpkt->size = len; *got_packet_ptr = 1; } return 0; @@ -332,11 +332,12 @@ const AVCodec ff_libmp3lame_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"), .type = AVMEDIA_TYPE_AUDIO, .id= AV_CODEC_ID_MP3, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size= sizeof(LAMEContext), .init = mp3lame_encode_init, .encode2 = mp3lame_encode_frame, .close = mp3lame_encode_close, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16P, ___ 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/libopenh264enc: Allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [0812a60feeb5e49efa268fb50d5850b1ad84eb70] | committer: Andreas Rheinhardt avcodec/libopenh264enc: Allow user-supplied buffers Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0812a60feeb5e49efa268fb50d5850b1ad84eb70 --- libavcodec/libopenh264enc.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 54babc3e97..de4b85c411 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -30,6 +30,7 @@ #include "libavutil/mathematics.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "libopenh264.h" @@ -404,10 +405,9 @@ static int svc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } av_log(avctx, AV_LOG_DEBUG, "%d slices\n", fbi.sLayerInfo[fbi.iLayerNum - 1].iNalCount); -if ((ret = ff_alloc_packet2(avctx, avpkt, size, size))) { -av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); +if ((ret = ff_get_encode_buffer(avctx, avpkt, size, 0))) return ret; -} + size = 0; for (layer = first_layer; layer < fbi.iLayerNum; layer++) { memcpy(avpkt->data + size, fbi.sLayerInfo[layer].pBsBuf, layer_size[layer]); @@ -433,11 +433,11 @@ const AVCodec ff_libopenh264_encoder = { .long_name = NULL_IF_CONFIG_SMALL("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H264, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(SVCContext), .init = svc_encode_init, .encode2= svc_encode_frame, .close = svc_encode_close, -.capabilities = AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, ___ 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/libtheoraenc: Avoid copying data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [6ba55e9652746382dadb9d91206e22e15939] | committer: Andreas Rheinhardt avcodec/libtheoraenc: Avoid copying data, allow user-supplied buffers Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one can use this information to avoid the implicit use of another intermediate buffer for the packet data; and by switching to ff_get_encode_buffer() one can also allow user-supplied buffers. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6ba55e9652746382dadb9d91206e22e15939 --- libavcodec/libtheoraenc.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 057cb9f026..a74fab9eff 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -37,6 +37,7 @@ #include "libavutil/log.h" #include "libavutil/base64.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" /* libtheora includes */ @@ -339,7 +340,7 @@ static int encode_frame(AVCodecContext* avc_context, AVPacket *pkt, } /* Copy ogg_packet content out to buffer */ -if ((ret = ff_alloc_packet2(avc_context, pkt, o_packet.bytes, 0)) < 0) +if ((ret = ff_get_encode_buffer(avc_context, pkt, o_packet.bytes, 0)) < 0) return ret; memcpy(pkt->data, o_packet.packet, o_packet.bytes); @@ -371,11 +372,12 @@ const AVCodec ff_libtheora_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libtheora Theora"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_THEORA, +.capabilities = AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_DELAY /* for statsfile summary */, .priv_data_size = sizeof(TheoraContext), .init = encode_init, .close = encode_close, .encode2= encode_frame, -.capabilities = AV_CODEC_CAP_DELAY, // needed to get the statsfile summary .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, ___ 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/libvorbisenc: Avoid copying data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [d8e66ec1d7233541fd84205cb10e8e6ff87167de] | committer: Andreas Rheinhardt avcodec/libvorbisenc: Avoid copying data, allow user-supplied buffers Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one can use this information to avoid the implicit use of another intermediate buffer for the packet data; and by switching to ff_get_encode_buffer() one can also allow user-supplied buffers. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d8e66ec1d7233541fd84205cb10e8e6ff87167de --- libavcodec/libvorbisenc.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index d0f4c65aac..ec674695d4 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -25,6 +25,7 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "audio_frame_queue.h" +#include "encode.h" #include "internal.h" #include "vorbis.h" #include "vorbis_parser.h" @@ -348,7 +349,7 @@ static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL); -if ((ret = ff_alloc_packet2(avctx, avpkt, op.bytes, 0)) < 0) +if ((ret = ff_get_encode_buffer(avctx, avpkt, op.bytes, 0)) < 0) return ret; av_fifo_generic_read(s->pkt_fifo, avpkt->data, op.bytes, NULL); @@ -378,11 +379,12 @@ const AVCodec ff_libvorbis_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libvorbis"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_VORBIS, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(LibvorbisEncContext), .init = libvorbis_encode_init, .encode2= libvorbis_encode_frame, .close = libvorbis_encode_close, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .priv_class = &vorbis_class, ___ 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/libshine: Avoid copying data, allow user-supplied buffer
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [6564ab0e01609c580c5f9ebd05c0a403b2a956b2] | committer: Andreas Rheinhardt avcodec/libshine: Avoid copying data, allow user-supplied buffer The libshine encoder already uses an internal buffer, so that the packet size is already known before allocating the packet; therefore one can avoid another (implicit) intermediate buffer by switching to ff_get_encode_buffer(), thereby also supporting user-supplied buffers. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6564ab0e01609c580c5f9ebd05c0a403b2a956b2 --- libavcodec/libshine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/libshine.c b/libavcodec/libshine.c index 4a9fc617f0..04d5914701 100644 --- a/libavcodec/libshine.c +++ b/libavcodec/libshine.c @@ -24,6 +24,7 @@ #include "libavutil/intreadwrite.h" #include "audio_frame_queue.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "mpegaudio.h" #include "mpegaudiodecheader.h" @@ -102,7 +103,7 @@ static int libshine_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, len = hdr.frame_size; if (len <= s->buffer_index) { -if ((ret = ff_alloc_packet2(avctx, avpkt, len, 0))) +if ((ret = ff_get_encode_buffer(avctx, avpkt, len, 0))) return ret; memcpy(avpkt->data, s->buffer, len); s->buffer_index -= len; @@ -111,7 +112,6 @@ static int libshine_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, &avpkt->duration); -avpkt->size = len; *got_packet_ptr = 1; } return 0; @@ -135,11 +135,11 @@ const AVCodec ff_libshine_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libshine MP3 (MPEG audio layer 3)"), .type = AVMEDIA_TYPE_AUDIO, .id= AV_CODEC_ID_MP3, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size= sizeof(SHINEContext), .init = libshine_encode_init, .encode2 = libshine_encode_frame, .close = libshine_encode_close, -.capabilities = AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, .supported_samplerates = libshine_sample_rates, ___ 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/libvpxenc: Avoid copying data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [3280c6f938c8b16254bfb68af54089af467274c5] | committer: Andreas Rheinhardt avcodec/libvpxenc: Avoid copying data, allow user-supplied buffers Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one can use this information to avoid the implicit use of another intermediate buffer for the packet data; and by switching to ff_get_encode_buffer() one can also allow user-supplied buffers. Reviewed-by: James Almer Reviewed-by: James Zern Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3280c6f938c8b16254bfb68af54089af467274c5 --- libavcodec/libvpxenc.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 8173af5dce..2d9e56837b 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -29,6 +29,7 @@ #include #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "libavutil/avassert.h" #include "libvpx.h" @@ -1173,7 +1174,7 @@ static inline void cx_pktcpy(struct FrameListData *dst, static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, AVPacket *pkt) { -int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); +int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0); uint8_t *side_data; if (ret >= 0) { int pict_type; @@ -1830,11 +1831,12 @@ const AVCodec ff_libvpx_vp8_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP8, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(VPxContext), .init = vp8_init, .encode2= vpx_encode, .close = vpx_free, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE }, .priv_class = &class_vp8, @@ -1861,11 +1863,12 @@ AVCodec ff_libvpx_vp9_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP9, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(VPxContext), .init = vp9_init, .encode2= vpx_encode, .close = vpx_free, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), .priv_class = &class_vp9, ___ 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/libvpxenc: Avoid one level of indentation
ffmpeg | branch: master | Andreas Rheinhardt | Wed Apr 28 00:06:36 2021 +0200| [e099a29f5a85b14c39e4df00fe644408fec14612] | committer: Andreas Rheinhardt avcodec/libvpxenc: Avoid one level of indentation Reviewed-by: James Almer Reviewed-by: James Zern Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e099a29f5a85b14c39e4df00fe644408fec14612 --- libavcodec/libvpxenc.c | 64 -- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 2d9e56837b..66bad444d0 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1176,42 +1176,40 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, { int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0); uint8_t *side_data; -if (ret >= 0) { -int pict_type; -memcpy(pkt->data, cx_frame->buf, pkt->size); -pkt->pts = pkt->dts = cx_frame->pts; - -if (!!(cx_frame->flags & VPX_FRAME_IS_KEY)) { -pict_type = AV_PICTURE_TYPE_I; -pkt->flags |= AV_PKT_FLAG_KEY; -} else { -pict_type = AV_PICTURE_TYPE_P; -} +int pict_type; -ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1, - cx_frame->have_sse ? 3 : 0, pict_type); +if (ret < 0) +return ret; -if (cx_frame->have_sse) { -int i; -/* Beware of the Y/U/V/all order! */ -for (i = 0; i < 3; ++i) { -avctx->error[i] += cx_frame->sse[i + 1]; -} -cx_frame->have_sse = 0; -} -if (cx_frame->sz_alpha > 0) { -side_data = av_packet_new_side_data(pkt, - AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, -cx_frame->sz_alpha + 8); -if(!side_data) { -av_packet_unref(pkt); -return AVERROR(ENOMEM); -} -AV_WB64(side_data, 1); -memcpy(side_data + 8, cx_frame->buf_alpha, cx_frame->sz_alpha); -} +memcpy(pkt->data, cx_frame->buf, pkt->size); +pkt->pts = pkt->dts = cx_frame->pts; + +if (!!(cx_frame->flags & VPX_FRAME_IS_KEY)) { +pict_type = AV_PICTURE_TYPE_I; +pkt->flags |= AV_PKT_FLAG_KEY; } else { -return ret; +pict_type = AV_PICTURE_TYPE_P; +} + +ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1, + cx_frame->have_sse ? 3 : 0, pict_type); + +if (cx_frame->have_sse) { +/* Beware of the Y/U/V/all order! */ +for (int i = 0; i < 3; ++i) +avctx->error[i] += cx_frame->sse[i + 1]; +cx_frame->have_sse = 0; +} +if (cx_frame->sz_alpha > 0) { +side_data = av_packet_new_side_data(pkt, + AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, +cx_frame->sz_alpha + 8); +if (!side_data) { +av_packet_unref(pkt); +return AVERROR(ENOMEM); +} +AV_WB64(side_data, 1); +memcpy(side_data + 8, cx_frame->buf_alpha, cx_frame->sz_alpha); } return pkt->size; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/libwebpenc: Allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [ad26efbf5268daec2b8c00e06568a984d3fa1b3a] | committer: Andreas Rheinhardt avcodec/libwebpenc: Allow user-supplied buffers Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad26efbf5268daec2b8c00e06568a984d3fa1b3a --- libavcodec/libwebpenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/libwebpenc.c b/libavcodec/libwebpenc.c index 2e5b811455..97adacb6b2 100644 --- a/libavcodec/libwebpenc.c +++ b/libavcodec/libwebpenc.c @@ -24,6 +24,7 @@ * WebP encoder using libwebp (WebPEncode API) */ +#include "encode.h" #include "libwebpenc_common.h" typedef LibWebPContextCommon LibWebPContext; @@ -57,7 +58,7 @@ static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, goto end; } -ret = ff_alloc_packet2(avctx, pkt, mw.size, mw.size); +ret = ff_get_encode_buffer(avctx, pkt, mw.size, 0); if (ret < 0) goto end; memcpy(pkt->data, mw.mem, mw.size); @@ -98,6 +99,7 @@ const AVCodec ff_libwebp_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_WEBP, +.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(LibWebPContext), .init = libwebp_encode_init, .encode2= libwebp_encode_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] avcodec/libwebpenc_animencoder: Allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [cfff94b7f8ddbda08b64c50057d3dd5b78773eb4] | committer: Andreas Rheinhardt avcodec/libwebpenc_animencoder: Allow user-supplied buffers Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cfff94b7f8ddbda08b64c50057d3dd5b78773eb4 --- libavcodec/libwebpenc_animencoder.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c index 5f0c6ba194..742aefb467 100644 --- a/libavcodec/libwebpenc_animencoder.c +++ b/libavcodec/libwebpenc_animencoder.c @@ -25,6 +25,7 @@ */ #include "config.h" +#include "encode.h" #include "libwebpenc_common.h" #include @@ -67,7 +68,7 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt, WebPData assembled_data = { 0 }; ret = WebPAnimEncoderAssemble(s->enc, &assembled_data); if (ret) { -ret = ff_alloc_packet2(avctx, pkt, assembled_data.size, assembled_data.size); +ret = ff_get_encode_buffer(avctx, pkt, assembled_data.size, 0); if (ret < 0) return ret; memcpy(pkt->data, assembled_data.bytes, assembled_data.size); @@ -136,11 +137,11 @@ const AVCodec ff_libwebp_anim_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_WEBP, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size = sizeof(LibWebPAnimContext), .init = libwebp_anim_encode_init, .encode2= libwebp_anim_encode_frame, .close = libwebp_anim_encode_close, -.capabilities = AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB32, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, ___ 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: Avoid copying data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [9c4f2bc3bf990c8ac35932db95ad3b41c264fb59] | committer: Andreas Rheinhardt avcodec/libx264: Avoid copying data, allow user-supplied buffers Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one can use this information to avoid the implicit use of another intermediate buffer for the packet data; and by switching to ff_get_encode_buffer() one can also allow user-supplied buffers. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9c4f2bc3bf990c8ac35932db95ad3b41c264fb59 --- libavcodec/libx264.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 1c27f7b441..36fdb567ff 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -28,6 +28,7 @@ #include "libavutil/time.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "packet_internal.h" #include "atsc_a53.h" @@ -144,7 +145,7 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, for (i = 0; i < nnal; i++) size += nals[i].i_payload; -if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0) +if ((ret = ff_get_encode_buffer(ctx, pkt, size, 0)) < 0) return ret; p = pkt->data; @@ -1147,12 +1148,13 @@ AVCodec ff_libx264_encoder = { .long_name= NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H264, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | +AV_CODEC_CAP_OTHER_THREADS | +AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(X264Context), .init = X264_init, .encode2 = X264_frame, .close= X264_close, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | -AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_class = &x264_class, .defaults = x264_defaults, #if X264_BUILD < 153 @@ -1182,12 +1184,13 @@ const AVCodec ff_libx264rgb_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H264, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(X264Context), .init = X264_init, .encode2= X264_frame, .close = X264_close, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | - AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_class = &rgbclass, .defaults = x264_defaults, .pix_fmts = pix_fmts_8bit_rgb, @@ -1213,12 +1216,13 @@ const AVCodec ff_libx262_encoder = { .long_name= NULL_IF_CONFIG_SMALL("libx262 MPEG2VIDEO"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MPEG2VIDEO, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | +AV_CODEC_CAP_OTHER_THREADS | +AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(X264Context), .init = X264_init, .encode2 = X264_frame, .close= X264_close, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | -AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_class = &X262_class, .defaults = x264_defaults, .pix_fmts = pix_fmts_8bit, ___ 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: Allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [a4b334327895f17211b4bbbc19ebab41a7aa35dc] | committer: Andreas Rheinhardt avcodec/libx265: Allow user-supplied buffers Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a4b334327895f17211b4bbbc19ebab41a7aa35dc --- libavcodec/libx265.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index a1bd205201..90658d3d9e 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -32,6 +32,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "packet_internal.h" @@ -531,7 +532,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, for (i = 0; i < nnal; i++) payload += nal[i].sizeBytes; -ret = ff_alloc_packet2(avctx, pkt, payload, payload); +ret = ff_get_encode_buffer(avctx, pkt, payload, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; @@ -687,6 +688,9 @@ AVCodec ff_libx265_encoder = { .long_name= NULL_IF_CONFIG_SMALL("libx265 H.265 / HEVC"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_HEVC, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | +AV_CODEC_CAP_OTHER_THREADS | +AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = libx265_encode_init, .init_static_data = libx265_encode_init_csp, .encode2 = libx265_encode_frame, @@ -694,8 +698,6 @@ AVCodec ff_libx265_encoder = { .priv_data_size = sizeof(libx265Context), .priv_class = &class, .defaults = x265_defaults, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | -AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal= FF_CODEC_CAP_AUTO_THREADS, .wrapper_name = "libx265", }; ___ 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/libxavs: Avoid overallocating, copying packet data
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [4085cfc94474db9bda90f7ac21be3ed0ac4da702] | committer: Andreas Rheinhardt avcodec/libxavs: Avoid overallocating, copying packet data When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data; also, there is no reason to add AV_INPUT_BUFFER_MIN_SIZE to the packet size any more, as the actually needed packet size can be easily calculated: It is three bytes more than the raw nal size per NALU. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4085cfc94474db9bda90f7ac21be3ed0ac4da702 --- libavcodec/libxavs.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index 253f4bde6a..b655bf79ff 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -27,6 +27,7 @@ #include #include #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "packet_internal.h" #include "libavutil/internal.h" @@ -85,18 +86,20 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, xavs_nal_t *nals, int nnal) { XavsContext *x4 = ctx->priv_data; -uint8_t *p; -int i, s, ret, size = x4->sei_size + AV_INPUT_BUFFER_MIN_SIZE; +int64_t size = x4->sei_size; +uint8_t *p, *p_end; +int i, s, ret; if (!nnal) return 0; for (i = 0; i < nnal; i++) -size += nals[i].i_payload; +size += 3U + nals[i].i_payload; -if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0) +if ((ret = ff_get_encode_buffer(ctx, pkt, size, 0)) < 0) return ret; p = pkt->data; +p_end = pkt->data + size; /* Write the SEI as part of the first frame. */ if (x4->sei_size > 0 && nnal > 0) { @@ -106,12 +109,14 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, } for (i = 0; i < nnal; i++) { +int size = p_end - p; s = xavs_nal_encode(p, &size, 1, nals + i); if (s < 0) return -1; +if (s != 3U + nals[i].i_payload) +return AVERROR_EXTERNAL; p += s; } -pkt->size = p - pkt->data; return 1; } @@ -150,7 +155,7 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt, if (!ret) { if (!frame && !(x4->end_of_stream)) { -if ((ret = ff_alloc_packet2(avctx, pkt, 4, 0)) < 0) +if ((ret = ff_get_encode_buffer(avctx, pkt, 4, 0)) < 0) return ret; pkt->data[0] = 0x0; @@ -421,11 +426,12 @@ const AVCodec ff_libxavs_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libxavs Chinese AVS (Audio Video Standard)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_CAVS, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(XavsContext), .init = XAVS_init, .encode2= XAVS_frame, .close = XAVS_close, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .priv_class = &xavs_class, ___ 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/libxavs: Improve returned error codes
ffmpeg | branch: master | Andreas Rheinhardt | Tue May 11 05:16:24 2021 +0200| [ea2ec1dfaea225d50251803ff1c35d26275ba23c] | committer: Andreas Rheinhardt avcodec/libxavs: Improve returned error codes Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea2ec1dfaea225d50251803ff1c35d26275ba23c --- libavcodec/libxavs.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index b655bf79ff..15bb8e5c1c 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -112,7 +112,7 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, int size = p_end - p; s = xavs_nal_encode(p, &size, 1, nals + i); if (s < 0) -return -1; +return AVERROR_EXTERNAL; if (s != 3U + nals[i].i_payload) return AVERROR_EXTERNAL; p += s; @@ -146,12 +146,12 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt, if (xavs_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0) -return -1; +return AVERROR_EXTERNAL; ret = encode_nals(avctx, pkt, nal, nnal); if (ret < 0) -return -1; +return ret; if (!ret) { if (!frame && !(x4->end_of_stream)) { @@ -345,7 +345,7 @@ static av_cold int XAVS_init(AVCodecContext *avctx) x4->enc = xavs_encoder_open(&x4->params); if (!x4->enc) -return -1; +return AVERROR_EXTERNAL; if (!(x4->pts_buffer = av_mallocz_array((avctx->max_b_frames+1), sizeof(*x4->pts_buffer 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/pnmenc: Avoid intermediate buffer, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Tue May 11 05:30:15 2021 +0200| [981c4caed32df4a801608d72bb9d0243390a2e1a] | committer: Andreas Rheinhardt avcodec/pnmenc: Avoid intermediate buffer, allow user-supplied buffers For all p*m encoders a very sharp upper bound for the size of the output packets is available before the packet is allocated. This can be used to avoid an intermediate buffer when encoding by using ff_get_encode_buffer() instead of ff_alloc_packet2() (without min_size); this also adds support for user-supplied buffers. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=981c4caed32df4a801608d72bb9d0243390a2e1a --- libavcodec/pnmenc.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index 80c7b66332..2e8b6372a3 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -23,6 +23,7 @@ #include "libavutil/imgutils.h" #include "libavutil/pixdesc.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, @@ -34,7 +35,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int size = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1); -if ((ret = ff_alloc_packet2(avctx, pkt, size + 200, 0)) < 0) +if ((ret = ff_get_encode_buffer(avctx, pkt, size + 200, 0)) < 0) return ret; bytestream_start = @@ -141,8 +142,8 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, ptr2 += p->linesize[2]; } } -pkt->size = bytestream - bytestream_start; pkt->flags |= AV_PKT_FLAG_KEY; +av_shrink_packet(pkt, bytestream - bytestream_start); *got_packet = 1; return 0; @@ -154,6 +155,7 @@ const AVCodec ff_pgm_encoder = { .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PGM, +.capabilities = AV_CODEC_CAP_DR1, .encode2= pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE @@ -168,6 +170,7 @@ const AVCodec ff_pgmyuv_encoder = { .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PGMYUV, +.capabilities = AV_CODEC_CAP_DR1, .encode2= pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE @@ -182,6 +185,7 @@ const AVCodec ff_ppm_encoder = { .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PPM, +.capabilities = AV_CODEC_CAP_DR1, .encode2= pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_NONE @@ -196,6 +200,7 @@ const AVCodec ff_pbm_encoder = { .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PBM, +.capabilities = AV_CODEC_CAP_DR1, .encode2= pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, @@ -209,6 +214,7 @@ const AVCodec ff_pfm_encoder = { .long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PFM, +.capabilities = AV_CODEC_CAP_DR1, .encode2= pnm_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_GBRPF32, AV_PIX_FMT_NONE }, ___ 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/pamenc: Avoid copying packet data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [314c086a859cffeb53ad4e227d77f42f6301a9b9] | committer: Andreas Rheinhardt avcodec/pamenc: Avoid copying packet data, allow user-supplied buffers When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=314c086a859cffeb53ad4e227d77f42f6301a9b9 --- libavcodec/pamenc.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index f1df7c88f5..c38de5c607 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -19,16 +19,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/avassert.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet) { -uint8_t *bytestream_start, *bytestream, *bytestream_end; -int i, h, w, n, linesize, depth, maxval, ret; +int i, h, w, n, linesize, depth, maxval, ret, header_size; +uint8_t *bytestream, *ptr; const char *tuple_type; -uint8_t *ptr; +char header[100]; h = avctx->height; w = avctx->width; @@ -91,17 +93,17 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return -1; } -if ((ret = ff_alloc_packet2(avctx, pkt, n*h + 200, 0)) < 0) +header_size = snprintf(header, sizeof(header), + "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLTYPE %s\nENDHDR\n", + w, h, depth, maxval, tuple_type); +av_assert1(header_size < sizeof(header)); + +if ((ret = ff_get_encode_buffer(avctx, pkt, n*h + header_size, 0)) < 0) return ret; -bytestream_start = bytestream = pkt->data; -bytestream_end = pkt->data + pkt->size; - -snprintf(bytestream, bytestream_end - bytestream, - "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLTYPE %s\nENDHDR\n", - w, h, depth, maxval, tuple_type); -bytestream += strlen(bytestream); +memcpy(bytestream, header, header_size); +bytestream += header_size; ptr = p->data[0]; linesize = p->linesize[0]; @@ -121,7 +123,6 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } -pkt->size = bytestream - bytestream_start; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; @@ -132,6 +133,7 @@ const AVCodec ff_pam_encoder = { .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PAM, +.capabilities = AV_CODEC_CAP_DR1, .encode2= pam_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, ___ 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/flacenc: Avoid copying packet data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [5abb5c04155b536f26fc88311ac3132890111360] | committer: Andreas Rheinhardt avcodec/flacenc: Avoid copying packet data, allow user-supplied buffers The FLAC encoder calculates the size in advance, so one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5abb5c04155b536f26fc88311ac3132890111360 --- libavcodec/flacenc.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 37ed1e4cce..de36d3 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -27,6 +27,7 @@ #include "avcodec.h" #include "bswapdsp.h" +#include "encode.h" #include "put_bits.h" #include "golomb.h" #include "internal.h" @@ -1378,7 +1379,7 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } } -if ((ret = ff_alloc_packet2(avctx, avpkt, frame_bytes, 0)) < 0) +if ((ret = ff_get_encode_buffer(avctx, avpkt, frame_bytes, 0)) < 0) return ret; out_bytes = write_frame(s, avpkt); @@ -1396,10 +1397,11 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, avpkt->pts = frame->pts; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); -avpkt->size = out_bytes; s->next_pts = avpkt->pts + avpkt->duration; +av_shrink_packet(avpkt, out_bytes); + *got_packet_ptr = 1; return 0; } @@ -1459,11 +1461,12 @@ const AVCodec ff_flac_encoder = { .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_FLAC, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(FlacEncodeContext), .init = flac_encode_init, .encode2= flac_encode_frame, .close = flac_encode_close, -.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, ___ 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/pngenc: Remove always-true check
ffmpeg | branch: master | Andreas Rheinhardt | Tue May 11 10:54:49 2021 +0200| [aaefb84b04a8a8d40b3d23ce4f0b0c92b093ddb9] | committer: Andreas Rheinhardt avcodec/pngenc: Remove always-true check Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aaefb84b04a8a8d40b3d23ce4f0b0c92b093ddb9 --- libavcodec/pngenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index a398155100..5a376765cf 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -847,7 +847,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, size_t max_packet_size; APNGFctlChunk fctl_chunk = {0}; -if (pict && avctx->codec_id == AV_CODEC_ID_APNG && s->color_type == PNG_COLOR_TYPE_PALETTE) { +if (pict && s->color_type == PNG_COLOR_TYPE_PALETTE) { uint32_t checksum = ~av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), ~0U, pict->data[1], 256 * sizeof(uint32_t)); if (avctx->frame_number == 0) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/pngenc: Avoid copying APNG data, allow user-supplied buffer
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [250d8661abdbe2929bfef17e699adfab10a9c67c] | committer: Andreas Rheinhardt avcodec/pngenc: Avoid copying APNG data, allow user-supplied buffer The APNG encoder already uses internal buffers, so that the packet size is already known before allocating the packet; therefore one can avoid another (implicit) intermediate buffer by switching to ff_get_encode_buffer(), thereby also supporting user-supplied buffers. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=250d8661abdbe2929bfef17e699adfab10a9c67c --- libavcodec/pngenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 5a376765cf..894b44197e 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -20,6 +20,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "bytestream.h" #include "lossless_videoencdsp.h" @@ -887,12 +888,11 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, if (!s->last_frame_packet) return AVERROR(ENOMEM); } else if (s->last_frame) { -ret = ff_alloc_packet2(avctx, pkt, max_packet_size, 0); +ret = ff_get_encode_buffer(avctx, pkt, s->last_frame_packet_size, 0); if (ret < 0) return ret; memcpy(pkt->data, s->last_frame_packet, s->last_frame_packet_size); -pkt->size = s->last_frame_packet_size; pkt->pts = pkt->dts = s->last_frame->pts; } @@ -1148,11 +1148,11 @@ const AVCodec ff_apng_encoder = { .long_name = NULL_IF_CONFIG_SMALL("APNG (Animated Portable Network Graphics) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_APNG, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size = sizeof(PNGEncContext), .init = png_enc_init, .close = png_enc_close, .encode2= encode_apng, -.capabilities = AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_RGBA64BE, ___ 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/libxavs2: Allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [3abdf0efac7d588efb757837e962afd9334b3bf6] | committer: Andreas Rheinhardt avcodec/libxavs2: Allow user-supplied buffers Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3abdf0efac7d588efb757837e962afd9334b3bf6 --- libavcodec/libxavs2.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c index 99fe0e3286..9c5a576e90 100644 --- a/libavcodec/libxavs2.c +++ b/libavcodec/libxavs2.c @@ -23,6 +23,7 @@ */ #include "xavs2.h" +#include "encode.h" #include "mpeg12.h" #include "libavutil/avstring.h" @@ -214,10 +215,9 @@ static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)) { -if (av_new_packet(pkt, cae->packet.len) < 0) { -av_log(avctx, AV_LOG_ERROR, "Failed to alloc xavs2 packet.\n"); +if ((ret = ff_get_encode_buffer(avctx, pkt, cae->packet.len, 0)) < 0) { cae->api->encoder_packet_unref(cae->encoder, &cae->packet); -return AVERROR(ENOMEM); +return ret; } pkt->pts = cae->packet.pts; @@ -230,7 +230,6 @@ static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } memcpy(pkt->data, cae->packet.stream, cae->packet.len); -pkt->size = cae->packet.len; cae->api->encoder_packet_unref(cae->encoder, &cae->packet); @@ -290,11 +289,12 @@ const AVCodec ff_libxavs2_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libxavs2 AVS2-P2/IEEE1857.4"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AVS2, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(XAVS2EContext), .init = xavs2_init, .encode2= xavs2_encode_frame, .close = xavs2_close, -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, ___ 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/sbcenc: Avoid copying packet data, allow user-supplied buffers
ffmpeg | branch: master | Andreas Rheinhardt | Sun Apr 25 01:43:26 2021 +0200| [7a3613696d9beb625c09c703723884eb18a58976] | committer: Andreas Rheinhardt avcodec/sbcenc: Avoid copying packet data, allow user-supplied buffers When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7a3613696d9beb625c09c703723884eb18a58976 --- libavcodec/sbcenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c index e87c623d4b..5f9a214a1a 100644 --- a/libavcodec/sbcenc.c +++ b/libavcodec/sbcenc.c @@ -32,6 +32,7 @@ #include "libavutil/opt.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "profiles.h" #include "put_bits.h" @@ -290,7 +291,7 @@ static int sbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (av_frame->nb_samples * frame->channels * 2 < frame->codesize) return 0; -if ((ret = ff_alloc_packet2(avctx, avpkt, frame_length, 0)) < 0) +if ((ret = ff_get_encode_buffer(avctx, avpkt, frame_length, 0)) < 0) return ret; /* Select the needed input data processing function and call it */ @@ -346,10 +347,10 @@ const AVCodec ff_sbc_encoder = { .long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), .type = AVMEDIA_TYPE_AUDIO, .id= AV_CODEC_ID_SBC, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size= sizeof(SBCEncContext), .init = sbc_encode_init, .encode2 = sbc_encode_frame, -.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, 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] avutil/mem: make max_alloc_size an atomic type
ffmpeg | branch: master | James Almer | Sat May 22 18:03:10 2021 -0300| [be96f4b616878c6245acd626e26cdd65a491b68d] | committer: James Almer avutil/mem: make max_alloc_size an atomic type Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be96f4b616878c6245acd626e26cdd65a491b68d --- libavutil/mem.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libavutil/mem.c b/libavutil/mem.c index fa227f5e12..c12c24aa90 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #if HAVE_MALLOC_H #include @@ -68,17 +69,17 @@ void free(void *ptr); * dynamic libraries and remove -Wl,-Bsymbolic from the linker flags. * Note that this will cost performance. */ -static size_t max_alloc_size= INT_MAX; +static atomic_size_t max_alloc_size = ATOMIC_VAR_INIT(INT_MAX); void av_max_alloc(size_t max){ -max_alloc_size = max; +atomic_store_explicit(&max_alloc_size, max, memory_order_relaxed); } void *av_malloc(size_t size) { void *ptr = NULL; -if (size > max_alloc_size) +if (size > atomic_load_explicit(&max_alloc_size, memory_order_relaxed)) return NULL; #if HAVE_POSIX_MEMALIGN @@ -134,7 +135,7 @@ void *av_malloc(size_t size) void *av_realloc(void *ptr, size_t size) { void *ret; -if (size > max_alloc_size) +if (size > atomic_load_explicit(&max_alloc_size, memory_order_relaxed)) return NULL; #if HAVE_ALIGNED_MALLOC @@ -483,15 +484,19 @@ void av_memcpy_backptr(uint8_t *dst, int back, int cnt) void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) { +size_t max_size; + if (min_size <= *size) return ptr; -if (min_size > max_alloc_size) { +max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed); + +if (min_size > max_size) { *size = 0; return NULL; } -min_size = FFMIN(max_alloc_size, FFMAX(min_size + min_size / 16 + 32, min_size)); +min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size)); ptr = av_realloc(ptr, min_size); /* we could set this to the unmodified min_size but this is safer ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavfi/dnn_filter_common.h: make filter option 'options' as deprecated
ffmpeg | branch: master | Guo, Yejun | Mon May 17 16:28:44 2021 +0800| [cde6d0288fc9bd2238b5078b4d998569ba65b2b7] | committer: Guo, Yejun lavfi/dnn_filter_common.h: make filter option 'options' as deprecated we'd use 'backend_configs' to avoid confusion. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cde6d0288fc9bd2238b5078b4d998569ba65b2b7 --- libavfilter/dnn_filter_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h index 09ddd8a5ca..36319bfef8 100644 --- a/libavfilter/dnn_filter_common.h +++ b/libavfilter/dnn_filter_common.h @@ -45,7 +45,7 @@ typedef struct DnnContext { { "input", "input name of the model", OFFSET(model_inputname), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },\ { "output", "output name of the model", OFFSET(model_outputnames_string), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },\ { "backend_configs","backend configs", OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },\ -{ "options","backend configs", OFFSET(backend_options), AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },\ +{ "options", "backend configs (deprecated, use backend_configs)", OFFSET(backend_options), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS | AV_OPT_FLAG_DEPRECATED},\ { "async", "use DNN async inference",OFFSET(async), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, FLAGS}, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavfi/dnn: refine code to separate processing and detection in backends
ffmpeg | branch: master | Guo, Yejun | Mon May 17 10:31:16 2021 +0800| [4c705a2775afca7eadc40835bfaafb29a9c5c38a] | committer: Guo, Yejun lavfi/dnn: refine code to separate processing and detection in backends > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4c705a2775afca7eadc40835bfaafb29a9c5c38a --- libavfilter/dnn/dnn_backend_native.c | 2 +- libavfilter/dnn/dnn_backend_openvino.c | 6 -- libavfilter/dnn/dnn_backend_tf.c | 20 +++- libavfilter/dnn/dnn_io_proc.c | 18 ++ libavfilter/dnn/dnn_io_proc.h | 3 ++- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c index b5f1c16538..a6be27f1fd 100644 --- a/libavfilter/dnn/dnn_backend_native.c +++ b/libavfilter/dnn/dnn_backend_native.c @@ -314,7 +314,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp if (native_model->model->frame_pre_proc != NULL) { native_model->model->frame_pre_proc(in_frame, &input, native_model->model->filter_ctx); } else { -ff_proc_from_frame_to_dnn(in_frame, &input, native_model->model->func_type, ctx); +ff_proc_from_frame_to_dnn(in_frame, &input, ctx); } } diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 1ff8a720b9..e0781e854a 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -186,15 +186,17 @@ static DNNReturnType fill_model_input_ov(OVModel *ov_model, RequestItem *request task = inference->task; switch (task->ov_model->model->func_type) { case DFT_PROCESS_FRAME: -case DFT_ANALYTICS_DETECT: if (task->do_ioproc) { if (ov_model->model->frame_pre_proc != NULL) { ov_model->model->frame_pre_proc(task->in_frame, &input, ov_model->model->filter_ctx); } else { -ff_proc_from_frame_to_dnn(task->in_frame, &input, ov_model->model->func_type, ctx); +ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } } break; +case DFT_ANALYTICS_DETECT: +ff_frame_to_dnn_detect(task->in_frame, &input, ctx); +break; case DFT_ANALYTICS_CLASSIFY: ff_frame_to_dnn_classify(task->in_frame, &input, inference->bbox_index, ctx); break; diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 5908aeb359..4c16c2bdb0 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -763,12 +763,22 @@ static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_n } input.data = (float *)TF_TensorData(input_tensor); -if (do_ioproc) { -if (tf_model->model->frame_pre_proc != NULL) { -tf_model->model->frame_pre_proc(in_frame, &input, tf_model->model->filter_ctx); -} else { -ff_proc_from_frame_to_dnn(in_frame, &input, tf_model->model->func_type, ctx); +switch (tf_model->model->func_type) { +case DFT_PROCESS_FRAME: +if (do_ioproc) { +if (tf_model->model->frame_pre_proc != NULL) { +tf_model->model->frame_pre_proc(in_frame, &input, tf_model->model->filter_ctx); +} else { +ff_proc_from_frame_to_dnn(in_frame, &input, ctx); +} } +break; +case DFT_ANALYTICS_DETECT: +ff_frame_to_dnn_detect(in_frame, &input, ctx); +break; +default: +avpriv_report_missing_feature(ctx, "model function type %d", tf_model->model->func_type); +break; } tf_outputs = av_malloc_array(nb_output, sizeof(*tf_outputs)); diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c index 02c8e13ed7..021d004e1d 100644 --- a/libavfilter/dnn/dnn_io_proc.c +++ b/libavfilter/dnn/dnn_io_proc.c @@ -97,7 +97,7 @@ DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l return DNN_SUCCESS; } -static DNNReturnType proc_from_frame_to_dnn_frameprocessing(AVFrame *frame, DNNData *input, void *log_ctx) +DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx) { struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); @@ -249,7 +249,7 @@ DNNReturnType ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t return DNN_SUCCESS; } -static DNNReturnType proc_from_frame_to_dnn_analytics(AVFrame *frame, DNNData *input, void *log_ctx) +DNNReturnType ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx) { struct SwsContext *sws_ctx; int linesizes[4]; @@ -277,17 +277,3 @@ static DNNReturnType proc_from_frame_to_dnn_analytics(AVFrame *frame, DNNData *i