Merge commit '2268db2cd052674fde55c7d48b7a5098ce89b4ba'

* commit '2268db2cd052674fde55c7d48b7a5098ce89b4ba':
  lavu: Drop the {minus,plus}1 suffix from AVComponentDescriptor fields

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
Hendrik Leppkes 2015-09-08 15:43:03 +02:00
commit 151aa2ebff
18 changed files with 510 additions and 486 deletions

View File

@ -19,6 +19,8 @@ API changes, most recent first:
xxxxxxx - Change type of AVPixFmtDescriptor.flags from uint8_t to uint64_t.
xxxxxxx - Change type of AVComponentDescriptor fields from uint16_t to int
and drop bit packing.
xxxxxxx - Add step, offset, and depth to AVComponentDescriptor to replace
the deprecated step_minus1, offset_plus1, and depth_minus1.
-------- 8< --------- FFmpeg 2.8 was cut here -------- 8< ---------

View File

@ -2821,7 +2821,7 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
if (!desc)
return AVERROR(EINVAL);
pixel_shift = desc->comp[0].depth_minus1 > 7;
pixel_shift = desc->comp[0].depth > 8;
av_log(s->avctx, AV_LOG_DEBUG, "Verifying checksum for frame with POC %d: ",
s->poc);

View File

@ -206,7 +206,7 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
AVFrame *dst = out;
AVFrame *src = frame->frame;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src->format);
int pixel_shift = !!(desc->comp[0].depth_minus1 > 7);
int pixel_shift = !!(desc->comp[0].depth > 8);
ret = av_frame_ref(out, src);
if (frame->flags & HEVC_FRAME_FLAG_BUMPING)

View File

@ -114,22 +114,22 @@ static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVP
switch (desc->nb_components) {
case 4:
match = match &&
desc->comp[3].depth_minus1 + 1 >= image->comps[3].prec &&
desc->comp[3].depth >= image->comps[3].prec &&
1 == image->comps[3].dx &&
1 == image->comps[3].dy;
case 3:
match = match &&
desc->comp[2].depth_minus1 + 1 >= image->comps[2].prec &&
desc->comp[2].depth >= image->comps[2].prec &&
1 << desc->log2_chroma_w == image->comps[2].dx &&
1 << desc->log2_chroma_h == image->comps[2].dy;
case 2:
match = match &&
desc->comp[1].depth_minus1 + 1 >= image->comps[1].prec &&
desc->comp[1].depth >= image->comps[1].prec &&
1 << desc->log2_chroma_w == image->comps[1].dx &&
1 << desc->log2_chroma_h == image->comps[1].dy;
case 1:
match = match &&
desc->comp[0].depth_minus1 + 1 >= image->comps[0].prec &&
desc->comp[0].depth >= image->comps[0].prec &&
1 == image->comps[0].dx &&
1 == image->comps[0].dy;
default:
@ -388,7 +388,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
}
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
pixel_size = desc->comp[0].step_minus1 + 1;
pixel_size = desc->comp[0].step;
ispacked = libopenjpeg_ispacked(avctx->pix_fmt);
switch (pixel_size) {

View File

@ -189,8 +189,8 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
}
for (i = 0; i < numcomps; i++) {
cmptparm[i].prec = desc->comp[i].depth_minus1 + 1;
cmptparm[i].bpp = desc->comp[i].depth_minus1 + 1;
cmptparm[i].prec = desc->comp[i].depth;
cmptparm[i].bpp = desc->comp[i].depth;
cmptparm[i].sgnd = 0;
cmptparm[i].dx = sub_dx[i];
cmptparm[i].dy = sub_dy[i];

View File

@ -78,7 +78,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
{
libx265Context *ctx = avctx->priv_data;
ctx->api = x265_api_get(av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1);
ctx->api = x265_api_get(av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth);
if (!ctx->api)
ctx->api = x265_api_get(0);
@ -261,7 +261,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
x265pic.pts = pic->pts;
x265pic.bitDepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1;
x265pic.bitDepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
x265pic.sliceType = pic->pict_type == AV_PICTURE_TYPE_I ? X265_TYPE_I :
pic->pict_type == AV_PICTURE_TYPE_P ? X265_TYPE_P :

View File

@ -83,7 +83,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
"P%c\n%d %d\n", c, avctx->width, h1);
bytestream += strlen(bytestream);
if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE) {
int maxdepth = (1 << (av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1)) - 1;
int maxdepth = (1 << av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth) - 1;
snprintf(bytestream, bytestream_end - bytestream,
"%d\n", maxdepth);
bytestream += strlen(bytestream);

View File

@ -269,7 +269,7 @@ static int config_input(AVFilterLink *inlink)
s->hsub = desc->log2_chroma_w;
s->vsub = desc->log2_chroma_h;
s->depth = desc->comp[0].depth_minus1+1;
s->depth = desc->comp[0].depth;
s->line = av_malloc_array(inlink->w, sizeof(*s->line));
if (!s->line)

View File

@ -186,7 +186,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
YADIFContext *s = ctx->priv;
ThreadData *td = arg;
int refs = s->cur->linesize[td->plane];
int df = (s->csp->comp[td->plane].depth_minus1 + 8) / 8;
int df = (s->csp->comp[td->plane].depth + 7) / 8;
int pix_3 = 3 * df;
int slice_start = (td->h * jobnr ) / nb_jobs;
int slice_end = (td->h * (jobnr+1)) / nb_jobs;
@ -486,7 +486,7 @@ static int config_props(AVFilterLink *link)
}
s->csp = av_pix_fmt_desc_get(link->format);
if (s->csp->comp[0].depth_minus1 / 8 == 1) {
if (s->csp->comp[0].depth > 8) {
s->filter_line = filter_line_c_16bit;
s->filter_edges = filter_edges_16bit;
} else {

View File

@ -41,8 +41,8 @@ void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
for (i = 0; i < 4; i++) {
const AVComponentDescriptor *comp = &(pixdesc->comp[i]);
if ((comp->step_minus1+1) > max_pixsteps[comp->plane]) {
max_pixsteps[comp->plane] = comp->step_minus1+1;
if (comp->step > max_pixsteps[comp->plane]) {
max_pixsteps[comp->plane] = comp->step;
if (max_pixstep_comps)
max_pixstep_comps[comp->plane] = i;
}

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@
#include "attributes.h"
#include "pixfmt.h"
#include "version.h"
typedef struct AVComponentDescriptor {
/**
@ -34,16 +35,16 @@ typedef struct AVComponentDescriptor {
int plane;
/**
* Number of elements between 2 horizontally consecutive pixels minus 1.
* Number of elements between 2 horizontally consecutive pixels.
* Elements are bits for bitstream formats, bytes otherwise.
*/
int step_minus1;
int step;
/**
* Number of elements before the component of the first pixel plus 1.
* Number of elements before the component of the first pixel.
* Elements are bits for bitstream formats, bytes otherwise.
*/
int offset_plus1;
int offset;
/**
* Number of least significant bits that must be shifted away
@ -52,9 +53,20 @@ typedef struct AVComponentDescriptor {
int shift;
/**
* Number of bits in the component minus 1.
* Number of bits in the component.
*/
int depth_minus1;
int depth;
#if FF_API_PLUS1_MINUS1
/** deprecated, use step instead */
attribute_deprecated int step_minus1;
/** deprecated, use depth instead */
attribute_deprecated int depth_minus1;
/** deprecated, use offset instead */
attribute_deprecated int offset_plus1;
#endif
} AVComponentDescriptor;
/**

View File

@ -105,6 +105,10 @@
#ifndef FF_API_FRAME_QP
#define FF_API_FRAME_QP (LIBAVUTIL_VERSION_MAJOR < 56)
#endif
#ifndef FF_API_PLUS1_MINUS1
#define FF_API_PLUS1_MINUS1 (LIBAVUTIL_VERSION_MAJOR < 56)
#endif
/**
* @}

View File

@ -1845,7 +1845,7 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
int i;
int hasAlpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpSrc;
uint16_t **dest16 = (uint16_t**)dest;
int SH = 22 + 7 - desc->comp[0].depth_minus1;
int SH = 22 + 8 - desc->comp[0].depth;
int A = 0; // init to silence warning
for (i = 0; i < dstW; i++) {
@ -2073,7 +2073,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*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 (desc->comp[0].depth_minus1 == 8) {
if (desc->comp[0].depth == 9) {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
} else if (desc->comp[0].depth_minus1 == 9) {

View File

@ -87,7 +87,7 @@ static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW,
int i;
int32_t *dst = (int32_t *) _dst;
const uint16_t *src = (const uint16_t *) _src;
int bits = desc->comp[0].depth_minus1;
int bits = desc->comp[0].depth - 1;
int sh = bits - 4;
if((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth_minus1<15)
@ -113,7 +113,7 @@ static void hScale16To15_c(SwsContext *c, int16_t *dst, int dstW,
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
int i;
const uint16_t *src = (const uint16_t *) _src;
int sh = desc->comp[0].depth_minus1;
int sh = desc->comp[0].depth - 1;
if(sh<15)
sh= isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : desc->comp[0].depth_minus1;
@ -796,7 +796,7 @@ static int swscale(SwsContext *c, const uint8_t *src[],
if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
fillPlane16(dst[3], dstStride[3], length, height, lastDstY,
1, desc->comp[3].depth_minus1,
1, desc->comp[3].depth,
isBE(dstFormat));
} else
fillPlane(dst[3], dstStride[3], length, height, lastDstY, 255);

View File

@ -651,14 +651,14 @@ 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;
return desc->comp[0].depth == 16;
}
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;
return desc->comp[0].depth >= 9 && desc->comp[0].depth <= 14;
}
#define isNBPS(x) is9_OR_10BPS(x)
@ -928,7 +928,7 @@ static inline void fillPlane16(uint8_t *plane, int stride, int width, int height
{
int i, j;
uint8_t *ptr = plane + stride * y;
int v = alpha ? 0xFFFF>>(15-bits) : (1<<bits);
int v = alpha ? 0xFFFF>>(16-bits) : (1<<(bits-1));
for (i = 0; i < height; i++) {
#define FILL(wfunc) \
for (j = 0; j < width; j++) {\

View File

@ -1417,7 +1417,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, desc_dst->comp[plane].depth_minus1,
plane == 3, desc_dst->comp[plane].depth,
isBE(c->dstFormat));
} else {
fillPlane(dst[plane], dstStride[plane], length, height, y,
@ -1427,8 +1427,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 = desc_src->comp[plane].depth_minus1 + 1;
const int dst_depth = desc_dst->comp[plane].depth_minus1 + 1;
const int src_depth = desc_src->comp[plane].depth;
const int dst_depth = desc_dst->comp[plane].depth;
const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
uint16_t *dstPtr2 = (uint16_t*)dstPtr;
@ -1543,7 +1543,7 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
} else {
if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
length *= 2;
else if (!desc_src->comp[0].depth_minus1)
else if (desc_src->comp[0].depth == 1)
length >>= 3; // monowhite/black
for (i = 0; i < height; i++) {
memcpy(dstPtr, srcPtr, length);
@ -1648,7 +1648,7 @@ void ff_get_unscaled_swscale(SwsContext *c)
dstFormat == AV_PIX_FMT_BGRA64LE || dstFormat == AV_PIX_FMT_BGRA64BE))
c->swscale = planarRgb16ToRgb16Wrapper;
if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth_minus1 == 7 &&
if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRP)
c->swscale = rgbToPlanarRgbWrapper;

View File

@ -1335,10 +1335,10 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
FF_ALLOCZ_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW*2+78, 16) * 2, fail);
c->srcBpc = 1 + desc_src->comp[0].depth_minus1;
c->srcBpc = desc_src->comp[0].depth;
if (c->srcBpc < 8)
c->srcBpc = 8;
c->dstBpc = 1 + desc_dst->comp[0].depth_minus1;
c->dstBpc = desc_dst->comp[0].depth;
if (c->dstBpc < 8)
c->dstBpc = 8;
if (isAnyRGB(srcFormat) || srcFormat == AV_PIX_FMT_PAL8)