summaryrefslogtreecommitdiff
path: root/libavcodec/a64multienc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-23 00:55:13 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-23 02:15:38 +0100
commit4da351ff0cff460db2110cf22f2e3eded8733a58 (patch)
treec1368ed3496a3f1ccb15442d292b053a02f7ae11 /libavcodec/a64multienc.c
parent87513d654546a99f8ddb045ca4fa5d33778a617e (diff)
downloadffmpeg-4da351ff0cff460db2110cf22f2e3eded8733a58.tar.gz
avcodec/a64multienc: simplify frame handling code
This also fixes a memleak Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/a64multienc.c')
-rw-r--r--libavcodec/a64multienc.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 25141c5639..2643b1a2db 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -65,7 +65,7 @@ static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1};
//static const int mc_colors[5]={0x0,0x8,0xa,0xf,0x7};
//static const int mc_colors[5]={0x0,0x9,0x8,0xa,0x3};
-static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
+static void to_meta_with_crop(AVCodecContext *avctx, const AVFrame *p, int *dest)
{
int blockx, blocky, x, y;
int luma = 0;
@@ -190,7 +190,6 @@ static void render_charset(AVCodecContext *avctx, uint8_t *charset,
static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
{
A64Context *c = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
av_freep(&c->mc_meta_charset);
av_freep(&c->mc_best_cb);
av_freep(&c->mc_charset);
@@ -242,14 +241,6 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx)
AV_WB32(avctx->extradata, c->mc_lifetime);
AV_WB32(avctx->extradata + 16, INTERLACED);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- a64multi_close_encoder(avctx);
- return AVERROR(ENOMEM);
- }
-
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("a64m");
@@ -274,10 +265,9 @@ static void a64_compress_colram(unsigned char *buf, int *charmap, uint8_t *colra
}
static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
- const AVFrame *pict, int *got_packet)
+ const AVFrame *p, int *got_packet)
{
A64Context *c = avctx->priv_data;
- AVFrame *const p = avctx->coded_frame;
int frame;
int x, y;
@@ -308,7 +298,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
/* no data, means end encoding asap */
- if (!pict) {
+ if (!p) {
/* all done, end encoding */
if (!c->mc_lifetime) return 0;
/* no more frames in queue, prepare to flush remaining frames */
@@ -321,15 +311,10 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} else {
/* fill up mc_meta_charset with data until lifetime exceeds */
if (c->mc_frame_counter < c->mc_lifetime) {
- ret = av_frame_ref(p, pict);
- if (ret < 0)
- return ret;
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
to_meta_with_crop(avctx, p, meta + 32000 * c->mc_frame_counter);
c->mc_frame_counter++;
if (c->next_pts == AV_NOPTS_VALUE)
- c->next_pts = pict->pts;
+ c->next_pts = p->pts;
/* lifetime is not reached so wait for next frame first */
return 0;
}