linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: The problem of VP9 decoder adapter V4L2.
       [not found]               ` <2022071418182653336122@amlogic.com>
@ 2022-07-14 11:03                 ` Hans Verkuil
  2022-07-14 14:00                   ` Nicolas Dufresne
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2022-07-14 11:03 UTC (permalink / raw)
  To: nanxin.qin, xiaohang.cui, arch-proaudio; +Cc: hui.zhang, zhi.zhou, linux-media



On 7/14/22 12:18, nanxin.qin@amlogic.com wrote:
> Hi, Hans 
> thanks for your reply. Currently, our source code has not been submitted to the kernel tree, so you might didn't got them. 
> 
> /drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c/
> / /
> /Or at least, it does a memcpy to the new buffer and it has some buffer refcounting,/
> /although I didn't go deep into the details. In any case, this might help./
> /
> /
>     if (frm_to_show->fb != inst->cur_fb) {
>         /* This frame is show exist frame and no decode output
>          * copy frame data from frm_to_show to current CAPTURE
>          * buffer
>          */
>         if ((frm_to_show->fb != NULL) &&
>             (inst->cur_fb->base_y.size >=
>             frm_to_show->fb->base_y.size) &&
>             (inst->cur_fb->base_c.size >=
>             frm_to_show->fb->base_c.size)) {
>             memcpy((void *)inst->cur_fb->base_y.va,
>                 (void *)frm_to_show->fb->base_y.va,
>                 frm_to_show->fb->base_y.size);
>             memcpy((void *)inst->cur_fb->base_c.va,
>                 (void *)frm_to_show->fb->base_c.va,
>                 frm_to_show->fb->base_c.size);
>         }
> You should be talking about this code, If the picture buffer is secure and protected, this memory may be prohibited memcpy, so what should we do? 

Yeah, that won't work for protected memory. But if it is in protected memory, doesn't that mean that you are using dmabuf for the actual buffer?

We don't have any codec drivers that work with protected memory in the kernel, but the only way to support that would be through dmabuf.

Question: does VP9 indicate that a buffer will be repeated when you receive the first buffer of that sequence? I.e., do you know when you dequeue the first buffer that it will be repeated? Or do you only discover that afterwards?

I'm also assuming that you are talking about a stateful codec driver, not a stateless codec driver, correct?

Regards,

	Hans

> Our idea is to dque this buffer to user space multiple times through the videobuf2 framework.
> But v4l2 does not support this behavior, if the buffer is not returned to the driver, it will be output again.
> 
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> nanxin.qin@amlogic.com
> 
>      
>     *From:* Hans Verkuil <mailto:hverkuil-cisco@xs4all.nl>
>     *Date:* 2022-07-14 15:59
>     *To:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; arch-proaudio <mailto:arch-proaudio@lists.archlinux.org>
>     *CC:* hui.zhang <mailto:hui.zhang@amlogic.com>; zhi.zhou <mailto:zhi.zhou@amlogic.com>
>     *Subject:* Re: The problem of VP9 decoder adapter V4L2.
>     [ EXTERNAL EMAIL ]
>      
>     Hmm, it looks I missed the earlier email.
>      
>     In any case, please post this to the linux-media@vger.kernel.org mailinglist.
>      
>     Please mention which driver you are using, is it drivers/staging/media/meson/vdec?
>      
>     If so, then clearly mention this in the subject line.
>      
>     If it is an out-of-tree driver, then also mention that, ideally with a link to the code.
>      
>     By posting to the mailinglist you'll reach the real experts on codecs.
>      
>     Based on a quick look at the meson driver it looks like it does not support this
>     feature. It can detect it, but it doesn't appear to do anything with that
>     information. But the mediatek decoder appears to handle this situation properly:
>      
>     drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
>      
>     Or at least, it does a memcpy to the new buffer and it has some buffer refcounting,
>     although I didn't go deep into the details. In any case, this might help.
>      
>     Regards,
>      
>     Hans
>      
>     On 7/14/22 09:32, nanxin.qin@amlogic.com wrote:
>     > Hi, Hans
>     >
>     > I'm sorry to bother you again. Do you have any good suggestions for this problem? The VP9 spec development team suggested a change to the V4L2 API to allow the vb2 can be deque more times, which seemed difficult.
>     >
>     >
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     > nanxin.qin@amlogic.com
>     >
>     >      
>     >     *From:* xiaohang.cui@amlogic.com <mailto:xiaohang.cui@amlogic.com>
>     >     *Date:* 2022-06-02 16:26
>     >     *To:* arch-proaudio <mailto:arch-proaudio@lists.archlinux.org>
>     >     *CC:* hverkuil-cisco@xs4all.nl <mailto:hverkuil-cisco@xs4all.nl>; hui.zhang <mailto:hui.zhang@amlogic.com>; Nanxin Qin <mailto:Nanxin.Qin@amlogic.com>
>     >     *Subject:* Re: Re: The problem of VP9 decoder adapter V4L2.
>     >     Dear linux.org multi-media team,
>     >
>     >     I am a multimedia software engineer from AmLogic. We have encountered some decoder problems on V4L2 when supporting VP9.
>     >
>     >     Reading the VP9 specification, show_existing_frame is a feature added in intra-only to solve the problem of video conferencing. If show_existing_frame is equal to 1, the decoder outputs the previously decoded frame. This part is explained in the specification output process.
>     >
>     >     At present, we need to implement VP9 decoder based on V4L2. All decoded frames need to be passed to userspace using VB2 buffer. If show_existing_frame exists, the same frame may be output multiple times. If VB2 buffer was dequed to userspace by APP, and no queue into the videobuf2 driver, then the VP9 decoder driver will fail to output the frame again because the VB2 buffer has not returned to the driver, In other words the buffer's owner is APP not decode driver. So the decoder cannot pass the frame from the VB2 buffer again.
>     >
>     >     According to the above analysis, the show_existing_frame feature seems to conflict with the V4L2 Videobuf2 framework because V4L2 does not allow the same VB2 buffer to be output more than once.
>     >
>     >     I would like to ask, for VP9 decoder adaptation on V4L2, how to should deal with the problem of repeated output frame?
>     >
>     >     I'm looking forward to receiving your reply. Thank you very much.
>     >
>     >     Attachment is the coded stream for reference (big_buck_bunny_720p.mp4).
>     >
>     >    
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     >
>     >     崔晓行
>     >     SW  Department
>     >
>     >     Amlogic Inc. Shenzhen office
>     >
>     >     -------------------------------------------------------------
>     >
>     >     深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层
>     >
>     >     Tel: 0755-86315800-8169
>     >
>     >          
>     >         *From:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>
>     >         *Date:* 2022-05-25 16:50
>     >         *To:* peter.derivaz <mailto:peter.derivaz@gmail.com>
>     >         *CC:* agrange <mailto:agrange@google.com>; tinghai.chen <mailto:tinghai.chen@amlogic.com>; hui.zhang <mailto:hui.zhang@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; yixin.peng <mailto:yixin.peng@amlogic.com>; Gan Zhang <mailto:Gan.Zhang@amlogic.com>; kuan.hu <mailto:Kuan.Hu@amlogic.com>; miaohong.chen <mailto:miaohong.chen@amlogic.com>; lele.xiang <mailto:lele.xiang@amlogic.com>; Shihong.Zheng <mailto:shihong.zheng@amlogic.com>
>     >         *Subject:* Re: Re: The problem of VP9 decoder adapter V4L2.
>     >         Hi, Peter
>     >
>     >         Thanks for your reply, we will try to feedback this problem with Linux, we plan to implement the second solution according to your proposal, which may be more convenient for us to implement, thanks again.
>     >
>     >        
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     >
>     >         nanxin.qin
>     >         SW  Department____
>     >
>     >         Amlogic Inc. Shenzhen office____
>     >
>     >         -------------------------------------------------------------____
>     >
>     >         深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层____
>     >
>     >         Tel: 0755-86315800-8169
>     >
>     >              
>     >             *From:* Peter de Rivaz <mailto:peter.derivaz@gmail.com>
>     >             *Date:* 2022-05-25 16:33
>     >             *To:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>
>     >             *CC:* agrange <mailto:agrange@google.com>; tinghai.chen <mailto:tinghai.chen@amlogic.com>; hui.zhang <mailto:hui.zhang@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; yixin.peng <mailto:yixin.peng@amlogic.com>; Zhang <mailto:Gan.Zhang@amlogic.com>; kuan.hu <mailto:Kuan.Hu@amlogic.com>; miaohong.chen <mailto:miaohong.chen@amlogic.com>; lele.xiang <mailto:lele.xiang@amlogic.com>; Shihong.Zheng <mailto:shihong.zheng@amlogic.com>
>     >             *Subject:* Re: The problem of VP9 decoder adapter V4L2.
>     >             **[ EXTERNAL EMAIL ]**
>     >            
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     >             I can see two choices:
>     >             1)
>     >             You could change the V4L2 API to allow the buffer to be returned multiple times (this would involve discussion on the Linux mailing lists as it is not something within our control).
>     >
>     >             2)
>     >             You could treat the frame with show_existing_frame=1 as a normal frame with zero motion vectors and no residual.
>     >             In other words, you just copy the reference frame data from the frame indicated by frame_to_show_map_idx into a new frame and return it.
>     >
>     >             Option 1 would be a bit more efficient, but option 2 is probably simpler to implement.
>     >
>     >             Peter de Rivaz
>     >
>     >             On Wed, May 25, 2022 at 8:55 AM nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com> <nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>> wrote:
>     >
>     >                     Dear:
>     >                     agrange, peter.derivaz
>     >
>     >                     I am a multimedia software engineer from AmLogic. We have encountered some problems when supporting VP9 decoder + V4L2.
>     >
>     >                     Reading the VP9 specification, show_existing_frame is a feature added in intra-only to solve the problem of video conferencing. If show_existing_frame is equal to 1, the decoder outputs the previously decoded frame. This part is explained in the specification output process.
>     >
>     >                     At present, we need to implement VP9 decoder based on V4L2. All decoded frames need to be passed to userspace using VB2 buffer. If show_existing_frame exists, the same frame may be output multiple times. If VB2 buffer was dequed to userspace by APP, and no queue into the videobuf2 driver, then the VP9 decoder driver will fail to output the frame again because the VB2 buffer has not returned to the driver, In other words the buffer's onwer is APP not decode driver. So the decoder cannot pass the frame from the VB2 buffer again.
>     >
>     >                     According to the above analysis, the show_existing_frame feature seems to conflict with the V4L2 Videobuf2 framework because V4L2 does not allow the same VB2 buffer to be output more than once.
>     >
>     >                     I would like to ask, for VP9 decoder adaptation V4L2 should be how to deal with the problem of repeated output frame?
>     >
>     >                     Thank you very much for your reply.
>     >
>     >                     Attached is the code stream for reference (big_buck_bunny_720p.mp4).
>     >
>     >                        
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     >
>     >                         nanxin.qin
>     >                         SW  Department____
>     >
>     >                         Amlogic Inc. Shenzhen office____
>     >
>     >                         -------------------------------------------------------------____
>     >
>     >                         深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层____
>     >
>     >                         Tel: 0755-86315800-8169
>     >
>      
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: The problem of VP9 decoder adapter V4L2.
  2022-07-14 11:03                 ` The problem of VP9 decoder adapter V4L2 Hans Verkuil
@ 2022-07-14 14:00                   ` Nicolas Dufresne
       [not found]                     ` <2022071513513162306438@amlogic.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Dufresne @ 2022-07-14 14:00 UTC (permalink / raw)
  To: Hans Verkuil, nanxin.qin, xiaohang.cui, arch-proaudio
  Cc: hui.zhang, zhi.zhou, linux-media

Hi,

here's some note of the discussion we had on IRC. First thing to mention, this
is a none-issue for stateless decoders, since the special frame with
show_existing_frame flag set are just never sent to the kernel in that case.
This only affect stateful decoders (which not much design time was put in
really).

The show_existing_frame flag have two uses cases. The most common one is for
video playback, it is used to simulate B-Frame (future references). In the case,
the frames is first decoded, but not outputed. It is part of the same temporal
unit (super frame) as another frame. This frame will use a VB2 buffer, but it
won't be displayed. In that case, it will only be displayed later once, with
show_existing_frame, and for that, you can just delay the buffer_done marking.

The problematic case would be for still picture handling (video with repeated
images and no noise). In this case, the same frames is being displayed over and
over. You could use this while encoding slide deck. There is currently no zero-
copy mechanism in place to allow this in VB2 design. I've made a suggestion to
Hans (which I doubt will be adopted), so I will leave that there for now.

regards,
Nicolas

Le jeudi 14 juillet 2022 à 13:03 +0200, Hans Verkuil a écrit :
> 
> On 7/14/22 12:18, nanxin.qin@amlogic.com wrote:
> > Hi, Hans 
> > thanks for your reply. Currently, our source code has not been submitted to
> > the kernel tree, so you might didn't got them. 
> > 
> > /drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c/
> > / /
> > /Or at least, it does a memcpy to the new buffer and it has some buffer
> > refcounting,/
> > /although I didn't go deep into the details. In any case, this might help./
> > /
> > /
> >     if (frm_to_show->fb != inst->cur_fb) {
> >         /* This frame is show exist frame and no decode output
> >          * copy frame data from frm_to_show to current CAPTURE
> >          * buffer
> >          */
> >         if ((frm_to_show->fb != NULL) &&
> >             (inst->cur_fb->base_y.size >=
> >             frm_to_show->fb->base_y.size) &&
> >             (inst->cur_fb->base_c.size >=
> >             frm_to_show->fb->base_c.size)) {
> >             memcpy((void *)inst->cur_fb->base_y.va,
> >                 (void *)frm_to_show->fb->base_y.va,
> >                 frm_to_show->fb->base_y.size);
> >             memcpy((void *)inst->cur_fb->base_c.va,
> >                 (void *)frm_to_show->fb->base_c.va,
> >                 frm_to_show->fb->base_c.size);
> >         }
> > You should be talking about this code, If the picture buffer is secure and
> > protected, this memory may be prohibited memcpy, so what should we do? 
> 
> Yeah, that won't work for protected memory. But if it is in protected memory,
> doesn't that mean that you are using dmabuf for the actual buffer?

Please note that older (stateful) Mediatek drivers will are unlikely to gain
secure memory (this is old HW). But if they do, Mediatek have a firmware running
on a pretty generic co-processor that sits ont the secure side. They could
simply add a function in the firmware to solve this problem.

On the secure note, be aware that another challenge exist with the handling the
the probability context updates. I notice that, similar to most stateless
decoders, Amlogic HW requires the driver to do the update. The probability
tabled filled during decode will inevitably have to be protected. You need a
special firmware feature to copy this table back and fort to allow the
probability updates. Or have that update happen forward (a bit like the VP9
stateless uAPI), but executed in secure space with compressed header being
parsed there* (firmware, OPT-TEE, ...).

* in Widevine L1, there is a small design error regarding VP9 and compressed
headers are encrypted

> 
> We don't have any codec drivers that work with protected memory in the kernel,
> but the only way to support that would be through dmabuf.
> 
> Question: does VP9 indicate that a buffer will be repeated when you receive
> the first buffer of that sequence? I.e., do you know when you dequeue the
> first buffer that it will be repeated? Or do you only discover that
> afterwards?
> 
> I'm also assuming that you are talking about a stateful codec driver, not a
> stateless codec driver, correct?
> 
> Regards,
> 
> 	Hans
> 
> > Our idea is to dque this buffer to user space multiple times through the videobuf2 framework.
> > But v4l2 does not support this behavior, if the buffer is not returned to the driver, it will be output again.
> > 
> > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > nanxin.qin@amlogic.com
> > 
> >      
> >     *From:* Hans Verkuil <mailto:hverkuil-cisco@xs4all.nl>
> >     *Date:* 2022-07-14 15:59
> >     *To:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; arch-proaudio <mailto:arch-proaudio@lists.archlinux.org>
> >     *CC:* hui.zhang <mailto:hui.zhang@amlogic.com>; zhi.zhou <mailto:zhi.zhou@amlogic.com>
> >     *Subject:* Re: The problem of VP9 decoder adapter V4L2.
> >     [ EXTERNAL EMAIL ]
> >      
> >     Hmm, it looks I missed the earlier email.
> >      
> >     In any case, please post this to the linux-media@vger.kernel.org mailinglist.
> >      
> >     Please mention which driver you are using, is it drivers/staging/media/meson/vdec?
> >      
> >     If so, then clearly mention this in the subject line.
> >      
> >     If it is an out-of-tree driver, then also mention that, ideally with a link to the code.
> >      
> >     By posting to the mailinglist you'll reach the real experts on codecs.
> >      
> >     Based on a quick look at the meson driver it looks like it does not support this
> >     feature. It can detect it, but it doesn't appear to do anything with that
> >     information. But the mediatek decoder appears to handle this situation properly:
> >      
> >     drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
> >      
> >     Or at least, it does a memcpy to the new buffer and it has some buffer refcounting,
> >     although I didn't go deep into the details. In any case, this might help.
> >      
> >     Regards,
> >      
> >     Hans
> >      
> >     On 7/14/22 09:32, nanxin.qin@amlogic.com wrote:
> >     > Hi, Hans
> >     >
> >     > I'm sorry to bother you again. Do you have any good suggestions for
> > this problem? The VP9 spec development team suggested a change to the V4L2
> > API to allow the vb2 can be deque more times, which seemed difficult.
> >     >
> >     >
> >     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >     > nanxin.qin@amlogic.com
> >     >
> >     >      
> >     >     *From:* xiaohang.cui@amlogic.com <mailto:xiaohang.cui@amlogic.com>
> >     >     *Date:* 2022-06-02 16:26
> >     >     *To:* arch-proaudio <mailto:arch-proaudio@lists.archlinux.org>
> >     >     *CC:* hverkuil-cisco@xs4all.nl <mailto:hverkuil-cisco@xs4all.nl>; hui.zhang <mailto:hui.zhang@amlogic.com>; Nanxin Qin <mailto:Nanxin.Qin@amlogic.com>
> >     >     *Subject:* Re: Re: The problem of VP9 decoder adapter V4L2.
> >     >     Dear linux.org multi-media team,
> >     >
> >     >     I am a multimedia software engineer from AmLogic. We have
> > encountered some decoder problems on V4L2 when supporting VP9.
> >     >
> >     >     Reading the VP9 specification, show_existing_frame is a feature
> > added in intra-only to solve the problem of video conferencing. If
> > show_existing_frame is equal to 1, the decoder outputs the previously
> > decoded frame. This part is explained in the specification output process.
> >     >
> >     >     At present, we need to implement VP9 decoder based on V4L2. All
> > decoded frames need to be passed to userspace using VB2 buffer. If
> > show_existing_frame exists, the same frame may be output multiple times. If
> > VB2 buffer was dequed to userspace by APP, and no queue into the videobuf2
> > driver, then the VP9 decoder driver will fail to output the frame again
> > because the VB2 buffer has not returned to the driver, In other words the
> > buffer's owner is APP not decode driver. So the decoder cannot pass the
> > frame from the VB2 buffer again.
> >     >
> >     >     According to the above analysis, the show_existing_frame feature
> > seems to conflict with the V4L2 Videobuf2 framework because V4L2 does not
> > allow the same VB2 buffer to be output more than once.
> >     >
> >     >     I would like to ask, for VP9 decoder adaptation on V4L2, how to
> > should deal with the problem of repeated output frame?
> >     >
> >     >     I'm looking forward to receiving your reply. Thank you very much.
> >     >
> >     >     Attachment is the coded stream for reference
> > (big_buck_bunny_720p.mp4).
> >     >
> >     >    
> >     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >     >
> >     >     崔晓行
> >     >     SW  Department
> >     >
> >     >     Amlogic Inc. Shenzhen office
> >     >
> >     >     -------------------------------------------------------------
> >     >
> >     >     深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层
> >     >
> >     >     Tel: 0755-86315800-8169
> >     >
> >     >          
> >     >         *From:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>
> >     >         *Date:* 2022-05-25 16:50
> >     >         *To:* peter.derivaz <mailto:peter.derivaz@gmail.com>
> >     >         *CC:* agrange <mailto:agrange@google.com>; tinghai.chen <mailto:tinghai.chen@amlogic.com>; hui.zhang <mailto:hui.zhang@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; yixin.peng <mailto:yixin.peng@amlogic.com>; Gan Zhang <mailto:Gan.Zhang@amlogic.com>; kuan.hu <mailto:Kuan.Hu@amlogic.com>; miaohong.chen <mailto:miaohong.chen@amlogic.com>; lele.xiang <mailto:lele.xiang@amlogic.com>; Shihong.Zheng <mailto:shihong.zheng@amlogic.com>
> >     >         *Subject:* Re: Re: The problem of VP9 decoder adapter V4L2.
> >     >         Hi, Peter
> >     >
> >     >         Thanks for your reply, we will try to feedback this problem with Linux, we plan to implement the second solution according to your proposal, which may be more convenient for us to implement, thanks again.
> >     >
> >     >        
> >     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >     >
> >     >         nanxin.qin
> >     >         SW  Department____
> >     >
> >     >         Amlogic Inc. Shenzhen office____
> >     >
> >     >         -------------------------------------------------------------____
> >     >
> >     >         深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层____
> >     >
> >     >         Tel: 0755-86315800-8169
> >     >
> >     >              
> >     >             *From:* Peter de Rivaz <mailto:peter.derivaz@gmail.com>
> >     >             *Date:* 2022-05-25 16:33
> >     >             *To:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>
> >     >             *CC:* agrange <mailto:agrange@google.com>; tinghai.chen <mailto:tinghai.chen@amlogic.com>; hui.zhang <mailto:hui.zhang@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; yixin.peng <mailto:yixin.peng@amlogic.com>; Zhang <mailto:Gan.Zhang@amlogic.com>; kuan.hu <mailto:Kuan.Hu@amlogic.com>; miaohong.chen <mailto:miaohong.chen@amlogic.com>; lele.xiang <mailto:lele.xiang@amlogic.com>; Shihong.Zheng <mailto:shihong.zheng@amlogic.com>
> >     >             *Subject:* Re: The problem of VP9 decoder adapter V4L2.
> >     >             **[ EXTERNAL EMAIL ]**
> >     >            
> >     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >     >             I can see two choices:
> >     >             1)
> >     >             You could change the V4L2 API to allow the buffer to be returned multiple times (this would involve discussion on the Linux mailing lists as it is not something within our control).
> >     >
> >     >             2)
> >     >             You could treat the frame with show_existing_frame=1 as a normal frame with zero motion vectors and no residual.
> >     >             In other words, you just copy the reference frame data from the frame indicated by frame_to_show_map_idx into a new frame and return it.
> >     >
> >     >             Option 1 would be a bit more efficient, but option 2 is probably simpler to implement.
> >     >
> >     >             Peter de Rivaz
> >     >
> >     >             On Wed, May 25, 2022 at 8:55 AM nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com> <nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>> wrote:
> >     >
> >     >                     Dear:
> >     >                     agrange, peter.derivaz
> >     >
> >     >                     I am a multimedia software engineer from AmLogic. We have encountered some problems when supporting VP9 decoder + V4L2.
> >     >
> >     >                     Reading the VP9 specification, show_existing_frame
> > is a feature added in intra-only to solve the problem of video conferencing.
> > If show_existing_frame is equal to 1, the decoder outputs the previously
> > decoded frame. This part is explained in the specification output process.
> >     >
> >     >                     At present, we need to implement VP9 decoder based
> > on V4L2. All decoded frames need to be passed to userspace using VB2 buffer.
> > If show_existing_frame exists, the same frame may be output multiple times.
> > If VB2 buffer was dequed to userspace by APP, and no queue into the
> > videobuf2 driver, then the VP9 decoder driver will fail to output the frame
> > again because the VB2 buffer has not returned to the driver, In other words
> > the buffer's onwer is APP not decode driver. So the decoder cannot pass the
> > frame from the VB2 buffer again.
> >     >
> >     >                     According to the above analysis, the
> > show_existing_frame feature seems to conflict with the V4L2 Videobuf2
> > framework because V4L2 does not allow the same VB2 buffer to be output more
> > than once.
> >     >
> >     >                     I would like to ask, for VP9 decoder adaptation
> > V4L2 should be how to deal with the problem of repeated output frame?
> >     >
> >     >                     Thank you very much for your reply.
> >     >
> >     >                     Attached is the code stream for reference
> > (big_buck_bunny_720p.mp4).
> >     >
> >     >                        
> >     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >     >
> >     >                         nanxin.qin
> >     >                         SW  Department____
> >     >
> >     >                         Amlogic Inc. Shenzhen office____
> >     >
> >     >                         -------------------------------------------------------------____
> >     >
> >     >                         深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层____
> >     >
> >     >                         Tel: 0755-86315800-8169
> >     >
> >      
> > 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: The problem of VP9 decoder adapter V4L2.
       [not found]                     ` <2022071513513162306438@amlogic.com>
@ 2022-07-15 10:56                       ` Hans Verkuil
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2022-07-15 10:56 UTC (permalink / raw)
  To: nanxin.qin, Nicolas Dufresne, xiaohang.cui, arch-proaudio
  Cc: hui.zhang, zhi.zhou, linux-media, tim.yao


On 7/15/22 07:51, nanxin.qin@amlogic.com wrote:
> Thank you very much for your support. 
> 
> We are going to use hardware copy (hardware has secure permissions) to solve this problem. 
> We also considered waiting for the vb2 buffer in the driver, and then marked the buffer done. 
> If the dmabuf does not return to the driver in a short time, it may affect the decoding process, 
> so it may not be suitable to do delay. 
> 
> Nicolas, Hans, do we have a chance in the future to solve this problem in v4l2 stateful?

It's very unlikely *unless* someone needs this for a driver that is posted
for inclusion into the kernel or is already in the kernel.

Spending time to come up with a solution for an out-of-tree driver is not
going to happen, that's not really our work.

One simple solution, however, is to simply dequeue an empty buffer marked
with V4L2_BUF_FLAG_ERROR: this indicates that something was received, but the
contents is likely to be corrupt (well, empty in this case), and userspace is
expected to skip that buffer. In the case of a codec when used for video
playback that would mean repeating the last valid frame. Which is what you want.

It feels like a hack, but on the other hand, this is how you are supposed to
handle a buffer marked with that flag. Note that this is limited to repeating
the last frame, it won't work if you repeat an earlier frame. But likely
repeating the last frame is what you need here.

A proper solution would likely need a way to indicate a reference to the frame
that needs to be repeated, but that's a lot more work.

Regards,

	Hans

> 
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> nanxin.qin@amlogic.com
> 
>      
>     *From:* Nicolas Dufresne <mailto:nicolas@ndufresne.ca>
>     *Date:* 2022-07-14 22:00
>     *To:* Hans Verkuil <mailto:hverkuil-cisco@xs4all.nl>; nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; arch-proaudio <mailto:arch-proaudio@lists.archlinux.org>
>     *CC:* hui.zhang <mailto:hui.zhang@amlogic.com>; zhi.zhou <mailto:zhi.zhou@amlogic.com>; linux-media <mailto:linux-media@vger.kernel.org>
>     *Subject:* Re: The problem of VP9 decoder adapter V4L2.
>     [ EXTERNAL EMAIL ]
>      
>     Hi,
>      
>     here's some note of the discussion we had on IRC. First thing to mention, this
>     is a none-issue for stateless decoders, since the special frame with
>     show_existing_frame flag set are just never sent to the kernel in that case.
>     This only affect stateful decoders (which not much design time was put in
>     really).
>      
>     The show_existing_frame flag have two uses cases. The most common one is for
>     video playback, it is used to simulate B-Frame (future references). In the case,
>     the frames is first decoded, but not outputed. It is part of the same temporal
>     unit (super frame) as another frame. This frame will use a VB2 buffer, but it
>     won't be displayed. In that case, it will only be displayed later once, with
>     show_existing_frame, and for that, you can just delay the buffer_done marking.
>      
>     The problematic case would be for still picture handling (video with repeated
>     images and no noise). In this case, the same frames is being displayed over and
>     over. You could use this while encoding slide deck. There is currently no zero-
>     copy mechanism in place to allow this in VB2 design. I've made a suggestion to
>     Hans (which I doubt will be adopted), so I will leave that there for now.
>      
>     regards,
>     Nicolas
>      
>     Le jeudi 14 juillet 2022 à 13:03 +0200, Hans Verkuil a écrit :
>     >
>     > On 7/14/22 12:18, nanxin.qin@amlogic.com wrote:
>     > > Hi, Hans 
>     > > thanks for your reply. Currently, our source code has not been submitted to
>     > > the kernel tree, so you might didn't got them. 
>     > >
>     > > /drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c/
>     > > / /
>     > > /Or at least, it does a memcpy to the new buffer and it has some buffer
>     > > refcounting,/
>     > > /although I didn't go deep into the details. In any case, this might help./
>     > > /
>     > > /
>     > >     if (frm_to_show->fb != inst->cur_fb) {
>     > >         /* This frame is show exist frame and no decode output
>     > >          * copy frame data from frm_to_show to current CAPTURE
>     > >          * buffer
>     > >          */
>     > >         if ((frm_to_show->fb != NULL) &&
>     > >             (inst->cur_fb->base_y.size >=
>     > >             frm_to_show->fb->base_y.size) &&
>     > >             (inst->cur_fb->base_c.size >=
>     > >             frm_to_show->fb->base_c.size)) {
>     > >             memcpy((void *)inst->cur_fb->base_y.va,
>     > >                 (void *)frm_to_show->fb->base_y.va,
>     > >                 frm_to_show->fb->base_y.size);
>     > >             memcpy((void *)inst->cur_fb->base_c.va,
>     > >                 (void *)frm_to_show->fb->base_c.va,
>     > >                 frm_to_show->fb->base_c.size);
>     > >         }
>     > > You should be talking about this code, If the picture buffer is secure and
>     > > protected, this memory may be prohibited memcpy, so what should we do? 
>     >
>     > Yeah, that won't work for protected memory. But if it is in protected memory,
>     > doesn't that mean that you are using dmabuf for the actual buffer?
>      
>     Please note that older (stateful) Mediatek drivers will are unlikely to gain
>     secure memory (this is old HW). But if they do, Mediatek have a firmware running
>     on a pretty generic co-processor that sits ont the secure side. They could
>     simply add a function in the firmware to solve this problem.
>      
>     On the secure note, be aware that another challenge exist with the handling the
>     the probability context updates. I notice that, similar to most stateless
>     decoders, Amlogic HW requires the driver to do the update. The probability
>     tabled filled during decode will inevitably have to be protected. You need a
>     special firmware feature to copy this table back and fort to allow the
>     probability updates. Or have that update happen forward (a bit like the VP9
>     stateless uAPI), but executed in secure space with compressed header being
>     parsed there* (firmware, OPT-TEE, ...).
>      
>     * in Widevine L1, there is a small design error regarding VP9 and compressed
>     headers are encrypted
>      
>     >
>     > We don't have any codec drivers that work with protected memory in the kernel,
>     > but the only way to support that would be through dmabuf.
>     >
>     > Question: does VP9 indicate that a buffer will be repeated when you receive
>     > the first buffer of that sequence? I.e., do you know when you dequeue the
>     > first buffer that it will be repeated? Or do you only discover that
>     > afterwards?
>     >
>     > I'm also assuming that you are talking about a stateful codec driver, not a
>     > stateless codec driver, correct?
>     >
>     > Regards,
>     >
>     > Hans
>     >
>     > > Our idea is to dque this buffer to user space multiple times through the videobuf2 framework.
>     > > But v4l2 does not support this behavior, if the buffer is not returned to the driver, it will be output again.
>     > >
>     > >
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     > > nanxin.qin@amlogic.com
>     > >
>     > >      
>     > >     *From:* Hans Verkuil <mailto:hverkuil-cisco@xs4all.nl>
>     > >     *Date:* 2022-07-14 15:59
>     > >     *To:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; arch-proaudio <mailto:arch-proaudio@lists.archlinux.org>
>     > >     *CC:* hui.zhang <mailto:hui.zhang@amlogic.com>; zhi.zhou <mailto:zhi.zhou@amlogic.com>
>     > >     *Subject:* Re: The problem of VP9 decoder adapter V4L2.
>     > >     [ EXTERNAL EMAIL ]
>     > >      
>     > >     Hmm, it looks I missed the earlier email.
>     > >      
>     > >     In any case, please post this to the linux-media@vger.kernel.org mailinglist.
>     > >      
>     > >     Please mention which driver you are using, is it drivers/staging/media/meson/vdec?
>     > >      
>     > >     If so, then clearly mention this in the subject line.
>     > >      
>     > >     If it is an out-of-tree driver, then also mention that, ideally with a link to the code.
>     > >      
>     > >     By posting to the mailinglist you'll reach the real experts on codecs.
>     > >      
>     > >     Based on a quick look at the meson driver it looks like it does not support this
>     > >     feature. It can detect it, but it doesn't appear to do anything with that
>     > >     information. But the mediatek decoder appears to handle this situation properly:
>     > >      
>     > >     drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
>     > >      
>     > >     Or at least, it does a memcpy to the new buffer and it has some buffer refcounting,
>     > >     although I didn't go deep into the details. In any case, this might help.
>     > >      
>     > >     Regards,
>     > >      
>     > >     Hans
>     > >      
>     > >     On 7/14/22 09:32, nanxin.qin@amlogic.com wrote:
>     > >     > Hi, Hans
>     > >     >
>     > >     > I'm sorry to bother you again. Do you have any good suggestions for
>     > > this problem? The VP9 spec development team suggested a change to the V4L2
>     > > API to allow the vb2 can be deque more times, which seemed difficult.
>     > >     >
>     > >     >
>     > >    
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     > >     > nanxin.qin@amlogic.com
>     > >     >
>     > >     >      
>     > >     >     *From:* xiaohang.cui@amlogic.com <mailto:xiaohang.cui@amlogic.com>
>     > >     >     *Date:* 2022-06-02 16:26
>     > >     >     *To:* arch-proaudio <mailto:arch-proaudio@lists.archlinux.org>
>     > >     >     *CC:* hverkuil-cisco@xs4all.nl <mailto:hverkuil-cisco@xs4all.nl>; hui.zhang <mailto:hui.zhang@amlogic.com>; Nanxin Qin <mailto:Nanxin.Qin@amlogic.com>
>     > >     >     *Subject:* Re: Re: The problem of VP9 decoder adapter V4L2.
>     > >     >     Dear linux.org multi-media team,
>     > >     >
>     > >     >     I am a multimedia software engineer from AmLogic. We have
>     > > encountered some decoder problems on V4L2 when supporting VP9.
>     > >     >
>     > >     >     Reading the VP9 specification, show_existing_frame is a feature
>     > > added in intra-only to solve the problem of video conferencing. If
>     > > show_existing_frame is equal to 1, the decoder outputs the previously
>     > > decoded frame. This part is explained in the specification output process.
>     > >     >
>     > >     >     At present, we need to implement VP9 decoder based on V4L2. All
>     > > decoded frames need to be passed to userspace using VB2 buffer. If
>     > > show_existing_frame exists, the same frame may be output multiple times. If
>     > > VB2 buffer was dequed to userspace by APP, and no queue into the videobuf2
>     > > driver, then the VP9 decoder driver will fail to output the frame again
>     > > because the VB2 buffer has not returned to the driver, In other words the
>     > > buffer's owner is APP not decode driver. So the decoder cannot pass the
>     > > frame from the VB2 buffer again.
>     > >     >
>     > >     >     According to the above analysis, the show_existing_frame feature
>     > > seems to conflict with the V4L2 Videobuf2 framework because V4L2 does not
>     > > allow the same VB2 buffer to be output more than once.
>     > >     >
>     > >     >     I would like to ask, for VP9 decoder adaptation on V4L2, how to
>     > > should deal with the problem of repeated output frame?
>     > >     >
>     > >     >     I'm looking forward to receiving your reply. Thank you very much.
>     > >     >
>     > >     >     Attachment is the coded stream for reference
>     > > (big_buck_bunny_720p.mp4).
>     > >     >
>     > >     >    
>     > >    
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     > >     >
>     > >     >     崔晓行
>     > >     >     SW  Department
>     > >     >
>     > >     >     Amlogic Inc. Shenzhen office
>     > >     >
>     > >     >     -------------------------------------------------------------
>     > >     >
>     > >     >     深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层
>     > >     >
>     > >     >     Tel: 0755-86315800-8169
>     > >     >
>     > >     >          
>     > >     >         *From:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>
>     > >     >         *Date:* 2022-05-25 16:50
>     > >     >         *To:* peter.derivaz <mailto:peter.derivaz@gmail.com>
>     > >     >         *CC:* agrange <mailto:agrange@google.com>; tinghai.chen <mailto:tinghai.chen@amlogic.com>; hui.zhang <mailto:hui.zhang@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; yixin.peng <mailto:yixin.peng@amlogic.com>; Gan Zhang <mailto:Gan.Zhang@amlogic.com>; kuan.hu <mailto:Kuan.Hu@amlogic.com>; miaohong.chen <mailto:miaohong.chen@amlogic.com>; lele.xiang <mailto:lele.xiang@amlogic.com>; Shihong.Zheng <mailto:shihong.zheng@amlogic.com>
>     > >     >         *Subject:* Re: Re: The problem of VP9 decoder adapter V4L2.
>     > >     >         Hi, Peter
>     > >     >
>     > >     >         Thanks for your reply, we will try to feedback this problem with Linux, we plan to implement the second solution according to your proposal, which may be more convenient for us to implement, thanks again.
>     > >     >
>     > >     >        
>     > >    
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     > >     >
>     > >     >         nanxin.qin
>     > >     >         SW  Department____
>     > >     >
>     > >     >         Amlogic Inc. Shenzhen office____
>     > >     >
>     > >     >         -------------------------------------------------------------____
>     > >     >
>     > >     >         深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层____
>     > >     >
>     > >     >         Tel: 0755-86315800-8169
>     > >     >
>     > >     >              
>     > >     >             *From:* Peter de Rivaz <mailto:peter.derivaz@gmail.com>
>     > >     >             *Date:* 2022-05-25 16:33
>     > >     >             *To:* nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>
>     > >     >             *CC:* agrange <mailto:agrange@google.com>; tinghai.chen <mailto:tinghai.chen@amlogic.com>; hui.zhang <mailto:hui.zhang@amlogic.com>; xiaohang.cui <mailto:xiaohang.cui@amlogic.com>; yixin.peng <mailto:yixin.peng@amlogic.com>; Zhang <mailto:Gan.Zhang@amlogic.com>; kuan.hu <mailto:Kuan.Hu@amlogic.com>; miaohong.chen <mailto:miaohong.chen@amlogic.com>; lele.xiang <mailto:lele.xiang@amlogic.com>; Shihong.Zheng <mailto:shihong.zheng@amlogic.com>
>     > >     >             *Subject:* Re: The problem of VP9 decoder adapter V4L2.
>     > >     >             **[ EXTERNAL EMAIL ]**
>     > >     >            
>     > >    
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     > >     >             I can see two choices:
>     > >     >             1)
>     > >     >             You could change the V4L2 API to allow the buffer to be returned multiple times (this would involve discussion on the Linux mailing lists as it is not something within our control).
>     > >     >
>     > >     >             2)
>     > >     >             You could treat the frame with show_existing_frame=1 as a normal frame with zero motion vectors and no residual.
>     > >     >             In other words, you just copy the reference frame data from the frame indicated by frame_to_show_map_idx into a new frame and return it.
>     > >     >
>     > >     >             Option 1 would be a bit more efficient, but option 2 is probably simpler to implement.
>     > >     >
>     > >     >             Peter de Rivaz
>     > >     >
>     > >     >             On Wed, May 25, 2022 at 8:55 AM nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com> <nanxin.qin@amlogic.com <mailto:nanxin.qin@amlogic.com>> wrote:
>     > >     >
>     > >     >                     Dear:
>     > >     >                     agrange, peter.derivaz
>     > >     >
>     > >     >                     I am a multimedia software engineer from AmLogic. We have encountered some problems when supporting VP9 decoder + V4L2.
>     > >     >
>     > >     >                     Reading the VP9 specification, show_existing_frame
>     > > is a feature added in intra-only to solve the problem of video conferencing.
>     > > If show_existing_frame is equal to 1, the decoder outputs the previously
>     > > decoded frame. This part is explained in the specification output process.
>     > >     >
>     > >     >                     At present, we need to implement VP9 decoder based
>     > > on V4L2. All decoded frames need to be passed to userspace using VB2 buffer.
>     > > If show_existing_frame exists, the same frame may be output multiple times.
>     > > If VB2 buffer was dequed to userspace by APP, and no queue into the
>     > > videobuf2 driver, then the VP9 decoder driver will fail to output the frame
>     > > again because the VB2 buffer has not returned to the driver, In other words
>     > > the buffer's onwer is APP not decode driver. So the decoder cannot pass the
>     > > frame from the VB2 buffer again.
>     > >     >
>     > >     >                     According to the above analysis, the
>     > > show_existing_frame feature seems to conflict with the V4L2 Videobuf2
>     > > framework because V4L2 does not allow the same VB2 buffer to be output more
>     > > than once.
>     > >     >
>     > >     >                     I would like to ask, for VP9 decoder adaptation
>     > > V4L2 should be how to deal with the problem of repeated output frame?
>     > >     >
>     > >     >                     Thank you very much for your reply.
>     > >     >
>     > >     >                     Attached is the code stream for reference
>     > > (big_buck_bunny_720p.mp4).
>     > >     >
>     > >     >                        
>     > >    
>     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>     > >     >
>     > >     >                         nanxin.qin
>     > >     >                         SW  Department____
>     > >     >
>     > >     >                         Amlogic Inc. Shenzhen office____
>     > >     >
>     > >     >                         -------------------------------------------------------------____
>     > >     >
>     > >     >                         深圳市南山区科技南四道8号创维半导体设计大厦东座9-10层____
>     > >     >
>     > >     >                         Tel: 0755-86315800-8169
>     > >     >
>     > >      
>     > >
>      
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-15 10:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2022052415253222043142@amlogic.com>
     [not found] ` <2022052416125814193863@amlogic.com>
     [not found]   ` <2022052515525877798112@amlogic.com>
     [not found]     ` <CAFixvNP+f1LPCx32nhbiK_T_Hfyrqc39u-UVBR3T6MuLb=GDmQ@mail.gmail.com>
     [not found]       ` <2022052516504276013416@amlogic.com>
     [not found]         ` <2022060216264643796616@amlogic.com>
     [not found]           ` <202207141532283153508@amlogic.com>
     [not found]             ` <8d61af39-9cd5-3e03-6b22-3e77625b81b6@xs4all.nl>
     [not found]               ` <2022071418182653336122@amlogic.com>
2022-07-14 11:03                 ` The problem of VP9 decoder adapter V4L2 Hans Verkuil
2022-07-14 14:00                   ` Nicolas Dufresne
     [not found]                     ` <2022071513513162306438@amlogic.com>
2022-07-15 10:56                       ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).