Update of /cvsroot/xine/xine-lib/contrib/ffmpeg/libpostproc
In directory 
sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv5335/contrib/ffmpeg/libpostproc

Added Files:
      Tag: ffmpeg_integration
        Makefile mangle.h postprocess.c postprocess.h 
        postprocess_altivec_template.c postprocess_internal.h 
        postprocess_template.c 
Log Message:
Start working on a branch where FFmpeg is not copied, patched and carved to be 
built with automake but instead imported inline and built using its own build 
system. This is an import of a slightly modified FFmpeg current tree. xine-lib 
builds, install and run fine with it, but there are of course plenty of things 
that needs to be fixed before it can even be considered for a 1.2.x series. 
Work will continue in the next days of course.

--- NEW FILE: Makefile ---

include ../config.mak

# Overload incdir, postproc include files go in a different directory.
incdir=$(prefix)/include/postproc

EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)

NAME=postproc
ifeq ($(BUILD_SHARED),yes)
LIBVERSION=$(SPPVERSION)
LIBMAJOR=$(SPPMAJOR)
endif

STATIC_OBJS=postprocess.o
SHARED_OBJS=postprocess_pic.o

HEADERS = postprocess.h

include ../common.mak

depend dep: postprocess.c

postprocess_pic.o: postprocess.c
        $(CC) -c $(CFLAGS) -fomit-frame-pointer -fPIC -DPIC -o $@ $<


--- NEW FILE: mangle.h ---
/*
 * mangle.h - This file has some CPP macros to deal with different symbol
 * mangling across binary formats.
 *
 * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net>
 *
 * 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 __MANGLE_H
#define __MANGLE_H

/* Feel free to add more to the list, eg. a.out IMO */
/* Use rip-relative addressing if compiling PIC code on x86-64. */
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__OS2__) || \
   (defined(__OpenBSD__) && !defined(__ELF__))
#if defined(ARCH_X86_64) && defined(PIC)
#define MANGLE(a) "_" #a"(%%rip)"
#else
#define MANGLE(a) "_" #a
#endif
#else
#if defined(ARCH_X86_64) && defined(PIC)
#define MANGLE(a) #a"(%%rip)"
#elif defined(CONFIG_DARWIN)
#define MANGLE(a) "_" #a
#else
#define MANGLE(a) #a
#endif
#endif

#endif /* !__MANGLE_H */


--- NEW FILE: postprocess.c ---
/*
 * Copyright (C) 2001-2003 Michael Niedermayer ([EMAIL PROTECTED])
 *
 * AltiVec optimizations (C) 2004 Romain Dolbeau <[EMAIL PROTECTED]>
 *
 * 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
[...1105 lines suppressed...]
                        width, height, QP_store, QPStride, 1, mode, c);
                postProcess(src[2], srcStride[2], dst[2], dstStride[2],
                        width, height, QP_store, QPStride, 2, mode, c);
        }
        else if(srcStride[1] == dstStride[1] && srcStride[2] == dstStride[2])
        {
                linecpy(dst[1], src[1], height, srcStride[1]);
                linecpy(dst[2], src[2], height, srcStride[2]);
        }
        else
        {
                int y;
                for(y=0; y<height; y++)
                {
                        memcpy(&(dst[1][y*dstStride[1]]), 
&(src[1][y*srcStride[1]]), width);
                        memcpy(&(dst[2][y*dstStride[2]]), 
&(src[2][y*srcStride[2]]), width);
                }
        }
}


--- NEW FILE: postprocess.h ---
/*
 * Copyright (C) 2001-2003 Michael Niedermayer ([EMAIL PROTECTED])
 *
 * 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 NEWPOSTPROCESS_H
#define NEWPOSTPROCESS_H

/**
 * @file postprocess.h
 * @brief
 *     external api for the pp stuff
 */

#ifdef __cplusplus
extern "C" {
#endif

#define LIBPOSTPROC_VERSION_INT ((51<<16)+(1<<8)+0)
#define LIBPOSTPROC_VERSION     51.1.0
#define LIBPOSTPROC_BUILD       LIBPOSTPROC_VERSION_INT

#define LIBPOSTPROC_IDENT       "postproc" AV_STRINGIFY(LIBPOSTPROC_VERSION)

#define PP_QUALITY_MAX 6

#define QP_STORE_T int8_t

typedef void pp_context_t;
typedef void pp_mode_t;

extern char *pp_help; ///< a simple help text

void  pp_postprocess(uint8_t * src[3], int srcStride[3],
                 uint8_t * dst[3], int dstStride[3],
                 int horizontalSize, int verticalSize,
                 QP_STORE_T *QP_store,  int QP_stride,
                 pp_mode_t *mode, pp_context_t *ppContext, int pict_type);


/**
 * returns a pp_mode_t or NULL if an error occured
 * name is the string after "-pp" on the command line
 * quality is a number from 0 to PP_QUALITY_MAX
 */
pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality);
void pp_free_mode(pp_mode_t *mode);

pp_context_t *pp_get_context(int width, int height, int flags);
void pp_free_context(pp_context_t *ppContext);

#define PP_CPU_CAPS_MMX   0x80000000
#define PP_CPU_CAPS_MMX2  0x20000000
#define PP_CPU_CAPS_3DNOW 0x40000000
#define PP_CPU_CAPS_ALTIVEC 0x10000000

#define PP_FORMAT         0x00000008
#define PP_FORMAT_420    (0x00000011|PP_FORMAT)
#define PP_FORMAT_422    (0x00000001|PP_FORMAT)
#define PP_FORMAT_411    (0x00000002|PP_FORMAT)
#define PP_FORMAT_444    (0x00000000|PP_FORMAT)

#define PP_PICT_TYPE_QP2  0x00000010 ///< MPEG2 style QScale

#ifdef __cplusplus
}
#endif

#endif

--- NEW FILE: postprocess_altivec_template.c ---
/*
 * AltiVec optimizations (C) 2004 Romain Dolbeau <[EMAIL PROTECTED]>
 *
 * based on code by Copyright (C) 2001-2003 Michael Niedermayer ([EMAIL 
PROTECTED])
 *
 * 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
[...1152 lines suppressed...]
  vector unsigned char align##i = vec_lvsr(i * stride, dst);            \
  vector unsigned char align##j = vec_lvsr(j * stride, dst);            \
  vector unsigned char mask##i = vec_perm(zero, (vector unsigned char)neg1, 
align##i); \
  vector unsigned char mask##j = vec_perm(zero, (vector unsigned char)neg1, 
align##j); \
  vector unsigned char dstR##i = vec_perm(temp##i, temp##i, align##i);  \
  vector unsigned char dstR##j = vec_perm(temp##j, temp##j, align##j);  \
  vector unsigned char dstAF##i = vec_sel(dstA##i, dstR##i, mask##i);   \
  vector unsigned char dstBF##i = vec_sel(dstR##i, dstB##i, mask##i);   \
  vector unsigned char dstAF##j = vec_sel(dstA##j, dstR##j, mask##j);   \
  vector unsigned char dstBF##j = vec_sel(dstR##j, dstB##j, mask##j);   \
  vec_st(dstAF##i, i * stride, dst);                                    \
  vec_st(dstBF##i, i * stride + 16, dst);                               \
  vec_st(dstAF##j, j * stride, dst);                                    \
  vec_st(dstBF##j, j * stride + 16, dst)

  STORE_DOUBLE_LINE(0,1);
  STORE_DOUBLE_LINE(2,3);
  STORE_DOUBLE_LINE(4,5);
  STORE_DOUBLE_LINE(6,7);
}

--- NEW FILE: postprocess_internal.h ---
/*
 * Copyright (C) 2001-2002 Michael Niedermayer ([EMAIL PROTECTED])
 *
 * 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
 */

/**
 * @file postprocess_internal.h
 * internal api header.
 */

#include "avutil.h"

#define V_DEBLOCK       0x01
#define H_DEBLOCK       0x02
#define DERING          0x04
#define LEVEL_FIX       0x08 ///< Brightness & Contrast

#define LUM_V_DEBLOCK   V_DEBLOCK               //   1
#define LUM_H_DEBLOCK   H_DEBLOCK               //   2
#define CHROM_V_DEBLOCK (V_DEBLOCK<<4)          //  16
#define CHROM_H_DEBLOCK (H_DEBLOCK<<4)          //  32
#define LUM_DERING      DERING                  //   4
#define CHROM_DERING    (DERING<<4)             //  64
#define LUM_LEVEL_FIX   LEVEL_FIX               //   8
#define CHROM_LEVEL_FIX (LEVEL_FIX<<4)          // 128 (not implemented yet)

// Experimental vertical filters
#define V_X1_FILTER     0x0200                  // 512
#define V_A_DEBLOCK     0x0400

// Experimental horizontal filters
#define H_X1_FILTER     0x2000                  // 8192
#define H_A_DEBLOCK     0x4000

/// select between full y range (255-0) or standart one (234-16)
#define FULL_Y_RANGE    0x8000                  // 32768

//Deinterlacing Filters
#define        LINEAR_IPOL_DEINT_FILTER         0x10000 // 65536
#define        LINEAR_BLEND_DEINT_FILTER        0x20000 // 131072
#define        CUBIC_BLEND_DEINT_FILTER         0x8000  // (not implemented yet)
#define        CUBIC_IPOL_DEINT_FILTER          0x40000 // 262144
#define        MEDIAN_DEINT_FILTER              0x80000 // 524288
#define        FFMPEG_DEINT_FILTER              0x400000
#define        LOWPASS5_DEINT_FILTER            0x800000

#define TEMP_NOISE_FILTER               0x100000
#define FORCE_QUANT                     0x200000

#if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC)
#    define PIC
#endif

//use if u want a faster postprocessing code
//cant differentiate between chroma & luma filters (both on or both off)
//obviosly the -pp option at the commandline has no effect except turning the 
here selected
//filters on
//#define COMPILE_TIME_MODE 0x77

#if 1
static inline int CLIP(int a){
        if(a&256) return ((a)>>31)^(-1);
        else      return a;
}
//#define CLIP(a) (((a)&256) ? ((a)>>31)^(-1) : (a))
#elif 0
#define CLIP(a) clip_tab[a]
#else
#define CLIP(a) (a)
#endif
/**
 * Postprocessng filter.
 */
struct PPFilter{
        const char *shortName;
        const char *longName;
        int chromDefault;       ///< is chrominance filtering on by default if 
this filter is manually activated
        int minLumQuality;      ///< minimum quality to turn luminance 
filtering on
        int minChromQuality;    ///< minimum quality to turn chrominance 
filtering on
        int mask;               ///< Bitmask to turn this filter on
};

/**
 * Postprocessng mode.
 */
typedef struct PPMode{
        int lumMode;                    ///< acivates filters for luminance
        int chromMode;                  ///< acivates filters for chrominance
        int error;                      ///< non zero on error

        int minAllowedY;                ///< for brigtness correction
        int maxAllowedY;                ///< for brihtness correction
        float maxClippedThreshold;      ///< amount of "black" u r willing to 
loose to get a brightness corrected picture

        int maxTmpNoise[3];             ///< for Temporal Noise Reducing filter 
(Maximal sum of abs differences)

        int baseDcDiff;
        int flatnessThreshold;

        int forcedQuant;                ///< quantizer if FORCE_QUANT is used
} PPMode;

/**
 * postprocess context.
 */
typedef struct PPContext{
        /**
         * info on struct for av_log
         */
        AVClass *av_class;

        uint8_t *tempBlocks; ///<used for the horizontal code

        /**
         * luma histogram.
         * we need 64bit here otherwise we'll going to have a problem
         * after watching a black picture for 5 hours
         */
        uint64_t *yHistogram;

        DECLARE_ALIGNED(8, uint64_t, packedYOffset);
        DECLARE_ALIGNED(8, uint64_t, packedYScale);

        /** Temporal noise reducing buffers */
        uint8_t *tempBlured[3];
        int32_t *tempBluredPast[3];

        /** Temporary buffers for handling the last row(s) */
        uint8_t *tempDst;
        uint8_t *tempSrc;

        uint8_t *deintTemp;

        DECLARE_ALIGNED(8, uint64_t, pQPb);
        DECLARE_ALIGNED(8, uint64_t, pQPb2);

        DECLARE_ALIGNED(8, uint64_t, mmxDcOffset[64]);
        DECLARE_ALIGNED(8, uint64_t, mmxDcThreshold[64]);

        QP_STORE_T *stdQPTable;       ///< used to fix MPEG2 style qscale
        QP_STORE_T *nonBQPTable;
        QP_STORE_T *forcedQPTable;

        int QP;
        int nonBQP;

        int frameNum;

        int cpuCaps;

        int qpStride; ///<size of qp buffers (needed to realloc them if needed)
        int stride;   ///<size of some buffers (needed to realloc them if 
needed)

        int hChromaSubSample;
        int vChromaSubSample;

        PPMode ppMode;
} PPContext;


static inline void linecpy(void *dest, void *src, int lines, int stride)
{
        if (stride > 0) {
                memcpy(dest, src, lines*stride);
        } else {
                memcpy(dest+(lines-1)*stride, src+(lines-1)*stride, 
-lines*stride);
        }
}

--- NEW FILE: postprocess_template.c ---
/*
 * Copyright (C) 2001-2002 Michael Niedermayer ([EMAIL PROTECTED])
 *
 * 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
*/
[...3804 lines suppressed...]
                        int x;
                        int start=yHistogram[i-1]/(max/256+1);
                        int end=yHistogram[i]/(max/256+1);
                        int inc= end > start ? 1 : -1;
                        for(x=start; x!=end+inc; x+=inc)
                                dst[ i*dstStride + x]+=128;
                }

                for(i=0; i<100; i+=2)
                {
                        dst[ (white)*dstStride + i]+=128;
                        dst[ (black)*dstStride + i]+=128;
                }

        }
#endif

        *c2= c; //copy local context back

}


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog

Reply via email to