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 F2D7145C80 for ; Thu, 30 Mar 2023 10:09:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4A0B668C65B; Thu, 30 Mar 2023 13:09:23 +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 995E068C2E3 for ; Thu, 30 Mar 2023 13:09:17 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230330100915euoutp01b79136cb9a68d06abb2aad2ddc987117~RKpUeK2nn2909829098euoutp01w for ; Thu, 30 Mar 2023 10:09:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230330100915euoutp01b79136cb9a68d06abb2aad2ddc987117~RKpUeK2nn2909829098euoutp01w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1680170955; bh=gJ9KIDWmRUWv+qZK+069SE39gToX5Q+B1/Krd6CNp+I=; h=From:To:In-Reply-To:Subject:Date:References:From; b=hqAJ++zXImHbCjledikRjjjJr4dhRCXkRvqq8RaeYizud9DFzB200Gc8CS2RMmunN /ryJAk7sY+v1Tpy/2OVs2AouUH7X7NRWgTOxhoaJzaSMYZyOeQsq8x8/o8KJ4BFzMD OfjR+/IiC5LjuhDi1PAwh9nqkSbXXwSAe+5xwTKA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230330100915eucas1p236f85b94f25ad1beab071f5c0cdaf344~RKpUXtId10548705487eucas1p2O for ; Thu, 30 Mar 2023 10:09:15 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 76.D6.10014.BCF55246; Thu, 30 Mar 2023 11:09:15 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230330100915eucas1p140f53ea9316c8d84d91e07814751e517~RKpUGuOFy1898918989eucas1p1I for ; Thu, 30 Mar 2023 10:09:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230330100915eusmtrp21c2b1b504d76ddedb977fc473a2bdb58~RKpUGP2Uv0554405544eusmtrp2X for ; Thu, 30 Mar 2023 10:09:15 +0000 (GMT) X-AuditID: cbfec7f5-b8bff7000000271e-79-64255fcb9ecf Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5E.0C.09583.BCF55246; Thu, 30 Mar 2023 11:09:15 +0100 (BST) Received: from AMDN5164 (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230330100915eusmtip23314158f3c43a8eb85548737c35a7be8~RKpT46rWO3234632346eusmtip2Y for ; Thu, 30 Mar 2023 10:09:15 +0000 (GMT) From: "Dawid Kozinski/Multimedia \(PLT\) /SRPOL/Staff Engineer/Samsung Electronics" To: "'FFmpeg development discussions and patches'" In-Reply-To: <62f45ea9-aa27-e1dd-a8c0-f3cc80f32ff0@gmail.com> Date: Thu, 30 Mar 2023 12:09:14 +0200 Message-ID: <000001d962ef$aecce670$0c66b350$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIsS2BDB9eN/JM+2OqHa+K6gtOmkAGoGne0Aq/C73muSomQAA== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJIsWRmVeSWpSXmKPExsWy7djPc7qn41VTDFb80LP49ukMswOjx59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F m1kCGKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLLUov07RL0 Mi7u/8ZecNWvYsGuz0wNjAf1uxg5OSQETCQmzD/F3sXIxSEksJRRYnNzAztEQkpi6dJFjBC2 sMSfa11sEEUtTBK/Vr1lA0mwCeRIrJ09kQnEFhHwkehev54Vomgvo0TTo0awbk4BW4kVGxez gNjCAskSh6efBGtgEVCV2Lv3J3MXIwcHr4ClRNtSCZAwr4CgxMmZT8DKmQUMJJYs/MUEYWtL LFv4mhniIAWJn0+XsULsdZJ4sOA9I0SNiMSNRy2MExiFZiEZNQvJqFlIRs1C0rKAkWUVo0hq aXFuem6xkV5xYm5xaV66XnJ+7iZGYExsO/Zzyw7Gla8+6h1iZOJgPMQowcGsJMJbaKyaIsSb klhZlVqUH19UmpNafIjRFOi1icxSosn5wKjMK4k3NDMwNTQxszQwtTQzVhLn9SzoSBQSSE8s Sc1OTS1ILYLpY+LglGpgquYJP/P+1zpN24tn2HbKxTRoVF2wPdUf9+l4V+GhfhPmnbv6WQIM EhX9V7OuEdI0mbpZaOrvFep5V+LeP8oxT4q6y/gnIFjruPDDzEaTi2pc55qf7k/68k2284Vs Pstxwzw/OZ24XSxPzz+vXZunx1v62+XF7bsm/9sE6hdrFFb/0+ysfX/qyjSJ2K1XGru+sTKK RjJ1KLCdWBTwxWmfjfbOH7pbU2WZl7Q7irz9/mTt6ukbWXl9Q6qNrvza5sJqcVvL7Fy0VfG7 Z+5Ooa6l3Ev2aM28mmy04d5e8VDPcMWKLzm/jmVXbrNd//GpNpeCwb11E33fbJBcGbs36lPJ PInD5w+xNO+Ua9WxfHZBiaU4I9FQi7moOBEAulgSChIDAAA= X-CMS-MailID: 20230330100915eucas1p140f53ea9316c8d84d91e07814751e517 X-Msg-Generator: CA X-RootMTR: 20230328135026eucas1p1abe4dd2289ba01bb018f7b37d1a147a7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230328135026eucas1p1abe4dd2289ba01bb018f7b37d1a147a7 References: <20230328135007.1765-1-d.kozinski@samsung.com> <62f45ea9-aa27-e1dd-a8c0-f3cc80f32ff0@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH v18 06/10] avcodec/evc_decoder: Provided support for EVC decoder 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 14:17 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v18 06/10] avcodec/evc_decoder: Provided > support for EVC decoder > = > On 3/28/2023 10:50 AM, Dawid Kozinski wrote: > > +static int libxevd_receive_frame(AVCodecContext *avctx, AVFrame > > +*frame) { > > + XevdContext *xectx =3D NULL; > > + AVPacket *pkt =3D NULL; > > + XEVD_IMGB *imgb =3D NULL; > > + > > + int xevd_ret =3D 0; > > + int ret =3D 0; > > + > > + xectx =3D avctx->priv_data; > > + > > + pkt =3D av_packet_alloc(); > > + if (!pkt) > > + return AVERROR(ENOMEM); > = > This is very inefficient. Just keep an AVPacket in the XevdContext, allocating it on > init(), unrefing it after being used in this function, and freeing it on close(). > = > > + > > + // obtain input data > > + ret =3D ff_decode_get_packet(avctx, pkt); > > + if (ret < 0 && ret !=3D AVERROR_EOF) { > > + av_packet_free(&pkt); > > + return ret; > > + } else if(ret =3D=3D AVERROR_EOF && xectx->draining_mode =3D=3D 0)= { // > > + End of stream situations. Enter draining mode > > + > > + frame =3D NULL; > > + xectx->draining_mode =3D 1; > > + > > + av_packet_free(&pkt); > > + > > + return AVERROR_EOF; > = > By returning EOF here you're effectively ending the decoding process. No > draining is taking place. This function is not going to be called again for the > xectx->draining_mode =3D=3D 1 to take effect. > = > > + } > > + > > + if (pkt->size > 0) { > > + int bs_read_pos =3D 0; > > + XEVD_STAT stat; > > + XEVD_BITB bitb; > > + int nalu_size; > > + > > + imgb =3D NULL; > > + > > + while(pkt->size > (bs_read_pos + XEVD_NAL_UNIT_LENGTH_BYTE)) { > > + memset(&stat, 0, sizeof(XEVD_STAT)); > > + > > + nalu_size =3D read_nal_unit_length(pkt->data + bs_read_pos, > XEVD_NAL_UNIT_LENGTH_BYTE, avctx); > > + if (nalu_size =3D=3D 0) { > > + av_log(avctx, AV_LOG_ERROR, "Invalid bitstream\n"); > > + av_packet_free(&pkt); > > + ret =3D AVERROR_INVALIDDATA; > > + return ret; > > + } > > + bs_read_pos +=3D XEVD_NAL_UNIT_LENGTH_BYTE; > > + > > + bitb.addr =3D pkt->data + bs_read_pos; > > + bitb.ssize =3D nalu_size; > > + > > + /* main decoding block */ > > + xevd_ret =3D xevd_decode(xectx->id, &bitb, &stat); > > + if (XEVD_FAILED(xevd_ret)) { > > + av_log(avctx, AV_LOG_ERROR, "Failed to decode bitstream\n"); > > + av_packet_free(&pkt); > > + ret =3D AVERROR_EXTERNAL; > > + return ret; > > + } > > + > > + bs_read_pos +=3D nalu_size; > > + > > + if (stat.nalu_type =3D=3D XEVD_NUT_SPS) { // EVC stream parameters > changed > > + if ((ret =3D export_stream_params(xectx, avctx)) !=3D = 0) { > > + av_log(avctx, AV_LOG_ERROR, "Failed to export stream > params\n"); > > + av_packet_free(&pkt); > > + return ret; > > + } > > + } > > + if (stat.read !=3D nalu_size) > > + av_log(avctx, AV_LOG_INFO, "Different reading of bitstream > (in:%d,read:%d)\n,", nalu_size, stat.read); > > + if (stat.fnum >=3D 0) { > > + // already has a decoded image > > + if (imgb) { > > + // xevd_pull uses pool of objects of type XEVD_IMGB. > > + // The pool size is equal MAX_PB_SIZE (26), so release object when > it is no more needed > > + imgb->release(imgb); > > + imgb =3D NULL; > = > Aren't you dropping an image you should be propagating instead with this? > = > > + } > > + xevd_ret =3D xevd_pull(xectx->id, &imgb); > > + if (XEVD_FAILED(xevd_ret)) { > > + av_log(avctx, AV_LOG_ERROR, "Failed to pull the decoded image > (xevd error code: %d, frame#=3D%d)\n", xevd_ret, stat.fnum); > > + ret =3D AVERROR_EXTERNAL; > > + av_packet_free(&pkt); > > + > > + return ret; > > + } else if (xevd_ret =3D=3D XEVD_OK_FRM_DELAYED) { > > + if (imgb) { > > + // xevd_pull uses pool of objects of type XEVD_IMGB. > > + // The pool size is equal MAX_PB_SIZE (26), so release object > when it is no more needed > > + imgb->release(imgb); > > + imgb =3D NULL; > = > Can an image be returned when xevd_ret =3D=3D XEVD_OK_FRM_DELAYED? If so, > shouldn't you propagate it? > = > > + } > > + av_packet_free(&pkt); > > + > > + return AVERROR(EAGAIN); > > + } > > + if (imgb) { // got frame > > + int ret =3D libxevd_image_copy(avctx, imgb, frame); > > + if(ret < 0) { > > + av_log(avctx, AV_LOG_ERROR, "Image copying error\n"); > > + if (imgb) { > > + imgb->release(imgb); > > + imgb =3D NULL; > > + } > > + av_packet_free(&pkt); > > + > > + return ret; > > + } > > + > > + // use ff_decode_frame_props() to fill frame properties > > + ret =3D ff_decode_frame_props(avctx, frame); > > + if (ret < 0) { > > + if (imgb) { > > + imgb->release(imgb); > > + imgb =3D NULL; > > + } > > + av_packet_free(&pkt); > > + av_frame_unref(frame); > > + > > + return ret; > > + } > > + // match timestamps and packet size > > + ret =3D ff_decode_frame_props_from_pkt(avctx, fram= e, pkt); > > + pkt->opaque =3D NULL; > = > You copy-pasted this from libdav1d.c without knowing what it's doing. > You don't need to clear opaque, and you don't need to call > ff_decode_frame_props_from_pkt() with the current packet when > ff_decode_frame_props() is already doing it for you. The former function is only > needed when you need props from a packet other than the last one fed to the > decoder. > = > > + if (ret < 0) { > > + if (imgb) { > > + imgb->release(imgb); > > + imgb =3D NULL; > > + } > > + av_packet_free(&pkt); > > + av_frame_unref(frame); > > + > > + return ret; > > + } > > + > > + frame->pkt_dts =3D pkt->dts; > > + > > + // xevd_pull uses pool of objects of type XEVD_IMGB. > > + // The pool size is equal MAX_PB_SIZE (26), so release object when > it is no more needed > > + imgb->release(imgb); > > + imgb =3D NULL; > > + > > + return 0; > > + } else > > + return AVERROR(EAGAIN); > > + } > > + } > > + } else { // decoder draining mode handling > > + xevd_ret =3D xevd_pull(xectx->id, &imgb); > > + if (xevd_ret =3D=3D XEVD_ERR_UNEXPECTED) // draining process completed > > + return AVERROR_EOF; > > + else if (XEVD_FAILED(xevd_ret)) { > > + av_log(avctx, AV_LOG_ERROR, "Failed to pull the decoded > > + image (xevd error code: %d)\n", xevd_ret); > > + > > + if (imgb) { > > + imgb->release(imgb); > > + imgb =3D NULL; > > + } > > + > > + av_packet_free(&pkt); > > + > > + return AVERROR_EXTERNAL; > > + } > > + if (imgb) { // got frame > > + int ret =3D libxevd_image_copy(avctx, imgb, frame); > > + if(ret < 0) { > > + if (imgb) { > > + imgb->release(imgb); > > + imgb =3D NULL; > > + } > > + av_packet_free(&pkt); > > + } > > + > > + frame->pkt_dts =3D pkt->dts; > > + > > + // xevd_pull uses pool of objects of type XEVD_IMGB. > > + // The pool size is equal MAX_PB_SIZE (26), so release object when it is > no more needed > > + imgb->release(imgb); > > + imgb =3D NULL; > > + > > + return 0; > > + } > > + return AVERROR_EOF; > > + } > > + return ret; > > +} > ___ I'm sorry for not replying earlier but I've been experiencing an internet connection issue since yesterday. I had an outage and no network connection. I will make all the necessary changes in the code and upload new patches as fast as possible. ____________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://protect2.fireeye.com/v1/url?k=3Da9b4cba4-c83fde97-a9b540eb- > 000babff9bb7-057645cded2a2511&q=3D1&e=3Da107ddf9-a9a2-4d0b-ac05- > 20a74e0f8ff9&u=3Dhttps%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpe > g-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".