summaryrefslogtreecommitdiff
path: root/libavcodec/v308enc.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2012-02-23 17:17:02 +0000
committerMichael Niedermayer <michaelni@gmx.at>2012-02-23 23:38:20 +0100
commitd1ede561a649ccb64eb740ef38709316fb51a3de (patch)
treee0ac1d7cee6e561f86f7b4836f75ab29a5c3d4f4 /libavcodec/v308enc.c
parent29a8f6b8d4eb531b43f0139261c2b7b5ef7fb443 (diff)
v308enc: switch to encode2()
Signed-off-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/v308enc.c')
-rw-r--r--libavcodec/v308enc.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c
index 77fe073852..d6598d2811 100644
--- a/libavcodec/v308enc.c
+++ b/libavcodec/v308enc.c
@@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
+#include "internal.h"
static av_cold int v308_encode_init(AVCodecContext *avctx)
{
@@ -40,19 +41,18 @@ static av_cold int v308_encode_init(AVCodecContext *avctx)
return 0;
}
-static int v308_encode_frame(AVCodecContext *avctx, uint8_t *buf,
- int buf_size, void *data)
+static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pic, int *got_packet)
{
- AVFrame *pic = data;
- uint8_t *dst = buf;
+ uint8_t *dst;
uint8_t *y, *u, *v;
- int i, j;
- int output_size = 0;
+ int i, j, ret;
- if (buf_size < avctx->width * avctx->height * 3) {
+ if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * 3)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Out buffer is too small.\n");
- return AVERROR(ENOMEM);
+ return ret;
}
+ dst = pkt->data;
avctx->coded_frame->reference = 0;
avctx->coded_frame->key_frame = 1;
@@ -67,14 +67,15 @@ static int v308_encode_frame(AVCodecContext *avctx, uint8_t *buf,
*dst++ = v[j];
*dst++ = y[j];
*dst++ = u[j];
- output_size += 3;
}
y += pic->linesize[0];
u += pic->linesize[1];
v += pic->linesize[2];
}
- return output_size;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+ return 0;
}
static av_cold int v308_encode_close(AVCodecContext *avctx)
@@ -89,7 +90,7 @@ AVCodec ff_v308_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_V308,
.init = v308_encode_init,
- .encode = v308_encode_frame,
+ .encode2 = v308_encode_frame,
.close = v308_encode_close,
.pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV444P, PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:4:4"),