avcodec/libopenjpegenc: Replace av_frame_alloc() and av_frame_ref() by av_frame_clone()

Simplifies code

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/54/head
Michael Niedermayer 11 years ago
parent a26e9c1040
commit 9b68538fdd
  1. 6
      libavcodec/libopenjpegenc.c

@ -501,13 +501,9 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
case AV_PIX_FMT_GBRP12: case AV_PIX_FMT_GBRP12:
case AV_PIX_FMT_GBRP14: case AV_PIX_FMT_GBRP14:
case AV_PIX_FMT_GBRP16: case AV_PIX_FMT_GBRP16:
gbrframe = av_frame_alloc(); gbrframe = av_frame_clone(frame);
if (!gbrframe) if (!gbrframe)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if ((ret = av_frame_ref(gbrframe, frame)) < 0) {
av_frame_free(&gbrframe);
return ret;
}
gbrframe->data[0] = frame->data[2]; // swap to be rgb gbrframe->data[0] = frame->data[2]; // swap to be rgb
gbrframe->data[1] = frame->data[0]; gbrframe->data[1] = frame->data[0];
gbrframe->data[2] = frame->data[1]; gbrframe->data[2] = frame->data[1];

Loading…
Cancel
Save