summaryrefslogtreecommitdiff
path: root/libavcodec/yuv4enc.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2012-02-23 17:17:03 +0000
committerMichael Niedermayer <michaelni@gmx.at>2012-02-23 23:40:51 +0100
commit1f801f3a705a5eea58f7d4d2b6a2a9fa3da462f0 (patch)
tree53ab7d39c79322c3ad81ceca21ff6bd6d50e066c /libavcodec/yuv4enc.c
parentd1ede561a649ccb64eb740ef38709316fb51a3de (diff)
yuv4enc: switch to encode2()
Signed-off-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/yuv4enc.c')
-rw-r--r--libavcodec/yuv4enc.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c
index db7b6245fb..5f37c3343a 100644
--- a/libavcodec/yuv4enc.c
+++ b/libavcodec/yuv4enc.c
@@ -21,6 +21,7 @@
*/
#include "avcodec.h"
+#include "internal.h"
static av_cold int yuv4_encode_init(AVCodecContext *avctx)
{
@@ -34,19 +35,18 @@ static av_cold int yuv4_encode_init(AVCodecContext *avctx)
return 0;
}
-static int yuv4_encode_frame(AVCodecContext *avctx, uint8_t *buf,
- int buf_size, void *data)
+static int yuv4_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 < 6 * (avctx->width + 1 >> 1) * (avctx->height + 1 >> 1)) {
+ if ((ret = ff_alloc_packet(pkt, 6 * (avctx->width + 1 >> 1) * (avctx->height + 1 >> 1))) < 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;
@@ -64,14 +64,15 @@ static int yuv4_encode_frame(AVCodecContext *avctx, uint8_t *buf,
*dst++ = y[ 2 * j + 1];
*dst++ = y[pic->linesize[0] + 2 * j ];
*dst++ = y[pic->linesize[0] + 2 * j + 1];
- output_size += 6;
}
y += 2 * 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 yuv4_encode_close(AVCodecContext *avctx)
@@ -86,7 +87,7 @@ AVCodec ff_yuv4_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_YUV4,
.init = yuv4_encode_init,
- .encode = yuv4_encode_frame,
+ .encode2 = yuv4_encode_frame,
.close = yuv4_encode_close,
.pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV420P, PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:2:0"),