On Fri, Oct 04, 2024 at 11:07:33PM +0200, Martin Schitter wrote: [...] > +static int half_add_alpha(AVCodecContext *avctx, AVFrame *frame, const > AVPacket *pkt) > +{ > + /* ffmpeg doesn't provide RGB half bit depth without alpha channel right > now > + * we simply add an opaque alpha layer as workaround */ > + > + int lw; > + const size_t soh = 2; > + const uint16_t opaque = 0x3c00; > + > + lw = frame->width; > + > + for(int y = 0; y < frame->height; y++){ > + for(int x = 0; x < frame->width; x++){ > + memcpy(&frame->data[0][soh*4*(lw*y + x)], &pkt->data[soh*3*(lw*y > + x)], soh*3); > + memcpy(&frame->data[0][soh*(4*(lw*y + x) + 3)], &opaque, soh);
opaque is in native byte order within 16bit, pkt->data is a byte array copying them together cannot be right also as this is a LE pixfmt, the 2nd part should be wrong > + } > + } > + return pkt->size; > +} > + > +/* DNxUncompressed utilizes a very dense bitpack representation of 10bit and > 12bit pixel data. > + > +Lines of Image data, which look like in their ordinary 8bit counterpart, > contain the most > +significant upper bits of the pixel data. These sections alternate with > shorter segments in > +which the complementary least significant bits of information get packed in > a gapless sequence. > + > ++----------------------+ +----------------------+ +------------------------+ > +----------~ > +| 8 m.s.bits of R[1] | | 8 m.s.bits of G[1] | | 8 m.s.bits of B[1] | > | msb R[2] ... one line > ++----------------------+ +----------------------+ +------------------------+ > +----------~ > + > ++---------------------------------------------------------------+ > +-----------~ > +| +------------+ +------------+ +------------+ +--------------+ | | > +--------~ > +| | 2 lsb R[2] | | 2 lsb B[1] | | 2 lsb G[1] | | 2 lsb R[1] | | | | > G[3]lsb ... LSB bits for line > +| +------------+ +------------+ +------------+ +--------------+ | | > +--------~ > ++---------------------------- one byte ------------------------ + > +-----------~ > + > +next line of MSB bytes... */ > + > +static int unpack_rg10(AVCodecContext *avctx, AVFrame *frame, const AVPacket > *pkt) > +{ > + int lw, msp, pack, lsp, p_off; > + uint16_t r,g,b; > + > + lw = frame->width; > + > + for(int y = 0; y < frame->height; y++){ > + for(int x = 0; x < frame->width; x++){ > + msp = pkt->data[y*3*(lw + lw/4) + 3*x]; > + p_off = y*(3*(lw + lw/4)) + 3*lw + 3*x/4; > + pack = pkt->data[p_off]; > + lsp = (pack >> (3*x%4)*2) & 0x3; I would suggest & instead of % because if the compiler doesnt optimize the modulo then it is the slower operation thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is a danger to trust the dream we wish for rather than the science we have, -- Dr. Kenneth Brown
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".