Message ID | HE1PR0301MB21541DBB0061629B4BC536298F299@HE1PR0301MB2154.eurprd03.prod.outlook.com |
---|---|
State | Accepted |
Commit | 835d8b7401466c2c22d4f439c3c331eb949d793e |
Headers | show |
Series | [FFmpeg-devel,01/39] avcodec/audiotoolboxenc: Remove AV_CODEC_CAP_DR1 | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
On 5/21/2021 6:17 AM, Andreas Rheinhardt wrote: > When the packet size is known in advance like here, one can avoid > an intermediate buffer for the packet data; this also makes it easy > to allow user-supplied buffers. Only one thing needed to be changed: > The earlier code relied on the buffer having been initially zeroed > by av_fast_padded_malloc(), so one now needs to zero the packet at > first. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavcodec/dvenc.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) Patches 1 to 26 LGTM (After addressing the comments i made in two of them).
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 393c8b34e9..a464e3ed87 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -39,6 +39,7 @@ #include "dv.h" #include "dv_profile_internal.h" #include "dv_tablegen.h" +#include "encode.h" #include "fdctdsp.h" #include "internal.h" #include "mathops.h" @@ -1170,8 +1171,10 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt, DVVideoContext *s = c->priv_data; int ret; - if ((ret = ff_alloc_packet2(c, pkt, s->sys->frame_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(c, pkt, s->sys->frame_size, 0)) < 0) return ret; + /* Fixme: Only zero the part that is not overwritten later. */ + memset(pkt->data, 0, pkt->size); c->pix_fmt = s->sys->pix_fmt; s->frame = frame; @@ -1209,10 +1212,11 @@ const AVCodec ff_dvvideo_encoder = { .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_DVVIDEO, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS, .priv_data_size = sizeof(DVVideoContext), .init = dvvideo_encode_init, .encode2 = dvvideo_encode_frame, - .capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data; this also makes it easy to allow user-supplied buffers. Only one thing needed to be changed: The earlier code relied on the buffer having been initially zeroed by av_fast_padded_malloc(), so one now needs to zero the packet at first. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/dvenc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)