|
|
|
@ -272,7 +272,6 @@ static av_cold int ljpeg_encode_close(AVCodecContext *avctx) |
|
|
|
|
static av_cold int ljpeg_encode_init(AVCodecContext *avctx) |
|
|
|
|
{ |
|
|
|
|
LJpegEncContext *s = avctx->priv_data; |
|
|
|
|
int chroma_v_shift, chroma_h_shift; |
|
|
|
|
|
|
|
|
|
if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P || |
|
|
|
|
avctx->pix_fmt == AV_PIX_FMT_YUV422P || |
|
|
|
@ -296,26 +295,7 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx) |
|
|
|
|
ff_dsputil_init(&s->dsp, avctx); |
|
|
|
|
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct); |
|
|
|
|
|
|
|
|
|
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, |
|
|
|
|
&chroma_v_shift); |
|
|
|
|
|
|
|
|
|
if ( avctx->pix_fmt == AV_PIX_FMT_BGR0 |
|
|
|
|
|| avctx->pix_fmt == AV_PIX_FMT_BGRA |
|
|
|
|
|| avctx->pix_fmt == AV_PIX_FMT_BGR24) { |
|
|
|
|
s->vsample[0] = s->hsample[0] = |
|
|
|
|
s->vsample[1] = s->hsample[1] = |
|
|
|
|
s->vsample[2] = s->hsample[2] = 1; |
|
|
|
|
} else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P) { |
|
|
|
|
s->vsample[0] = s->vsample[1] = s->vsample[2] = 2; |
|
|
|
|
s->hsample[0] = s->hsample[1] = s->hsample[2] = 1; |
|
|
|
|
} else { |
|
|
|
|
s->vsample[0] = 2; |
|
|
|
|
s->vsample[1] = 2 >> chroma_v_shift; |
|
|
|
|
s->vsample[2] = 2 >> chroma_v_shift; |
|
|
|
|
s->hsample[0] = 2; |
|
|
|
|
s->hsample[1] = 2 >> chroma_h_shift; |
|
|
|
|
s->hsample[2] = 2 >> chroma_h_shift; |
|
|
|
|
} |
|
|
|
|
ff_mjpeg_init_hvsample(avctx, s->hsample, s->vsample); |
|
|
|
|
|
|
|
|
|
ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance, |
|
|
|
|
s->huff_code_dc_luminance, |
|
|
|
|