<commit_before>/*****************************************************************************
 * imageresample.c: scaling and chroma conversion using the old libavcodec API
 *****************************************************************************
 * Copyright (C) 1999-2001 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *
 * This program 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.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_filter.h>

/* ffmpeg header */
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
#   include <libavcodec/avcodec.h>
#elif defined(HAVE_FFMPEG_AVCODEC_H)
#   include <ffmpeg/avcodec.h>
#else
#   include <avcodec.h>
#endif

#include "../codec/avcodec/chroma.h"

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static int  OpenFilter( vlc_object_t * );
static void CloseFilter( vlc_object_t * );

static void Conversion( filter_t *, picture_t *, picture_t * );
static picture_t *Conversion_Filter( filter_t *, picture_t * );

/*****************************************************************************
 * Module descriptor
 *****************************************************************************/
vlc_module_begin();
    set_capability( "video filter2", 50 );
    set_callbacks( OpenFilter, CloseFilter );
    set_description( N_("FFmpeg video filter") );
vlc_module_end();

/*****************************************************************************
 * chroma_sys_t: chroma method descriptor
 *****************************************************************************
 * This structure is part of the chroma transformation descriptor, it
 * describes the chroma plugin specific properties.
 *****************************************************************************/
struct filter_sys_t
{
    int i_src_vlc_chroma;
    int i_src_ffmpeg_chroma;
    int i_dst_vlc_chroma;
    int i_dst_ffmpeg_chroma;
    AVPicture tmp_pic;
    ImgReSampleContext *p_rsc;
};

/*****************************************************************************
 * OpenFilter: allocate a chroma function
 *****************************************************************************
 * This function allocates and initializes a chroma function
 *****************************************************************************/
int OpenFilter( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t *)p_this;
    int i_ffmpeg_chroma[2], i_vlc_chroma[2], i;

    /*
     * Check the source chroma first, then the destination chroma
     */
    i_vlc_chroma[0] = p_filter->fmt_in.video.i_chroma;
    i_vlc_chroma[1] = p_filter->fmt_out.video.i_chroma;
    for( i = 0; i < 2; i++ )
    {
        i_ffmpeg_chroma[i] = GetFfmpegChroma( i_vlc_chroma[i] );
        if( i_ffmpeg_chroma[i] < 0 ) return VLC_EGENERIC;
    }

    p_filter->pf_video_filter = Conversion_Filter;

    p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
    if( p_filter->p_sys == NULL )
    {
        return VLC_ENOMEM;
    }

    p_filter->p_sys->i_src_vlc_chroma = p_filter->fmt_in.video.i_chroma;
    p_filter->p_sys->i_dst_vlc_chroma = p_filter->fmt_out.video.i_chroma;
    p_filter->p_sys->i_src_ffmpeg_chroma = i_ffmpeg_chroma[0];
    p_filter->p_sys->i_dst_ffmpeg_chroma = i_ffmpeg_chroma[1];

    if( ( p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height ||
          p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width ) &&
        ( p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('I','4','2','0') ||
          p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','1','2') ))
    {<commit_msg>Fix compilation with old ffmpeg.<commit_after>/*****************************************************************************
 * imageresample.c: scaling and chroma conversion using the old libavcodec API
 *****************************************************************************
 * Copyright (C) 1999-2001 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *
 * This program 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.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_filter.h>

/* ffmpeg header */
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
#   include <libavcodec/avcodec.h>
#elif defined(HAVE_FFMPEG_AVCODEC_H)
#   include <ffmpeg/avcodec.h>
#else
#   include <avcodec.h>
#endif

#include "../codec/avcodec/chroma.h"

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static int  OpenFilter( vlc_object_t * );
static void CloseFilter( vlc_object_t * );

static void Conversion( filter_t *, picture_t *, picture_t * );
static picture_t *Conversion_Filter( filter_t *, picture_t * );

/*****************************************************************************
 * Module descriptor
 *****************************************************************************/
vlc_module_begin();
    set_capability( "video filter2", 50 );
    set_callbacks( OpenFilter, CloseFilter );
    set_description( N_("FFmpeg video filter") );
vlc_module_end();

/*****************************************************************************
 * chroma_sys_t: chroma method descriptor
 *****************************************************************************
 * This structure is part of the chroma transformation descriptor, it
 * describes the chroma plugin specific properties.
 *****************************************************************************/
struct filter_sys_t
{
    int i_src_vlc_chroma;
    int i_src_ffmpeg_chroma;
    int i_dst_vlc_chroma;
    int i_dst_ffmpeg_chroma;
    AVPicture tmp_pic;
    ImgReSampleContext *p_rsc;
};

/*****************************************************************************
 * OpenFilter: allocate a chroma function
 *****************************************************************************
 * This function allocates and initializes a chroma function
 *****************************************************************************/
int OpenFilter( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t *)p_this;
    int i_ffmpeg_chroma[2];

    /*
     * Check the source chroma first, then the destination chroma
     */
    if( GetFfmpegChroma( &i_ffmpeg_chroma[0], p_filter->fmt_in.video ) == VLC_EGENERIC )
        return VLC_EGENERIC;
    if( GetFfmpegChroma( &i_ffmpeg_chroma[1], p_filter->fmt_out.video ) == VLC_EGENERIC )
        return VLC_EGENERIC;

    p_filter->pf_video_filter = Conversion_Filter;

    p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
    if( p_filter->p_sys == NULL )
    {
        return VLC_ENOMEM;
    }

    p_filter->p_sys->i_src_vlc_chroma = p_filter->fmt_in.video.i_chroma;
    p_filter->p_sys->i_dst_vlc_chroma = p_filter->fmt_out.video.i_chroma;
    p_filter->p_sys->i_src_ffmpeg_chroma = i_ffmpeg_chroma[0];
    p_filter->p_sys->i_dst_ffmpeg_chroma = i_ffmpeg_chroma[1];

    if( ( p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height ||
          p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width ) &&
        ( p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('I','4','2','0') ||
          p_filter->p_sys->i_dst_vlc_chroma == VLC_FOURCC('Y','V','1','2') ))
    {
{'fraction_non_alphanumeric': 0.32968800257317465, 'fraction_numerical': 0.007505092741503163, 'mean_word_length': 5.358554873892297, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6868471', 'n_tokens_mistral': 2806, 'n_tokens_neox': 2579, 'n_words': 630}