1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit '50ba57e0ce63d9904269ea0728936a0c79f8bfb5'

* commit '50ba57e0ce63d9904269ea0728936a0c79f8bfb5':
  lavc: do not use av_pix_fmt_descriptors directly.

Conflicts:
	libavcodec/imgconvert.c
	libavcodec/libopenjpegdec.c
	libavcodec/libopenjpegenc.c
	libavcodec/mpegvideo.c
	libavcodec/rawdec.c
	libavcodec/rawenc.c
	libavcodec/tiffenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-10-12 16:48:26 +02:00
commit af7dd79a32
8 changed files with 61 additions and 46 deletions

View File

@ -390,13 +390,15 @@ static const PixFmtInfo pix_fmt_info[AV_PIX_FMT_NB] = {
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
{
*h_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w;
*v_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
*h_shift = desc->log2_chroma_w;
*v_shift = desc->log2_chroma_h;
}
int ff_is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
{
return av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
return desc->flags & PIX_FMT_HWACCEL;
}
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
@ -421,10 +423,10 @@ int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i;
if (!desc->nb_components) {
if (!desc || !desc->nb_components) {
*min = *max = 0;
return AVERROR(EINVAL);
}
@ -441,16 +443,14 @@ int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat
int has_alpha)
{
const PixFmtInfo *pf, *ps;
const AVPixFmtDescriptor *src_desc;
const AVPixFmtDescriptor *dst_desc;
const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt);
const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt);
int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth;
int ret, loss;
if (dst_pix_fmt >= AV_PIX_FMT_NB || dst_pix_fmt <= AV_PIX_FMT_NONE)
return ~0;
src_desc = &av_pix_fmt_descriptors[src_pix_fmt];
dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];
ps = &pix_fmt_info[src_pix_fmt];
/* compute loss */
@ -509,7 +509,7 @@ int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat
static int avg_bits_per_pixel(enum AVPixelFormat pix_fmt)
{
const PixFmtInfo *info = &pix_fmt_info[pix_fmt];
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
return info->padded_size ?
info->padded_size : av_get_bits_per_pixel(desc);
@ -719,7 +719,7 @@ void avpicture_free(AVPicture *picture)
static inline int is_yuv_planar(enum AVPixelFormat fmt)
{
const PixFmtInfo *info = &pix_fmt_info[fmt];
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[fmt];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
int i;
int planes[4] = { 0 };
@ -741,14 +741,15 @@ static inline int is_yuv_planar(enum AVPixelFormat fmt)
int av_picture_crop(AVPicture *dst, const AVPicture *src,
enum AVPixelFormat pix_fmt, int top_band, int left_band)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int y_shift;
int x_shift;
if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
return -1;
y_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h;
x_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w;
y_shift = desc->log2_chroma_h;
x_shift = desc->log2_chroma_w;
if (is_yuv_planar(pix_fmt)) {
dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
@ -772,6 +773,7 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright,
int *color)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
uint8_t *optr;
int y_shift;
int x_shift;
@ -782,8 +784,8 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
!is_yuv_planar(pix_fmt)) return -1;
for (i = 0; i < 3; i++) {
x_shift = i ? av_pix_fmt_descriptors[pix_fmt].log2_chroma_w : 0;
y_shift = i ? av_pix_fmt_descriptors[pix_fmt].log2_chroma_h : 0;
x_shift = i ? desc->log2_chroma_w : 0;
y_shift = i ? desc->log2_chroma_h : 0;
if (padtop || padleft) {
memset(dst->data[i], color[i],

View File

@ -65,24 +65,24 @@ typedef struct {
static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVPixelFormat pix_fmt)
{
AVPixFmtDescriptor descriptor = av_pix_fmt_descriptors[pix_fmt];
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int match = 1;
if (descriptor.nb_components != image->numcomps) {
if (desc->nb_components != image->numcomps) {
return 0;
}
switch (descriptor.nb_components) {
case 4: match = match && descriptor.comp[3].depth_minus1 + 1 >= image->comps[3].prec &&
switch (desc->nb_components) {
case 4: match = match && desc->comp[3].depth_minus1 + 1 >= image->comps[3].prec &&
1 == image->comps[3].dx &&
1 == image->comps[3].dy;
case 3: match = match && descriptor.comp[2].depth_minus1 + 1 >= image->comps[2].prec &&
1 << descriptor.log2_chroma_w == image->comps[2].dx &&
1 << descriptor.log2_chroma_h == image->comps[2].dy;
case 2: match = match && descriptor.comp[1].depth_minus1 + 1 >= image->comps[1].prec &&
1 << descriptor.log2_chroma_w == image->comps[1].dx &&
1 << descriptor.log2_chroma_h == image->comps[1].dy;
case 1: match = match && descriptor.comp[0].depth_minus1 + 1 >= image->comps[0].prec &&
case 3: match = match && desc->comp[2].depth_minus1 + 1 >= 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 &&
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 &&
1 == image->comps[0].dx &&
1 == image->comps[0].dy;
default:
@ -125,15 +125,17 @@ static inline enum AVPixelFormat libopenjpeg_guess_pix_fmt(const opj_image_t *im
return AV_PIX_FMT_NONE;
}
static inline int libopenjpeg_ispacked(enum AVPixelFormat pix_fmt) {
static inline int libopenjpeg_ispacked(enum AVPixelFormat pix_fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i, component_plane;
if (pix_fmt == AV_PIX_FMT_GRAY16)
return 0;
component_plane = av_pix_fmt_descriptors[pix_fmt].comp[0].plane;
for (i = 1; i < av_pix_fmt_descriptors[pix_fmt].nb_components; i++) {
if (component_plane != av_pix_fmt_descriptors[pix_fmt].comp[i].plane)
component_plane = desc->comp[0].plane;
for (i = 1; i < desc->nb_components; i++) {
if (component_plane != desc->comp[i].plane)
return 0;
}
return 1;
@ -232,6 +234,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size;
LibOpenJPEGContext *ctx = avctx->priv_data;
AVFrame *picture = &ctx->image, *output = data;
const AVPixFmtDescriptor *desc;
opj_dinfo_t *dec;
opj_cio_t *stream;
opj_image_t *image;
@ -338,7 +341,8 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
goto done;
}
pixel_size = av_pix_fmt_descriptors[avctx->pix_fmt].comp[0].step_minus1 + 1;
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
pixel_size = desc->comp[0].step_minus1 + 1;
ispacked = libopenjpeg_ispacked(avctx->pix_fmt);
switch (pixel_size) {

View File

@ -69,6 +69,7 @@ static void info_callback(const char *msg, void *data)
static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *parameters)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
opj_image_cmptparm_t *cmptparm;
opj_image_t *img;
int i;
@ -79,10 +80,10 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
sub_dx[0] = sub_dx[3] = 1;
sub_dy[0] = sub_dy[3] = 1;
sub_dx[1] = sub_dx[2] = 1<<av_pix_fmt_descriptors[avctx->pix_fmt].log2_chroma_w;
sub_dy[1] = sub_dy[2] = 1<<av_pix_fmt_descriptors[avctx->pix_fmt].log2_chroma_h;
sub_dx[1] = sub_dx[2] = 1 << desc->log2_chroma_w;
sub_dy[1] = sub_dy[2] = 1 << desc->log2_chroma_h;
numcomps = av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
numcomps = desc->nb_components;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_GRAY8:
@ -135,8 +136,8 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
return NULL;
}
for (i = 0; i < numcomps; i++) {
cmptparm[i].prec = av_pix_fmt_descriptors[avctx->pix_fmt].comp[i].depth_minus1 + 1;
cmptparm[i].bpp = av_pix_fmt_descriptors[avctx->pix_fmt].comp[i].depth_minus1 + 1;
cmptparm[i].prec = desc->comp[i].depth_minus1 + 1;
cmptparm[i].bpp = desc->comp[i].depth_minus1 + 1;
cmptparm[i].sgnd = 0;
cmptparm[i].dx = sub_dx[i];
cmptparm[i].dy = sub_dy[i];

View File

@ -1524,8 +1524,9 @@ void ff_MPV_frame_end(MpegEncContext *s)
!(s->flags & CODEC_FLAG_EMU_EDGE) &&
!s->avctx->lowres
) {
int hshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_w;
int vshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_h;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
int hshift = desc->log2_chroma_w;
int vshift = desc->log2_chroma_h;
s->dsp.draw_edges(s->current_picture.f.data[0], s->current_picture.f.linesize[0],
s->h_edge_pos, s->v_edge_pos,
EDGE_WIDTH, EDGE_WIDTH,
@ -2713,9 +2714,10 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
&& s->current_picture.f.reference
&& !s->intra_only
&& !(s->flags&CODEC_FLAG_EMU_EDGE)) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
int sides = 0, edge_h;
int hshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_w;
int vshift = av_pix_fmt_descriptors[s->avctx->pix_fmt].log2_chroma_h;
int hshift = desc->log2_chroma_w;
int vshift = desc->log2_chroma_h;
if (y==0) sides |= EDGE_TOP;
if (y + h >= s->v_edge_pos) sides |= EDGE_BOTTOM;

View File

@ -145,6 +145,7 @@ static int raw_decode(AVCodecContext *avctx,
int buf_size = avpkt->size;
int linesize_align = 4;
RawVideoContext *context = avctx->priv_data;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int res, len;
AVFrame *frame = data;
@ -206,7 +207,7 @@ static int raw_decode(AVCodecContext *avctx,
avctx->width, avctx->height)) < 0)
return res;
if((avctx->pix_fmt==AV_PIX_FMT_PAL8 && buf_size < context->length) ||
(av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) {
(desc->flags & PIX_FMT_PSEUDOPAL)) {
frame->data[1]= (uint8_t*)context->palette;
}
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {

View File

@ -33,10 +33,12 @@
static av_cold int raw_init_encoder(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
avctx->coded_frame = avctx->priv_data;
avcodec_get_frame_defaults(avctx->coded_frame);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc);
if(!avctx->codec_tag)
avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
return 0;

View File

@ -289,7 +289,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
{
int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
int chroma_shift = desc->log2_chroma_w;
int linesize_align[AV_NUM_DATA_POINTERS];
int align;
@ -486,7 +487,8 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
int unaligned;
AVPicture picture;
int stride_align[AV_NUM_DATA_POINTERS];
const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1 + 1;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
const int pixel_size = desc->comp[0].step_minus1 + 1;
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);

View File

@ -43,14 +43,15 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet)
{
enum AVPixelFormat pix_fmt = avctx->pix_fmt;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
uint32_t pixdepth, bpp, bpad, ncolors = 0, lsize, vclass, be = 0;
uint32_t rgb[3] = { 0 }, bitorder = 0;
uint32_t header_size;
int i, out_size, ret;
uint8_t *ptr, *buf;
pixdepth = av_get_bits_per_pixel(&av_pix_fmt_descriptors[pix_fmt]);
if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_BE)
pixdepth = av_get_bits_per_pixel(desc);
if (desc->flags & PIX_FMT_BE)
be = 1;
switch (pix_fmt) {
case AV_PIX_FMT_ARGB: