X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fqtrleenc.c;h=a4ed85aaf250120d9621e4beecd7cdce71fb1671;hb=7bbd060324f05a32aa3cc748ea484abf499cfbd8;hp=590c39dceab52c791a30392ee0454af38abad5c7;hpb=f35c4ede9e0e360143a5b81adbbbec23f37fdce2;p=ffmpeg diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 590c39dceab..a4ed85aaf25 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -37,7 +37,7 @@ typedef struct QtrleEncContext { AVCodecContext *avctx; int pixel_size; - AVPicture previous_frame; + AVFrame *previous_frame; unsigned int max_buf_size; int logical_width; /** @@ -67,7 +67,7 @@ static av_cold int qtrle_encode_end(AVCodecContext *avctx) { QtrleEncContext *s = avctx->priv_data; - avpicture_free(&s->previous_frame); + av_frame_free(&s->previous_frame); av_free(s->rlecode_table); av_free(s->length_table); av_free(s->skip_table); @@ -77,7 +77,6 @@ static av_cold int qtrle_encode_end(AVCodecContext *avctx) static av_cold int qtrle_encode_init(AVCodecContext *avctx) { QtrleEncContext *s = avctx->priv_data; - int ret; if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) { return AVERROR(EINVAL); @@ -116,9 +115,10 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Error allocating memory.\n"); return AVERROR(ENOMEM); } - if ((ret = avpicture_alloc(&s->previous_frame, avctx->pix_fmt, avctx->width, avctx->height)) < 0) { + s->previous_frame = av_frame_alloc(); + if (!s->previous_frame) { av_log(avctx, AV_LOG_ERROR, "Error allocating picture\n"); - return ret; + return AVERROR(ENOMEM); } s->max_buf_size = s->logical_width*s->avctx->height*s->pixel_size*2 /* image base material */ @@ -157,7 +157,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, ui uint8_t *this_line = p-> data[0] + line*p-> linesize[0] + (width - 1)*s->pixel_size; - uint8_t *prev_line = s->previous_frame.data[0] + line*s->previous_frame.linesize[0] + + uint8_t *prev_line = s->previous_frame->data[0] + line * s->previous_frame->linesize[0] + (width - 1)*s->pixel_size; s->length_table[width] = 0; @@ -329,13 +329,13 @@ static int encode_frame(QtrleEncContext *s, const AVFrame *p, uint8_t *buf) unsigned line_size = s->logical_width * s->pixel_size; for (start_line = 0; start_line < s->avctx->height; start_line++) if (memcmp(p->data[0] + start_line*p->linesize[0], - s->previous_frame.data[0] + start_line*s->previous_frame.linesize[0], + s->previous_frame->data[0] + start_line * s->previous_frame->linesize[0], line_size)) break; for (end_line=s->avctx->height; end_line > start_line; end_line--) if (memcmp(p->data[0] + (end_line - 1)*p->linesize[0], - s->previous_frame.data[0] + (end_line - 1)*s->previous_frame.linesize[0], + s->previous_frame->data[0] + (end_line - 1) * s->previous_frame->linesize[0], line_size)) break; } @@ -382,8 +382,12 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, pkt->size = encode_frame(s, pict, pkt->data); /* save the current frame */ - av_picture_copy(&s->previous_frame, (const AVPicture *)pict, - avctx->pix_fmt, avctx->width, avctx->height); + av_frame_unref(s->previous_frame); + ret = av_frame_ref(s->previous_frame, pict); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "cannot add reference\n"); + return ret; + } #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS