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 9558B45053 for ; Wed, 5 Apr 2023 08:59:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3990568BB30; Wed, 5 Apr 2023 11:59:57 +0300 (EEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D4BF68A9F0 for ; Wed, 5 Apr 2023 11:59:51 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230405085949euoutp01defdeb9ca8fcb2f29b47648143c56d5f~S-kaMtoyn2449924499euoutp01E for ; Wed, 5 Apr 2023 08:59:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230405085949euoutp01defdeb9ca8fcb2f29b47648143c56d5f~S-kaMtoyn2449924499euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1680685189; bh=3PS+8V3nZj2VrLQSMPd/nmcBKzBk7q/8+mB15Cw1o78=; h=From:To:In-Reply-To:Subject:Date:References:From; b=awNzxOkDVwBZNzXoWy/k1cRfZywtJiC5YYQ7pavYR3Q2dC9hdJB/x8LWnckNFRFjB /dDybaPRo4/MVALMQCd/e61z3NIJu/s2WvF+MxqwCiLcXNbodSnW34wxCv21XEibyQ IZLyO6K33U/38ivKUFbrA431bdf6RL26jj0rRWJU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230405085949eucas1p1b69bce3e69dcb41bab3be7e6f51b489b~S-kaFXwCJ0296202962eucas1p1s for ; Wed, 5 Apr 2023 08:59:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 94.EA.09966.5883D246; Wed, 5 Apr 2023 09:59:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230405085949eucas1p2738c14184075df72873e25785d5dad99~S-kZsAP9O0763907639eucas1p2h for ; Wed, 5 Apr 2023 08:59:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230405085949eusmtrp285ffec3cf5496c210c6acc96d40966c4~S-kZriyoJ2667926679eusmtrp2V for ; Wed, 5 Apr 2023 08:59:49 +0000 (GMT) X-AuditID: cbfec7f4-d39ff700000026ee-56-642d38856d30 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id EB.23.09583.5883D246; Wed, 5 Apr 2023 09:59:49 +0100 (BST) Received: from AMDN5164 (unknown [106.120.40.55]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230405085949eusmtip2c66854fd27d00bba01d222286322fe94~S-kZdqDGZ0520205202eusmtip2s for ; Wed, 5 Apr 2023 08:59:49 +0000 (GMT) From: "Dawid Kozinski/Multimedia \(PLT\) /SRPOL/Staff Engineer/Samsung Electronics" To: "'FFmpeg development discussions and patches'" In-Reply-To: Date: Wed, 5 Apr 2023 10:59:48 +0200 Message-ID: <000001d9679c$fa09ddd0$ee1d9970$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQGM5txV9OZ+/VXCV7ycEbMZ+vWQJgIswwOHAtEMFWavjX2lwA== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsWy7djPc7qtFropBu8m6lh8+3SG2YHR48+i zSwBjFFcNimpOZllqUX6dglcGYt/b2IquDmLqWLS2Y9sDYyLJzN1MXJySAiYSJz/+pati5GL Q0hgBaPE6+l7wRJCApOYJI58VYRITGSSuLluHhtMx89/nxkhipYzStx8VQ9R1MIk8XXfMXaQ BJtAnsTjz2uZQWwRAR+J7vXrWUFsTgFbiaezZoPZwkA1t+/+BxvKIqAicf7TKTCbV8BSYmf/ fihbUOLkzCcsIDazgJ7Es1OzoGxtiWULXzNDHKQg8fPpMlaIXU4STdu2M0LUiEjceNTCCFEz kUPi5S5/CNtF4uiZF6wQtrDEq+Nb2CFsGYn/O+cDfc8BZBdLHOp3gDBrJA79SIeosJZ423gc aqKjxJzPu1kgSvgkbrwVhFjKJzFp23RmiDCvREebEISpItHXKQbRKCXxdNkc5gmMSrOQfDgL yYezkHw4C8knCxhZVjGKp5YW56anFhvlpZbrFSfmFpfmpesl5+duYgQmh9P/jn/Zwbj81Ue9 Q4xMHIyHGCU4mJVEeFW7tFKEeFMSK6tSi/Lji0pzUosPMUpzsCiJ82rbnkwWEkhPLEnNTk0t SC2CyTJxcEo1MKVcCPlQL/K21l/conRWwv5jv6dkRO/4vZuFL/9bu8vFmEWbbZ/cTdqh43zK jZtHrmptp3xMzPymyQGTAx2mFK86effNyylRn1q3hj5oUReoPL6abcI79RvfDrVV6TTln1k6 Q/rhwWO2PJNzV5T9FRZmne7wx0eb8W/gx0Otm3df4RJ98fVXereaSa0V44Z5vbHOj7+6PLi9 S4RzvpaIy4nyZ4z/LWR3z/YVM/yhG/JEZuEBs4s+8uJnj05d2VPZIuLL5HbU7ruWX2VbET+j yvw9U+srd1+sF3OzuiT1rz7l4hmvIxkFgRcWJ4Qd3f6H12dx1OkJG+3mrdNPvl4mtrh058YA ftePMq1F/96kMSuxFGckGmoxFxUnAgAeT8lefQMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRmVeSWpSXmKPExsVy+t/xe7qtFropBi/+CFp8+3SG2YHR48+i zSwBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6 GXM+trAVLFvIWDH17GSmBsZfmV2MnBwSAiYSP/99ZgSxhQSWMkoc2JwAEZeSWLp0ESOELSzx 51oXWxcjF1BNE5PExdnvmUASbAI5EmtnTwSzRQR8JLrXr2eFKNrDKPH0YwcrSIJTwFbi6azZ QDYHhzBQw+7Z/iBhFgEVifOfTrGB2LwClhI7+/dD2YISJ2c+YQGxmQUMJJYs/MUEYWtLLFv4 mhniIAWJn0+XsULsdZJo2radEaJGROLGoxbGCYxCs5CMmoVk1Cwko2YhaVnAyLKKUSS1tDg3 PbfYSK84Mbe4NC9dLzk/dxMjMCa2Hfu5ZQfjylcf9Q4xMnEwHmKU4GBWEuFV7dJKEeJNSays Si3Kjy8qzUktPsRoCvTbRGYp0eR8YFTmlcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJpCeWpGan phakFsH0MXFwSjUwNX+SCliktI7ref3yKRtKDj5NcGFUDLp69E381+f/9b8mzcks/FoUEj2Z Ybl53Mvlm/e+/rbMRvxvamPAPqZVTxt/x/JW+XK++bTjWvO/hw+X6j2c4NPj9HNrcE1UYVe7 d7CohMRVrhQttdkdX0tf3ntr1v7hTYf4Pp337BPtPtR+kWXfN3H2QYfUuLmph3itv4YLha5q 3vGt73FI+cqUPPfP05RVrTqutpTGMlvvLd89e++P5u/nDPafMpWXcsnt1ol3+FXw69DMhUqh 39vVwvV3hogefywUtGj51Hl8vNcXbI05f/Ls8v4M2aBvGpvDuW55rFpYOE13Z35TScSDoN0q 3Ss2W1zgPvvmfeXXYCWW4oxEQy3mouJEAFisf9wSAwAA X-CMS-MailID: 20230405085949eucas1p2738c14184075df72873e25785d5dad99 X-Msg-Generator: CA X-RootMTR: 20230328134650eucas1p16239b9b4a13a09b2baecdd2012fd01c5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230328134650eucas1p16239b9b4a13a09b2baecdd2012fd01c5 References: <20230328134636.234-1-d.kozinski@samsung.com> Subject: Re: [FFmpeg-devel] [PATCH v18 02/10] avcodec/evc_parser: Added parser implementation for EVC format 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 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: > -----Original Message----- > From: ffmpeg-devel On Behalf Of James > Almer > Sent: =B6roda, 29 marca 2023 16:57 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v18 02/10] avcodec/evc_parser: Added > parser implementation for EVC format > = > = > = > On 3/28/2023 10:46 AM, Dawid Kozinski wrote: > > - Added constants definitions for EVC parser > > - Provided NAL units parsing following ISO_IEC_23094-1 > > - EVC parser registration > > > > Signed-off-by: Dawid Kozinski > > --- > > libavcodec/Makefile | 1 + > > libavcodec/evc.h | 155 +++++ > > libavcodec/evc_parser.c | 1270 > +++++++++++++++++++++++++++++++++++++++ > > libavcodec/parsers.c | 1 + > > 4 files changed, 1427 insertions(+) > > create mode 100644 libavcodec/evc.h > > create mode 100644 libavcodec/evc_parser.c > > > = > [...] > = > > +static int parse_nal_unit(AVCodecParserContext *s, const uint8_t *buf, > > + int buf_size, AVCodecContext *avctx) { > > + EVCParserContext *ev =3D s->priv_data; > > + int nalu_type, nalu_size; > > + int tid; > > + const uint8_t *data =3D buf; > > + int data_size =3D buf_size; > > + > > + s->picture_structure =3D AV_PICTURE_STRUCTURE_FRAME; > > + s->key_frame =3D -1; > > + > > + > > + nalu_size =3D buf_size; > > + if (nalu_size <=3D 0) { > > + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size); > > + return AVERROR_INVALIDDATA; > > + } > > + > > + // @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic (Table 4 > - NAL unit type codes and NAL unit type classes) > > + // @see enum EVCNALUnitType in evc.h > > + nalu_type =3D get_nalu_type(data, data_size, avctx); > > + if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) { > > + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", > nalu_type); > > + return AVERROR_INVALIDDATA; > > + } > > + ev->nalu_type =3D nalu_type; > > + > > + tid =3D get_temporal_id(data, data_size, avctx); > > + if (tid < 0) { > > + av_log(avctx, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid); > > + return AVERROR_INVALIDDATA; > > + } > > + ev->nuh_temporal_id =3D tid; > > + > > + if (data_size < nalu_size) { > > + av_log(avctx, AV_LOG_ERROR, "NAL unit does not fit in the data > buffer\n"); > > + return AVERROR_INVALIDDATA; > > + } > > + > > + data +=3D EVC_NALU_HEADER_SIZE; > > + data_size -=3D EVC_NALU_HEADER_SIZE; > > + > > + if (nalu_type =3D=3D EVC_SPS_NUT) { > > + EVCParserSPS *sps; > > + int SubGopLength; > > + > > + sps =3D parse_sps(data, nalu_size, ev); > > + if (!sps) { > > + av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n"); > > + return AVERROR_INVALIDDATA; > > + } > > + > > + s->coded_width =3D sps->pic_width_in_luma_samples; > > + s->coded_height =3D sps->pic_height_in_luma_samples; > > + s->width =3D sps->pic_width_in_luma_samples - s= ps- > >picture_crop_left_offset - sps->picture_crop_right_offset; > > + s->height =3D sps->pic_height_in_luma_samples - s= ps- > >picture_crop_top_offset - sps->picture_crop_bottom_offset; > > + > > + SubGopLength =3D (int)pow(2.0, sps->log2_sub_gop_length); > > + avctx->gop_size =3D SubGopLength; > > + > > + avctx->delay =3D (sps->sps_max_dec_pic_buffering_minus1) ? > > + sps->sps_max_dec_pic_buffering_minus1 - 1 : SubGopLength + > > + sps->max_num_tid0_ref_pics - 1; > > + > > + if (sps->profile_idc =3D=3D 1) avctx->profile =3D FF_PROFILE_EVC_MAIN; > > + else avctx->profile =3D FF_PROFILE_EVC_BASELINE; > > + > > + ev->time_base =3D avctx->time_base.den; > = > This looks like a write only field. Also, avctx->time_base is no longer used for > decoding. > What you can do is setting avctx->frame_rate using > vui->num_units_in_tick and vui->time_scale if present. See h264_parser.c > = > > + > > + switch (sps->chroma_format_idc) { > > + case 0: /* YCBCR400_10LE */ > > + av_log(avctx, AV_LOG_ERROR, "YCBCR400_10LE: Not supported > chroma format\n"); > > + s->format =3D AV_PIX_FMT_GRAY10LE; > > + return -1; > > + case 1: /* YCBCR420_10LE */ > > + s->format =3D AV_PIX_FMT_YUV420P10LE; > > + break; > > + case 2: /* YCBCR422_10LE */ > > + av_log(avctx, AV_LOG_ERROR, "YCBCR422_10LE: Not supported > chroma format\n"); > > + s->format =3D AV_PIX_FMT_YUV422P10LE; > > + return -1; > > + case 3: /* YCBCR444_10LE */ > > + av_log(avctx, AV_LOG_ERROR, "YCBCR444_10LE: Not supported > chroma format\n"); > > + s->format =3D AV_PIX_FMT_YUV444P10LE; > > + return -1; > > + default: > > + s->format =3D AV_PIX_FMT_NONE; > > + av_log(avctx, AV_LOG_ERROR, "Unknown supported chroma > format\n"); > > + return -1; > > + } > > + } else if (nalu_type =3D=3D EVC_PPS_NUT) { > > + EVCParserPPS *pps; > > + > > + pps =3D parse_pps(data, nalu_size, ev); > > + if (!pps) { > > + av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n"); > > + return AVERROR_INVALIDDATA; > > + } > > + } else if (nalu_type =3D=3D EVC_SEI_NUT) // Supplemental Enhancem= ent > Information > > + return 0; > > + else if (nalu_type =3D=3D EVC_APS_NUT) // Adaptation parameter s= et > > + return 0; > > + else if (nalu_type =3D=3D EVC_FD_NUT) /* Filler data */ > > + return 0; > = > Use a switch() statement for this instead. > = > > + else if (nalu_type =3D=3D EVC_IDR_NUT || nalu_type =3D=3D EVC_NOID= R_NUT) { // > Coded slice of a IDR or non-IDR picture > > + EVCParserSliceHeader *sh; > > + EVCParserSPS *sps; > > + int slice_pic_parameter_set_id; > > + > > + sh =3D parse_slice_header(data, nalu_size, ev); > > + if (!sh) { > > + av_log(avctx, AV_LOG_ERROR, "Slice header parsing error\n"); > > + return AVERROR_INVALIDDATA; > > + } > > + > > + switch (sh->slice_type) { > > + case EVC_SLICE_TYPE_B: { > > + s->pict_type =3D AV_PICTURE_TYPE_B; > > + break; > > + } > > + case EVC_SLICE_TYPE_P: { > > + s->pict_type =3D AV_PICTURE_TYPE_P; > > + break; > > + } > > + case EVC_SLICE_TYPE_I: { > > + s->pict_type =3D AV_PICTURE_TYPE_I; > > + break; > > + } > > + default: { > > + s->pict_type =3D AV_PICTURE_TYPE_NONE; > > + } > > + } > > + > > + s->key_frame =3D (nalu_type =3D=3D EVC_IDR_NUT) ? 1 : 0; > > + > > + // POC (picture order count of the current picture) derivation > > + // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture > order count > > + slice_pic_parameter_set_id =3D sh->slice_pic_parameter_set_id; > > + sps =3D &ev->sps[slice_pic_parameter_set_id]; > > + > > + if (sps->sps_pocs_flag) { > > + > > + int PicOrderCntMsb =3D 0; > > + ev->poc.prevPicOrderCntVal =3D ev->poc.PicOrderCntVal; > > + > > + if (nalu_type =3D=3D EVC_IDR_NUT) > > + PicOrderCntMsb =3D 0; > > + else { > > + int MaxPicOrderCntLsb =3D 1 << (sps- > >log2_max_pic_order_cnt_lsb_minus4 + 4); > > + > > + int prevPicOrderCntLsb =3D ev->poc.PicOrderCntVal & > (MaxPicOrderCntLsb - 1); > > + int prevPicOrderCntMsb =3D ev->poc.PicOrderCntVal - > prevPicOrderCntLsb; > > + > > + > > + if ((sh->slice_pic_order_cnt_lsb < prevPicOrderCntLsb) && > > + ((prevPicOrderCntLsb - sh->slice_pic_order_cnt_lsb) >=3D > (MaxPicOrderCntLsb / 2))) > > + > > + PicOrderCntMsb =3D prevPicOrderCntMsb + MaxPicOrderCntLsb; > > + > > + else if ((sh->slice_pic_order_cnt_lsb > prevPicOrderCntLsb) && > > + ((sh->slice_pic_order_cnt_lsb - prevPicOrderCntLsb) > > (MaxPicOrderCntLsb / 2))) > > + > > + PicOrderCntMsb =3D prevPicOrderCntMsb - MaxPicOrderCntLsb; > > + > > + else > > + PicOrderCntMsb =3D prevPicOrderCntMsb; > > + } > > + ev->poc.PicOrderCntVal =3D PicOrderCntMsb + sh- > >slice_pic_order_cnt_lsb; > > + > > + } else { > > + if (nalu_type =3D=3D EVC_IDR_NUT) { > > + ev->poc.PicOrderCntVal =3D 0; > > + ev->poc.DocOffset =3D -1; > > + } else { > > + int SubGopLength =3D (int)pow(2.0, sps->log2_sub_gop_length); > > + if (tid =3D=3D 0) { > > + ev->poc.PicOrderCntVal =3D ev->poc.prevPicOrderCnt= Val + > SubGopLength; > > + ev->poc.DocOffset =3D 0; > > + ev->poc.prevPicOrderCntVal =3D ev->poc.PicOrderCntVal; > > + } else { > > + int ExpectedTemporalId; > > + int PocOffset; > > + int prevDocOffset =3D ev->poc.DocOffset; > > + > > + ev->poc.DocOffset =3D (prevDocOffset + 1) % SubGopLength; > > + if (ev->poc.DocOffset =3D=3D 0) { > > + ev->poc.prevPicOrderCntVal +=3D SubGopLength; > > + ExpectedTemporalId =3D 0; > > + } else > > + ExpectedTemporalId =3D 1 + (int)log2(ev->poc.DocOffset); > > + while (tid !=3D ExpectedTemporalId) { > > + ev->poc.DocOffset =3D (ev->poc.DocOffset + 1) % SubGopLength; > > + if (ev->poc.DocOffset =3D=3D 0) > > + ExpectedTemporalId =3D 0; > > + else > > + ExpectedTemporalId =3D 1 + (int)log2(ev->poc.DocOffset); > > + } > > + PocOffset =3D (int)(SubGopLength * ((2.0 * ev->poc.DocOffset + 1) / > (int)pow(2.0, tid) - 2)); > > + ev->poc.PicOrderCntVal =3D ev->poc.prevPicOrderCnt= Val + > PocOffset; > > + } > > + } > > + } > > + > > + s->output_picture_number =3D ev->poc.PicOrderCntVal; > > + s->key_frame =3D (nalu_type =3D=3D EVC_IDR_NUT) ? 1 : 0; > > + > > + return 0; > > + } > > + data +=3D (nalu_size - EVC_NALU_HEADER_SIZE); > > + data_size -=3D (nalu_size - EVC_NALU_HEADER_SIZE); > = > What does this even do? They are local variables, and this is not in a loop. > = > > + > > + return 0; > > +} > = > [...] > = > > +// Find the end of the current frame in the bitstream. > > +// The end of frame is the end of Access Unit. > > +// Function returns the position of the first byte of the next frame, or > END_NOT_FOUND > > +static int evc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, > > + int buf_size, AVCodecContext *avctx) > > +{ > > + EVCParserContext *ctx =3D s->priv_data; > > + > > + const uint8_t *data =3D buf; > > + int data_size =3D buf_size; > > + > > + while (data_size > 0) { > > + > > + if (ctx->to_read =3D=3D 0) { > > + // Nothing must be read and appended to the data from previous > chunks. > > + // The previous chunk of data provided the complete NALU prefix or > provided the complete NALU. > > + > > + if (ctx->nalu_prefix_assembled) // NALU prefix has been assembled > from previous and current chunks of incoming data > > + ctx->nalu_prefix_assembled =3D 0; > > + else { // Buffer size is not enough for buffer to store NAL unit 4-bytes > prefix (length) > > + if (data_size < EVC_NALU_LENGTH_PREFIX_SIZE) { > > + ctx->to_read =3D EVC_NALU_LENGTH_PREFIX_SIZE - data_size; > > + ctx->incomplete_nalu_prefix_read =3D 1; > > + return END_NOT_FOUND; > > + } > > + > > + ctx->nalu_size =3D read_nal_unit_length(data, data_siz= e, avctx); > > + ctx->bytes_read +=3D EVC_NALU_LENGTH_PREFIX_SIZE; > > + > > + data +=3D EVC_NALU_LENGTH_PREFIX_SIZE; > > + data_size -=3D EVC_NALU_LENGTH_PREFIX_SIZE; > > + } > > + > > + if (data_size < ctx->nalu_size) { > > + > > + ctx->to_read =3D ctx->nalu_size - data_size; > > + ctx->incomplete_nalu_read =3D 1; > > + return END_NOT_FOUND; > > + } > > + > > + // the entire NALU can be read > > + if (parse_nal_unit(s, data, ctx->nalu_size, avctx) !=3D 0)= { > = > NALU parsing should happen always, not only when the parser is required > to assemble a full access unit. > = > > + av_log(avctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); > > + return AVERROR_INVALIDDATA; > > + } > > + > > + data +=3D ctx->nalu_size; > > + data_size -=3D ctx->nalu_size; > > + > > + ctx->bytes_read +=3D ctx->nalu_size; > > + > > + if (end_of_access_unit_found(s, avctx)) { > > + > > + // parser should return buffer that contains complete AU > > + int read_bytes =3D ctx->bytes_read; > > + ctx->bytes_read =3D 0; > > + return read_bytes; > > + } > > + > > + // go to the next iteration > > + continue; > > + > > + } else { > > + // The previous chunk of input data did not contain the complete valid > NALU prefix or did not contain the complete NALU. > > + // > > + // Missing data must be read from the current data chunk and merged > with the data from the previous data chunk > > + // to assemble a complete NALU or complete NALU prefix. > > + // > > + // The data from the previous data chunk are stored in pc->buf > > + > > + if (ctx->to_read < data_size) { > > + > > + if (ctx->incomplete_nalu_prefix_read =3D=3D 1) { > > + > > + uint8_t nalu_prefix[EVC_NALU_LENGTH_PREFIX_SIZE]; > > + evc_assemble_nalu_prefix(s, data, data_size, nalu_prefix, avctx); > > + > > + ctx->nalu_size =3D read_nal_unit_length(nalu_prefi= x, > EVC_NALU_LENGTH_PREFIX_SIZE, avctx); > > + > > + // update variable storing amout of read bytes for teh current AU > > + ctx->bytes_read +=3D ctx->to_read; > > + > > + // update data pointer and data size > > + data +=3D ctx->to_read; > > + data_size -=3D ctx->to_read; > > + > > + // reset variable storing amount of bytes to read from the new > data chunk > > + ctx->to_read =3D 0; > > + > > + ctx->incomplete_nalu_prefix_read =3D 0; > > + ctx->nalu_prefix_assembled =3D 1; > > + > > + continue; > > + } > > + if (ctx->incomplete_nalu_read =3D=3D 1) { > > + > > + uint8_t *nalu =3D (uint8_t *)av_malloc(ctx->nalu_size); > > + > > + // assemble NAL unit using data from previous data chunks (pc- > >buffer) and the current one (data) > > + evc_assemble_nalu(s, data, ctx->to_read, nalu, ctx->nalu_size, > avctx); > > + > > + if (parse_nal_unit(s, nalu, ctx->nalu_size, avctx) !=3D 0) { > > + av_log(avctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); > > + return AVERROR_INVALIDDATA; > > + } > > + av_free(nalu); > > + > > + // update variable storing amout of read bytes for teh current AU > > + ctx->bytes_read +=3D ctx->nalu_size; > > + > > + // update data pointer and data size > > + data +=3D ctx->to_read; > > + data_size -=3D ctx->to_read; > > + > > + ctx->incomplete_nalu_read =3D 0; > > + > > + if (end_of_access_unit_found(s, avctx)) { > > + > > + // parser should return buffer that contains complete AU > > + int read_bytes =3D ctx->to_read; > > + > > + ctx->to_read =3D 0; > > + ctx->bytes_read =3D 0; > > + > > + return read_bytes; > > + } > > + > > + // reset variable storing amount of bytes to read from the new > data chunk > > + ctx->to_read =3D 0; > > + > > + continue; > > + } > > + } else { > > + // needed more input data to assemble complete valid NAL Unit > > + ctx->to_read =3D ctx->to_read - data_size; > > + return END_NOT_FOUND; > > + } > > + } > > + } > > + > > + return END_NOT_FOUND; > > +} > > + > > +static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx, > > + const uint8_t **poutbuf, int *poutbuf_size, > > + const uint8_t *buf, int buf_size) > > +{ > > + int next; > > + EVCParserContext *ev =3D s->priv_data; > > + ParseContext *pc =3D &ev->pc; > > + > > + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) > > + next =3D buf_size; > > + else { > > + next =3D evc_find_frame_end(s, buf, buf_size, avctx); > > + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { > > + *poutbuf =3D NULL; > > + *poutbuf_size =3D 0; > > + return buf_size; > > + } > > + } > = > Case in point, you should call the function to parse the packet's NALUs > here, so it's done also when PARSER_FLAG_COMPLETE_FRAMES is signaled. > = > > + > > + // poutbuf contains just one Access Unit > > + *poutbuf =3D buf; > > + *poutbuf_size =3D buf_size; > > + > > + return next; > > +} > > + > > +static int evc_parser_init(AVCodecParserContext *s) > > +{ > > + EVCParserContext *ev =3D s->priv_data; > > + ev->incomplete_nalu_prefix_read =3D 0; > > + > > + return 0; > > +} > > + > > +const AVCodecParser ff_evc_parser =3D { > > + .codec_ids =3D { AV_CODEC_ID_EVC }, > > + .priv_data_size =3D sizeof(EVCParserContext), > > + .parser_init =3D evc_parser_init, > > + .parser_parse =3D evc_parse, > > + .parser_close =3D ff_parse_close, > > +}; > > diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c > > index d355808018..2c077ec3ae 100644 > > --- a/libavcodec/parsers.c > > +++ b/libavcodec/parsers.c > > @@ -41,6 +41,7 @@ extern const AVCodecParser ff_dvaudio_parser; > > extern const AVCodecParser ff_dvbsub_parser; > > extern const AVCodecParser ff_dvdsub_parser; > > extern const AVCodecParser ff_dvd_nav_parser; > > +extern const AVCodecParser ff_evc_parser; > > extern const AVCodecParser ff_flac_parser; > > extern const AVCodecParser ff_ftr_parser; > > extern const AVCodecParser ff_g723_1_parser; > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://protect2.fireeye.com/v1/url?k=3De23962f4-bda25bf8-e238e9bb- > 000babff3563-acac272a35bdd12c&q=3D1&e=3Ddaa29860-f1f6-44c2-9ab6- > d68c3d42950a&u=3Dhttps%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmp > eg-devel > = > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". We've just uploaded new patches. Everything you have requested has been fixed. _______________________________________________ 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".