From patchwork Sun Nov 27 17:03:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39494 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6959259pzb; Sun, 27 Nov 2022 09:06:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5YgyqzfXExaKl0fvwRKtIvk77Bz6XU+ItS7IfyzXbztYnpMNveLRplvpw2cDkiRkGwYObL X-Received: by 2002:a05:6402:528f:b0:461:9cbd:8fba with SMTP id en15-20020a056402528f00b004619cbd8fbamr20655747edb.19.1669568783373; Sun, 27 Nov 2022 09:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669568783; cv=none; d=google.com; s=arc-20160816; b=GU84W/pKHsKp3BNiFso26qqKcj9bOt9mVfCvSK4diACEckAJ53eS1jShJXTH2OB1O8 1z/vhTltilnys2jA+otPRKF6vxBUcYathO9dq8zfalONa0hKMATF6JO+orYOoQQC6z3x x+U0MLV+Ahc9yjjJcuFZdszOF0RlmF4OLGBx5KhZo3CO5UdiRkzKZYKTZK7svq38hhGN pQDNFfKlf0G2/YYGeJiJ9R0nHaLP+Ep1JYX9TGuv+vKmipATC8b+mKlrTHM3A0/f79yf W+YZ8HI2o/iBtCK8CqJNQIVNTL+j1vyF8hFz0mj1IoELDhxakrVM0V5ty2HyGAiHMs5i 98uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=Q9rrOpR9pjhiTaOBC18aCqjvG11Cwo1xUVErkmUW0vg=; b=PfTDkwDlgHkU2qRRnZWew4nYT0HOiY5vvopf1T1N6xGAc2GjOJ16n31ypEBry+PGsi GA5RJAk0jqhh7rxaBfmH8vrdgTZvuZYePjg/GEvsMx8m6afMAr0u/WT1ZTQ+HTGbhaXr TmX+G8tiD0TX2JI3ph/vDXv5kUFupRkVTtDTGjTnNJ6awtw5LIgpGgMeuB9RJ/aqzQrD VTbJJkbnamb5d23qnvLkBJ0xTh710eSNdsNJkGH5DkVlVheHsu0MkFYu0R++u419alxk EdnxVEBiSCRgpuQ18MQWeEJVuY5Q8F9c5LACydSAEN98vFtqB4Cu3TY3RAMm6lscIwSi b8+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eq10-20020a056402298a00b00469e712cba8si8153915edb.558.2022.11.27.09.06.23; Sun, 27 Nov 2022 09:06:23 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4A3F168B8F3; Sun, 27 Nov 2022 19:06:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9160D6808AB for ; Sun, 27 Nov 2022 19:05:53 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 57215240D27 for ; Sun, 27 Nov 2022 18:05:53 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id AV_zyI-WTDBK for ; Sun, 27 Nov 2022 18:05:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 60201240499 for ; Sun, 27 Nov 2022 18:05:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D36DE3A1943 for ; Sun, 27 Nov 2022 18:05:45 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2022 18:03:23 +0100 Message-Id: <20221127170351.11477-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221127170351.11477-1-anton@khirnov.net> References: <20221127170351.11477-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/30] lavc/libx264: reindent after previous commit X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gh53FwASAlCQ --- 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;