[FFmpeg-devel] [PATCH 3/7] lavfi/vf_pp: convert to the video_enc_params API

Michael Niedermayer michael at niedermayer.cc
Fri Dec 4 19:03:15 EET 2020


On Fri, Oct 02, 2020 at 08:03:27PM +0200, Anton Khirnov wrote:
> ---
>  libavfilter/Makefile        |  2 +-
>  libavfilter/qp_table.c      | 66 +++++++++++++++++++++++++++++++++++++
>  libavfilter/qp_table.h      | 32 ++++++++++++++++++
>  libavfilter/vf_pp.c         | 19 ++++++++---
>  tests/fate/filter-video.mak |  6 ++--

I think the qp_table changes should be in a seperate patch


[...]
> +int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h)
> +{
> +    AVFrameSideData *sd;
> +    AVVideoEncParams *par;
> +    unsigned int mb_h = (frame->height + 15) / 16;
> +    unsigned int mb_w = (frame->width + 15) / 16;
> +    unsigned int nb_mb = mb_h * mb_w;
> +    unsigned int block_idx;
> +
> +    *table = NULL;
> +
> +    sd = av_frame_get_side_data(frame, AV_FRAME_DATA_VIDEO_ENC_PARAMS);
> +    if (!sd)
> +        return 0;

> +    par = (AVVideoEncParams*)sd->data;
> +    if (par->type != AV_VIDEO_ENC_PARAMS_MPEG2 ||
> +        (par->nb_blocks != 0 && par->nb_blocks != nb_mb))
> +        return 0;

This should be an error of some kind (patchwelcome or something else indicating lack of support)


> +
> +    *table = av_malloc(nb_mb);
> +    if (!*table)
> +        return AVERROR(ENOMEM);
> +    if (table_w)
> +        *table_w = mb_w;
> +    if (table_h)
> +        *table_h = mb_h;
> +
> +    if (par->nb_blocks == 0) {
> +        memset(*table, par->qp, nb_mb);
> +        return 0;
> +    }
> +
> +    for (block_idx = 0; block_idx < nb_mb; block_idx++) {
> +        AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx);
> +        (*table)[block_idx] = par->qp + b->delta_qp;
> +    }
> +
> +    return 0;
> +}
> +
> diff --git a/libavfilter/qp_table.h b/libavfilter/qp_table.h
> new file mode 100644
> index 0000000000..5a9ec889b6
> --- /dev/null
> +++ b/libavfilter/qp_table.h
> @@ -0,0 +1,32 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#ifndef AVFILTER_QP_TABLE_H
> +#define AVFILTER_QP_TABLE_H
> +
> +#include <stdint.h>
> +
> +#include "libavutil/frame.h"
> +

> +/**
> + * Extract a "classic" libpostproc-style QP table from AVVideoEncParams side
> + * data.
> + */

This description is inadequate i think.
Few except me and you will understand what that is
I think the description should be sufficient to use the function without having
to read its implementation

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20201204/973063cb/attachment.sig>


More information about the ffmpeg-devel mailing list