Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/14] avcodec/get_buffer: Remove redundant check
@ 2024-04-29  0:28 Andreas Rheinhardt
  2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 02/14] avcodec/mpegpicture: Store linesize in ScratchpadContext Andreas Rheinhardt
                   ` (55 more replies)
  0 siblings, 56 replies; 64+ messages in thread
From: Andreas Rheinhardt @ 2024-04-29  0:28 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It is unnecessary to check for whether the number of planes
of an already existing audio pool coincides with the number
of planes to use for the frame: If the common format of both
is planar, then the number of planes coincides with the number
of channels for which there is already a check*; if not,
then both the existing pool as well as the frame use one pool.

*: In fact, one could reuse the pool in this case even if the
number of channels changes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/get_buffer.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/libavcodec/get_buffer.c b/libavcodec/get_buffer.c
index 9b35fde7c6..ff19f61e86 100644
--- a/libavcodec/get_buffer.c
+++ b/libavcodec/get_buffer.c
@@ -65,20 +65,15 @@ static void frame_pool_free(FFRefStructOpaque unused, void *obj)
 static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
 {
     FramePool *pool = avctx->internal->pool;
-    int i, ret, ch, planes;
-
-    if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
-        int planar = av_sample_fmt_is_planar(frame->format);
-        ch     = frame->ch_layout.nb_channels;
-        planes = planar ? ch : 1;
-    }
+    int i, ret;
 
     if (pool && pool->format == frame->format) {
         if (avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
             pool->width == frame->width && pool->height == frame->height)
             return 0;
-        if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pool->planes == planes &&
-            pool->channels == ch && frame->nb_samples == pool->samples)
+        if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
+            pool->channels == frame->ch_layout.nb_channels &&
+            frame->nb_samples == pool->samples)
             return 0;
     }
 
@@ -141,7 +136,8 @@ static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
         break;
         }
     case AVMEDIA_TYPE_AUDIO: {
-        ret = av_samples_get_buffer_size(&pool->linesize[0], ch,
+        ret = av_samples_get_buffer_size(&pool->linesize[0],
+                                         frame->ch_layout.nb_channels,
                                          frame->nb_samples, frame->format, 0);
         if (ret < 0)
             goto fail;
@@ -153,9 +149,9 @@ static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
         }
 
         pool->format     = frame->format;
-        pool->planes     = planes;
-        pool->channels   = ch;
+        pool->channels   = frame->ch_layout.nb_channels;
         pool->samples = frame->nb_samples;
+        pool->planes     = av_sample_fmt_is_planar(pool->format) ? pool->channels : 1;
         break;
         }
     default: av_assert0(0);
-- 
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".

^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2024-04-30 21:07 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-29  0:28 [FFmpeg-devel] [PATCH 01/14] avcodec/get_buffer: Remove redundant check Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 02/14] avcodec/mpegpicture: Store linesize in ScratchpadContext Andreas Rheinhardt
2024-04-29 15:09   ` [FFmpeg-devel] [PATCH v2 2/14] " Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 03/14] avcodec/mpegvideo_dec: Sync linesize and uvlinesize between threads Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 04/14] avcodec/mpegvideo_dec: Factor allocating dummy frames out Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 05/14] avcodec/mpegpicture: Mark dummy frames as such Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 06/14] avcodec/mpeg12dec: Allocate dummy frames for non-I fields Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 07/14] avcodec/mpegvideo_motion: Remove dead checks for existence of reference Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 08/14] avcodec/mpegvideo_motion: Optimize check away Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 09/14] " Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 10/14] avcodec/mpegvideo_motion: Avoid constant function argument Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 11/14] avcodec/msmpeg4enc: Only calculate coded_cbp when used Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 12/14] avcodec/mpegvideo: Only allocate coded_block when needed Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 13/14] avcodec/mpegvideo: Don't reset coded_block unnecessarily Andreas Rheinhardt
2024-04-29  0:35 ` [FFmpeg-devel] [PATCH 14/14] avcodec/mpegvideo: Only allocate cbp_table, pred_dir_table when needed Andreas Rheinhardt
2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 15/57] avcodec/mpegpicture: Always reset motion val buffer Andreas Rheinhardt
2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 16/57] avcodec/mpegvideo: Redo aligning mb_height for VC-1 Andreas Rheinhardt
2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 17/57] avcodec/mpegvideo, mpegpicture: Add buffer pool Andreas Rheinhardt
2024-04-30 20:40   ` Michael Niedermayer
2024-04-30 20:58     ` James Almer
2024-04-30 21:07       ` Andreas Rheinhardt
2024-04-30 21:06     ` Andreas Rheinhardt
2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 18/57] avcodec/mpegpicture: Reindent after the previous commit Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 19/57] avcodec/mpegpicture: Use RefStruct-pool API Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 20/57] avcodec/mpegvideo: Shorten variable names Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 21/57] avcodec/mpegpicture: Reduce value of MAX_PLANES define Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 22/57] avcodec/mpegpicture: Cache AVFrame.data and linesize values Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 23/57] avcodec/rv30, rv34, rv40: Avoid indirection Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 24/57] avcodec/mpegvideo: Add const where appropriate Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 25/57] avcodec/vc1_pred: Remove unused function parameter Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 26/57] avcodec/mpegpicture: Improve error messages and code Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 27/57] avcodec/mpegpicture: Split ff_alloc_picture() into check and alloc part Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 28/57] avcodec/mpegvideo_enc: Pass AVFrame*, not Picture* to alloc_picture() Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 29/57] avcodec/mpegvideo_enc: Move copying properties " Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 30/57] avcodec/mpegpicture: Rename Picture->MPVPicture Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 31/57] avcodec/mpegpicture: Split MPVPicture into WorkPicture and ordinary Pic Andreas Rheinhardt
2024-04-30 18:57   ` Michael Niedermayer
2024-04-30 19:07     ` Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 32/57] avcodec/error_resilience: Deduplicate cleanup code Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 33/57] avcodec/mpegvideo_enc: Factor setting length of B frame chain out Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 34/57] avcodec/mpegvideo_enc: Return early when getting length of B frame chain Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 35/57] avcodec/mpegvideo_enc: Reindentation Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 36/57] avcodec/mpeg12dec: Don't initialize inter tables for IPU Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 37/57] avcodec/mpeg12dec: Only initialize IDCT " Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 38/57] avcodec/mpeg12dec: Remove write-only assignment Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 39/57] avcodec/mpeg12dec: Set out_format only once Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 40/57] avformat/riff: Declare VCR2 to be MPEG-2 Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 41/57] avcodec/mpegvideo_dec: Add close function for mpegvideo-decoders Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 42/57] avcodec/mpegpicture: Make MPVPicture refcounted Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 43/57] avcodec/mpeg4videoenc: Avoid branch for writing stuffing Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 44/57] avcodec/mpeg4videoenc: Simplify writing startcodes Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 45/57] avcodec/mpegpicture: Use ThreadProgress instead of ThreadFrame API Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 46/57] avcodec/mpegpicture: Avoid loop and branch when setting motion_val Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 47/57] avcodec/mpegpicture: Use union for b_scratchpad and rd_scratchpad Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 48/57] avcodec/mpegpicture: Avoid MotionEstContext in ff_mpeg_framesize_alloc() Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 49/57] avcodec/mpegvideo_enc: Unify initializing PutBitContexts Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 50/57] avcodec/mpeg12enc: Simplify writing startcodes Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 51/57] avcodec/mpegvideo_dec: Simplify check for "does pic exist?" Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 52/57] avcodec/mpegvideo_dec: Don't sync encoder-only coded_picture_number Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 53/57] avcodec/mpeg12dec: Pass Mpeg1Context* in mpeg_field_start() Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 54/57] avcodec/mpeg12dec: Don't initialize inter_scantable Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 55/57] avcodec/mpegvideo: Remove pblocks Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 56/57] avcodec/mpegvideo: Use enum for msmpeg4_version Andreas Rheinhardt
2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 57/57] avcodec/ituh263enc: Remove redundant check 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