mirror of https://github.com/FFmpeg/FFmpeg.git
* qatar/master: mss3: use standard zigzag table mss3: split DSP functions that are used in MTS2(MSS4) into separate file motion-test: do not use getopt() tcp: add initial timeout limit for incoming connections configure: Change the rdtsc check to a linker check avconv: propagate fatal errors from lavfi. lavfi: add error handling to filter_samples(). fate-run: make avconv() properly deal with multiple inputs. asplit: don't leak the input buffer. af_resample: fix request_frame() behavior. af_asyncts: fix request_frame() behavior. libx264: support aspect ratio switching matroskadec: honor error_recognition when encountering unknown elements. lavr: resampling: add support for s32p, fltp, and dblp internal sample formats lavr: resampling: add filter type and Kaiser window beta to AVOptions lavr: Use AV_SAMPLE_FMT_NONE to auto-select the internal sample format lavr: mix: validate internal sample format in ff_audio_mix_init() Conflicts: ffmpeg.c ffplay.c libavcodec/libx264.c libavfilter/audio.c libavfilter/split.c libavformat/tcp.c tests/fate-run.sh Merged-by: Michael Niedermayer <michaelni@gmx.at>pull/59/head
commit
f8911b987d
45 changed files with 648 additions and 339 deletions
@ -0,0 +1,114 @@ |
||||
/*
|
||||
* Common stuff for some Microsoft Screen codecs |
||||
* Copyright (C) 2012 Konstantin Shishkov |
||||
* |
||||
* 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 |
||||
*/ |
||||
|
||||
#include <stdint.h> |
||||
#include "libavutil/common.h" |
||||
#include "mss34dsp.h" |
||||
|
||||
static const uint8_t luma_quant[64] = { |
||||
16, 11, 10, 16, 24, 40, 51, 61, |
||||
12, 12, 14, 19, 26, 58, 60, 55, |
||||
14, 13, 16, 24, 40, 57, 69, 56, |
||||
14, 17, 22, 29, 51, 87, 80, 62, |
||||
18, 22, 37, 56, 68, 109, 103, 77, |
||||
24, 35, 55, 64, 81, 104, 113, 92, |
||||
49, 64, 78, 87, 103, 121, 120, 101, |
||||
72, 92, 95, 98, 112, 100, 103, 99 |
||||
}; |
||||
|
||||
static const uint8_t chroma_quant[64] = { |
||||
17, 18, 24, 47, 99, 99, 99, 99, |
||||
18, 21, 26, 66, 99, 99, 99, 99, |
||||
24, 26, 56, 99, 99, 99, 99, 99, |
||||
47, 66, 99, 99, 99, 99, 99, 99, |
||||
99, 99, 99, 99, 99, 99, 99, 99, |
||||
99, 99, 99, 99, 99, 99, 99, 99, |
||||
99, 99, 99, 99, 99, 99, 99, 99, |
||||
99, 99, 99, 99, 99, 99, 99, 99 |
||||
}; |
||||
|
||||
void ff_mss34_gen_quant_mat(uint16_t *qmat, int quality, int luma) |
||||
{ |
||||
int i; |
||||
const uint8_t *qsrc = luma ? luma_quant : chroma_quant; |
||||
|
||||
if (quality >= 50) { |
||||
int scale = 200 - 2 * quality; |
||||
|
||||
for (i = 0; i < 64; i++) |
||||
qmat[i] = (qsrc[i] * scale + 50) / 100; |
||||
} else { |
||||
for (i = 0; i < 64; i++) |
||||
qmat[i] = (5000 * qsrc[i] / quality + 50) / 100; |
||||
} |
||||
} |
||||
|
||||
#define DCT_TEMPLATE(blk, step, SOP, shift) \ |
||||
const int t0 = -39409 * blk[7 * step] - 58980 * blk[1 * step]; \
|
||||
const int t1 = 39410 * blk[1 * step] - 58980 * blk[7 * step]; \
|
||||
const int t2 = -33410 * blk[5 * step] - 167963 * blk[3 * step]; \
|
||||
const int t3 = 33410 * blk[3 * step] - 167963 * blk[5 * step]; \
|
||||
const int t4 = blk[3 * step] + blk[7 * step]; \
|
||||
const int t5 = blk[1 * step] + blk[5 * step]; \
|
||||
const int t6 = 77062 * t4 + 51491 * t5; \
|
||||
const int t7 = 77062 * t5 - 51491 * t4; \
|
||||
const int t8 = 35470 * blk[2 * step] - 85623 * blk[6 * step]; \
|
||||
const int t9 = 35470 * blk[6 * step] + 85623 * blk[2 * step]; \
|
||||
const int tA = SOP(blk[0 * step] - blk[4 * step]); \
|
||||
const int tB = SOP(blk[0 * step] + blk[4 * step]); \
|
||||
\
|
||||
blk[0 * step] = ( t1 + t6 + t9 + tB) >> shift; \
|
||||
blk[1 * step] = ( t3 + t7 + t8 + tA) >> shift; \
|
||||
blk[2 * step] = ( t2 + t6 - t8 + tA) >> shift; \
|
||||
blk[3 * step] = ( t0 + t7 - t9 + tB) >> shift; \
|
||||
blk[4 * step] = (-(t0 + t7) - t9 + tB) >> shift; \
|
||||
blk[5 * step] = (-(t2 + t6) - t8 + tA) >> shift; \
|
||||
blk[6 * step] = (-(t3 + t7) + t8 + tA) >> shift; \
|
||||
blk[7 * step] = (-(t1 + t6) + t9 + tB) >> shift; \
|
||||
|
||||
#define SOP_ROW(a) ((a) << 16) + 0x2000 |
||||
#define SOP_COL(a) ((a + 32) << 16) |
||||
|
||||
void ff_mss34_dct_put(uint8_t *dst, int stride, int *block) |
||||
{ |
||||
int i, j; |
||||
int *ptr; |
||||
|
||||
ptr = block; |
||||
for (i = 0; i < 8; i++) { |
||||
DCT_TEMPLATE(ptr, 1, SOP_ROW, 13); |
||||
ptr += 8; |
||||
} |
||||
|
||||
ptr = block; |
||||
for (i = 0; i < 8; i++) { |
||||
DCT_TEMPLATE(ptr, 8, SOP_COL, 22); |
||||
ptr++; |
||||
} |
||||
|
||||
ptr = block; |
||||
for (j = 0; j < 8; j++) { |
||||
for (i = 0; i < 8; i++) |
||||
dst[i] = av_clip_uint8(ptr[i] + 128); |
||||
dst += stride; |
||||
ptr += 8; |
||||
} |
||||
} |
@ -0,0 +1,45 @@ |
||||
/*
|
||||
* Common stuff for some Microsoft Screen codecs |
||||
* Copyright (C) 2012 Konstantin Shishkov |
||||
* |
||||
* 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 AVCODEC_MSS34DSP_H |
||||
#define AVCODEC_MSS34DSP_H |
||||
|
||||
#include <stdint.h> |
||||
|
||||
/**
|
||||
* Generate quantisation matrix for given quality. |
||||
* |
||||
* @param qmat destination matrix |
||||
* @param quality quality setting (1-100) |
||||
* @param luma generate quantisation matrix for luma or chroma |
||||
*/ |
||||
void ff_mss34_gen_quant_mat(uint16_t *qmat, int quality, int luma); |
||||
|
||||
/**
|
||||
* Transform and output DCT block. |
||||
* |
||||
* @param dst output plane |
||||
* @param stride output plane stride |
||||
* @param block block to transform and output |
||||
*/ |
||||
void ff_mss34_dct_put(uint8_t *dst, int stride, int *block); |
||||
|
||||
#endif /* AVCODEC_MSS34DSP_H */ |
@ -0,0 +1,102 @@ |
||||
/*
|
||||
* Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> |
||||
* |
||||
* 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 |
||||
*/ |
||||
|
||||
#if defined(CONFIG_RESAMPLE_DBL) |
||||
#define SET_TYPE(func) func ## _dbl |
||||
#define FELEM double |
||||
#define FELEM2 double |
||||
#define FELEML double |
||||
#define OUT(d, v) d = v |
||||
#define DBL_TO_FELEM(d, v) d = v |
||||
#elif defined(CONFIG_RESAMPLE_FLT) |
||||
#define SET_TYPE(func) func ## _flt |
||||
#define FELEM float |
||||
#define FELEM2 float |
||||
#define FELEML float |
||||
#define OUT(d, v) d = v |
||||
#define DBL_TO_FELEM(d, v) d = v |
||||
#elif defined(CONFIG_RESAMPLE_S32) |
||||
#define SET_TYPE(func) func ## _s32 |
||||
#define FELEM int32_t |
||||
#define FELEM2 int64_t |
||||
#define FELEML int64_t |
||||
#define OUT(d, v) d = av_clipl_int32((v + (1 << 29)) >> 30) |
||||
#define DBL_TO_FELEM(d, v) d = av_clipl_int32(llrint(v * (1 << 30))); |
||||
#else |
||||
#define SET_TYPE(func) func ## _s16 |
||||
#define FELEM int16_t |
||||
#define FELEM2 int32_t |
||||
#define FELEML int64_t |
||||
#define OUT(d, v) d = av_clip_int16((v + (1 << 14)) >> 15) |
||||
#define DBL_TO_FELEM(d, v) d = av_clip_int16(lrint(v * (1 << 15))) |
||||
#endif |
||||
|
||||
static void SET_TYPE(resample_one)(ResampleContext *c, int no_filter, |
||||
void *dst0, int dst_index, const void *src0, |
||||
int src_size, int index, int frac) |
||||
{ |
||||
FELEM *dst = dst0; |
||||
const FELEM *src = src0; |
||||
|
||||
if (no_filter) { |
||||
dst[dst_index] = src[index]; |
||||
} else { |
||||
int i; |
||||
int sample_index = index >> c->phase_shift; |
||||
FELEM2 val = 0; |
||||
FELEM *filter = ((FELEM *)c->filter_bank) + |
||||
c->filter_length * (index & c->phase_mask); |
||||
|
||||
if (sample_index < 0) { |
||||
for (i = 0; i < c->filter_length; i++) |
||||
val += src[FFABS(sample_index + i) % src_size] * |
||||
(FELEM2)filter[i]; |
||||
} else if (c->linear) { |
||||
FELEM2 v2 = 0; |
||||
for (i = 0; i < c->filter_length; i++) { |
||||
val += src[abs(sample_index + i)] * (FELEM2)filter[i]; |
||||
v2 += src[abs(sample_index + i)] * (FELEM2)filter[i + c->filter_length]; |
||||
} |
||||
val += (v2 - val) * (FELEML)frac / c->src_incr; |
||||
} else { |
||||
for (i = 0; i < c->filter_length; i++) |
||||
val += src[sample_index + i] * (FELEM2)filter[i]; |
||||
} |
||||
|
||||
OUT(dst[dst_index], val); |
||||
} |
||||
} |
||||
|
||||
static void SET_TYPE(set_filter)(void *filter0, double *tab, int phase, |
||||
int tap_count) |
||||
{ |
||||
int i; |
||||
FELEM *filter = ((FELEM *)filter0) + phase * tap_count; |
||||
for (i = 0; i < tap_count; i++) { |
||||
DBL_TO_FELEM(filter[i], tab[i]); |
||||
} |
||||
} |
||||
|
||||
#undef SET_TYPE |
||||
#undef FELEM |
||||
#undef FELEM2 |
||||
#undef FELEML |
||||
#undef OUT |
||||
#undef DBL_TO_FELEM |
Loading…
Reference in new issue