Commit 9dcc4c30 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  configure: add support for bdver1 and bdver2 CPU types.
  avio: make avio_close NULL the freed buffer
  pixdesc: cosmetics
  proresenc: Don't free a buffer not owned by the codec
  proresenc: Write the full value in one put_bits call
  adpcmenc: Calculate the IMA_QT predictor without overflow
  x86: Add convenience macros to check for CPU extensions and flags
  x86: h264dsp: drop some unnecessary ifdefs around prototype declarations
  mss12: merge decode_pixel() and decode_top_left_pixel()
  mss12: reduce SliceContext size from 1067 to 164 KB
  mss12: move SliceContexts out of the common context into the codec contexts

Conflicts:
	libavformat/aviobuf.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 9de76229 b36f87ff
......@@ -2404,7 +2404,7 @@ suncc_flags(){
prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
*-sse3) echo -xarch=sse3 ;;
core2) echo -xarch=ssse3 -xchip=core2 ;;
amdfam10|barcelona) echo -xarch=sse4_1 ;;
amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;;
athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
k8|opteron|athlon64|athlon-fx)
echo -xarch=sse2a ;;
......@@ -2773,7 +2773,7 @@ elif enabled x86; then
disable cmov
;;
# targets that do support conditional mov (cmov)
i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom)
i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom|bdver*)
cpuflags="-march=$cpu"
enable cmov
enable fast_cmov
......
......@@ -30,7 +30,7 @@
typedef struct MSS1Context {
MSS12Context ctx;
AVFrame pic;
SliceContext sc[2];
SliceContext sc;
} MSS1Context;
static void arith_normalise(ArithCoder *c)
......@@ -89,7 +89,7 @@ static int arith_get_number(ArithCoder *c, int mod_val)
return val;
}
static int arith_get_prob(ArithCoder *c, int *probs)
static int arith_get_prob(ArithCoder *c, int16_t *probs)
{
int range = c->high - c->low + 1;
int val = ((c->value - c->low + 1) * probs[0] - 1) / range;
......@@ -162,7 +162,8 @@ static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
c->pal_stride = -ctx->pic.linesize[0];
c->keyframe = !arith_get_bit(&acoder);
if (c->keyframe) {
ff_mss12_codec_reset(c);
c->corrupted = 0;
ff_mss12_slicecontext_reset(&ctx->sc);
pal_changed = decode_pal(c, &acoder);
ctx->pic.key_frame = 1;
ctx->pic.pict_type = AV_PICTURE_TYPE_I;
......@@ -172,7 +173,7 @@ static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
ctx->pic.key_frame = 0;
ctx->pic.pict_type = AV_PICTURE_TYPE_P;
}
c->corrupted = ff_mss12_decode_rect(&c->sc[0], &acoder, 0, 0,
c->corrupted = ff_mss12_decode_rect(&ctx->sc, &acoder, 0, 0,
avctx->width, avctx->height);
if (c->corrupted)
return AVERROR_INVALIDDATA;
......@@ -194,7 +195,7 @@ static av_cold int mss1_decode_init(AVCodecContext *avctx)
c->ctx.avctx = avctx;
avctx->coded_frame = &c->pic;
ret = ff_mss12_decode_init(&c->ctx, 0);
ret = ff_mss12_decode_init(&c->ctx, 0, &c->sc, NULL);
avctx->pix_fmt = PIX_FMT_PAL8;
......
This diff is collapsed.
......@@ -38,10 +38,9 @@
#define THRESH_HIGH 50
typedef struct Model {
int cum_prob[MODEL_MAX_SYMS + 1];
int weights[MODEL_MAX_SYMS + 1];
int idx2sym[MODEL_MAX_SYMS + 1];
int sym2idx[MODEL_MAX_SYMS + 1];
int16_t cum_prob[MODEL_MAX_SYMS + 1];
int16_t weights[MODEL_MAX_SYMS + 1];
uint8_t idx2sym[MODEL_MAX_SYMS + 1];
int num_syms;
int thr_weight, threshold;
} Model;
......@@ -60,7 +59,7 @@ typedef struct PixContext {
int cache_size, num_syms;
uint8_t cache[12];
Model cache_model, full_model;
Model sec_models[4][8][4];
Model sec_models[15][4];
int special_initial_cache;
} PixContext;
......@@ -86,21 +85,18 @@ typedef struct MSS12Context {
int rgb_stride;
int free_colours;
int keyframe;
Model intra_region, inter_region;
Model pivot, edge_mode, split_mode;
PixContext intra_pix_ctx, inter_pix_ctx;
int mvX, mvY;
int corrupted;
int slice_split;
int full_model_syms;
SliceContext sc[2];
} MSS12Context;
int ff_mss12_decode_rect(SliceContext *ctx, ArithCoder *acoder,
int x, int y, int width, int height);
void ff_mss12_model_update(Model *m, int val);
void ff_mss12_codec_reset(MSS12Context *ctx);
av_cold int ff_mss12_decode_init(MSS12Context *ctx, int version);
void ff_mss12_slicecontext_reset(SliceContext *sc);
av_cold int ff_mss12_decode_init(MSS12Context *c, int version,
SliceContext* sc1, SliceContext *sc2);
av_cold int ff_mss12_decode_end(MSS12Context *ctx);
#define ARITH_GET_BIT(VERSION) \
......
......@@ -106,7 +106,7 @@ static int arith2_get_number(ArithCoder *c, int n)
return val;
}
static int arith2_get_prob(ArithCoder *c, int *probs)
static int arith2_get_prob(ArithCoder *c, int16_t *probs)
{
int range = c->high - c->low + 1, n = *probs;
int scale = av_log2(range) - av_log2(n);
......@@ -671,14 +671,18 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
buf += get_bits_count(&gb) >> 3;
buf_size -= get_bits_count(&gb) >> 3;
} else {
if (keyframe)
ff_mss12_codec_reset(c);
if (keyframe) {
c->corrupted = 0;
ff_mss12_slicecontext_reset(&ctx->sc[0]);
if (c->slice_split)
ff_mss12_slicecontext_reset(&ctx->sc[1]);
}
else if (c->corrupted)
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
c->keyframe = keyframe;
if (c->corrupted = ff_mss12_decode_rect(&c->sc[0], &acoder, 0, 0,
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0,
avctx->width,
ctx->split_position))
return AVERROR_INVALIDDATA;
......@@ -690,7 +694,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
if (c->corrupted = ff_mss12_decode_rect(&c->sc[1], &acoder, 0,
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0,
ctx->split_position,
avctx->width,
avctx->height - ctx->split_position))
......@@ -830,7 +834,7 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx)
int ret;
c->avctx = avctx;
avctx->coded_frame = &ctx->pic;
if (ret = ff_mss12_decode_init(c, 1))
if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1]))
return ret;
c->pal_stride = c->mask_stride;
c->pal_pic = av_malloc(c->pal_stride * avctx->height);
......
......@@ -39,11 +39,9 @@ IDCT_ADD_FUNC(8_dc, 10, sse2)
IDCT_ADD_FUNC(8, 8, mmx)
IDCT_ADD_FUNC(8, 8, sse2)
IDCT_ADD_FUNC(8, 10, sse2)
#if HAVE_AVX_EXTERNAL
IDCT_ADD_FUNC(, 10, avx)
IDCT_ADD_FUNC(8_dc, 10, avx)
IDCT_ADD_FUNC(8, 10, avx)
#endif
#define IDCT_ADD_REP_FUNC(NUM, REP, DEPTH, OPT) \
......@@ -64,10 +62,8 @@ IDCT_ADD_REP_FUNC(, 16intra, 8, mmx)
IDCT_ADD_REP_FUNC(, 16intra, 8, mmx2)
IDCT_ADD_REP_FUNC(, 16intra, 8, sse2)
IDCT_ADD_REP_FUNC(, 16intra, 10, sse2)
#if HAVE_AVX_EXTERNAL
IDCT_ADD_REP_FUNC(, 16, 10, avx)
IDCT_ADD_REP_FUNC(, 16intra, 10, avx)
#endif
#define IDCT_ADD_REP_FUNC2(NUM, REP, DEPTH, OPT) \
......@@ -79,9 +75,7 @@ IDCT_ADD_REP_FUNC2(, 8, 8, mmx)
IDCT_ADD_REP_FUNC2(, 8, 8, mmx2)
IDCT_ADD_REP_FUNC2(, 8, 8, sse2)
IDCT_ADD_REP_FUNC2(, 8, 10, sse2)
#if HAVE_AVX_EXTERNAL
IDCT_ADD_REP_FUNC2(, 8, 10, avx)
#endif
void ff_h264_luma_dc_dequant_idct_mmx(DCTELEM *output, DCTELEM *input, int qmul);
void ff_h264_luma_dc_dequant_idct_sse2(DCTELEM *output, DCTELEM *input, int qmul);
......
......@@ -796,7 +796,7 @@ int avio_close(AVIOContext *s)
avio_flush(s);
h = s->opaque;
av_free(s->buffer);
av_freep(&s->buffer);
if (!s->write_flag)
av_log(s, AV_LOG_DEBUG, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count);
av_free(s);
......
......@@ -26,8 +26,10 @@
#include "intreadwrite.h"
void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
const AVPixFmtDescriptor *desc, int x, int y, int c, int w,
void av_read_image_line(uint16_t *dst,
const uint8_t *data[4], const int linesize[4],
const AVPixFmtDescriptor *desc,
int x, int y, int c, int w,
int read_pal_component)
{
AVComponentDescriptor comp = desc->comp[c];
......@@ -53,7 +55,8 @@ void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesiz
*dst++ = val;
}
} else {
const uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
const uint8_t *p = data[plane] + y * linesize[plane] +
x * step + comp.offset_plus1 - 1;
int is_8bit = shift + depth <= 8;
if (is_8bit)
......@@ -71,8 +74,10 @@ void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesiz
}
}
void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
void av_write_image_line(const uint16_t *src,
uint8_t *data[4], const int linesize[4],
const AVPixFmtDescriptor *desc,
int x, int y, int c, int w)
{
AVComponentDescriptor comp = desc->comp[c];
int plane = comp.plane;
......@@ -93,7 +98,8 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi
}
} else {
int shift = comp.shift;
uint8_t *p = data[plane] + y * linesize[plane] + x * step + comp.offset_plus1 - 1;
uint8_t *p = data[plane] + y * linesize[plane] +
x * step + comp.offset_plus1 - 1;
if (shift + depth <= 8) {
p += !!(flags & PIX_FMT_BE);
......
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVUTIL_X86_CPU_H
#define AVUTIL_X86_CPU_H
#include "config.h"
#include "libavutil/cpu.h"
#define CPUEXT(flags, suffix, cpuext) \
(HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext))
#define AV_CPU_FLAG_AMD3DNOW AV_CPU_FLAG_3DNOW
#define AV_CPU_FLAG_AMD3DNOWEXT AV_CPU_FLAG_3DNOWEXT
#define EXTERNAL_AMD3DNOW(flags) CPUEXT(flags, _EXTERNAL, AMD3DNOW)
#define EXTERNAL_AMD3DNOWEXT(flags) CPUEXT(flags, _EXTERNAL, AMD3DNOWEXT)
#define EXTERNAL_MMX(flags) CPUEXT(flags, _EXTERNAL, MMX)
#define EXTERNAL_MMXEXT(flags) CPUEXT(flags, _EXTERNAL, MMXEXT)
#define EXTERNAL_SSE(flags) CPUEXT(flags, _EXTERNAL, SSE)
#define EXTERNAL_SSE2(flags) CPUEXT(flags, _EXTERNAL, SSE2)
#define EXTERNAL_SSE3(flags) CPUEXT(flags, _EXTERNAL, SSE3)
#define EXTERNAL_SSSE3(flags) CPUEXT(flags, _EXTERNAL, SSSE3)
#define EXTERNAL_SSE4(flags) CPUEXT(flags, _EXTERNAL, SSE4)
#define EXTERNAL_SSE42(flags) CPUEXT(flags, _EXTERNAL, SSE42)
#define EXTERNAL_AVX(flags) CPUEXT(flags, _EXTERNAL, AVX)
#define EXTERNAL_FMA4(flags) CPUEXT(flags, _EXTERNAL, FMA4)
#define INLINE_AMD3DNOW(flags) CPUEXT(flags, _INLINE, AMD3DNOW)
#define INLINE_AMD3DNOWEXT(flags) CPUEXT(flags, _INLINE, AMD3DNOWEXT)
#define INLINE_MMX(flags) CPUEXT(flags, _INLINE, MMX)
#define INLINE_MMXEXT(flags) CPUEXT(flags, _INLINE, MMXEXT)
#define INLINE_SSE(flags) CPUEXT(flags, _INLINE, SSE)
#define INLINE_SSE2(flags) CPUEXT(flags, _INLINE, SSE2)
#define INLINE_SSE3(flags) CPUEXT(flags, _INLINE, SSE3)
#define INLINE_SSSE3(flags) CPUEXT(flags, _INLINE, SSSE3)
#define INLINE_SSE4(flags) CPUEXT(flags, _INLINE, SSE4)
#define INLINE_SSE42(flags) CPUEXT(flags, _INLINE, SSE42)
#define INLINE_AVX(flags) CPUEXT(flags, _INLINE, AVX)
#define INLINE_FMA4(flags) CPUEXT(flags, _INLINE, FMA4)
#endif /* AVUTIL_X86_CPU_H */
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