mardi 31 mars 2020

Segmentation Fault accessing qpscale_table in AVFrame

I'm modifying this file slightly: https://gist.github.com/yohhoy/f0444d3fc47f2bb2d0e2 This code decodes a video and makes opencv Mats out of the frame pixels as it goes.

In particular I only want to grab frames that have specific macroblock-related data. I'm attempting to get that data like this:

total_qp = get_total_qp(decframe->qscale_table, mb_width, mb_height, mb_stride);

However, whenever I try to access the data by iterating over that array, I get a segmentation fault:

static float get_total_qp(int8_t *qscale_table, int mb_width, int mb_height, int mb_stride)
{
    int mb_count = mb_height * mb_width;
    int y, x;
    float qp_total = 0.0f;
    for (y = 0; y < mb_height; y++) {
        for (x = 0; x < mb_width; x++) {
            qp_total += qscale_table[x + y * mb_stride]; <-- SEGFAULT here
        }
    }
    return qp_total;
}

I've also tried sending in: frame->qscale_table

and I've tried populating it, but this own't compile because it can't find that function:

int8_t *qscale_table = av_frame_get_qp_table(decframe->qscale_table, &mb_stride, &qscale_type);

So my question is this: Given an AVFrame* how do I ensure that the qscale_table is populated and access it?

Aucun commentaire:

Enregistrer un commentaire