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 },