From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 02/30] lavc/libx264: reindent after previous commit
Date: Sun, 27 Nov 2022 18:03:23 +0100
Message-ID: <20221127170351.11477-2-anton@khirnov.net> (raw)
In-Reply-To: <20221127170351.11477-1-anton@khirnov.net>
---
libavcodec/libx264.c | 260 +++++++++++++++++++++----------------------
1 file changed, 130 insertions(+), 130 deletions(-)
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 009cad4bdf..36c36d0e09 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -358,157 +358,157 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame,
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
- 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];
- }
-
- x4->pic.i_pts = frame->pts;
-
- x4->reordered_opaque[x4->next_reordered_opaque].reordered_opaque = frame->reordered_opaque;
- x4->reordered_opaque[x4->next_reordered_opaque].wallclock = wallclock;
- if (ctx->export_side_data & AV_CODEC_EXPORT_DATA_PRFT)
- x4->reordered_opaque[x4->next_reordered_opaque].wallclock = av_gettime();
- x4->pic.opaque = &x4->reordered_opaque[x4->next_reordered_opaque];
- x4->next_reordered_opaque++;
- x4->next_reordered_opaque %= x4->nb_reordered_opaque;
+ 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];
+ }
- switch (frame->pict_type) {
- case AV_PICTURE_TYPE_I:
- x4->pic.i_type = x4->forced_idr > 0 ? X264_TYPE_IDR
- : X264_TYPE_KEYFRAME;
- break;
- case AV_PICTURE_TYPE_P:
- x4->pic.i_type = X264_TYPE_P;
- break;
- case AV_PICTURE_TYPE_B:
- x4->pic.i_type = X264_TYPE_B;
- break;
- default:
- x4->pic.i_type = X264_TYPE_AUTO;
- break;
- }
- reconfig_encoder(ctx, frame);
+ x4->pic.i_pts = frame->pts;
- if (x4->a53_cc) {
- void *sei_data;
- size_t sei_size;
+ x4->reordered_opaque[x4->next_reordered_opaque].reordered_opaque = frame->reordered_opaque;
+ x4->reordered_opaque[x4->next_reordered_opaque].wallclock = wallclock;
+ if (ctx->export_side_data & AV_CODEC_EXPORT_DATA_PRFT)
+ x4->reordered_opaque[x4->next_reordered_opaque].wallclock = av_gettime();
+ x4->pic.opaque = &x4->reordered_opaque[x4->next_reordered_opaque];
+ x4->next_reordered_opaque++;
+ x4->next_reordered_opaque %= x4->nb_reordered_opaque;
- ret = ff_alloc_a53_sei(frame, 0, &sei_data, &sei_size);
- if (ret < 0) {
+ switch (frame->pict_type) {
+ case AV_PICTURE_TYPE_I:
+ x4->pic.i_type = x4->forced_idr > 0 ? X264_TYPE_IDR
+ : X264_TYPE_KEYFRAME;
+ break;
+ case AV_PICTURE_TYPE_P:
+ x4->pic.i_type = X264_TYPE_P;
+ break;
+ case AV_PICTURE_TYPE_B:
+ x4->pic.i_type = X264_TYPE_B;
+ break;
+ default:
+ x4->pic.i_type = X264_TYPE_AUTO;
+ break;
+ }
+ reconfig_encoder(ctx, frame);
+
+ if (x4->a53_cc) {
+ void *sei_data;
+ size_t sei_size;
+
+ ret = ff_alloc_a53_sei(frame, 0, &sei_data, &sei_size);
+ if (ret < 0) {
+ av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n");
+ } else if (sei_data) {
+ x4->pic.extra_sei.payloads = av_mallocz(sizeof(x4->pic.extra_sei.payloads[0]));
+ if (x4->pic.extra_sei.payloads == NULL) {
av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n");
- } else if (sei_data) {
- x4->pic.extra_sei.payloads = av_mallocz(sizeof(x4->pic.extra_sei.payloads[0]));
- if (x4->pic.extra_sei.payloads == NULL) {
- av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n");
- av_free(sei_data);
- } else {
- x4->pic.extra_sei.sei_free = av_free;
-
- x4->pic.extra_sei.payloads[0].payload_size = sei_size;
- x4->pic.extra_sei.payloads[0].payload = sei_data;
- x4->pic.extra_sei.num_payloads = 1;
- x4->pic.extra_sei.payloads[0].payload_type = 4;
- }
+ av_free(sei_data);
+ } else {
+ x4->pic.extra_sei.sei_free = av_free;
+
+ x4->pic.extra_sei.payloads[0].payload_size = sei_size;
+ x4->pic.extra_sei.payloads[0].payload = sei_data;
+ x4->pic.extra_sei.num_payloads = 1;
+ x4->pic.extra_sei.payloads[0].payload_type = 4;
}
}
+ }
- sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST);
- if (sd) {
- if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {
- if (!x4->roi_warned) {
- x4->roi_warned = 1;
- av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
+ sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST);
+ if (sd) {
+ if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {
+ if (!x4->roi_warned) {
+ x4->roi_warned = 1;
+ av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
+ }
+ } else {
+ if (frame->interlaced_frame == 0) {
+ int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;
+ int mby = (frame->height + MB_SIZE - 1) / MB_SIZE;
+ int qp_range = 51 + 6 * (bit_depth - 8);
+ int nb_rois;
+ const AVRegionOfInterest *roi;
+ uint32_t roi_size;
+ float *qoffsets;
+
+ roi = (const AVRegionOfInterest*)sd->data;
+ roi_size = roi->self_size;
+ if (!roi_size || sd->size % roi_size != 0) {
+ free_picture(ctx);
+ av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n");
+ return AVERROR(EINVAL);
}
- } else {
- if (frame->interlaced_frame == 0) {
- int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;
- int mby = (frame->height + MB_SIZE - 1) / MB_SIZE;
- int qp_range = 51 + 6 * (bit_depth - 8);
- int nb_rois;
- const AVRegionOfInterest *roi;
- uint32_t roi_size;
- float *qoffsets;
-
- roi = (const AVRegionOfInterest*)sd->data;
- roi_size = roi->self_size;
- if (!roi_size || sd->size % roi_size != 0) {
- free_picture(ctx);
- av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n");
- return AVERROR(EINVAL);
- }
- nb_rois = sd->size / roi_size;
+ nb_rois = sd->size / roi_size;
+
+ qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets));
+ if (!qoffsets) {
+ free_picture(ctx);
+ return AVERROR(ENOMEM);
+ }
+ // This list must be iterated in reverse because the first
+ // region in the list applies when regions overlap.
+ for (int i = nb_rois - 1; i >= 0; i--) {
+ int startx, endx, starty, endy;
+ float qoffset;
- qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets));
- if (!qoffsets) {
+ roi = (const AVRegionOfInterest*)(sd->data + roi_size * i);
+
+ starty = FFMIN(mby, roi->top / MB_SIZE);
+ endy = FFMIN(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE);
+ startx = FFMIN(mbx, roi->left / MB_SIZE);
+ endx = FFMIN(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE);
+
+ if (roi->qoffset.den == 0) {
+ av_free(qoffsets);
free_picture(ctx);
- return AVERROR(ENOMEM);
+ av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must not be zero.\n");
+ return AVERROR(EINVAL);
}
- // This list must be iterated in reverse because the first
- // region in the list applies when regions overlap.
- for (int i = nb_rois - 1; i >= 0; i--) {
- int startx, endx, starty, endy;
- float qoffset;
-
- roi = (const AVRegionOfInterest*)(sd->data + roi_size * i);
-
- starty = FFMIN(mby, roi->top / MB_SIZE);
- endy = FFMIN(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE);
- startx = FFMIN(mbx, roi->left / MB_SIZE);
- endx = FFMIN(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE);
-
- if (roi->qoffset.den == 0) {
- av_free(qoffsets);
- free_picture(ctx);
- av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must not be zero.\n");
- return AVERROR(EINVAL);
- }
- qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den;
- qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range);
+ qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den;
+ qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range);
- for (int y = starty; y < endy; y++) {
- for (int x = startx; x < endx; x++) {
- qoffsets[x + y*mbx] = qoffset;
- }
+ for (int y = starty; y < endy; y++) {
+ for (int x = startx; x < endx; x++) {
+ qoffsets[x + y*mbx] = qoffset;
}
}
+ }
- x4->pic.prop.quant_offsets = qoffsets;
- x4->pic.prop.quant_offsets_free = av_free;
- } else {
- if (!x4->roi_warned) {
- x4->roi_warned = 1;
- av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
- }
+ x4->pic.prop.quant_offsets = qoffsets;
+ x4->pic.prop.quant_offsets_free = av_free;
+ } else {
+ if (!x4->roi_warned) {
+ x4->roi_warned = 1;
+ av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
}
}
}
+ }
- if (x4->udu_sei) {
- for (int j = 0; j < frame->nb_side_data; j++) {
- AVFrameSideData *side_data = frame->side_data[j];
- void *tmp;
- x264_sei_payload_t *sei_payload;
- if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED)
- continue;
- tmp = av_fast_realloc(sei->payloads, &sei_data_size, (sei->num_payloads + 1) * sizeof(*sei_payload));
- if (!tmp) {
- free_picture(ctx);
- return AVERROR(ENOMEM);
- }
- sei->payloads = tmp;
- sei->sei_free = av_free;
- sei_payload = &sei->payloads[sei->num_payloads];
- sei_payload->payload = av_memdup(side_data->data, side_data->size);
- if (!sei_payload->payload) {
- free_picture(ctx);
- return AVERROR(ENOMEM);
- }
- sei_payload->payload_size = side_data->size;
- sei_payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED;
- sei->num_payloads++;
+ if (x4->udu_sei) {
+ for (int j = 0; j < frame->nb_side_data; j++) {
+ AVFrameSideData *side_data = frame->side_data[j];
+ void *tmp;
+ x264_sei_payload_t *sei_payload;
+ if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED)
+ continue;
+ tmp = av_fast_realloc(sei->payloads, &sei_data_size, (sei->num_payloads + 1) * sizeof(*sei_payload));
+ if (!tmp) {
+ free_picture(ctx);
+ return AVERROR(ENOMEM);
+ }
+ sei->payloads = tmp;
+ sei->sei_free = av_free;
+ sei_payload = &sei->payloads[sei->num_payloads];
+ sei_payload->payload = av_memdup(side_data->data, side_data->size);
+ if (!sei_payload->payload) {
+ free_picture(ctx);
+ return AVERROR(ENOMEM);
}
+ sei_payload->payload_size = side_data->size;
+ sei_payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED;
+ sei->num_payloads++;
}
+ }
*ppic = &x4->pic;
return 0;
--
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".
next prev parent reply other threads:[~2022-11-27 17:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Anton Khirnov [this message]
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
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=20221127170351.11477-2-anton@khirnov.net \
--to=anton@khirnov.net \
--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