From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B3ECC453D2 for ; Mon, 29 May 2023 12:31:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F0A568C1A1; Mon, 29 May 2023 15:31:22 +0300 (EEST) Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4C42968BE0F for ; Mon, 29 May 2023 15:31:14 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1685363465; bh=4WOWvkyBmacWvaNCSgrfvr9/NdfL/OuiyDcVSaE35cY=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=ADNqThuOrxEPj9QZO1/b4B8SNewBF2Cr2n2A9KDRqf56iriF0kRqjlMqLM8yuKpzc ThnWnBDYwByayZPG5VTaW/qODbXZRdZ2vqNZH3jY8cSFWUD4Fvm/6eH+WfkumSCQSe 9UPmNd8sP+Ohw65I7w7I4Qw0ktIwIyUp7U06jLTQ= Received: from smtpclient.apple ([119.147.10.188]) by newxmesmtplogicsvrszc2-0.qq.com (NewEsmtp) with SMTP id 7C42C608; Mon, 29 May 2023 20:31:04 +0800 X-QQ-mid: xmsmtpt1685363464ty0pqbdfg Message-ID: X-QQ-XMAILINFO: N7h1OCCDntujMIyX70PXON4dUKMGE6/x3iIRPNEhVyF2bY1S7L7dgPPVYaPBfy p5zUxWi5sNxvSGmDTfx81tiQvT3qz0sMIyHPgx/uOr7Lhr27LULJQke94yGf5BkuI/VlOYlvkeGe zYzaIlSNAUrnaM8TaXWxFJNY/9kYXORODjwbafM3+o7++ICc7eSMd4ie/GYlM0WjAaR1Ql8tjTle Z1yHCbzg0MCGVgClQLw1r1paPKuBOVZ/82MXfdyUAdfV7B3hd6obYhcC/zv4kVgp/aO8wbpPAl4h eaotYSnF5T+r70iZ3IFi1O3wpDe5QcS06+Y8VcF4NlGqend2o15xtIRmyBTsBYabQZNvVtepR6nM 0unodYKJ40sy//lR5FZBAJ/3TMh6frD1TK8YXzfcH17giq1/nQoYqvRL3u8mmhFuCTPTiOH6VjXW w0DhavERUaz5WJxngK2MqMtwhc4ZgsGNhl4HEgCFUUhgify7ZNOWqhpQmeTSd7K2W+rMmuOnDQw1 j7pWcRHn5Yn0F9op4lwzvekocGWuF9cpwKf+4fwd980H2Iy7QPwVT74lZ7cnnm9QBqSoaUh6ze7p dO5CqX0lRque6jdv6KqWpbOvo6Ss/9W2ZG5yWN/2wZF+Eyp45Vivb8nQxmoyl89D5C4KfYZor+3r O4Ys9g76lDp8XFp/e5Nm4zt9kbWulViKJY7/Axch0tK11jFbC8aN3cmdhip71Y52wor2wHDgZls2 ZMeXJb5qS38qFJsmVcEi/oe7U3OoIlF2VM+BVvf/E1M7CRXVnBWq+NKXVffGekvvyfFpeCxclcjI lV9ZQNiU6xUVO9M9pbTcaKCVvkrQLD9XI+lQ1/HWQEUEGlHXhBrfB1uZWL9U+74HIL9BRbvQfUBf cGthSwZZGjs+phK0/UIjkWYhrqr1bTEUdv/B+ih6QKQv2NBspyVJrACr6WMvSj54BRmbBGefa5BV 7i6Uc2af7kIxG/p9KhDp9zVAjv7EOKg/oUlIyVTD6TqOfJz8RUqqd46rm9BEziOQrDCVbM7qMz3K s9+6euOw== Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) From: =?utf-8?B?InpoaWxpemhhbyjotbXlv5fnq4spIg==?= In-Reply-To: Date: Mon, 29 May 2023 20:31:04 +0800 X-OQ-MSGID: <528C33D7-AC71-4C15-8E32-23A83378991D@foxmail.com> References: To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3696.120.41.1.1) Subject: Re: [FFmpeg-devel] [PATCH 1/5] avcodec/h264_mp4toannexb_bsf: refactor start_code_size handling 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 Cc: Andreas Rheinhardt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Ping for the patchset. > On May 20, 2023, at 00:41, Zhao Zhili wrote: > > From: Zhao Zhili > > start_code_size depends on whether PS comes from out-of-band or > in-band. Make the code more readable. > --- > libavcodec/h264_mp4toannexb_bsf.c | 34 ++++++++++++++++++++++++------- > 1 file changed, 27 insertions(+), 7 deletions(-) > > diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c > index d11be455c2..7dce1ae9b6 100644 > --- a/libavcodec/h264_mp4toannexb_bsf.c > +++ b/libavcodec/h264_mp4toannexb_bsf.c > @@ -43,10 +43,26 @@ typedef struct H264BSFContext { > int extradata_parsed; > } H264BSFContext; > > +enum PsSource { > + PS_OUT_OF_BAND = -1, > + PS_NONE = 0, > + PS_IN_BAND = 1, > +}; > + > static void count_or_copy(uint8_t **out, uint64_t *out_size, > - const uint8_t *in, int in_size, int ps, int copy) > + const uint8_t *in, int in_size, enum PsSource ps, int copy) > { > - uint8_t start_code_size = ps < 0 ? 0 : *out_size == 0 || ps ? 4 : 3; > + uint8_t start_code_size; > + > + if (ps == PS_OUT_OF_BAND) > + /* start code already present in out-of-band ps data, so don't need to > + * add it manually again > + */ > + start_code_size = 0; > + else if (ps == PS_IN_BAND || *out_size == 0) > + start_code_size = 4; > + else > + start_code_size = 3; > > if (copy) { > memcpy(*out + start_code_size, in, in_size); > @@ -202,6 +218,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *opkt) > > do { > uint32_t nal_size = 0; > + enum PsSource ps; > > /* possible overread ok due to padding */ > for (int i = 0; i < s->length_size; i++) > @@ -230,7 +247,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *opkt) > if (!s->sps_size) { > LOG_ONCE(ctx, AV_LOG_WARNING, "SPS not present in the stream, nor in AVCC, stream may be unreadable\n"); > } else { > - count_or_copy(&out, &out_size, s->sps, s->sps_size, -1, j); > + count_or_copy(&out, &out_size, s->sps, s->sps_size, PS_OUT_OF_BAND, j); > sps_seen = 1; > } > } > @@ -246,19 +263,22 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *opkt) > if (new_idr && unit_type == H264_NAL_IDR_SLICE && !sps_seen && !pps_seen) { > if (ctx->par_out->extradata) > count_or_copy(&out, &out_size, ctx->par_out->extradata, > - ctx->par_out->extradata_size, -1, j); > + ctx->par_out->extradata_size, PS_OUT_OF_BAND, j); > new_idr = 0; > /* if only SPS has been seen, also insert PPS */ > } else if (new_idr && unit_type == H264_NAL_IDR_SLICE && sps_seen && !pps_seen) { > if (!s->pps_size) { > LOG_ONCE(ctx, AV_LOG_WARNING, "PPS not present in the stream, nor in AVCC, stream may be unreadable\n"); > } else { > - count_or_copy(&out, &out_size, s->pps, s->pps_size, -1, j); > + count_or_copy(&out, &out_size, s->pps, s->pps_size, PS_OUT_OF_BAND, j); > } > } > > - count_or_copy(&out, &out_size, buf, nal_size, > - unit_type == H264_NAL_SPS || unit_type == H264_NAL_PPS, j); > + if (unit_type == H264_NAL_SPS || unit_type == H264_NAL_PPS) > + ps = PS_IN_BAND; > + else > + ps = PS_NONE; > + count_or_copy(&out, &out_size, buf, nal_size, ps, j); > if (!new_idr && unit_type == H264_NAL_SLICE) { > new_idr = 1; > sps_seen = 0; > -- > 2.25.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". _______________________________________________ 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".