@@ -18724,8 +18724,7 @@ that value the speed drops by a factor of approximately 2. Default value is
@code{3}.
@item qp
-Force a constant quantization parameter. If not set, the filter will use the QP
-from the video stream (if available).
+Force a constant quantization parameter.
@end table
@section v360
@@ -51,9 +51,6 @@ typedef struct USPPContext {
AVCodecContext *avctx_enc[BLOCK*BLOCK];
AVFrame *frame;
AVFrame *frame_dec;
- uint8_t *non_b_qp_table;
- int non_b_qp_alloc_size;
- int use_bframe_qp;
} USPPContext;
#define OFFSET(x) offsetof(USPPContext, x)
@@ -61,7 +58,6 @@ typedef struct USPPContext {
static const AVOption uspp_options[] = {
{ "quality", "set quality", OFFSET(log2_count), AV_OPT_TYPE_INT, {.i64 = 3}, 0, MAX_LEVEL, FLAGS },
{ "qp", "force a constant quantizer parameter", OFFSET(qp), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, FLAGS },
- { "use_bframe_qp", "use B-frames' QP", OFFSET(use_bframe_qp), AV_OPT_TYPE_BOOL,{.i64 = 0}, 0, 1, FLAGS },
{ NULL }
};
@@ -182,7 +178,7 @@ static void store_slice_c(uint8_t *dst, const uint16_t *src,
static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
int dst_stride[3], int src_stride[3], int width,
- int height, uint8_t *qp_store, int qp_stride)
+ int height)
{
int x, y, i, j;
const int count = 1<<p->log2_count;
@@ -215,18 +211,8 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
memset(p->temp[i], 0, (h + 2 * block) * stride * sizeof(int16_t));
}
- if (p->qp)
- p->frame->quality = p->qp * FF_QP2LAMBDA;
- else {
- int qpsum=0;
- int qpcount = (height>>4) * (height>>4);
+ p->frame->quality = p->qp * FF_QP2LAMBDA;
- for (y = 0; y < (height>>4); y++) {
- for (x = 0; x < (width>>4); x++)
- qpsum += qp_store[x + y * qp_stride];
- }
- p->frame->quality = ff_norm_qscale((qpsum + qpcount/2) / qpcount, p->qscale_type) * FF_QP2LAMBDA;
- }
// init per MB qscale stuff FIXME
p->frame->height = height + BLOCK;
p->frame->width = width + BLOCK;
@@ -384,68 +370,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterLink *outlink = ctx->outputs[0];
AVFrame *out = in;
- int qp_stride = 0;
- uint8_t *qp_table = NULL;
-
- /* if we are not in a constant user quantizer mode and we don't want to use
- * the quantizers from the B-frames (B-frames often have a higher QP), we
- * need to save the qp table from the last non B-frame; this is what the
- * following code block does */
- 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;
- }
-
- av_assert0(w * h <= uspp->non_b_qp_alloc_size);
- memcpy(uspp->non_b_qp_table, qp_table, w * h);
- }
- }
-
if (uspp->log2_count && !ctx->is_disabled) {
- if (!uspp->use_bframe_qp && uspp->non_b_qp_table)
- qp_table = uspp->non_b_qp_table;
-
- if (qp_table || uspp->qp) {
-
- /* get a new frame if in-place is not possible or if the dimensions
- * are not multiple of 8 */
- if (!av_frame_is_writable(in) || (inlink->w & 7) || (inlink->h & 7)) {
- const int aligned_w = FFALIGN(inlink->w, 8);
- const int aligned_h = FFALIGN(inlink->h, 8);
-
- out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
- if (!out) {
- av_frame_free(&in);
- return AVERROR(ENOMEM);
- }
- av_frame_copy_props(out, in);
- out->width = in->width;
- out->height = in->height;
+ /* get a new frame if in-place is not possible or if the dimensions
+ * are not multiple of 8 */
+ if (!av_frame_is_writable(in) || (inlink->w & 7) || (inlink->h & 7)) {
+ const int aligned_w = FFALIGN(inlink->w, 8);
+ const int aligned_h = FFALIGN(inlink->h, 8);
+
+ out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
+ if (!out) {
+ av_frame_free(&in);
+ return AVERROR(ENOMEM);
}
-
- filter(uspp, out->data, in->data, out->linesize, in->linesize,
- inlink->w, inlink->h, qp_table, qp_stride);
+ av_frame_copy_props(out, in);
+ out->width = in->width;
+ out->height = in->height;
}
+
+ filter(uspp, out->data, in->data, out->linesize, in->linesize,
+ inlink->w, inlink->h);
}
if (in != out) {
@@ -473,7 +416,6 @@ static av_cold void uninit(AVFilterContext *ctx)
av_freep(&uspp->avctx_enc[i]);
}
- av_freep(&uspp->non_b_qp_table);
av_freep(&uspp->outbuf);
av_frame_free(&uspp->frame);
}