]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/r210enc.c
r210enc: switch to ff_alloc_packet2().
[ffmpeg] / libavcodec / r210enc.c
index f5ba42da502a70483d46e8b38890cd60908a39b6..331b072013ff5ffe2c136bc3dc64d27947408c3b 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "avcodec.h"
+#include "internal.h"
 #include "bytestream.h"
 
 static av_cold int encode_init(AVCodecContext *avctx)
@@ -33,25 +34,24 @@ static av_cold int encode_init(AVCodecContext *avctx)
     return 0;
 }
 
-static int encode_frame(AVCodecContext *avctx, uint8_t *buf,
-                        int buf_size, void *data)
+static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+                        const AVFrame *pic, int *got_packet)
 {
-    AVFrame *pic = data;
-    int i, j;
+    int i, j, ret;
     int aligned_width = FFALIGN(avctx->width, 64);
     int pad = (aligned_width - avctx->width) * 4;
     uint8_t *src_line;
-    uint8_t *dst = buf;
+    uint8_t *dst;
 
-    if (buf_size < 4 * aligned_width * avctx->height) {
-        av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
-        return AVERROR(ENOMEM);
+    if ((ret = ff_alloc_packet2(avctx, pkt, 4 * aligned_width * avctx->height)) < 0) {
+        return ret;
     }
 
     avctx->coded_frame->reference = 0;
     avctx->coded_frame->key_frame = 1;
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
     src_line = pic->data[0];
+    dst = pkt->data;
 
     for (i = 0; i < avctx->height; i++) {
         uint16_t *src = (uint16_t *)src_line;
@@ -74,7 +74,9 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf,
         src_line += pic->linesize[0];
     }
 
-    return 4 * aligned_width * avctx->height;
+    pkt->flags |= AV_PKT_FLAG_KEY;
+    *got_packet = 1;
+    return 0;
 }
 
 static av_cold int encode_close(AVCodecContext *avctx)
@@ -90,7 +92,7 @@ AVCodec ff_r210_encoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = CODEC_ID_R210,
     .init           = encode_init,
-    .encode         = encode_frame,
+    .encode2        = encode_frame,
     .close          = encode_close,
     .pix_fmts       = (const enum PixelFormat[]) { PIX_FMT_RGB48, PIX_FMT_NONE },
     .long_name      = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"),
@@ -102,7 +104,7 @@ AVCodec ff_r10k_encoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = CODEC_ID_R10K,
     .init           = encode_init,
-    .encode         = encode_frame,
+    .encode2        = encode_frame,
     .close          = encode_close,
     .pix_fmts       = (const enum PixelFormat[]) { PIX_FMT_RGB48, PIX_FMT_NONE },
     .long_name      = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"),
@@ -114,7 +116,7 @@ AVCodec ff_avrp_encoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = CODEC_ID_AVRP,
     .init           = encode_init,
-    .encode         = encode_frame,
+    .encode2        = encode_frame,
     .close          = encode_close,
     .pix_fmts       = (const enum PixelFormat[]) { PIX_FMT_RGB48, PIX_FMT_NONE },
     .long_name      = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"),