* [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_enc: Ignore ICC profile size when not MJPEG
@ 2022-04-11 23:49 Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_enc: Fix unnecessary linear growth of buffer Andreas Rheinhardt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-04-11 23:49 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
MJPEG is the only mpegvideo-based encoder making use of it.
Fixes linking failures in case mpegvideo_enc.c is compiled
with AMV, LJPEG and MJPEG encoders disabled.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_enc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 40bcf09c0b..4a5e5a5059 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1687,8 +1687,11 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
size_t pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - AV_INPUT_BUFFER_PADDING_SIZE
:
s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000;
- if ((ret = ff_mjpeg_add_icc_profile_size(avctx, s->new_picture, &pkt_size)) < 0)
- return ret;
+ if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) {
+ ret = ff_mjpeg_add_icc_profile_size(avctx, s->new_picture, &pkt_size);
+ if (ret < 0)
+ return ret;
+ }
if ((ret = ff_alloc_packet(avctx, pkt, pkt_size)) < 0)
return ret;
if (s->mb_info) {
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_enc: Fix unnecessary linear growth of buffer
2022-04-11 23:49 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_enc: Ignore ICC profile size when not MJPEG Andreas Rheinhardt
@ 2022-04-11 23:50 ` Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_enc: Remove always-true check Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 4/4] avcodec/mjpegenc: Don't unnecessarily grow buffer Andreas Rheinhardt
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-04-11 23:50 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
If one encodes MJPEG with a single slice and uses input with
AV_FRAME_DATA_ICC_PROFILE side data, the current allocation code
in ff_mpv_encode_picture() will always increase the size of the
temporary buffer used for allocating packets by the size needed
for to write the ICC chunk even when the current buffer is actually
large enough. This commit fixes this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_enc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 4a5e5a5059..434bbb3a68 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1684,9 +1684,8 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
/* output? */
if (s->new_picture->data[0]) {
int growing_buffer = context_count == 1 && !pkt->data && !s->data_partitioning;
- size_t pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - AV_INPUT_BUFFER_PADDING_SIZE
- :
- s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000;
+ size_t pkt_size = 10000 + s->mb_width * s->mb_height *
+ (growing_buffer ? 64 : (MAX_MB_BYTES + 100));
if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) {
ret = ff_mjpeg_add_icc_profile_size(avctx, s->new_picture, &pkt_size);
if (ret < 0)
@@ -1694,6 +1693,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
}
if ((ret = ff_alloc_packet(avctx, pkt, pkt_size)) < 0)
return ret;
+ pkt->size = avctx->internal->byte_buffer_size - AV_INPUT_BUFFER_PADDING_SIZE;
if (s->mb_info) {
s->mb_info_ptr = av_packet_new_side_data(pkt,
AV_PKT_DATA_H263_MB_INFO,
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_enc: Remove always-true check
2022-04-11 23:49 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_enc: Ignore ICC profile size when not MJPEG Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_enc: Fix unnecessary linear growth of buffer Andreas Rheinhardt
@ 2022-04-11 23:50 ` Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 4/4] avcodec/mjpegenc: Don't unnecessarily grow buffer Andreas Rheinhardt
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-04-11 23:50 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is a remnant of the old way for user-supplied buffers;
it is always-true since 93016f5d1d280f9cb7856883af287fa66affc04c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_enc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 434bbb3a68..c9d8c48026 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1683,7 +1683,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
/* output? */
if (s->new_picture->data[0]) {
- int growing_buffer = context_count == 1 && !pkt->data && !s->data_partitioning;
+ int growing_buffer = context_count == 1 && !s->data_partitioning;
size_t pkt_size = 10000 + s->mb_width * s->mb_height *
(growing_buffer ? 64 : (MAX_MB_BYTES + 100));
if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) {
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 4/4] avcodec/mjpegenc: Don't unnecessarily grow buffer
2022-04-11 23:49 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_enc: Ignore ICC profile size when not MJPEG Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_enc: Fix unnecessary linear growth of buffer Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_enc: Remove always-true check Andreas Rheinhardt
@ 2022-04-11 23:50 ` Andreas Rheinhardt
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-04-11 23:50 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The size of the ICC chunk has already been accounted for when
the packet's buffer was initially set in ff_mpv_encode_picture()
and the header (including the ICC chunk) has already been written
at this point.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mjpegenc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 1e9b97535a..8cada8366c 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -131,7 +131,6 @@ static void mjpeg_encode_picture_frame(MpegEncContext *s)
}
bytes_needed = (total_bits + 7) / 8;
- ff_mjpeg_add_icc_profile_size(s->avctx, s->picture->f, &bytes_needed);
ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
for (int i = 0; i < m->huff_ncode; i++) {
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-11 23:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 23:49 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_enc: Ignore ICC profile size when not MJPEG Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_enc: Fix unnecessary linear growth of buffer Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_enc: Remove always-true check Andreas Rheinhardt
2022-04-11 23:50 ` [FFmpeg-devel] [PATCH 4/4] avcodec/mjpegenc: Don't unnecessarily grow buffer Andreas Rheinhardt
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git