[FFmpeg-cvslog] r210enc: switch to encode2()

Paul B Mahol git at videolan.org
Fri Feb 17 23:04:18 CET 2012


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Feb 17 21:27:44 2012 +0000| [48ad7f822d8fdaf99aeeec67552e32fe8a83a687] | committer: Michael Niedermayer

r210enc: switch to encode2()

Signed-off-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48ad7f822d8fdaf99aeeec67552e32fe8a83a687
---

 libavcodec/r210enc.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c
index f5ba42d..10ae001 100644
--- a/libavcodec/r210enc.c
+++ b/libavcodec/r210enc.c
@@ -21,6 +21,7 @@
  */
 
 #include "avcodec.h"
+#include "internal.h"
 #include "bytestream.h"
 
 static av_cold int encode_init(AVCodecContext *avctx)
@@ -33,25 +34,25 @@ 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_packet(pkt, 4 * aligned_width * avctx->height)) < 0) {
+        av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
+        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 +75,10 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf,
         src_line += pic->linesize[0];
     }
 
-    return 4 * aligned_width * avctx->height;
+    pkt->size   = 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 +94,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 +106,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 +118,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"),



More information about the ffmpeg-cvslog mailing list