aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/jpeglsenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-17 13:27:46 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-17 13:55:50 +0100
commitbe1e6e7503b2f10b0176201418eb97912cee093f (patch)
tree620da8277e8837ccbb93a2a21e14a9b188c95b16 /libavcodec/jpeglsenc.c
parentf4f7888bab7061f08c54356c285adaba24383dc0 (diff)
parent1c01b0253ebfe05f907c3a723101fe77f6dd2336 (diff)
downloadffmpeg-be1e6e7503b2f10b0176201418eb97912cee093f.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: mpegvideo_enc: use the AVFrame API properly. ffv1: use the AVFrame API properly. jpegls: use the AVFrame API properly. huffyuv: use the AVFrame API properly. Conflicts: libavcodec/ffv1.c libavcodec/ffv1.h libavcodec/ffv1dec.c libavcodec/ffv1enc.c Changes to ffv1 are more redone than merged due to them being based on an ancient codebase and a good part of that having being done already as well. Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/jpeglsenc.c')
-rw-r--r--libavcodec/jpeglsenc.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 308d6d3e68..030178f9ac 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -249,8 +249,7 @@ static void ls_store_lse(JLSState *state, PutBitContext *pb)
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
- JpeglsContext *const s = avctx->priv_data;
- AVFrame *const p = &s->picture;
+ const AVFrame *const p = pict;
const int near = avctx->prediction_method;
PutBitContext pb, pb2;
GetBitContext gb;
@@ -259,10 +258,6 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
int i, size, ret;
int comps;
- *p = *pict;
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
-
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16)
comps = 1;
@@ -349,7 +344,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
Rc[j] = last[j];
}
last = cur;
- cur += s->picture.linesize[0];
+ cur += p->linesize[0];
}
} else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
int j, width;
@@ -363,7 +358,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
Rc[j] = last[j];
}
last = cur;
- cur += s->picture.linesize[0];
+ cur += p->linesize[0];
}
}
@@ -403,12 +398,20 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
+static av_cold int encode_close(AVCodecContext *avctx)
+{
+ av_frame_free(&avctx->coded_frame);
+ return 0;
+}
+
static av_cold int encode_init_ls(AVCodecContext *ctx)
{
- JpeglsContext *c = (JpeglsContext *)ctx->priv_data;
+ ctx->coded_frame = av_frame_alloc();
+ if (!ctx->coded_frame)
+ return AVERROR(ENOMEM);
- c->avctx = ctx;
- ctx->coded_frame = &c->picture;
+ ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ ctx->coded_frame->key_frame = 1;
if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 &&
ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&
@@ -426,8 +429,8 @@ AVCodec ff_jpegls_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS,
- .priv_data_size = sizeof(JpeglsContext),
.init = encode_init_ls,
+ .close = encode_close,
.encode2 = encode_picture_ls,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24,