From 28f36dce3e5c6be6b7f208362fca3531ed3cb50d Mon Sep 17 00:00:00 2001 From: Michael Bradshaw Date: Thu, 31 Jan 2013 16:03:58 -0700 Subject: [PATCH] libopenjpegenc: simplify switch statement Signed-off-by: Michael Bradshaw --- libavcodec/libopenjpegenc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 51a60165eb..2bbbae902a 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -377,15 +377,6 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, cpyresult = libopenjpeg_copy_packed16(avctx, frame, image); break; case AV_PIX_FMT_GBR24P: - gbrframe = *frame; - gbrframe.data[0] = frame->data[2]; // swap to be rgb - gbrframe.data[1] = frame->data[0]; - gbrframe.data[2] = frame->data[1]; - gbrframe.linesize[0] = frame->linesize[2]; - gbrframe.linesize[1] = frame->linesize[0]; - gbrframe.linesize[2] = frame->linesize[1]; - cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image); - break; case AV_PIX_FMT_GBRP9: case AV_PIX_FMT_GBRP10: case AV_PIX_FMT_GBRP12: @@ -398,7 +389,11 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, gbrframe.linesize[0] = frame->linesize[2]; gbrframe.linesize[1] = frame->linesize[0]; gbrframe.linesize[2] = frame->linesize[1]; - cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image); + if (avctx->pix_fmt == AV_PIX_FMT_GBR24P) { + cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image); + } else { + cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image); + } break; case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_YUV410P: