*/
#include "avcodec.h"
+#include "internal.h"
#include "bytestream.h"
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;
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)
.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"),
.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"),
.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"),