<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi all,<div><br></div><div>I've been trying to find a way to extract dequantized DCT coefficients, and here's what I've come up with so far:<br><br><div>static void print_macroblocks(const H264Context *h, H264SliceContext *sl) {</div><div>    int frame_width = h->width;</div><div>    int frame_height = h->height;</div><div>    int mb_width = frame_width / h->mb_width;   // Number of macroblocks horizontally</div><div>    int mb_height = frame_height / h->mb_height; // Number of macroblocks vertically</div><div>    int pixel_shift = h->pixel_shift; // 0 for 8-bit, 1 for higher bit depth</div><div>    int block_width;</div><div>    int block_height;</div><div><br></div><div>    printf("frame_width: %d, frame_height: %d, mb_width: %d, mb_height: %d\n", frame_width, frame_height, mb_width, mb_height);</div><div><br></div><div>    for (int channel = 0; channel < 3; channel++) {</div><div>        printf("Channel");</div><div>        if (channel == 0) {</div><div>            printf(" Y:\n");</div><div>        } else if (channel == 1) {</div><div>            printf(" Cb:\n");</div><div>        } else {</div><div>            printf(" Cr:\n");</div><div>        }</div><div><br></div><div>        for (int mb_y = 0; mb_y < mb_height; mb_y++) {</div><div>            for (int mb_x = 0; mb_x < mb_width; mb_x++) {</div><div>                printf("Macroblock [%d, %d]:\n", mb_y, mb_x);</div><div><br></div><div>                // Adjust block dimensions based on chroma format</div><div>                block_width = (channel == 0) ? 16 : 16 >> (CHROMA422(h) ? 1 : CHROMA444(h) ? 0 : 1);</div><div>                block_height = (channel == 0) ? 16 : 16 >> (CHROMA422(h) ? 0 : CHROMA444(h) ? 0 : 1);</div><div><br></div><div>                for (int sub_y = 0; sub_y < block_height; sub_y++) {</div><div>                    for (int sub_x = 0; sub_x < block_width; sub_x++) {</div><div>                        int index = ((mb_y * block_height + sub_y) * frame_width + (mb_x * block_width + sub_x)) << pixel_shift;</div><div>                        if (channel == 0 && sl->intra16x16_pred_mode == 1 && sub_x < 4 && sub_y < 4) {</div><div>                            printf("%d ", sl->mb_luma_dc[0][sub_y * 4 + sub_x]);</div><div>                        } else {</div><div>                            printf("%d ", sl->mb[index]);</div><div>                        }</div><div>                    }</div><div>                    printf("\n");</div><div>                }</div><div>            }</div><div>        }</div><div>    }</div><div>}</div></div><div><br></div><div>I'm calling this function at the end of ff_h264_decode_mb_cabac and ff_h264_decode_mb_cavlc. Could anyone tell me if I'm on the right track? If so, I'm thinking of returning this as another type of side data a la AV_FRAME_DATA_MOTION_VECTORS. Would that be the right direction? Thank you so much for your help in advance!</div><div><br></div><div>Cheers,</div><div>Peter</div></div></div></div></div></div>