#include "libavutil/frame.h"
#include "libavutil/mem.h"
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "idctdsp.h"
#include "internal.h"
#include "jpegtables.h"
+#include "mathops.h"
#include "mjpegenc_common.h"
#include "mjpeg.h"
int left[4], top[4], topleft[4];
int x, y, i;
-#if FF_API_PRIVATE_OPT
-FF_DISABLE_DEPRECATION_WARNINGS
- if (avctx->prediction_method)
- s->pred = avctx->prediction_method + 1;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
for (i = 0; i < 4; i++)
buffer[0][i] = 1 << (9 - 1);
const int modified_predictor = y ? s->pred : 1;
uint8_t *ptr = frame->data[0] + (linesize * y);
- if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) < width * 4 * 4) {
+ if (put_bytes_left(pb, 0) < width * 4 * 4) {
av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
const int mb_height = (avctx->height + s->vsample[0] - 1) / s->vsample[0];
int mb_x, mb_y;
-#if FF_API_PRIVATE_OPT
-FF_DISABLE_DEPRECATION_WARNINGS
- if (avctx->prediction_method)
- s->pred = avctx->prediction_method + 1;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
for (mb_y = 0; mb_y < mb_height; mb_y++) {
- if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) <
+ if (put_bytes_left(pb, 0) <
mb_width * 4 * 3 * s->hsample[0] * s->vsample[0]) {
av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
{
+ int ret = ff_mjpeg_encode_check_pix_fmt(avctx);
LJpegEncContext *s = avctx->priv_data;
- if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
- avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
- avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
- avctx->color_range == AVCOL_RANGE_MPEG) &&
- avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
- av_log(avctx, AV_LOG_ERROR,
- "Limited range YUV is non-standard, set strict_std_compliance to "
- "at least unofficial to use it.\n");
- return AVERROR(EINVAL);
- }
-
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
- avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
- avctx->coded_frame->key_frame = 1;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
+ if (ret < 0)
+ return ret;
s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
if (!s->scratch)
- goto fail;
+ return AVERROR(ENOMEM);
ff_idctdsp_init(&s->idsp, avctx);
ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
avpriv_mjpeg_val_dc);
return 0;
-fail:
- ljpeg_encode_close(avctx);
- return AVERROR(ENOMEM);
}
#define OFFSET(x) offsetof(LJpegEncContext, x)
.version = LIBAVUTIL_VERSION_INT,
};
-AVCodec ff_ljpeg_encoder = {
+const AVCodec ff_ljpeg_encoder = {
.name = "ljpeg",
.long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
.type = AVMEDIA_TYPE_VIDEO,
.init = ljpeg_encode_init,
.encode2 = ljpeg_encode_frame,
.close = ljpeg_encode_close,
- .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY,
+ .capabilities = AV_CODEC_CAP_FRAME_THREADS,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_BGR24 , AV_PIX_FMT_BGRA , AV_PIX_FMT_BGR0,
AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P,