On Mon, Sep 23, 2024 at 11:16:45AM +0200, Martin Schitter wrote:
[...]
> +static av_cold int dnxuc_decode_init(AVCodecContext *avctx)
> +{
> + return 0;
> +}
unneeded
[...]
> +/* 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;
> + r = (msp << 2) + lsp;
> + // av_log(0, AV_LOG_DEBUG, "r: %04x, %02x, %02x, %02x, %d\n",
> + // r, msp, lsp, pack, p_off);
> +
> + msp = pkt->data[y*3*(lw + lw/4) + 3*x + 1];
> + p_off = y*(3*(lw + lw/4)) + 3*lw + (3*x+1)/4;
> + pack = pkt->data[p_off];
> + lsp = (pack >> ((3*x+1)%4)*2) & 0x3;
> + g = (msp << 2) + lsp;
> + // av_log(0, AV_LOG_DEBUG, "g: %04x, %02x, %02x, %02x, %d\n",
> + // g, msp, lsp, pack, p_off);
> +
> + msp = pkt->data[y*3*(lw + lw/4) + 3*x + 2];
> + p_off = y*(3*(lw + lw/4)) + 3*lw + (3*x+2)/4;
> + pack = pkt->data[p_off];
> + lsp = (pack >> ((3*x+2)%4)*2) & 0x3;
> + b = (msp << 2) + lsp;
> + // av_log(0, AV_LOG_DEBUG, "b: %04x, %02x, %02x, %02x, %d\n\n",
> + // b, msp, lsp, pack, p_off);
> +
> + memcpy(&frame->data[2][2*(y*lw + x)], &r, 2);
> + memcpy(&frame->data[0][2*(y*lw + x)], &g, 2);
> + memcpy(&frame->data[1][2*(y*lw + x)], &b, 2);
this probably should be AV_WL16() or something like that
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The smallest minority on earth is the individual. Those who deny
individual rights cannot claim to be defenders of minorities. - Ayn Rand
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list [email protected] https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
