diff options
author | Niklas Haas <git@haasn.dev> | 2022-03-10 13:51:18 +0100 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2022-04-11 17:29:57 +0200 |
commit | e254af31549ce6b4964936b3fe2124c3a18e69f8 (patch) | |
tree | 107d7bbd4f00af7b5f5732598fca7d270640eaee /libavcodec/ljpegenc.c | |
parent | 4a580975d4b978894d20dd443163cc8b6a2dbf2a (diff) | |
download | ffmpeg-e254af31549ce6b4964936b3fe2124c3a18e69f8.tar.gz |
avcodec/mjpegenc: support writing ICC profiles
This is mostly straightforward. The major complication is that, as a
result of the 16-bit chunk size limitation, ICC profiles may need to be
split up into multiple chunks.
We also need to make sure to allocate enough extra space in the packet
to fit the ICC profile, so modify both mpegvideo_enc.c and ljpegenc.c to
take into account this extra overhead, failing cleanly if necessary.
Also add a FATE transcode test to ensure that the ICC profile gets
written (and read) correctly. Note that this ICC profile is smaller than
64 kB, so this doesn't test the APP2 chunk re-arranging code at all.
Signed-off-by: Niklas Haas <git@haasn.dev>
Diffstat (limited to 'libavcodec/ljpegenc.c')
-rw-r--r-- | libavcodec/ljpegenc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index d525437121..fc7a462734 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -220,7 +220,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const int height = avctx->height; const int mb_width = (width + s->hsample[0] - 1) / s->hsample[0]; const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0]; - int max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE; + size_t max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE; int ret, header_bits; if( avctx->pix_fmt == AV_PIX_FMT_BGR0 @@ -233,12 +233,14 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, * s->hsample[0] * s->vsample[0]; } + if ((ret = ff_mjpeg_add_icc_profile_size(avctx, pict, &max_pkt_size)) < 0) + return ret; if ((ret = ff_alloc_packet(avctx, pkt, max_pkt_size)) < 0) return ret; init_put_bits(&pb, pkt->data, pkt->size); - ff_mjpeg_encode_picture_header(avctx, &pb, NULL, &s->scantable, + ff_mjpeg_encode_picture_header(avctx, &pb, pict, NULL, &s->scantable, s->pred, s->matrix, s->matrix, 0); header_bits = put_bits_count(&pb); |