---
libavcodec/asv1enc.c | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/libavcodec/asv1enc.c b/libavcodec/asv1enc.c
index 026205c..a540ed1 100644
--- a/libavcodec/asv1enc.c
+++ b/libavcodec/asv1enc.c
@@ -126,11 +126,13 @@ static inline void asv2_encode_block(ASV1Context *a,
DCTELEM block[64])
}
}
+#define MAX_MB_SIZE (30*16*16*3/2/8)
+
static inline int encode_mb(ASV1Context *a, DCTELEM block[6][64])
{
int i;
- if(a->pb.buf_end - a->pb.buf - (put_bits_count(&a->pb)>>3) <
30*16*16*3/2/8){
+ if (a->pb.buf_end - a->pb.buf - (put_bits_count(&a->pb)>>3) < MAX_MB_SIZE)
{
av_log(a->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
@@ -170,15 +172,19 @@ static inline void dct_get(ASV1Context *a, int mb_x, int
mb_y)
}
}
-static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int
buf_size, void *data)
+static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pict, int *got_packet)
{
ASV1Context * const a = avctx->priv_data;
- AVFrame *pict = data;
AVFrame * const p= &a->picture;
- int size;
+ int size, ret;
int mb_x, mb_y;
- init_put_bits(&a->pb, buf, buf_size);
+ if (!pkt->data &&
+ (ret = av_new_packet(pkt,
FFALIGN(a->mb_width*a->mb_height*MAX_MB_SIZE, 32))) < 0)
+ return ret;
+
+ init_put_bits(&a->pb, pkt->data, pkt->size);
*p = *pict;
p->pict_type= AV_PICTURE_TYPE_I;
@@ -215,14 +221,17 @@ static int encode_frame(AVCodecContext *avctx, unsigned
char *buf, int buf_size,
size= put_bits_count(&a->pb)/32;
if(avctx->codec_id == CODEC_ID_ASV1)
- a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size);
+ a->dsp.bswap_buf((uint32_t*)pkt->data, (uint32_t*)pkt->data, size);
else{
int i;
for(i=0; i<4*size; i++)
- buf[i]= av_reverse[ buf[i] ];
+ pkt->data[i] = av_reverse[pkt->data[i]];
}
- return size*4;
+ pkt->size = size*4;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+ return 0;
}
static av_cold int encode_init(AVCodecContext *avctx)
@@ -257,7 +266,7 @@ AVCodec ff_asv1_encoder = {
.id = CODEC_ID_ASV1,
.priv_data_size = sizeof(ASV1Context),
.init = encode_init,
- .encode = encode_frame,
+ .encode2 = encode_frame,
//encode_end,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P,
PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ASUS V1"),
@@ -271,7 +280,7 @@ AVCodec ff_asv2_encoder = {
.id = CODEC_ID_ASV2,
.priv_data_size = sizeof(ASV1Context),
.init = encode_init,
- .encode = encode_frame,
+ .encode2 = encode_frame,
//encode_end,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P,
PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ASUS V2"),
--
1.7.8.3
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel