From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 12/15] avcodec/mpegvideo_dec: Move getting Picture slot into alloc_picture()
Date: Fri, 5 Apr 2024 14:41:35 +0200
Message-ID: <GV1P250MB07373AB3396DACA5AAC622058F032@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737AB31294010EE180AF5828F032@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpegvideo_dec.c | 63 ++++++++++++++++----------------------
1 file changed, 26 insertions(+), 37 deletions(-)
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index b6ef4e5582..d337a6565b 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -235,12 +235,20 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s)
return err;
}
-static int alloc_picture(MpegEncContext *s, Picture *pic)
+static int alloc_picture(MpegEncContext *s, Picture **picp, int reference)
{
AVCodecContext *avctx = s->avctx;
+ int idx = ff_find_unused_picture(s->avctx, s->picture, 0);
+ Picture *pic;
int ret;
+ if (idx < 0)
+ return idx;
+
+ pic = &s->picture[idx];
+
pic->tf.f = pic->f;
+ pic->reference = reference;
/* WM Image / Screen codecs allocate internal buffers with different
* dimensions / colorspaces; ignore user-defined callbacks for these. */
@@ -248,7 +256,7 @@ static int alloc_picture(MpegEncContext *s, Picture *pic)
avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
avctx->codec_id != AV_CODEC_ID_MSS2) {
ret = ff_thread_get_ext_buffer(avctx, &pic->tf,
- pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
+ reference ? AV_GET_BUFFER_FLAG_REF : 0);
} else {
pic->f->width = avctx->width;
pic->f->height = avctx->height;
@@ -262,9 +270,14 @@ static int alloc_picture(MpegEncContext *s, Picture *pic)
if (ret < 0)
goto fail;
- return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 0, s->out_format,
- s->mb_stride, s->mb_width, s->mb_height, s->b8_stride,
- &s->linesize, &s->uvlinesize);
+ ret = ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, 0, s->out_format,
+ s->mb_stride, s->mb_width, s->mb_height, s->b8_stride,
+ &s->linesize, &s->uvlinesize);
+ if (ret < 0)
+ goto fail;
+ *picp = pic;
+
+ return 0;
fail:
ff_mpeg_unref_picture(pic);
return ret;
@@ -272,27 +285,16 @@ fail:
static int av_cold alloc_dummy_frame(MpegEncContext *s, Picture **picp)
{
- int idx = ff_find_unused_picture(s->avctx, s->picture, 0);
Picture *pic;
- int ret;
-
- if (idx < 0)
- return idx;
-
- pic = &s->picture[idx];
-
- pic->reference = 3;
- pic->f->pict_type = AV_PICTURE_TYPE_P;
-
- ret = alloc_picture(s, pic);
+ int ret = alloc_picture(s, picp, 1);
if (ret < 0)
return ret;
+ pic = *picp;
+
ff_thread_report_progress(&pic->tf, INT_MAX, 0);
ff_thread_report_progress(&pic->tf, INT_MAX, 1);
- *picp = pic;
-
return 0;
}
@@ -320,8 +322,7 @@ static void color_frame(AVFrame *frame, int luma)
*/
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
- Picture *pic;
- int idx, ret;
+ int ret;
s->mb_skipped = 0;
@@ -351,23 +352,11 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
ff_mpeg_unref_picture(&s->last_picture);
ff_mpeg_unref_picture(&s->next_picture);
- idx = ff_find_unused_picture(s->avctx, s->picture, 0);
- if (idx < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return idx;
- }
- pic = &s->picture[idx];
-
- pic->reference = 0;
- if (!s->droppable) {
- if (s->pict_type != AV_PICTURE_TYPE_B)
- pic->reference = 3;
- }
-
- if (alloc_picture(s, pic) < 0)
- return -1;
+ ret = alloc_picture(s, &s->current_picture_ptr,
+ s->pict_type != AV_PICTURE_TYPE_B && !s->droppable);
+ if (ret < 0)
+ return ret;
- s->current_picture_ptr = pic;
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first;
s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (!s->progressive_frame &&
!s->progressive_sequence);
--
2.40.1
_______________________________________________
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".
next prev parent reply other threads:[~2024-04-05 12:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 12:33 [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 02/15] avcodec/mpegutils: Move definitions to better places Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 03/15] avcodec/mpeg12: Remove always-false check Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 04/15] avcodec/mpegvideo_dec, mpeg12dec: Move MPEG1/2 code to mpeg12dec.c Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 05/15] avcodec/mpeg12dec: Remove redundant check Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 06/15] avcodec/mpeg12dec: Don't pretend MPEG-1/2 to support alpha Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 07/15] avcodec/mpegvideo_dec: Don't emit non-keyframe warning for H.261 Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 08/15] avcodec/mpeg12dec: Remove unnecessary FFCodec.close Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 09/15] avcodec/mpegvideo_dec: Remove obsolete current_picture_ptr reuse code Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 10/15] avcodec/mpegvideo_dec: Remove redundant code to reset keyframe flag Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 11/15] avcodec/mpegvideo_dec: Factor allocating dummy frame out Andreas Rheinhardt
2024-04-05 12:41 ` Andreas Rheinhardt [this message]
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 13/15] avcodec/mpegvideo: Remove pointless check Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 14/15] avcodec/mpeg12dec: Remove redundant mpeg_enc_ctx_allocated Andreas Rheinhardt
2024-04-05 12:41 ` [FFmpeg-devel] [PATCH 15/15] avcodec/mpegvideo_dec, h264_slice: Return proper error codes Andreas Rheinhardt
2024-04-07 22:34 ` [FFmpeg-devel] [PATCH 01/15] avcodec/mpegvideo_enc: Don't update current_picture unnecessarily Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=GV1P250MB07373AB3396DACA5AAC622058F032@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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