libswscale/swscale_unscaled.c File Reference

#include <inttypes.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include "config.h"
#include <assert.h>
#include "swscale.h"
#include "swscale_internal.h"
#include "rgb2rgb.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/cpu.h"
#include "libavutil/avutil.h"
#include "libavutil/mathematics.h"
#include "libavutil/bswap.h"
#include "libavutil/pixdesc.h"

Go to the source code of this file.

Defines

#define RGB2YUV_SHIFT   15
#define BY   ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BV   (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define BU   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GY   ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GV   (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define GU   (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RY   ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RV   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define RU   (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
#define isRGBA32(x)
#define IS_NOT_NE(bpp, fmt)
#define CONV_IS(src, dst)   (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)
#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)
#define COPY816(w)
#define COPY_UP(r, w)
#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt)
#define isByteRGB(f)
#define isPlanarGray(x)   (isGray(x) && (x) != PIX_FMT_GRAY8A)

Typedefs

typedef void(* rgbConvFn )(const uint8_t *, uint8_t *, int)

Functions

static void fillPlane (uint8_t *plane, int stride, int width, int height, int y, uint8_t val)
static void fillPlane16 (uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits)
static void copyPlane (const uint8_t *src, int srcStride, int srcSliceY, int srcSliceH, int width, uint8_t *dst, int dstStride)
static int planarToNv12Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int planarToYuy2Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int planarToUyvyWrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int yuv422pToYuy2Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int yuv422pToUyvyWrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int yuyvToYuv420Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int yuyvToYuv422Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int uyvyToYuv420Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int uyvyToYuv422Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static void gray8aToPacked32 (const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static void gray8aToPacked32_1 (const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static void gray8aToPacked24 (const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static int packed_16bpc_bswap (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int palToRgbWrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static void gbr24ptopacked24 (const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int width)
static void gbr24ptopacked32 (const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
static int planarRgbToRgbWrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static rgbConvFn findRgbConvFn (SwsContext *c)
static int rgbToRgbWrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int bgr24ToYv12Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int yvu9ToYv12Wrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int packedCopyWrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int planarCopyWrapper (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
void ff_get_unscaled_swscale (SwsContext *c)
 Set c->swScale to an unscaled converter if one exists for the specific source and destination formats, bit depths, flags, etc.
static void reset_ptr (const uint8_t *src[], int format)
static int check_image_pointers (const uint8_t *const data[4], enum PixelFormat pix_fmt, const int linesizes[4])
int attribute_align_arg sws_scale (struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
 swscale wrapper, so we don't need to export the SwsContext.
void sws_convertPalette8ToPacked32 (const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
 Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
void sws_convertPalette8ToPacked24 (const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
 Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.


Define Documentation

#define BU   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 40 of file swscale_unscaled.c.

#define BV   (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 39 of file swscale_unscaled.c.

#define BY   ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 38 of file swscale_unscaled.c.

#define CONV_IS ( src,
dst   )     (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)

Referenced by findRgbConvFn().

#define COPY816 (  ) 

Value:

if(shiftonly){\
                            for (j = 0; j < length; j++)\
                                w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
                        }else{\
                            for (j = 0; j < length; j++)\
                                w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
                                               (srcPtr[j]>>(2*8-dst_depth)));\
                        }

Referenced by planarCopyWrapper().

#define COPY_UP ( r,
 ) 

Value:

if(shiftonly){\
        for (j = 0; j < length; j++){ \
            unsigned int v= r(&srcPtr2[j]);\
            w(&dstPtr2[j], v<<(dst_depth-src_depth));\
        }\
    }else{\
        for (j = 0; j < length; j++){ \
            unsigned int v= r(&srcPtr2[j]);\
            w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
                        (v>>(2*src_depth-dst_depth)));\
        }\
    }

Referenced by planarCopyWrapper().

#define DITHER_COPY ( dst,
dstStride,
src,
srcStride,
bswap,
dbswap   ) 

Value:

uint16_t scale= dither_scale[dst_depth-1][src_depth-1];\
    int shift= src_depth-dst_depth + dither_scale[src_depth-2][dst_depth-1];\
    for (i = 0; i < height; i++) {\
        const uint8_t *dither= dithers[src_depth-9][i&7];\
        for (j = 0; j < length-7; j+=8){\
            dst[j+0] = dbswap((bswap(src[j+0]) + dither[0])*scale>>shift);\
            dst[j+1] = dbswap((bswap(src[j+1]) + dither[1])*scale>>shift);\
            dst[j+2] = dbswap((bswap(src[j+2]) + dither[2])*scale>>shift);\
            dst[j+3] = dbswap((bswap(src[j+3]) + dither[3])*scale>>shift);\
            dst[j+4] = dbswap((bswap(src[j+4]) + dither[4])*scale>>shift);\
            dst[j+5] = dbswap((bswap(src[j+5]) + dither[5])*scale>>shift);\
            dst[j+6] = dbswap((bswap(src[j+6]) + dither[6])*scale>>shift);\
            dst[j+7] = dbswap((bswap(src[j+7]) + dither[7])*scale>>shift);\
        }\
        for (; j < length; j++)\
            dst[j] = dbswap((bswap(src[j]) + dither[j&7])*scale>>shift);\
        dst += dstStride;\
        src += srcStride;\
    }

Definition at line 593 of file swscale_unscaled.c.

Referenced by planarCopyWrapper().

#define GU   (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 43 of file swscale_unscaled.c.

#define GV   (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 42 of file swscale_unscaled.c.

#define GY   ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 41 of file swscale_unscaled.c.

#define IS_DIFFERENT_ENDIANESS ( src_fmt,
dst_fmt,
pix_fmt   ) 

Value:

((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) ||     \
     (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))

Definition at line 749 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

#define IS_NOT_NE ( bpp,
fmt   ) 

Value:

(((bpp + 7) >> 3) == 2 && \
     (!(av_pix_fmt_descriptors[fmt].flags & PIX_FMT_BE) != !HAVE_BIGENDIAN))

Referenced by findRgbConvFn().

#define isByteRGB (  ) 

Value:

Referenced by ff_get_unscaled_swscale().

#define isPlanarGray (  )     (isGray(x) && (x) != PIX_FMT_GRAY8A)

Referenced by ff_get_unscaled_swscale().

#define isRGBA32 (  ) 

Value:

(            \
           (x) == PIX_FMT_ARGB   \
        || (x) == PIX_FMT_RGBA   \
        || (x) == PIX_FMT_BGRA   \
        || (x) == PIX_FMT_ABGR   \
        )

Definition at line 405 of file swscale_unscaled.c.

Referenced by findRgbConvFn(), and rgbToRgbWrapper().

#define RGB2YUV_SHIFT   15

Definition at line 37 of file swscale_unscaled.c.

#define RU   (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 46 of file swscale_unscaled.c.

#define RV   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 45 of file swscale_unscaled.c.

#define RY   ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Definition at line 44 of file swscale_unscaled.c.


Typedef Documentation

typedef void(* rgbConvFn)(const uint8_t *, uint8_t *, int)

Definition at line 413 of file swscale_unscaled.c.


Function Documentation

static int bgr24ToYv12Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 533 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int check_image_pointers ( const uint8_t *const   data[4],
enum PixelFormat  pix_fmt,
const int  linesizes[4] 
) [static]

Definition at line 887 of file swscale_unscaled.c.

Referenced by sws_scale().

static void copyPlane ( const uint8_t *  src,
int  srcStride,
int  srcSliceY,
int  srcSliceH,
int  width,
uint8_t *  dst,
int  dstStride 
) [static]

Definition at line 73 of file swscale_unscaled.c.

Referenced by planarToNv12Wrapper(), and yvu9ToYv12Wrapper().

void ff_get_unscaled_swscale ( SwsContext c  ) 

Set c->swScale to an unscaled converter if one exists for the specific source and destination formats, bit depths, flags, etc.

Definition at line 754 of file swscale_unscaled.c.

Referenced by sws_init_context().

static void fillPlane ( uint8_t *  plane,
int  stride,
int  width,
int  height,
int  y,
uint8_t  val 
) [static]

Definition at line 48 of file swscale_unscaled.c.

static void fillPlane16 ( uint8_t *  plane,
int  stride,
int  width,
int  height,
int  y,
int  alpha,
int  bits 
) [static]

Definition at line 59 of file swscale_unscaled.c.

Referenced by planarCopyWrapper().

static rgbConvFn findRgbConvFn ( SwsContext c  )  [static]

Definition at line 414 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale(), and rgbToRgbWrapper().

static void gbr24ptopacked24 ( const uint8_t *  src[],
int  srcStride[],
uint8_t *  dst,
int  dstStride,
int  srcSliceH,
int  width 
) [static]

Definition at line 319 of file swscale_unscaled.c.

Referenced by planarRgbToRgbWrapper().

static void gbr24ptopacked32 ( const uint8_t *  src[],
int  srcStride[],
uint8_t *  dst,
int  dstStride,
int  srcSliceH,
int  alpha_first,
int  width 
) [static]

Definition at line 335 of file swscale_unscaled.c.

Referenced by planarRgbToRgbWrapper().

static void gray8aToPacked24 ( const uint8_t *  src,
uint8_t *  dst,
int  num_pixels,
const uint8_t *  palette 
) [static]

Definition at line 237 of file swscale_unscaled.c.

Referenced by palToRgbWrapper().

static void gray8aToPacked32 ( const uint8_t *  src,
uint8_t *  dst,
int  num_pixels,
const uint8_t *  palette 
) [static]

Definition at line 220 of file swscale_unscaled.c.

Referenced by palToRgbWrapper().

static void gray8aToPacked32_1 ( const uint8_t *  src,
uint8_t *  dst,
int  num_pixels,
const uint8_t *  palette 
) [static]

Definition at line 228 of file swscale_unscaled.c.

Referenced by palToRgbWrapper().

static int packed_16bpc_bswap ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 251 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int packedCopyWrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 566 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int palToRgbWrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 273 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int planarCopyWrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 614 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int planarRgbToRgbWrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 362 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int planarToNv12Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 90 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int planarToUyvyWrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 122 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int planarToYuy2Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 110 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static void reset_ptr ( const uint8_t *  src[],
int  format 
) [static]

Definition at line 875 of file swscale_unscaled.c.

Referenced by sws_scale().

static int rgbToRgbWrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 490 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

void sws_convertPalette8ToPacked24 ( const uint8_t *  src,
uint8_t *  dst,
int  num_pixels,
const uint8_t *  palette 
)

Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.

With the palette format "ABCD", the destination frame ends up with the format "ABC".

Parameters:
src source frame buffer
dst destination frame buffer
num_pixels number of pixels to convert
palette array with [256] entries, which must match color arrangement (RGB or BGR) of src

Definition at line 1075 of file swscale_unscaled.c.

Referenced by palToRgbWrapper(), and put_image().

void sws_convertPalette8ToPacked32 ( const uint8_t *  src,
uint8_t *  dst,
int  num_pixels,
const uint8_t *  palette 
)

Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.

The output frame will have the same packed format as the palette.

Parameters:
src source frame buffer
dst destination frame buffer
num_pixels number of pixels to convert
palette array with [256] entries, which must match color arrangement (RGB or BGR) of src

Definition at line 1065 of file swscale_unscaled.c.

Referenced by palToRgbWrapper(), and put_image().

int attribute_align_arg sws_scale ( struct SwsContext c,
const uint8_t *const   srcSlice[],
const int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *const   dst[],
const int  dstStride[] 
)

swscale wrapper, so we don't need to export the SwsContext.

Scale the image slice in srcSlice and put the resulting scaled slice in the image in dst.

Assumes planar YUV to be in YUV order instead of YVU.

Definition at line 906 of file swscale_unscaled.c.

Referenced by blur(), do_video_resample(), doTest(), draw_slice(), main(), queue_picture(), scale_image(), scale_slice(), and write_video_frame().

static int uyvyToYuv420Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 189 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int uyvyToYuv422Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 206 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int yuv422pToUyvyWrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 146 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int yuv422pToYuy2Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 134 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int yuyvToYuv420Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 158 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int yuyvToYuv422Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dstParam[],
int  dstStride[] 
) [static]

Definition at line 175 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().

static int yvu9ToYv12Wrapper ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[] 
) [static]

Definition at line 549 of file swscale_unscaled.c.

Referenced by ff_get_unscaled_swscale().


Generated on Fri Oct 26 02:46:14 2012 for FFmpeg by  doxygen 1.5.8