Commit a9bd51b1 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '9953ff3c'

* commit '9953ff3c':
  mpegvideo: fix indentation
  sws: do not use av_pix_fmt_descriptors directly.

Conflicts:
	libavcodec/mpegvideo.c
	libswscale/swscale_internal.h
	libswscale/swscale_unscaled.c
	libswscale/utils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents a33ed6bc 9953ff3c
......@@ -1270,12 +1270,13 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
yuv2packedX_fn *yuv2packedX)
{
enum AVPixelFormat dstFormat = c->dstFormat;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
if (is16BPS(dstFormat)) {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
} else if (is9_OR_10BPS(dstFormat)) {
if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) {
if (desc->comp[0].depth_minus1 == 8) {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
} else {
......
......@@ -81,6 +81,9 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
int srcW, int srcH, int dstW, int dstH, int flags,
struct Results *r)
{
const AVPixFmtDescriptor *desc_yuva420p = av_pix_fmt_desc_get(AV_PIX_FMT_YUVA420P);
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(srcFormat);
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(dstFormat);
static enum AVPixelFormat cur_srcFormat;
static int cur_srcW, cur_srcH;
static uint8_t *src[4];
......@@ -116,8 +119,8 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
srcFormat, SWS_BILINEAR, NULL, NULL, NULL);
if (!srcContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,
av_pix_fmt_descriptors[srcFormat].name);
desc_yuva420p->name,
desc_src->name);
res = -1;
goto end;
}
......@@ -152,15 +155,14 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
flags, NULL, NULL, NULL);
if (!dstContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[srcFormat].name,
av_pix_fmt_descriptors[dstFormat].name);
desc_src->name, desc_dst->name);
res = -1;
goto end;
}
printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
av_pix_fmt_descriptors[srcFormat].name, srcW, srcH,
av_pix_fmt_descriptors[dstFormat].name, dstW, dstH,
desc_src->name, srcW, srcH,
desc_dst->name, dstW, dstH,
flags);
fflush(stdout);
......@@ -191,8 +193,8 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
NULL, NULL, NULL);
if (!outContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[dstFormat].name,
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);
desc_dst->name,
desc_yuva420p->name);
res = -1;
goto end;
}
......@@ -245,6 +247,7 @@ static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h,
const int dstW[] = { srcW - srcW / 3, srcW, srcW + srcW / 3, 0 };
const int dstH[] = { srcH - srcH / 3, srcH, srcH + srcH / 3, 0 };
enum AVPixelFormat srcFormat, dstFormat;
const AVPixFmtDescriptor *desc_src, *desc_dst;
for (srcFormat = srcFormat_in != AV_PIX_FMT_NONE ? srcFormat_in : 0;
srcFormat < AV_PIX_FMT_NB; srcFormat++) {
......@@ -252,6 +255,8 @@ static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h,
!sws_isSupportedOutput(srcFormat))
continue;
desc_src = av_pix_fmt_desc_get(srcFormat);
for (dstFormat = dstFormat_in != AV_PIX_FMT_NONE ? dstFormat_in : 0;
dstFormat < AV_PIX_FMT_NB; dstFormat++) {
int i, j, k;
......@@ -261,9 +266,9 @@ static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h,
!sws_isSupportedOutput(dstFormat))
continue;
printf("%s -> %s\n",
av_pix_fmt_descriptors[srcFormat].name,
av_pix_fmt_descriptors[dstFormat].name);
desc_dst = av_pix_fmt_desc_get(dstFormat);
printf("%s -> %s\n", desc_src->name, desc_dst->name);
fflush(stdout);
for (k = 0; flags[k] && !res; k++)
......
......@@ -66,10 +66,11 @@ static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW,
const uint8_t *_src, const int16_t *filter,
const int32_t *filterPos, int filterSize)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
int i;
int32_t *dst = (int32_t *) _dst;
const uint16_t *src = (const uint16_t *) _src;
int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
int bits = desc->comp[0].depth_minus1;
int sh = bits - 4;
if((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)
......@@ -92,9 +93,10 @@ static void hScale16To15_c(SwsContext *c, int16_t *dst, int dstW,
const uint8_t *_src, const int16_t *filter,
const int32_t *filterPos, int filterSize)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
int i;
const uint16_t *src = (const uint16_t *) _src;
int sh = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
int sh = desc->comp[0].depth_minus1;
if(sh<15)
sh= isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
......@@ -755,7 +757,7 @@ static void reset_ptr(const uint8_t *src[], int format)
static int check_image_pointers(const uint8_t * const data[4], enum AVPixelFormat pix_fmt,
const int linesizes[4])
{
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i;
for (i = 0; i < 4; i++) {
......
......@@ -27,6 +27,7 @@
#include <altivec.h>
#endif
#include "libavutil/avassert.h"
#include "libavutil/avutil.h"
#include "libavutil/common.h"
#include "libavutil/log.h"
......@@ -555,28 +556,50 @@ attribute_deprecated
const char *sws_format_name(enum AVPixelFormat format);
#endif
#define is16BPS(x) \
(av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 15)
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return desc->comp[0].depth_minus1 == 15;
}
#define is9_OR_10BPS(x) \
(av_pix_fmt_descriptors[x].comp[0].depth_minus1 >= 8 && \
av_pix_fmt_descriptors[x].comp[0].depth_minus1 <= 13)
static av_always_inline int is9_OR_10BPS(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return desc->comp[0].depth_minus1 >= 8 && desc->comp[0].depth_minus1 <= 13;
}
#define isNBPS(x) is9_OR_10BPS(x)
#define isBE(x) \
(av_pix_fmt_descriptors[x].flags & PIX_FMT_BE)
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return desc->flags & PIX_FMT_BE;
}
static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return !(desc->flags & PIX_FMT_RGB) && desc->nb_components >= 2;
}
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return ((desc->flags & PIX_FMT_PLANAR) && isYUV(pix_fmt));
}
static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return (desc->flags & PIX_FMT_RGB);
}
#define isYUV(x) \
(!(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB) && \
av_pix_fmt_descriptors[x].nb_components >= 2)
#define isPlanarYUV(x) \
((av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR) && \
isYUV(x))
#define isRGB(x) \
(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB)
#if 0 // FIXME
#define isGray(x) \
(!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) && \
......@@ -658,9 +681,12 @@ const char *sws_format_name(enum AVPixelFormat format);
(x)==AV_PIX_FMT_GBR24P \
)
#define isALPHA(x) \
(av_pix_fmt_descriptors[x].nb_components == 2 || \
av_pix_fmt_descriptors[x].nb_components == 4)
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return desc->nb_components == 2 || desc->nb_components == 4;
}
#if 1
#define isPacked(x) ( \
......@@ -672,26 +698,43 @@ const char *sws_format_name(enum AVPixelFormat format);
|| isBGRinInt(x) \
)
#else
#define isPacked(x) \
((av_pix_fmt_descriptors[x].nb_components >= 2 && \
!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR)) || \
(x) == AV_PIX_FMT_PAL8)
static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return ((desc->nb_components >= 2 && !(desc->flags & PIX_FMT_PLANAR)) ||
pix_fmt == AV_PIX_FMT_PAL8);
}
#endif
#define isPlanar(x) \
(av_pix_fmt_descriptors[x].nb_components >= 2 && \
(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
#define isPackedRGB(x) \
((av_pix_fmt_descriptors[x].flags & \
(PIX_FMT_PLANAR | PIX_FMT_RGB)) == PIX_FMT_RGB)
#define isPlanarRGB(x) \
((av_pix_fmt_descriptors[x].flags & \
(PIX_FMT_PLANAR | PIX_FMT_RGB)) == (PIX_FMT_PLANAR | PIX_FMT_RGB))
#define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || \
(av_pix_fmt_descriptors[x].flags & PIX_FMT_PSEUDOPAL))
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return (desc->nb_components >= 2 && (desc->flags & PIX_FMT_PLANAR));
}
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return ((desc->flags & (PIX_FMT_PLANAR | PIX_FMT_RGB)) == PIX_FMT_RGB);
}
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return ((desc->flags & (PIX_FMT_PLANAR | PIX_FMT_RGB)) ==
(PIX_FMT_PLANAR | PIX_FMT_RGB));
}
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
av_assert0(desc);
return (desc->flags & PIX_FMT_PAL) || (desc->flags & PIX_FMT_PSEUDOPAL);
}
extern const uint64_t ff_dither4[2];
extern const uint64_t ff_dither8[2];
......
......@@ -531,10 +531,12 @@ static rgbConvFn findRgbConvFn(SwsContext *c)
const int srcId = c->srcFormatBpp;
const int dstId = c->dstFormatBpp;
rgbConvFn conv = NULL;
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(srcFormat);
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(dstFormat);
#define IS_NOT_NE(bpp, fmt) \
#define IS_NOT_NE(bpp, desc) \
(((bpp + 7) >> 3) == 2 && \
(!(av_pix_fmt_descriptors[fmt].flags & PIX_FMT_BE) != !HAVE_BIGENDIAN))
(!(desc->flags & PIX_FMT_BE) != !HAVE_BIGENDIAN))
#define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
......@@ -629,6 +631,8 @@ static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
{
const enum AVPixelFormat srcFormat = c->srcFormat;
const enum AVPixelFormat dstFormat = c->dstFormat;
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
const int srcBpp = (c->srcFormatBpp + 7) >> 3;
const int dstBpp = (c->dstFormatBpp + 7) >> 3;
rgbConvFn conv = findRgbConvFn(c);
......@@ -639,8 +643,8 @@ static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
} else {
const uint8_t *srcPtr = src[0];
uint8_t *dstPtr = dst[0];
int src_bswap = IS_NOT_NE(c->srcFormatBpp, srcFormat);
int dst_bswap = IS_NOT_NE(c->dstFormatBpp, dstFormat);
int src_bswap = IS_NOT_NE(c->srcFormatBpp, desc_src);
int dst_bswap = IS_NOT_NE(c->dstFormatBpp, desc_dst);
if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
!isRGBA32(dstFormat))
......@@ -761,6 +765,8 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY, int srcSliceH,
uint8_t *dst[], int dstStride[])
{
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
int plane, i, j;
for (plane = 0; plane < 4; plane++) {
int length = (plane == 0 || plane == 3) ? c->srcW : -((-c->srcW ) >> c->chrDstHSubSample);
......@@ -777,7 +783,7 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
if (!src[plane] || (plane == 1 && !src[2])) {
if (is16BPS(c->dstFormat) || isNBPS(c->dstFormat)) {
fillPlane16(dst[plane], dstStride[plane], length, height, y,
plane == 3, av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1);
plane == 3, desc_dst->comp[plane].depth_minus1);
} else {
fillPlane(dst[plane], dstStride[plane], length, height, y,
(plane == 3) ? 255 : 128);
......@@ -786,8 +792,8 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
if(isNBPS(c->srcFormat) || isNBPS(c->dstFormat)
|| (is16BPS(c->srcFormat) != is16BPS(c->dstFormat))
) {
const int src_depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1 + 1;
const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1 + 1;
const int src_depth = desc_src->comp[plane].depth_minus1 + 1;
const int dst_depth = desc_dst->comp[plane].depth_minus1 + 1;
const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
......@@ -905,7 +911,7 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
} else {
if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
length *= 2;
else if (!av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1)
else if (!desc_src->comp[0].depth_minus1)
length >>= 3; // monowhite/black
for (i = 0; i < height; i++) {
memcpy(dstPtr, srcPtr, length);
......
......@@ -197,7 +197,11 @@ extern const int32_t ff_yuv2rgb_coeffs[8][4];
#if FF_API_SWS_FORMAT_NAME
const char *sws_format_name(enum AVPixelFormat format)
{
return av_get_pix_fmt_name(format);
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
if (desc)
return desc->name;
else
return "Unknown format";
}
#endif
......@@ -767,14 +771,17 @@ static int initMMX2HScaler(int dstW, int xInc, uint8_t *filterCode,
static void getSubSampleFactors(int *h, int *v, enum AVPixelFormat format)
{
*h = av_pix_fmt_descriptors[format].log2_chroma_w;
*v = av_pix_fmt_descriptors[format].log2_chroma_h;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
*h = desc->log2_chroma_w;
*v = desc->log2_chroma_h;
}
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
int srcRange, const int table[4], int dstRange,
int brightness, int contrast, int saturation)
{
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
memcpy(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
memcpy(c->dstColorspaceTable, table, sizeof(int) * 4);
......@@ -786,8 +793,8 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
if (isYUV(c->dstFormat) || isGray(c->dstFormat))
return -1;
c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->dstFormat]);
c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->srcFormat]);
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
contrast, saturation);
......@@ -873,6 +880,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
int flags, cpu_flags;
enum AVPixelFormat srcFormat = c->srcFormat;
enum AVPixelFormat dstFormat = c->dstFormat;
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(srcFormat);
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(dstFormat);
cpu_flags = av_get_cpu_flags();
flags = c->flags;
......@@ -935,8 +944,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
c->lumXInc = (((int64_t)srcW << 16) + (dstW >> 1)) / dstW;
c->lumYInc = (((int64_t)srcH << 16) + (dstH >> 1)) / dstH;
c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]);
c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]);
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
c->vRounder = 4 * 0x0001000100010001ULL;
usesVFilter = (srcFilter->lumV && srcFilter->lumV->length > 1) ||
......@@ -1015,10 +1024,10 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
}
}
c->srcBpc = 1 + av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1;
c->srcBpc = 1 + desc_src->comp[0].depth_minus1;
if (c->srcBpc < 8)
c->srcBpc = 8;
c->dstBpc = 1 + av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1;
c->dstBpc = 1 + desc_dst->comp[0].depth_minus1;
if (c->dstBpc < 8)
c->dstBpc = 8;
if (isAnyRGB(srcFormat) || srcFormat == AV_PIX_FMT_PAL8)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment