Commit a51540d8 authored by Paul B Mahol's avatar Paul B Mahol

lavc: do not use av_pix_fmt_descriptors directly

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 27ccc82e
......@@ -230,6 +230,7 @@ static int decode_frame(AVCodecContext *avctx,
unsigned int buf_size = avpkt->size;
const uint8_t *buf_end = buf + buf_size;
const AVPixFmtDescriptor *desc;;
EXRContext *const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *const p = &s->picture;
......@@ -494,9 +495,10 @@ static int decode_frame(AVCodecContext *avctx,
avcodec_set_dimensions(avctx, w, h);
}
bxmin = xmin * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
axmax = (avctx->width - (xmax + 1)) * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
out_line_size = avctx->width * 2 * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
bxmin = xmin * 2 * desc->nb_components;
axmax = (avctx->width - (xmax + 1)) * 2 * desc->nb_components;
out_line_size = avctx->width * 2 * desc->nb_components;
scan_line_size = xdelta * current_channel_offset;
uncompressed_size = scan_line_size * scan_lines_per_block;
......@@ -590,7 +592,7 @@ static int decode_frame(AVCodecContext *avctx,
// Zero out the start if xmin is not 0
memset(ptr_x, 0, bxmin);
ptr_x += xmin * av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
ptr_x += xmin * desc->nb_components;
if (s->bits_per_color_id == 2) {
// 32-bit
for (x = 0; x < xdelta; x++) {
......
......@@ -916,6 +916,7 @@ static int sort_stt(FFV1Context *s, uint8_t stt[256]){
static av_cold int encode_init(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
FFV1Context *s = avctx->priv_data;
int i, j, k, m;
......@@ -983,7 +984,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV411P:
case AV_PIX_FMT_YUV410P:
s->chroma_planes= av_pix_fmt_descriptors[avctx->pix_fmt].nb_components < 3 ? 0 : 1;
s->chroma_planes= desc->nb_components < 3 ? 0 : 1;
s->colorspace= 0;
break;
case AV_PIX_FMT_YUVA444P:
......
......@@ -519,7 +519,8 @@ static int decode_frame_ilbm(AVCodecContext *avctx,
}
}
} else if (avctx->codec_tag == MKTAG('D','E','E','P')) {
int raw_width = avctx->width * (av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]) >> 3);
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int raw_width = avctx->width * (av_get_bits_per_pixel(desc) >> 3);
int x;
for(y = 0; y < avctx->height && buf < buf_end; y++ ) {
uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
......
......@@ -101,7 +101,7 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
out = pkt->data + 18; /* skip past the header we write */
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(av_pix_fmt_desc_get(avctx->pix_fmt));
switch(avctx->pix_fmt) {
case AV_PIX_FMT_PAL8: {
int pal_bpp = 24; /* Only write 32bit palette if there is transparency information */
......
......@@ -239,6 +239,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
TiffEncoderContext *s = avctx->priv_data;
AVFrame *const p = &s->picture;
int i;
......@@ -260,8 +261,8 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
s->subsampling[1] = 1;
avctx->bits_per_coded_sample =
s->bpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
s->bpp_tab_size = av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
s->bpp = av_get_bits_per_pixel(desc);
s->bpp_tab_size = desc->nb_components;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGBA64LE:
......@@ -305,7 +306,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
}
for (i = 0; i < s->bpp_tab_size; i++)
bpp_tab[i] = av_pix_fmt_descriptors[avctx->pix_fmt].comp[i].depth_minus1 + 1;
bpp_tab[i] = desc->comp[i].depth_minus1 + 1;
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || s->compr == TIFF_LZW)
//best choose for DEFLATE
......
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