[FFmpeg-devel] [PATCH 2/5] libxvid: add working lumimasking

Michael Niedermayer michaelni at gmx.at
Sun Jul 28 14:53:18 CEST 2013


On Sat, Jul 27, 2013 at 04:32:31PM -0700, Timothy Gu wrote:
> The old implementation does not specify the param and is not usable.
> ---
>  doc/encoders.texi    | 17 +++++++++++++++++
>  libavcodec/libxvid.c | 28 ++++++++++++++++++++++++++--
>  2 files changed, 43 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index c703000..a42e7ba 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1339,6 +1339,23 @@ distortion-based search using square pattern.
>  
>  @end table
>  
> + at item lumi_masking_mode
> +Set human visual system masking mode. Possible values:
> +
> + at c FIXME: I'm not able to explain the difference between the modes.
> + at c        Need someone who is more familiar with this.
> + at table @samp
> + at item off
> +Disable masking.
> +
> + at item lumi
> +Luminance masking.
> +
> + at item variance
> +Variance masking.
> +
> + at end table
> +
>  @end table
>  
>  @section png
> diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
> index 05a12db..15b3734 100644
> --- a/libavcodec/libxvid.c
> +++ b/libavcodec/libxvid.c
> @@ -63,6 +63,7 @@ struct xvid_context {
>      int twopassfd;
>      unsigned char *intra_matrix;   /**< P-Frame Quant Matrix */
>      unsigned char *inter_matrix;   /**< I-Frame Quant Matrix */
> +    int lumi_masking_mode;         /**< Luminance masking mode */
>  };
>  
>  /**
> @@ -355,6 +356,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)  {
>      xvid_plugin_single_t single       = { 0 };
>      struct xvid_ff_pass1 rc2pass1     = { 0 };
>      xvid_plugin_2pass2_t rc2pass2     = { 0 };
> +    xvid_plugin_lumimasking_t masking = { 0 };
>      xvid_gbl_init_t xvid_gbl_init     = { 0 };
>      xvid_enc_create_t xvid_enc_create = { 0 };
>      xvid_enc_plugin_t plugins[7];
> @@ -526,9 +528,13 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)  {
>      }
>  
>      /* Luminance Masking */
> -    if( 0.0 != avctx->lumi_masking ) {
> +    if( avctx->lumi_masking != 0.0 || x->lumi_masking_mode ) {
> +        masking.method = ( x->lumi_masking_mode == 2 );
>          plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
> -        plugins[xvid_enc_create.num_plugins].param = NULL;
> +
> +        /* The old behavior is that when avctx->lumi_masking is specified,
> +         * plugins[...].param = NULL. Trying to keep the old behavior here. */
> +        plugins[xvid_enc_create.num_plugins].param = x->lumi_masking_mode ? &masking : NULL ;
>          xvid_enc_create.num_plugins++;
>      }
>  
> @@ -762,6 +768,23 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) {
>      return 0;
>  }
>  
> +#define OFFSET(x) offsetof(struct xvid_context, x)
> +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> +static const AVOption options[] = {
> +    { "lumi_masking_mode", "HVS masking mode",                      OFFSET(lumi_masking_mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE, "lumi_masking_mode" },
> +        { "off",           NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "lumi_masking_mode" },
> +        { "lumi",          NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "lumi_masking_mode" },
> +        { "variance",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "lumi_masking_mode" },
> +    { NULL },
> +};

this doesnt allow both to be specified also it uses the AVCodecContext
lumi_masking parameter for variance masking


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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130728/96b487d1/attachment.asc>


More information about the ffmpeg-devel mailing list