Merge commit 'a0cabd0a27587525e90a44660c795d40d2f44fe2'

* commit 'a0cabd0a27587525e90a44660c795d40d2f44fe2':
  mimic: cosmetics, reformat
  iff: drop ff_ prefix from a static function.
  pngdec: cosmetics, reformat.
  dxa: return meaningful error codes.
  eatgq: cosmetics, reformat.

Conflicts:
	libavcodec/dxa.c
	libavcodec/eatgq.c
	libavcodec/iff.c
	libavcodec/mimic.c
	libavcodec/pngdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-01-26 15:19:48 +01:00
commit 8ab97a60ef
5 changed files with 245 additions and 233 deletions

View File

@ -234,7 +234,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
if (uncompress(c->decomp_buf, &dsize, avpkt->data + bytestream2_tell(&gb),
bytestream2_get_bytes_left(&gb)) != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Uncompress failed!\n");
return AVERROR_INVALIDDATA;
return AVERROR_UNKNOWN;
}
}
switch(compr){

View File

@ -47,7 +47,8 @@ typedef struct TgqContext {
GetByteContext gb;
} TgqContext;
static av_cold int tgq_decode_init(AVCodecContext *avctx){
static av_cold int tgq_decode_init(AVCodecContext *avctx)
{
TgqContext *s = avctx->priv_data;
uint8_t idct_permutation[64];
s->avctx = avctx;
@ -58,7 +59,8 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx){
return 0;
}
static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb){
static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb)
{
uint8_t *perm = s->scantable.permutated;
int i, j, value;
block[0] = get_sbits(gb, 8) * s->qtable[0];
@ -103,7 +105,9 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb
block[0] += 128 << 4;
}
static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], int mb_x, int mb_y){
static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64],
int mb_x, int mb_y)
{
int linesize = s->frame.linesize[0];
uint8_t *dest_y = s->frame.data[0] + (mb_y * 16 * linesize) + mb_x * 16;
uint8_t *dest_cb = s->frame.data[1] + (mb_y * 8 * s->frame.linesize[1]) + mb_x * 8;
@ -119,7 +123,9 @@ static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], int mb_x, int m
}
}
static inline void tgq_dconly(TgqContext *s, unsigned char *dst, int dst_stride, int dc){
static inline void tgq_dconly(TgqContext *s, unsigned char *dst,
int dst_stride, int dc)
{
int level = av_clip_uint8((dc*s->qtable[0] + 2056) >> 4);
int j;
for (j = 0; j < 8; j++)
@ -142,10 +148,8 @@ static void tgq_idct_put_mb_dconly(TgqContext *s, int mb_x, int mb_y, const int8
}
}
/**
* @return <0 on error
*/
static int tgq_decode_mb(TgqContext *s, int mb_y, int mb_x){
static int tgq_decode_mb(TgqContext *s, int mb_y, int mb_x)
{
int mode;
int i;
int8_t dc[6];
@ -179,18 +183,21 @@ static int tgq_decode_mb(TgqContext *s, int mb_y, int mb_x){
return 0;
}
static void tgq_calculate_qtable(TgqContext *s, int quant){
static void tgq_calculate_qtable(TgqContext *s, int quant)
{
int i, j;
const int a = (14 * (100 - quant)) / 100 + 1;
const int b = (11 * (100 - quant)) / 100 + 4;
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++)
s->qtable[j*8+i] = ((a*(j+i)/(7+7) + b)*ff_inv_aanscales[j*8+i])>>(14-4);
s->qtable[j * 8 + i] = ((a * (j + i) / (7 + 7) + b) *
ff_inv_aanscales[j * 8 + i]) >> (14 - 4);
}
static int tgq_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt){
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
TgqContext *s = avctx->priv_data;
@ -240,7 +247,8 @@ static int tgq_decode_frame(AVCodecContext *avctx,
return avpkt->size;
}
static av_cold int tgq_decode_end(AVCodecContext *avctx){
static av_cold int tgq_decode_end(AVCodecContext *avctx)
{
TgqContext *s = avctx->priv_data;
if (s->frame.data[0])
s->avctx->release_buffer(avctx, &s->frame);

View File

@ -139,7 +139,7 @@ static av_always_inline uint32_t gray2rgb(const uint32_t x) {
/**
* Convert CMAP buffer (stored in extradata) to lavc palette format
*/
static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
{
IffContext *s = avctx->priv_data;
int count, i;
@ -671,10 +671,10 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return res;
} else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt == AV_PIX_FMT_PAL8) {
if ((res = ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
if ((res = cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
return res;
} else if (avctx->pix_fmt == AV_PIX_FMT_RGB32 && avctx->bits_per_coded_sample <= 8) {
if ((res = ff_cmap_read_palette(avctx, s->mask_palbuf)) < 0)
if ((res = cmap_read_palette(avctx, s->mask_palbuf)) < 0)
return res;
}
s->init = 1;

View File

@ -131,7 +131,8 @@ static int mimic_decode_update_thread_context(AVCodecContext *avctx, const AVCod
{
MimicContext *dst = avctx->priv_data, *src = avctx_from->priv_data;
if (avctx == avctx_from) return 0;
if (avctx == avctx_from)
return 0;
dst->cur_index = src->next_cur_index;
dst->prev_index = src->next_prev_index;
@ -232,25 +233,23 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
for (plane = 0; plane < 3; plane++) {
const int is_chroma = !!plane;
const int qscale = av_clip(10000-quality,is_chroma?1000:2000,10000)<<2;
const int qscale = av_clip(10000 - quality, is_chroma ? 1000 : 2000,
10000) << 2;
const int stride = ctx->flipped_ptrs[ctx->cur_index ].linesize[plane];
const uint8_t *src = ctx->flipped_ptrs[ctx->prev_index].data[plane];
uint8_t *dst = ctx->flipped_ptrs[ctx->cur_index ].data[plane];
for (y = 0; y < ctx->num_vblocks[plane]; y++) {
for (x = 0; x < ctx->num_hblocks[plane]; x++) {
/* Check for a change condition in the current block.
* - iframes always change.
* - Luma plane changes on get_bits1 == 0
* - Chroma planes change on get_bits1 == 1 */
if (is_iframe || get_bits1(&ctx->gb) == is_chroma) {
/* Luma planes may use a backreference from the 15 last
* frames preceding the previous. (get_bits1 == 1)
* Chroma planes don't use backreferences. */
if (is_chroma || is_iframe || !get_bits1(&ctx->gb)) {
if (!vlc_decode_block(ctx, num_coeffs, qscale))
return 0;
ctx->dsp.idct_put(dst, stride, ctx->dct_block);
@ -260,7 +259,8 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
uint8_t *p = ctx->flipped_ptrs[index].data[0];
if (index != ctx->cur_index && p) {
ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0);
ff_thread_await_progress(&ctx->buf_ptrs[index],
cur_row, 0);
p += src -
ctx->flipped_ptrs[ctx->prev_index].data[plane];
ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8);
@ -270,7 +270,8 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
}
}
} else {
ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index], cur_row, 0);
ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index],
cur_row, 0);
ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8);
}
src += 8;
@ -279,7 +280,8 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
src += (stride - ctx->num_hblocks[plane]) << 3;
dst += (stride - ctx->num_hblocks[plane]) << 3;
ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index], cur_row++, 0);
ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index],
cur_row++, 0);
}
}
@ -305,12 +307,12 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int swap_buf_size = buf_size - MIMIC_HEADER_SIZE;
MimicContext *ctx = avctx->priv_data;
GetByteContext gb;
int is_pframe;
int width, height;
int quality, num_coeffs;
int swap_buf_size = buf_size - MIMIC_HEADER_SIZE;
int res;
if (buf_size <= MIMIC_HEADER_SIZE) {
@ -356,7 +358,8 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
}
ctx->buf_ptrs[ctx->cur_index].reference = 3;
ctx->buf_ptrs[ctx->cur_index].pict_type = is_pframe ? AV_PICTURE_TYPE_P:AV_PICTURE_TYPE_I;
ctx->buf_ptrs[ctx->cur_index].pict_type = is_pframe ? AV_PICTURE_TYPE_P :
AV_PICTURE_TYPE_I;
if (ff_thread_get_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index])) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;

View File

@ -98,6 +98,7 @@ static void png_put_interlaced_row(uint8_t *dst, int width,
mask = png_pass_mask[pass];
dsp_mask = png_pass_dsp_mask[pass];
switch (bits_per_pixel) {
case 1:
src_x = 0;
@ -508,13 +509,13 @@ static int decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
PNGDecContext * const s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PNGDecContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *p;
AVDictionary *metadata = NULL;
uint8_t *crow_buf_base = NULL;
AVFrame *p;
uint32_t tag, length;
int64_t sig;
int ret;
@ -533,9 +534,8 @@ static int decode_frame(AVCodecContext *avctx,
return -1;
}
s->y=
s->state=0;
// memset(s, 0, sizeof(PNGDecContext));
s->y = s->state = 0;
/* init the zlib */
s->zstream.zalloc = ff_png_zalloc;
s->zstream.zfree = ff_png_zfree;
@ -582,7 +582,8 @@ static int decode_frame(AVCodecContext *avctx,
bytestream2_skip(&s->gb, 4); /* crc */
s->state |= PNG_IHDR;
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n",
av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "
"compression_type=%d filter_type=%d interlace_type=%d\n",
s->width, s->height, s->bit_depth, s->color_type,
s->compression_type, s->filter_type, s->interlace_type);
break;