[FFmpeg-cvslog] y41penc: switch to encode2()
Paul B Mahol
git at videolan.org
Fri Feb 17 23:04:19 CET 2012
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Feb 17 21:27:45 2012 +0000| [545e8879021a7026789158055d3b28133eafa91e] | committer: Michael Niedermayer
y41penc: 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=545e8879021a7026789158055d3b28133eafa91e
---
libavcodec/y41penc.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c
index e5905cf..1b81a52 100644
--- a/libavcodec/y41penc.c
+++ b/libavcodec/y41penc.c
@@ -21,6 +21,7 @@
*/
#include "avcodec.h"
+#include "internal.h"
static av_cold int y41p_encode_init(AVCodecContext *avctx)
{
@@ -40,22 +41,22 @@ static av_cold int y41p_encode_init(AVCodecContext *avctx)
return 0;
}
-static int y41p_encode_frame(AVCodecContext *avctx, uint8_t *buf,
- int buf_size, void *data)
+static int y41p_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 i, j, ret;
- if (buf_size < avctx->width * avctx->height * 1.5) {
+ if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * 1.5)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Out buffer is too small.\n");
- return AVERROR(ENOMEM);
+ return ret;
}
avctx->coded_frame->reference = 0;
avctx->coded_frame->key_frame = 1;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ dst = pkt->data;
for (i = avctx->height - 1; i >= 0; i--) {
y = &pic->data[0][i * pic->linesize[0]];
@@ -79,7 +80,10 @@ static int y41p_encode_frame(AVCodecContext *avctx, uint8_t *buf,
}
}
- return avctx->width * avctx->height * 1.5;
+ pkt->size = 1.5 * avctx->width * avctx->height;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+ return 0;
}
static av_cold int y41p_encode_close(AVCodecContext *avctx)
@@ -94,7 +98,7 @@ AVCodec ff_y41p_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_Y41P,
.init = y41p_encode_init,
- .encode = y41p_encode_frame,
+ .encode2 = y41p_encode_frame,
.close = y41p_encode_close,
.pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV411P,
PIX_FMT_NONE },
More information about the ffmpeg-cvslog
mailing list