Commit 24abd806 authored by Anton Khirnov's avatar Anton Khirnov

ljpegenc: deMpegEncContextize

The encoder uses almost none of the mpegvideo infrastructure, only some
fields from MpegEncContext.

The FATE results change because now an all-zero quant matrix is written
into the file. Since it is not used for anything for ljpeg, this should
not be a problem.
parent 86eb2eaa
This diff is collapsed.
......@@ -609,8 +609,6 @@ typedef struct MpegEncContext {
/* MJPEG specific */
struct MJpegContext *mjpeg_ctx;
int mjpeg_vsample[3]; ///< vertical sampling factors, default = {2, 1, 1}
int mjpeg_hsample[3]; ///< horizontal sampling factors, default = {2, 1, 1}
/* MSMPEG4 specific */
int mv_table_index;
......
......@@ -227,7 +227,6 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
int i, ret;
int chroma_h_shift, chroma_v_shift;
MPV_encode_defaults(s);
......@@ -240,19 +239,6 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
return -1;
}
break;
case AV_CODEC_ID_LJPEG:
if (avctx->pix_fmt != AV_PIX_FMT_YUVJ420P &&
avctx->pix_fmt != AV_PIX_FMT_YUVJ422P &&
avctx->pix_fmt != AV_PIX_FMT_YUVJ444P &&
avctx->pix_fmt != AV_PIX_FMT_BGRA &&
((avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
avctx->pix_fmt != AV_PIX_FMT_YUV422P &&
avctx->pix_fmt != AV_PIX_FMT_YUV444P) ||
avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)) {
av_log(avctx, AV_LOG_ERROR, "colorspace not supported in LJPEG\n");
return -1;
}
break;
case AV_CODEC_ID_MJPEG:
if (avctx->pix_fmt != AV_PIX_FMT_YUVJ420P &&
avctx->pix_fmt != AV_PIX_FMT_YUVJ422P &&
......@@ -538,9 +524,6 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
s->inter_quant_bias = avctx->inter_quant_bias;
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
&chroma_v_shift);
if (avctx->codec_id == AV_CODEC_ID_MPEG4 &&
s->avctx->time_base.den > (1 << 16) - 1) {
av_log(avctx, AV_LOG_ERROR,
......@@ -564,24 +547,10 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1);
s->rtp_mode = 1;
break;
case AV_CODEC_ID_LJPEG:
case AV_CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
s->intra_only = 1; /* force intra only for jpeg */
if (avctx->codec->id == AV_CODEC_ID_LJPEG &&
avctx->pix_fmt == AV_PIX_FMT_BGRA) {
s->mjpeg_vsample[0] = s->mjpeg_hsample[0] =
s->mjpeg_vsample[1] = s->mjpeg_hsample[1] =
s->mjpeg_vsample[2] = s->mjpeg_hsample[2] = 1;
} else {
s->mjpeg_vsample[0] = 2;
s->mjpeg_vsample[1] = 2 >> chroma_v_shift;
s->mjpeg_vsample[2] = 2 >> chroma_v_shift;
s->mjpeg_hsample[0] = 2;
s->mjpeg_hsample[1] = 2 >> chroma_h_shift;
s->mjpeg_hsample[2] = 2 >> chroma_h_shift;
}
if (!(CONFIG_MJPEG_ENCODER || CONFIG_LJPEG_ENCODER) ||
if (!CONFIG_MJPEG_ENCODER ||
ff_mjpeg_encode_init(s) < 0)
return -1;
avctx->delay = 0;
......@@ -838,7 +807,7 @@ av_cold int ff_MPV_encode_end(AVCodecContext *avctx)
ff_rate_control_uninit(s);
ff_MPV_common_end(s);
if ((CONFIG_MJPEG_ENCODER || CONFIG_LJPEG_ENCODER) &&
if (CONFIG_MJPEG_ENCODER &&
s->out_format == FMT_MJPEG)
ff_mjpeg_encode_close(s);
......
2b1a2d5ad7f357df955d8548320d13f7 *tests/data/fate/vsynth1-ljpeg.avi
aed2be6710c0dddacfa410dff7ce7e79 *tests/data/fate/vsynth1-ljpeg.avi
6312924 tests/data/fate/vsynth1-ljpeg.avi
c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ljpeg.out.rawvideo
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200
db9fd56e154b1056c9443a82a96db6f5 *tests/data/fate/vsynth2-ljpeg.avi
5d603cecd59db0f255a53bda837a6bae *tests/data/fate/vsynth2-ljpeg.avi
4766902 tests/data/fate/vsynth2-ljpeg.avi
dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth2-ljpeg.out.rawvideo
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment