- if (!uspp->qp) {
- qp_table = av_frame_get_qp_table(in, &qp_stride, &uspp->qscale_type);
-
- if (qp_table && !uspp->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
- int w, h;
-
- /* if the qp stride is not set, it means the QP are only defined on
- * a line basis */
- if (!qp_stride) {
- w = AV_CEIL_RSHIFT(inlink->w, 4);
- h = 1;
- } else {
- w = qp_stride;
- h = AV_CEIL_RSHIFT(inlink->h, 4);
- }
-
- if (w * h > uspp->non_b_qp_alloc_size) {
- int ret = av_reallocp_array(&uspp->non_b_qp_table, w, h);
- if (ret < 0) {
- uspp->non_b_qp_alloc_size = 0;
- return ret;
- }
- uspp->non_b_qp_alloc_size = w * h;
- }
+ if (!uspp->qp && (uspp->use_bframe_qp || in->pict_type != AV_PICTURE_TYPE_B)) {
+ ret = ff_qp_table_extract(in, &qp_table, &qp_stride, NULL, &uspp->qscale_type);
+ if (ret < 0) {
+ av_frame_free(&in);
+ return ret;
+ }