From patchwork Thu Jul 2 14:33:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 20776 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9025F44B851 for ; Thu, 2 Jul 2020 17:34:04 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7755268AA6E; Thu, 2 Jul 2020 17:34:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 993596808A9 for ; Thu, 2 Jul 2020 17:33:57 +0300 (EEST) Received: by mail-pf1-f193.google.com with SMTP id a14so8049282pfi.2 for ; Thu, 02 Jul 2020 07:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tBPaHCZQzw1x/xlbdyqt4RXGgic5bo2OXlANZeX/bTw=; b=Z/sew147nYKo523YXbXbLDhKFsUVnbThLGaQta//BCllyIk8QdzvA6HcOp3UbdgHgC n/yxy+bU8k8jm7WsKF5LCkcW1R7p45NUgXLv4IRFJNhnT9YhKdDk3aQDzyvnkrXog8x7 TuveQfWL1UU2+k34aqZ7rLP1TwZtLVtqzbirA4fXTA2xHNiv7Sz/X3Zw1JF7k2pMVgSA CEPsvSfADwjO5TBncXQfLiM21Pt0h1orBwwOD9x3paVmqk3uLKyO3TGRI4Z+ueEcQ7zS a4fI/oOjXp9fMj3LU7ttYkRg7etrYILT7ibXCAbkX/sOzT48FrxlLet9lafMoUqUlkC6 gw2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tBPaHCZQzw1x/xlbdyqt4RXGgic5bo2OXlANZeX/bTw=; b=kxx/uFD6X+DWYP5S5II7iVOpuYCNdJ71wYRQnZE+uxLlCN5B9RDWzZyTHFM8AovtQo vpmH52sDPUxPLcjTWUT7u6UyhofCAFv3j/K7j4+DQmEKp3acr9NCrpAE+09jOW2wnMTm rxm3gaHbVvDZt15x/b+85623pISbz7IJNHYr69z/6wfpDjJMJxSwuwcCS6ynVojoNTi0 7QxkaCyhh5O9yKRkWyBwxWkN0OLocKWVdAed2CmuDH8qAT/qR/rPkY9HMXPJMxVvmIZ+ L2FLCI6yxIBYHIMUI75fjaxCJo1TcRkNWVexifxn+mEv6NVL09bERd+joCIJlpTBNp17 z3Aw== X-Gm-Message-State: AOAM531OUnT5d1g3wOBUibhyd6SBVu+ZD0Vfh+I+SD+Qvde42V9tO8Fb Q8R97EzG/d8RdbE69Hd2jStAwheE X-Google-Smtp-Source: ABdhPJy+MeWKW1FZyPxMslgmZlSwPjPHxH+xdp5PverQ2dmidiFMeowfOVRe5u8sml4QLR1nz3AijA== X-Received: by 2002:a05:6a00:148c:: with SMTP id v12mr28485763pfu.171.1593700435508; Thu, 02 Jul 2020 07:33:55 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id t188sm9409114pfc.198.2020.07.02.07.33.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2020 07:33:55 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Jul 2020 22:33:25 +0800 Message-Id: <1593700407-32390-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593700407-32390-1-git-send-email-lance.lmwang@gmail.com> References: <1593700407-32390-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/h264_slice: replace cur->f with out for better readability X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/h264_slice.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 2a41de2..725390e 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1125,9 +1125,10 @@ static int h264_export_frame_props(H264Context *h) { const SPS *sps = h->ps.sps; H264Picture *cur = h->cur_pic_ptr; + AVFrame *out = cur->f; - cur->f->interlaced_frame = 0; - cur->f->repeat_pict = 0; + out->interlaced_frame = 0; + out->repeat_pict = 0; /* Signal interlacing information externally. */ /* Prioritize picture timing SEI information over used @@ -1150,59 +1151,59 @@ static int h264_export_frame_props(H264Context *h) break; case H264_SEI_PIC_STRUCT_TOP_FIELD: case H264_SEI_PIC_STRUCT_BOTTOM_FIELD: - cur->f->interlaced_frame = 1; + out->interlaced_frame = 1; break; case H264_SEI_PIC_STRUCT_TOP_BOTTOM: case H264_SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE(h)) - cur->f->interlaced_frame = 1; + out->interlaced_frame = 1; else // try to flag soft telecine progressive - cur->f->interlaced_frame = h->prev_interlaced_frame; + out->interlaced_frame = h->prev_interlaced_frame; break; case H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: /* Signal the possibility of telecined film externally * (pic_struct 5,6). From these hints, let the applications * decide if they apply deinterlacing. */ - cur->f->repeat_pict = 1; + out->repeat_pict = 1; break; case H264_SEI_PIC_STRUCT_FRAME_DOUBLING: - cur->f->repeat_pict = 2; + out->repeat_pict = 2; break; case H264_SEI_PIC_STRUCT_FRAME_TRIPLING: - cur->f->repeat_pict = 4; + out->repeat_pict = 4; break; } if ((pt->ct_type & 3) && pt->pic_struct <= H264_SEI_PIC_STRUCT_BOTTOM_TOP) - cur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; + out->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; } else { /* Derive interlacing flag from used decoding process. */ - cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); + out->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); } - h->prev_interlaced_frame = cur->f->interlaced_frame; + h->prev_interlaced_frame = out->interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]) { /* Derive top_field_first from field pocs. */ - cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; + out->top_field_first = cur->field_poc[0] < cur->field_poc[1]; } else { if (sps->pic_struct_present_flag && h->sei.picture_timing.present) { /* Use picture timing SEI information. Even if it is a * information of a past frame, better than nothing. */ if (h->sei.picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM || h->sei.picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP) - cur->f->top_field_first = 1; + out->top_field_first = 1; else - cur->f->top_field_first = 0; - } else if (cur->f->interlaced_frame) { + out->top_field_first = 0; + } else if (out->interlaced_frame) { /* Default to top field first when pic_struct_present_flag * is not set but interlaced frame detected */ - cur->f->top_field_first = 1; + out->top_field_first = 1; } else { /* Most likely progressive */ - cur->f->top_field_first = 0; + out->top_field_first = 0; } } @@ -1211,7 +1212,7 @@ static int h264_export_frame_props(H264Context *h) h->sei.frame_packing.content_interpretation_type > 0 && h->sei.frame_packing.content_interpretation_type < 3) { H264SEIFramePacking *fp = &h->sei.frame_packing; - AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f); + AVStereo3D *stereo = av_stereo3d_create_side_data(out); if (stereo) { switch (fp->arrangement_type) { case H264_SEI_FPA_TYPE_CHECKERBOARD: @@ -1258,7 +1259,7 @@ static int h264_export_frame_props(H264Context *h) h->sei.display_orientation.vflip)) { H264SEIDisplayOrientation *o = &h->sei.display_orientation; double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); - AVFrameSideData *rotation = av_frame_new_side_data(cur->f, + AVFrameSideData *rotation = av_frame_new_side_data(out, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (rotation) { @@ -1269,7 +1270,7 @@ static int h264_export_frame_props(H264Context *h) } if (h->sei.afd.present) { - AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, + AVFrameSideData *sd = av_frame_new_side_data(out, AV_FRAME_DATA_AFD, sizeof(uint8_t)); if (sd) { @@ -1281,7 +1282,7 @@ static int h264_export_frame_props(H264Context *h) if (h->sei.a53_caption.buf_ref) { H264SEIA53Caption *a53 = &h->sei.a53_caption; - AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f, AV_FRAME_DATA_A53_CC, a53->buf_ref); + AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref); if (!sd) av_buffer_unref(&a53->buf_ref); a53->buf_ref = NULL; @@ -1293,7 +1294,7 @@ static int h264_export_frame_props(H264Context *h) H264SEIUnregistered *unreg = &h->sei.unregistered; if (unreg->buf_ref[i]) { - AVFrameSideData *sd = av_frame_new_side_data_from_buf(cur->f, + AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_SEI_UNREGISTERED, unreg->buf_ref[i]); if (!sd) @@ -1306,7 +1307,7 @@ static int h264_export_frame_props(H264Context *h) if (h->sei.picture_timing.timecode_cnt > 0) { uint32_t *tc_sd; - AVFrameSideData *tcside = av_frame_new_side_data(cur->f, + AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE, sizeof(uint32_t)*4); if (!tcside)