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/30] lavc/libx264: factor out setting up the input frame
@ 2022-11-27 17:03 Anton Khirnov
  2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 02/30] lavc/libx264: reindent after previous commit Anton Khirnov
                   ` (28 more replies)
  0 siblings, 29 replies; 37+ messages in thread
From: Anton Khirnov @ 2022-11-27 17:03 UTC (permalink / raw)
  To: ffmpeg-devel

X264_frame() is currently too large and complex.
---
 libavcodec/libx264.c | 45 +++++++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index ca0b5a145b..009cad4bdf 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -333,19 +333,20 @@ static enum AVPixelFormat csp_to_pixfmt(int csp)
     return AV_PIX_FMT_NONE;
 }
 
-static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
-                      int *got_packet)
+static int setup_frame(AVCodecContext *ctx, const AVFrame *frame,
+                       x264_picture_t **ppic)
 {
     X264Context *x4 = ctx->priv_data;
-    x264_nal_t *nal;
-    int nnal, i, ret;
-    x264_picture_t pic_out = {0};
-    int pict_type;
-    int bit_depth;
+    x264_sei_t *sei = &x4->pic.extra_sei;
+    unsigned int sei_data_size = 0;
     int64_t wallclock = 0;
-    X264Opaque *out_opaque;
+    int bit_depth, ret;
     AVFrameSideData *sd;
 
+    *ppic = NULL;
+    if (!frame)
+        return 0;
+
     x264_picture_init( &x4->pic );
     x4->pic.img.i_csp   = x4->params.i_csp;
 #if X264_BUILD >= 153
@@ -357,11 +358,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
         x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
     x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
 
-    if (frame) {
-        x264_sei_t *sei = &x4->pic.extra_sei;
-        unsigned int sei_data_size = 0;
-
-        for (i = 0; i < x4->pic.img.i_plane; i++) {
+        for (int i = 0; i < x4->pic.img.i_plane; i++) {
             x4->pic.img.plane[i]    = frame->data[i];
             x4->pic.img.i_stride[i] = frame->linesize[i];
         }
@@ -512,10 +509,28 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
                 sei->num_payloads++;
             }
         }
-    }
+
+    *ppic = &x4->pic;
+    return 0;
+}
+
+static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
+                      int *got_packet)
+{
+    X264Context *x4 = ctx->priv_data;
+    x264_nal_t *nal;
+    int nnal, ret;
+    x264_picture_t pic_out = {0}, *pic_in;
+    int pict_type;
+    int64_t wallclock = 0;
+    X264Opaque *out_opaque;
+
+    ret = setup_frame(ctx, frame, &pic_in);
+    if (ret < 0)
+        return ret;
 
     do {
-        if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
+        if (x264_encoder_encode(x4->enc, &nal, &nnal, pic_in, &pic_out) < 0)
             return AVERROR_EXTERNAL;
 
         if (nnal && (ctx->flags & AV_CODEC_FLAG_RECON_FRAME)) {
-- 
2.35.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] 37+ messages in thread

end of thread, other threads:[~2023-01-04 17:26 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-27 17:03 [FFmpeg-devel] [PATCH 01/30] lavc/libx264: factor out setting up the input frame Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 02/30] lavc/libx264: reindent after previous commit Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 03/30] lavc/libx264: use a local variable for input frame in setup_frame() Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 04/30] lavc/libx264: factor out setting up ROI Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 05/30] lavc/libx264: reindent after previous commit Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 06/30] lavc/libx264: unify cleanup in setup_frame() Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 07/30] lavc/libx264: do not ignore memory allocation errors Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 08/30] lavc/libx264: reindent after previous commit Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 09/30] lavc/libx264: reorder control flow in setup_roi() to reduce nesting depth Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 10/30] lavc/libx264: reindent after previous commit Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 11/30] lavc/libx264: use a local variable to shorten code Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 12/30] lavc/libx264: print an error on invalid opaque pointer Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 13/30] lavc/libx264: zero reordered opaque on alloc Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 14/30] lavc/libx264: do not leave an invalid array size on alloc error Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 15/30] lavc/libx265: restructure handling reordered_opaque Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 16/30] lavc: add a codec flag for propagating opaque from frames to packets Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 17/30] lavc: support AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE in all no-delay encoders Anton Khirnov
2022-11-27 17:43   ` Michael Niedermayer
2022-11-27 19:43     ` Anton Khirnov
2022-11-27 20:00   ` James Almer
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 18/30] lavc/encode: pass through frame durations to encoded packets Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 19/30] lavc/librav1e: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 20/30] lavc/nvenc: " Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 21/30] lavc/adxenc: rescale packet duration according to timebase Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 22/30] lavc/adxenc: support AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE Anton Khirnov
2023-01-04 16:26   ` Andreas Rheinhardt
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 23/30] lavc/ffv1enc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE Anton Khirnov
2023-01-04 17:27   ` Andreas Rheinhardt
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 24/30] lavc/pngenc: " Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 25/30] lavc/pngenc: stop setting dts unnecessarily for APNG Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 26/30] lavc/libtheoraenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 27/30] lavc/libtheoraenc: stop setting dts unnecessarily Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 28/30] lavc/libx264: pass through frame durations to encoded packets Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 29/30] lavc/libx265: " Anton Khirnov
2022-11-27 17:03 ` [FFmpeg-devel] [PATCH 30/30] lavc/libaomenc: " Anton Khirnov
2022-11-27 20:19   ` James Almer
2023-01-04 16:15     ` Anton Khirnov

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