[FFmpeg-devel] [FFmpeg-cvslog] avcodec/cfhd: add bayer support

Michael Niedermayer michael at niedermayer.cc
Tue Jul 30 13:25:56 EEST 2019


On Mon, Jul 29, 2019 at 06:22:29PM +0200, Carl Eugen Hoyos wrote:
> Am Mo., 29. Juli 2019 um 18:07 Uhr schrieb Paul B Mahol <onemda at gmail.com>:
> >
> > On Mon, Jul 29, 2019 at 6:05 PM Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
> >
> > > Am Mo., 29. Juli 2019 um 16:35 Uhr schrieb Paul B Mahol <git at videolan.org
> > > >:
> > >
> > > > +static inline void process_bayer(AVFrame *frame)
> > > > +{
> > > > +    const int linesize = frame->linesize[0];
> > > > +    uint16_t *r = (uint16_t *)frame->data[0];
> > > > +    uint16_t *g1 = (uint16_t *)(frame->data[0] + 2);
> > > > +    uint16_t *g2 = (uint16_t *)(frame->data[0] + frame->linesize[0]);
> > > > +    uint16_t *b = (uint16_t *)(frame->data[0] + frame->linesize[0] + 2);
> > > > +    const int mid = 2048;
> > > > +
> > > > +    for (int y = 0; y < frame->height >> 1; y++) {
> > > > +        for (int x = 0; x < frame->width; x += 2) {
> > > > +            int R, G1, G2, B;
> > > > +            int g, rg, bg, gd;
> > > > +
> > > > +            g  = r[x];
> > > > +            rg = g1[x];
> > > > +            bg = g2[x];
> > > > +            gd = b[x];
> > > > +            gd -= mid;
> > > > +
> > > > +            R  = (rg - mid) * 2 + g;
> > > > +            G1 = g + gd;
> > > > +            G2 = g - gd;
> > > > +            B  = (bg - mid) * 2 + g;
> > > > +
> > > > +            R  = av_clip_uintp2(R  * 16, 16);
> > > > +            G1 = av_clip_uintp2(G1 * 16, 16);
> > > > +            G2 = av_clip_uintp2(G2 * 16, 16);
> > > > +            B  = av_clip_uintp2(B  * 16, 16);
> > > > +
> > > > +            r[x]  = R;
> > > > +            g1[x] = G1;
> > > > +            g2[x] = G2;
> > > > +            b[x]  = B;
> > >
> > > Doesn't this mean you have to disable direct rendering?
> > >
> >
> > Nope. Do you even know what is DR for?
> 
> The way I remembered was that there are access limitations for
> direct rendering.

Prior to 2.0 there where buffer_hints that allowed a decoder to
specify that it would not read from its buffer.

One could set FF_BUFFER_HINTS_VALID without FF_BUFFER_HINTS_READABLE
to indicate that a decoder would not need to read from a frame. (some
decoders did this IIRC)
So the allocation code could place the frame in final memory even if that
would be slow or impossible to read.
I do not know if that was actually done by any user applications but
it was supported.

Thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190730/7bf360f0/attachment.sig>


More information about the ffmpeg-devel mailing list