mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Merge commit '9953ff3cd844eb5f6d8dfce98cad94b78a0fc7dc'
* commit '9953ff3cd844eb5f6d8dfce98cad94b78a0fc7dc': 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: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
a9bd51b1e6
@ -1270,12 +1270,13 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
|
|||||||
yuv2packedX_fn *yuv2packedX)
|
yuv2packedX_fn *yuv2packedX)
|
||||||
{
|
{
|
||||||
enum AVPixelFormat dstFormat = c->dstFormat;
|
enum AVPixelFormat dstFormat = c->dstFormat;
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
|
||||||
|
|
||||||
if (is16BPS(dstFormat)) {
|
if (is16BPS(dstFormat)) {
|
||||||
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
|
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
|
||||||
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
|
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
|
||||||
} else if (is9_OR_10BPS(dstFormat)) {
|
} 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;
|
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
|
||||||
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
|
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
|
||||||
} else {
|
} 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,
|
int srcW, int srcH, int dstW, int dstH, int flags,
|
||||||
struct Results *r)
|
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 enum AVPixelFormat cur_srcFormat;
|
||||||
static int cur_srcW, cur_srcH;
|
static int cur_srcW, cur_srcH;
|
||||||
static uint8_t *src[4];
|
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);
|
srcFormat, SWS_BILINEAR, NULL, NULL, NULL);
|
||||||
if (!srcContext) {
|
if (!srcContext) {
|
||||||
fprintf(stderr, "Failed to get %s ---> %s\n",
|
fprintf(stderr, "Failed to get %s ---> %s\n",
|
||||||
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,
|
desc_yuva420p->name,
|
||||||
av_pix_fmt_descriptors[srcFormat].name);
|
desc_src->name);
|
||||||
res = -1;
|
res = -1;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@ -152,15 +155,14 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
|
|||||||
flags, NULL, NULL, NULL);
|
flags, NULL, NULL, NULL);
|
||||||
if (!dstContext) {
|
if (!dstContext) {
|
||||||
fprintf(stderr, "Failed to get %s ---> %s\n",
|
fprintf(stderr, "Failed to get %s ---> %s\n",
|
||||||
av_pix_fmt_descriptors[srcFormat].name,
|
desc_src->name, desc_dst->name);
|
||||||
av_pix_fmt_descriptors[dstFormat].name);
|
|
||||||
res = -1;
|
res = -1;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
|
printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
|
||||||
av_pix_fmt_descriptors[srcFormat].name, srcW, srcH,
|
desc_src->name, srcW, srcH,
|
||||||
av_pix_fmt_descriptors[dstFormat].name, dstW, dstH,
|
desc_dst->name, dstW, dstH,
|
||||||
flags);
|
flags);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
@ -191,8 +193,8 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
|
|||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if (!outContext) {
|
if (!outContext) {
|
||||||
fprintf(stderr, "Failed to get %s ---> %s\n",
|
fprintf(stderr, "Failed to get %s ---> %s\n",
|
||||||
av_pix_fmt_descriptors[dstFormat].name,
|
desc_dst->name,
|
||||||
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);
|
desc_yuva420p->name);
|
||||||
res = -1;
|
res = -1;
|
||||||
goto end;
|
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 dstW[] = { srcW - srcW / 3, srcW, srcW + srcW / 3, 0 };
|
||||||
const int dstH[] = { srcH - srcH / 3, srcH, srcH + srcH / 3, 0 };
|
const int dstH[] = { srcH - srcH / 3, srcH, srcH + srcH / 3, 0 };
|
||||||
enum AVPixelFormat srcFormat, dstFormat;
|
enum AVPixelFormat srcFormat, dstFormat;
|
||||||
|
const AVPixFmtDescriptor *desc_src, *desc_dst;
|
||||||
|
|
||||||
for (srcFormat = srcFormat_in != AV_PIX_FMT_NONE ? srcFormat_in : 0;
|
for (srcFormat = srcFormat_in != AV_PIX_FMT_NONE ? srcFormat_in : 0;
|
||||||
srcFormat < AV_PIX_FMT_NB; srcFormat++) {
|
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))
|
!sws_isSupportedOutput(srcFormat))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
desc_src = av_pix_fmt_desc_get(srcFormat);
|
||||||
|
|
||||||
for (dstFormat = dstFormat_in != AV_PIX_FMT_NONE ? dstFormat_in : 0;
|
for (dstFormat = dstFormat_in != AV_PIX_FMT_NONE ? dstFormat_in : 0;
|
||||||
dstFormat < AV_PIX_FMT_NB; dstFormat++) {
|
dstFormat < AV_PIX_FMT_NB; dstFormat++) {
|
||||||
int i, j, k;
|
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))
|
!sws_isSupportedOutput(dstFormat))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
printf("%s -> %s\n",
|
desc_dst = av_pix_fmt_desc_get(dstFormat);
|
||||||
av_pix_fmt_descriptors[srcFormat].name,
|
|
||||||
av_pix_fmt_descriptors[dstFormat].name);
|
printf("%s -> %s\n", desc_src->name, desc_dst->name);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
for (k = 0; flags[k] && !res; k++)
|
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 uint8_t *_src, const int16_t *filter,
|
||||||
const int32_t *filterPos, int filterSize)
|
const int32_t *filterPos, int filterSize)
|
||||||
{
|
{
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
|
||||||
int i;
|
int i;
|
||||||
int32_t *dst = (int32_t *) _dst;
|
int32_t *dst = (int32_t *) _dst;
|
||||||
const uint16_t *src = (const uint16_t *) _src;
|
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;
|
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)
|
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 uint8_t *_src, const int16_t *filter,
|
||||||
const int32_t *filterPos, int filterSize)
|
const int32_t *filterPos, int filterSize)
|
||||||
{
|
{
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
|
||||||
int i;
|
int i;
|
||||||
const uint16_t *src = (const uint16_t *) _src;
|
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)
|
if(sh<15)
|
||||||
sh= isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
|
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,
|
static int check_image_pointers(const uint8_t * const data[4], enum AVPixelFormat pix_fmt,
|
||||||
const int linesizes[4])
|
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;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <altivec.h>
|
#include <altivec.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/avutil.h"
|
#include "libavutil/avutil.h"
|
||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
#include "libavutil/log.h"
|
#include "libavutil/log.h"
|
||||||
@ -555,28 +556,50 @@ attribute_deprecated
|
|||||||
const char *sws_format_name(enum AVPixelFormat format);
|
const char *sws_format_name(enum AVPixelFormat format);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define is16BPS(x) \
|
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
|
||||||
(av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 15)
|
{
|
||||||
|
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) \
|
static av_always_inline int is9_OR_10BPS(enum AVPixelFormat pix_fmt)
|
||||||
(av_pix_fmt_descriptors[x].comp[0].depth_minus1 >= 8 && \
|
{
|
||||||
av_pix_fmt_descriptors[x].comp[0].depth_minus1 <= 13)
|
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 isNBPS(x) is9_OR_10BPS(x)
|
||||||
|
|
||||||
#define isBE(x) \
|
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
|
||||||
(av_pix_fmt_descriptors[x].flags & PIX_FMT_BE)
|
{
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
|
||||||
|
av_assert0(desc);
|
||||||
|
return desc->flags & PIX_FMT_BE;
|
||||||
|
}
|
||||||
|
|
||||||
#define isYUV(x) \
|
static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
|
||||||
(!(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB) && \
|
{
|
||||||
av_pix_fmt_descriptors[x].nb_components >= 2)
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
|
||||||
|
av_assert0(desc);
|
||||||
|
return !(desc->flags & PIX_FMT_RGB) && desc->nb_components >= 2;
|
||||||
|
}
|
||||||
|
|
||||||
#define isPlanarYUV(x) \
|
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
|
||||||
((av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR) && \
|
{
|
||||||
isYUV(x))
|
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 isRGB(x) \
|
|
||||||
(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB)
|
|
||||||
#if 0 // FIXME
|
#if 0 // FIXME
|
||||||
#define isGray(x) \
|
#define isGray(x) \
|
||||||
(!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) && \
|
(!(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 \
|
(x)==AV_PIX_FMT_GBR24P \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define isALPHA(x) \
|
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
|
||||||
(av_pix_fmt_descriptors[x].nb_components == 2 || \
|
{
|
||||||
av_pix_fmt_descriptors[x].nb_components == 4)
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
|
||||||
|
av_assert0(desc);
|
||||||
|
return desc->nb_components == 2 || desc->nb_components == 4;
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
#define isPacked(x) ( \
|
#define isPacked(x) ( \
|
||||||
@ -672,26 +698,43 @@ const char *sws_format_name(enum AVPixelFormat format);
|
|||||||
|| isBGRinInt(x) \
|
|| isBGRinInt(x) \
|
||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
#define isPacked(x) \
|
static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
|
||||||
((av_pix_fmt_descriptors[x].nb_components >= 2 && \
|
{
|
||||||
!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR)) || \
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
|
||||||
(x) == AV_PIX_FMT_PAL8)
|
av_assert0(desc);
|
||||||
|
return ((desc->nb_components >= 2 && !(desc->flags & PIX_FMT_PLANAR)) ||
|
||||||
|
pix_fmt == AV_PIX_FMT_PAL8);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#define isPlanar(x) \
|
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
|
||||||
(av_pix_fmt_descriptors[x].nb_components >= 2 && \
|
{
|
||||||
(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
|
||||||
|
av_assert0(desc);
|
||||||
|
return (desc->nb_components >= 2 && (desc->flags & PIX_FMT_PLANAR));
|
||||||
|
}
|
||||||
|
|
||||||
#define isPackedRGB(x) \
|
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
|
||||||
((av_pix_fmt_descriptors[x].flags & \
|
{
|
||||||
(PIX_FMT_PLANAR | PIX_FMT_RGB)) == PIX_FMT_RGB)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
#define isPlanarRGB(x) \
|
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
|
||||||
((av_pix_fmt_descriptors[x].flags & \
|
{
|
||||||
(PIX_FMT_PLANAR | PIX_FMT_RGB)) == (PIX_FMT_PLANAR | PIX_FMT_RGB))
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
#define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || \
|
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
|
||||||
(av_pix_fmt_descriptors[x].flags & PIX_FMT_PSEUDOPAL))
|
{
|
||||||
|
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_dither4[2];
|
||||||
extern const uint64_t ff_dither8[2];
|
extern const uint64_t ff_dither8[2];
|
||||||
|
@ -531,10 +531,12 @@ static rgbConvFn findRgbConvFn(SwsContext *c)
|
|||||||
const int srcId = c->srcFormatBpp;
|
const int srcId = c->srcFormatBpp;
|
||||||
const int dstId = c->dstFormatBpp;
|
const int dstId = c->dstFormatBpp;
|
||||||
rgbConvFn conv = NULL;
|
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 && \
|
(((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)
|
#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 srcFormat = c->srcFormat;
|
||||||
const enum AVPixelFormat dstFormat = c->dstFormat;
|
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 srcBpp = (c->srcFormatBpp + 7) >> 3;
|
||||||
const int dstBpp = (c->dstFormatBpp + 7) >> 3;
|
const int dstBpp = (c->dstFormatBpp + 7) >> 3;
|
||||||
rgbConvFn conv = findRgbConvFn(c);
|
rgbConvFn conv = findRgbConvFn(c);
|
||||||
@ -639,8 +643,8 @@ static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
|
|||||||
} else {
|
} else {
|
||||||
const uint8_t *srcPtr = src[0];
|
const uint8_t *srcPtr = src[0];
|
||||||
uint8_t *dstPtr = dst[0];
|
uint8_t *dstPtr = dst[0];
|
||||||
int src_bswap = IS_NOT_NE(c->srcFormatBpp, srcFormat);
|
int src_bswap = IS_NOT_NE(c->srcFormatBpp, desc_src);
|
||||||
int dst_bswap = IS_NOT_NE(c->dstFormatBpp, dstFormat);
|
int dst_bswap = IS_NOT_NE(c->dstFormatBpp, desc_dst);
|
||||||
|
|
||||||
if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
|
if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
|
||||||
!isRGBA32(dstFormat))
|
!isRGBA32(dstFormat))
|
||||||
@ -761,6 +765,8 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
|
|||||||
int srcStride[], int srcSliceY, int srcSliceH,
|
int srcStride[], int srcSliceY, int srcSliceH,
|
||||||
uint8_t *dst[], int dstStride[])
|
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;
|
int plane, i, j;
|
||||||
for (plane = 0; plane < 4; plane++) {
|
for (plane = 0; plane < 4; plane++) {
|
||||||
int length = (plane == 0 || plane == 3) ? c->srcW : -((-c->srcW ) >> c->chrDstHSubSample);
|
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 (!src[plane] || (plane == 1 && !src[2])) {
|
||||||
if (is16BPS(c->dstFormat) || isNBPS(c->dstFormat)) {
|
if (is16BPS(c->dstFormat) || isNBPS(c->dstFormat)) {
|
||||||
fillPlane16(dst[plane], dstStride[plane], length, height, y,
|
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 {
|
} else {
|
||||||
fillPlane(dst[plane], dstStride[plane], length, height, y,
|
fillPlane(dst[plane], dstStride[plane], length, height, y,
|
||||||
(plane == 3) ? 255 : 128);
|
(plane == 3) ? 255 : 128);
|
||||||
@ -786,8 +792,8 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
|
|||||||
if(isNBPS(c->srcFormat) || isNBPS(c->dstFormat)
|
if(isNBPS(c->srcFormat) || isNBPS(c->dstFormat)
|
||||||
|| (is16BPS(c->srcFormat) != is16BPS(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 src_depth = desc_src->comp[plane].depth_minus1 + 1;
|
||||||
const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1 + 1;
|
const int dst_depth = desc_dst->comp[plane].depth_minus1 + 1;
|
||||||
const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
|
const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
|
||||||
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
|
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
|
||||||
|
|
||||||
@ -905,7 +911,7 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
|
|||||||
} else {
|
} else {
|
||||||
if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
|
if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
|
||||||
length *= 2;
|
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
|
length >>= 3; // monowhite/black
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
memcpy(dstPtr, srcPtr, length);
|
memcpy(dstPtr, srcPtr, length);
|
||||||
|
@ -197,7 +197,11 @@ extern const int32_t ff_yuv2rgb_coeffs[8][4];
|
|||||||
#if FF_API_SWS_FORMAT_NAME
|
#if FF_API_SWS_FORMAT_NAME
|
||||||
const char *sws_format_name(enum AVPixelFormat format)
|
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
|
#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)
|
static void getSubSampleFactors(int *h, int *v, enum AVPixelFormat format)
|
||||||
{
|
{
|
||||||
*h = av_pix_fmt_descriptors[format].log2_chroma_w;
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
|
||||||
*v = av_pix_fmt_descriptors[format].log2_chroma_h;
|
*h = desc->log2_chroma_w;
|
||||||
|
*v = desc->log2_chroma_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
|
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
|
||||||
int srcRange, const int table[4], int dstRange,
|
int srcRange, const int table[4], int dstRange,
|
||||||
int brightness, int contrast, int saturation)
|
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->srcColorspaceTable, inv_table, sizeof(int) * 4);
|
||||||
memcpy(c->dstColorspaceTable, 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))
|
if (isYUV(c->dstFormat) || isGray(c->dstFormat))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->dstFormat]);
|
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
|
||||||
c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->srcFormat]);
|
c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
|
||||||
|
|
||||||
ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
|
ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
|
||||||
contrast, saturation);
|
contrast, saturation);
|
||||||
@ -873,6 +880,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
|
|||||||
int flags, cpu_flags;
|
int flags, cpu_flags;
|
||||||
enum AVPixelFormat srcFormat = c->srcFormat;
|
enum AVPixelFormat srcFormat = c->srcFormat;
|
||||||
enum AVPixelFormat dstFormat = c->dstFormat;
|
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();
|
cpu_flags = av_get_cpu_flags();
|
||||||
flags = c->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->lumXInc = (((int64_t)srcW << 16) + (dstW >> 1)) / dstW;
|
||||||
c->lumYInc = (((int64_t)srcH << 16) + (dstH >> 1)) / dstH;
|
c->lumYInc = (((int64_t)srcH << 16) + (dstH >> 1)) / dstH;
|
||||||
c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]);
|
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
|
||||||
c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]);
|
c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
|
||||||
c->vRounder = 4 * 0x0001000100010001ULL;
|
c->vRounder = 4 * 0x0001000100010001ULL;
|
||||||
|
|
||||||
usesVFilter = (srcFilter->lumV && srcFilter->lumV->length > 1) ||
|
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)
|
if (c->srcBpc < 8)
|
||||||
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)
|
if (c->dstBpc < 8)
|
||||||
c->dstBpc = 8;
|
c->dstBpc = 8;
|
||||||
if (isAnyRGB(srcFormat) || srcFormat == AV_PIX_FMT_PAL8)
|
if (isAnyRGB(srcFormat) || srcFormat == AV_PIX_FMT_PAL8)
|
||||||
|
Loading…
Reference in New Issue
Block a user