[FFmpeg-devel] [PATCH v1] avcodec/magicyuv: remove duplicate code
Paul B Mahol
onemda at gmail.com
Wed Oct 9 18:00:09 EEST 2019
ok
On 10/9/19, Limin Wang <lance.lmwang at gmail.com> wrote:
>
> ping, I hope it makes sense to reduce the code size.
>
> On Tue, Sep 24, 2019 at 09:13:52AM +0800, lance.lmwang at gmail.com wrote:
>> From: Limin Wang <lance.lmwang at gmail.com>
>>
>> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
>> ---
>> libavcodec/magicyuv.c | 30 ++++++------------------------
>> 1 file changed, 6 insertions(+), 24 deletions(-)
>>
>> diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
>> index f4fb2a7809..21a32785bc 100644
>> --- a/libavcodec/magicyuv.c
>> +++ b/libavcodec/magicyuv.c
>> @@ -547,10 +547,7 @@ static int magy_decode_frame(AVCodecContext *avctx,
>> void *data,
>> s->hshift[2] =
>> s->vshift[2] = 0;
>> s->decorrelate = 0;
>> - s->max = 256;
>> s->bps = 8;
>> - s->huff_build = huff_build;
>> - s->magy_decode_slice = magy_decode_slice;
>>
>> format = bytestream2_get_byte(&gbyte);
>> switch (format) {
>> @@ -587,61 +584,46 @@ static int magy_decode_frame(AVCodecContext *avctx,
>> void *data,
>> avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
>> s->hshift[1] =
>> s->hshift[2] = 1;
>> - s->max = 1024;
>> - s->huff_build = huff_build10;
>> - s->magy_decode_slice = magy_decode_slice10;
>> s->bps = 10;
>> break;
>> case 0x76:
>> avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
>> - s->max = 1024;
>> - s->huff_build = huff_build10;
>> - s->magy_decode_slice = magy_decode_slice10;
>> s->bps = 10;
>> break;
>> case 0x6d:
>> avctx->pix_fmt = AV_PIX_FMT_GBRP10;
>> s->decorrelate = 1;
>> - s->max = 1024;
>> - s->huff_build = huff_build10;
>> - s->magy_decode_slice = magy_decode_slice10;
>> s->bps = 10;
>> break;
>> case 0x6e:
>> avctx->pix_fmt = AV_PIX_FMT_GBRAP10;
>> s->decorrelate = 1;
>> - s->max = 1024;
>> - s->huff_build = huff_build10;
>> - s->magy_decode_slice = magy_decode_slice10;
>> s->bps = 10;
>> break;
>> case 0x6f:
>> avctx->pix_fmt = AV_PIX_FMT_GBRP12;
>> s->decorrelate = 1;
>> - s->max = 4096;
>> - s->huff_build = huff_build12;
>> - s->magy_decode_slice = magy_decode_slice10;
>> s->bps = 12;
>> break;
>> case 0x70:
>> avctx->pix_fmt = AV_PIX_FMT_GBRAP12;
>> s->decorrelate = 1;
>> - s->max = 4096;
>> - s->huff_build = huff_build12;
>> - s->magy_decode_slice = magy_decode_slice10;
>> s->bps = 12;
>> break;
>> case 0x73:
>> avctx->pix_fmt = AV_PIX_FMT_GRAY10;
>> - s->max = 1024;
>> - s->huff_build = huff_build10;
>> - s->magy_decode_slice = magy_decode_slice10;
>> s->bps = 10;
>> break;
>> default:
>> avpriv_request_sample(avctx, "Format 0x%X", format);
>> return AVERROR_PATCHWELCOME;
>> }
>> + s->max = 1 << s->bps;
>> + s->magy_decode_slice = s->bps == 8 ? magy_decode_slice :
>> magy_decode_slice10;
>> + if ( s->bps == 8)
>> + s->huff_build = huff_build;
>> + else
>> + s->huff_build = s->bps == 10 ? huff_build10 : huff_build12;
>> s->planes = av_pix_fmt_count_planes(avctx->pix_fmt);
>>
>> bytestream2_skip(&gbyte, 1);
>> --
>> 2.21.0
>>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list