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

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  build: fix standalone compilation of OMA muxer
  build: fix standalone compilation of Microsoft XMV demuxer
  build: fix standalone compilation of Core Audio Format demuxer
  kvmc: fix invalid reads
  4xm: Add a check in decode_i_frame to prevent buffer overreads
  adpcm: fix IMA SMJPEG decoding
  options: set minimum for "threads" to zero
  bsd: use number of logical CPUs as automatic thread count
  windows: use number of CPUs as automatic thread count
  linux: use number of CPUs as automatic thread count
  pthreads: reset active_thread_type when slice thread_init returrns early
  v410dec: include correct headers
  Drop ALT_ prefix from BITSTREAM_READER_LE name.
  lavfi: always build vsrc_buffer.
  ra144enc: zero the reflection coeffs if the filter is unstable
  sws: readd PAL8 to isPacked()
  mov: Don't stick the QuickTime field ordering atom in extradata.
  truespeech: fix invalid reads in truespeech_apply_twopoint_filter()

Conflicts:
	configure
	libavcodec/4xm.c
	libavcodec/avcodec.h
	libavfilter/Makefile
	libavfilter/allfilters.c
	libavformat/Makefile
	libswscale/swscale_internal.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-12-23 03:00:12 +01:00
commit d1c28e3530
48 changed files with 291 additions and 84 deletions

View File

@ -2139,6 +2139,7 @@ static int transcode_init(OutputFile *output_files,
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->field_order = icodec->field_order;
codec->extradata = av_mallocz(extra_size);
if (!codec->extradata) {
return AVERROR(ENOMEM);

9
configure vendored
View File

@ -1174,6 +1174,7 @@ HAVE_LIST="
gethrtime
GetProcessMemoryInfo
GetProcessTimes
GetSystemInfo
getrusage
gnu_as
ibm_asm
@ -1206,6 +1207,7 @@ HAVE_LIST="
posix_memalign
round
roundf
sched_getaffinity
sdl
sdl_video_size
setmode
@ -1224,6 +1226,7 @@ HAVE_LIST="
symver
symver_asm_label
symver_gnu_asm
sysctl
sys_mman_h
sys_resource_h
sys_select_h
@ -1654,14 +1657,13 @@ postproc_deps="gpl"
# programs
avconv_deps="avcodec avformat swscale"
avconv_select="buffer_filter"
ffplay_deps="avcodec avformat swscale sdl"
ffplay_select="buffersink_filter rdft"
ffprobe_deps="avcodec avformat"
ffserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer"
ffserver_extralibs='$ldl'
ffmpeg_deps="avcodec avformat swscale swresample"
ffmpeg_select="buffer_filter buffersink_filter"
ffmpeg_select="buffersink_filter"
doc_deps="texi2html"
@ -3000,12 +3002,15 @@ check_func ${malloc_prefix}posix_memalign && enable posix_memalign
check_func setrlimit
check_func strerror_r
check_func strptime
check_func sched_getaffinity
check_func sysctl
check_func_headers conio.h kbhit
check_func_headers windows.h PeekNamedPipe
check_func_headers io.h setmode
check_func_headers lzo/lzo1x.h lzo1x_999_compress
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
check_func_headers windows.h GetProcessTimes
check_func_headers windows.h GetSystemInfo
check_func_headers windows.h MapViewOfFile
check_func_headers windows.h VirtualAlloc

View File

@ -2213,6 +2213,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files,
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->field_order = icodec->field_order;
codec->extradata = av_mallocz(extra_size);
if (!codec->extradata) {
return AVERROR(ENOMEM);

View File

@ -688,8 +688,11 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){
unsigned int prestream_size;
const uint8_t *prestream;
if (bitstream_size > (1<<26) || length < bitstream_size + 12)
return -1;
if (bitstream_size > (1<<26) || length < bitstream_size + 12) {
av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n");
return AVERROR_INVALIDDATA;
}
prestream_size = 4 * AV_RL32(buf + bitstream_size + 4);
prestream = buf + bitstream_size + 12;

View File

@ -1007,11 +1007,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
break;
case CODEC_ID_ADPCM_IMA_AMV:
case CODEC_ID_ADPCM_IMA_SMJPEG:
c->status[0].predictor = (int16_t)bytestream_get_le16(&src);
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) {
c->status[0].predictor = sign_extend(bytestream_get_le16(&src), 16);
c->status[0].step_index = bytestream_get_le16(&src);
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
src += 4;
} else {
c->status[0].predictor = sign_extend(bytestream_get_be16(&src), 16);
c->status[0].step_index = bytestream_get_byte(&src);
src += 1;
}
for (n = nb_samples >> (1 - st); n > 0; n--, src++) {
char hi, lo;

View File

@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "dsputil.h"
#include "get_bits.h"

View File

@ -1335,6 +1335,15 @@ typedef struct AVFrame {
struct AVCodecInternal;
enum AVFieldOrder {
AV_FIELD_UNKNOWN,
AV_FIELD_PROGRESSIVE,
AV_FIELD_TT, //< Top coded_first, top displayed first
AV_FIELD_BB, //< Bottom coded first, bottom displayed first
AV_FIELD_TB, //< Top coded first, bottom displayed first
AV_FIELD_BT, //< Bottom coded first, top displayed first
};
/**
* main external API structure.
* New fields can be added to the end with minor version bumps.
@ -3191,6 +3200,12 @@ typedef struct AVCodecContext {
*/
struct AVCodecInternal *internal;
/** Field order
* - encoding: set by libavcodec
* - decoding: Set by libavcodec
*/
enum AVFieldOrder field_order;
/**
* Current statistics for PTS correction.
* - decoding: maintained and used by libavcodec, not intended to be used by user apps

View File

@ -27,7 +27,7 @@
#include "binkdsp.h"
#include "mathops.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#define BINK_FLAG_ALPHA 0x00100000

View File

@ -29,7 +29,7 @@
*/
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "dsputil.h"
#include "dct.h"

View File

@ -29,7 +29,7 @@
*/
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "bytestream.h"
#include "dsputil.h"

View File

@ -29,7 +29,7 @@
*/
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "libavutil/lzo.h"
#include "libavutil/imgutils.h"

View File

@ -21,7 +21,7 @@
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
typedef union MacroBlock {

View File

@ -21,7 +21,7 @@
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
typedef struct Escape130Context {

View File

@ -26,7 +26,7 @@
*/
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "acelp_vectors.h"
#include "celp_filters.h"

View File

@ -124,7 +124,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
#define CLOSE_READER(name, gb) (gb)->index = name##_index
#ifdef ALT_BITSTREAM_READER_LE
#ifdef BITSTREAM_READER_LE
# ifdef LONG_BITSTREAM_READER
# define UPDATE_CACHE(name, gb) name##_cache = \
@ -164,7 +164,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
#define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
#ifdef ALT_BITSTREAM_READER_LE
#ifdef BITSTREAM_READER_LE
# define SHOW_UBITS(name, gb, num) zero_extend(name##_cache, num)
# define SHOW_SBITS(name, gb, num) sign_extend(name##_cache, num)
#else
@ -254,7 +254,7 @@ static inline unsigned int get_bits1(GetBitContext *s)
{
unsigned int index = s->index;
uint8_t result = s->buffer[index>>3];
#ifdef ALT_BITSTREAM_READER_LE
#ifdef BITSTREAM_READER_LE
result >>= index & 7;
result &= 1;
#else
@ -288,7 +288,7 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n)
if (n <= MIN_CACHE_BITS)
return get_bits(s, n);
else {
#ifdef ALT_BITSTREAM_READER_LE
#ifdef BITSTREAM_READER_LE
int ret = get_bits(s, 16);
return ret | (get_bits(s, n-16) << 16);
#else

View File

@ -23,7 +23,7 @@
* @file
* Intel Indeo 2 decoder.
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "indeo2data.h"
@ -163,7 +163,7 @@ static int ir2_decode_frame(AVCodecContext *avctx,
s->decode_delta = buf[18];
/* decide whether frame uses deltas or not */
#ifndef ALT_BITSTREAM_READER_LE
#ifndef BITSTREAM_READER_LE
for (i = 0; i < buf_size; i++)
buf[i] = av_reverse[buf[i]];
#endif
@ -205,7 +205,7 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){
ir2_vlc.table = vlc_tables;
ir2_vlc.table_allocated = 1 << CODE_VLC_BITS;
#ifdef ALT_BITSTREAM_READER_LE
#ifdef BITSTREAM_READER_LE
init_vlc(&ir2_vlc, CODE_VLC_BITS, IR2_CODES,
&ir2_codes[0][1], 4, 2,
&ir2_codes[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE);

View File

@ -26,7 +26,7 @@
#define IR2_CODES 143
static const uint16_t ir2_codes[IR2_CODES][2] = {
#ifdef ALT_BITSTREAM_READER_LE
#ifdef BITSTREAM_READER_LE
{0x0000, 3}, {0x0004, 3}, {0x0006, 3}, {0x0001, 5},
{0x0009, 5}, {0x0019, 5}, {0x000D, 5}, {0x001D, 5},
{0x0023, 6}, {0x0013, 6}, {0x0033, 6}, {0x000B, 6},

View File

@ -27,7 +27,7 @@
* Known FOURCCs: 'IV50'
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"

View File

@ -41,7 +41,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "dsputil.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#define PALETTE_COUNT 256

View File

@ -26,7 +26,7 @@
* Indeo5 decoders.
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "ivi_common.h"

View File

@ -57,17 +57,21 @@ typedef struct BitBuf {
#define kmvc_init_getbits(bb, src) bb.bits = 7; bb.bitbuf = *src++;
#define kmvc_getbit(bb, src, res) {\
#define kmvc_getbit(bb, src, src_end, res) {\
res = 0; \
if (bb.bitbuf & (1 << bb.bits)) res = 1; \
bb.bits--; \
if(bb.bits == -1) { \
if (src >= src_end) { \
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); \
return AVERROR_INVALIDDATA; \
} \
bb.bitbuf = *src++; \
bb.bits = 7; \
} \
}
static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h)
static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src_size, int w, int h)
{
BitBuf bb;
int res, val;
@ -75,13 +79,18 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w,
int bx, by;
int l0x, l1x, l0y, l1y;
int mx, my;
const uint8_t *src_end = src + src_size;
kmvc_init_getbits(bb, src);
for (by = 0; by < h; by += 8)
for (bx = 0; bx < w; bx += 8) {
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) { // fill whole 8x8 block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
@ -89,14 +98,22 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w,
for (i = 0; i < 4; i++) {
l0x = bx + (i & 1) * 4;
l0y = by + (i & 2) * 2;
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) {
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) { // fill whole 4x4 block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
} else { // copy block from already decoded place
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
mx = val & 0xF;
my = val >> 4;
@ -108,16 +125,24 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w,
for (j = 0; j < 4; j++) {
l1x = l0x + (j & 1) * 2;
l1y = l0y + (j & 2);
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) {
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) { // fill whole 2x2 block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
BLK(ctx->cur, l1x, l1y) = val;
BLK(ctx->cur, l1x + 1, l1y) = val;
BLK(ctx->cur, l1x, l1y + 1) = val;
BLK(ctx->cur, l1x + 1, l1y + 1) = val;
} else { // copy block from already decoded place
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
mx = val & 0xF;
my = val >> 4;
@ -140,9 +165,11 @@ static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w,
}
}
}
return 0;
}
static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h)
static int kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int src_size, int w, int h)
{
BitBuf bb;
int res, val;
@ -150,15 +177,20 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w,
int bx, by;
int l0x, l1x, l0y, l1y;
int mx, my;
const uint8_t *src_end = src + src_size;
kmvc_init_getbits(bb, src);
for (by = 0; by < h; by += 8)
for (bx = 0; bx < w; bx += 8) {
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) {
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) { // fill whole 8x8 block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
@ -171,14 +203,22 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w,
for (i = 0; i < 4; i++) {
l0x = bx + (i & 1) * 4;
l0y = by + (i & 2) * 2;
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) {
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) { // fill whole 4x4 block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
} else { // copy block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
@ -190,16 +230,24 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w,
for (j = 0; j < 4; j++) {
l1x = l0x + (j & 1) * 2;
l1y = l0y + (j & 2);
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) {
kmvc_getbit(bb, src, res);
kmvc_getbit(bb, src, src_end, res);
if (!res) { // fill whole 2x2 block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
BLK(ctx->cur, l1x, l1y) = val;
BLK(ctx->cur, l1x + 1, l1y) = val;
BLK(ctx->cur, l1x, l1y + 1) = val;
BLK(ctx->cur, l1x + 1, l1y + 1) = val;
} else { // copy block
if (src >= src_end) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = *src++;
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
@ -222,6 +270,8 @@ static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w,
}
}
}
return 0;
}
static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt)
@ -299,10 +349,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa
memcpy(ctx->cur, ctx->prev, 320 * 200);
break;
case 3:
kmvc_decode_intra_8x8(ctx, buf, avctx->width, avctx->height);
kmvc_decode_intra_8x8(ctx, buf, buf_size, avctx->width, avctx->height);
break;
case 4:
kmvc_decode_inter_8x8(ctx, buf, avctx->width, avctx->height);
kmvc_decode_inter_8x8(ctx, buf, buf_size, avctx->width, avctx->height);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression method %i\n", header & KMVC_METHOD);

View File

@ -112,13 +112,10 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
build_basic_mjpeg_vlc(s);
}
}
if (avctx->extradata_size > 9 &&
AV_RL32(avctx->extradata + 4) == MKTAG('f','i','e','l')) {
if (avctx->extradata[9] == 6) { /* quicktime icefloe 019 */
if (avctx->field_order == AV_FIELD_BB) { /* quicktime icefloe 019 */
s->interlace_polarity = 1; /* bottom field first */
av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n");
}
}
if (avctx->codec->id == CODEC_ID_AMV)
s->flipped = 1;

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "msgsmdec.h"
#include "gsmdec_template.c"

View File

@ -35,7 +35,7 @@
#include "avcodec.h"
#include "dsputil.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
const float ff_nelly_dequantization_table[127] = {

View File

@ -41,7 +41,7 @@
#include "fmtconvert.h"
#include "sinewin.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"

View File

@ -371,7 +371,8 @@ static const AVOption options[]={
{"float", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"},
#endif
{"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E|D},
{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, 0, INT_MAX, V|E|D, "threads"},
{"auto", "detect a good number of threads", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"},
{"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"dc", "intra_dc_precision", OFFSET(intra_dc_precision), AV_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E},

View File

@ -30,6 +30,17 @@
*/
#include "config.h"
#if HAVE_SCHED_GETAFFINITY
#define _GNU_SOURCE
#include <sched.h>
#elif HAVE_GETSYSTEMINFO
#include <windows.h>
#elif HAVE_SYSCTL
#include <sys/sysctl.h>
#include <sys/types.h>
#endif
#include "avcodec.h"
#include "internal.h"
#include "thread.h"
@ -135,6 +146,40 @@ typedef struct FrameThreadContext {
int die; ///< Set when threads should exit.
} FrameThreadContext;
/* H264 slice threading seems to be buggy with more than 16 threads,
* limit the number of threads to 16 for automatic detection */
#define MAX_AUTO_THREADS 16
static int get_logical_cpus(AVCodecContext *avctx)
{
int ret, nb_cpus = 1;
#if HAVE_SCHED_GETAFFINITY
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
ret = sched_getaffinity(0, sizeof(cpuset), &cpuset);
if (!ret) {
nb_cpus = CPU_COUNT(&cpuset);
}
#elif HAVE_GETSYSTEMINFO
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
nb_cpus = sysinfo.dwNumberOfProcessors;
#elif HAVE_SYSCTL
int mib[2] = { CTL_HW, HW_NCPU };
size_t len = sizeof(nb_cpus);
ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0);
if (ret == -1)
nb_cpus = 0;
#endif
av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
return FFMIN(nb_cpus, MAX_AUTO_THREADS);
}
static void* attribute_align_arg worker(void *v)
{
AVCodecContext *avctx = v;
@ -239,8 +284,17 @@ static int thread_init(AVCodecContext *avctx)
ThreadContext *c;
int thread_count = avctx->thread_count;
if (thread_count <= 1)
if (!thread_count) {
int nb_cpus = get_logical_cpus(avctx);
// use number of cores + 1 as thread count if there is motre than one
if (nb_cpus > 1)
thread_count = avctx->thread_count = nb_cpus + 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
c = av_mallocz(sizeof(ThreadContext));
if (!c)
@ -704,6 +758,13 @@ static int frame_thread_init(AVCodecContext *avctx)
FrameThreadContext *fctx;
int i, err = 0;
if (!thread_count) {
int nb_cpus = get_logical_cpus(avctx);
// use number of cores + 1 as thread count if there is motre than one
if (nb_cpus > 1)
thread_count = avctx->thread_count = nb_cpus + 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;

View File

@ -35,7 +35,7 @@
#include <stddef.h>
#include <stdio.h>
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"

View File

@ -477,7 +477,10 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame,
* The filter is unstable: use the coefficients of the previous frame.
*/
ff_int_to_int16(block_coefs[NBLOCKS - 1], ractx->lpc_coef[1]);
ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx);
if (ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx)) {
/* the filter is still unstable. set reflection coeffs to zero. */
memset(lpc_refl, 0, sizeof(lpc_refl));
}
}
init_put_bits(&pb, frame, buf_size);
for (i = 0; i < LPC_ORDER; i++) {

View File

@ -20,7 +20,7 @@
*/
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "ra288.h"
#include "lpc.h"

View File

@ -27,7 +27,7 @@
#include "libavutil/mathematics.h"
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "dsputil.h"

View File

@ -35,7 +35,7 @@
#include "libavutil/audioconvert.h"
#include "mathops.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "bytestream.h"

View File

@ -25,7 +25,7 @@
*/
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"

View File

@ -179,6 +179,7 @@ static void truespeech_apply_twopoint_filter(TSContext *dec, int quart)
for(i = 0; i < 146; i++)
tmp[i] = dec->filtbuf[i];
off = (t / 25) + dec->offset1[quart >> 1] + 18;
off = av_clip(off, 0, 145);
ptr0 = tmp + 145 - off;
ptr1 = tmp + 146;
filter = (const int16_t*)ts_order2_coeffs + (t % 25) * 2;

View File

@ -27,7 +27,7 @@
* @author Alex Beregszaszi
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
//#define DEBUG
#include <limits.h>
#include "avcodec.h"

View File

@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "get_bits.h"
static av_cold int v410_decode_init(AVCodecContext *avctx)
{

View File

@ -24,7 +24,7 @@
* VBLE Decoder
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "dsputil.h"

View File

@ -26,7 +26,7 @@
* @author Denes Balatoni ( dbalatoni programozo hu )
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"

View File

@ -29,7 +29,7 @@
#include <inttypes.h>
#include <math.h>
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"

View File

@ -18,7 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "unary.h"

View File

@ -35,7 +35,7 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "bytestream.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
// for av_memcpy_backptr
#include "libavutil/lzo.h"

View File

@ -23,7 +23,7 @@
#include "avcodec.h"
#include "libavutil/intreadwrite.h"
#include "bytestream.h"
#define ALT_BITSTREAM_READER_LE
#define BITSTREAM_READER_LE
#include "get_bits.h"
// for av_memcpy_backptr
#include "libavutil/lzo.h"

View File

@ -20,6 +20,7 @@ OBJS = allfilters.o \
formats.o \
graphparser.o \
transform.o \
vsrc_buffer.o
OBJS-$(CONFIG_AVCODEC) += avcodec.o
@ -83,7 +84,6 @@ OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o
OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o
OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o
OBJS-$(CONFIG_BUFFER_FILTER) += vsrc_buffer.o
OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o
OBJS-$(CONFIG_COLOR_FILTER) += vsrc_color.o
OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o

View File

@ -94,7 +94,6 @@ void avfilter_register_all(void)
REGISTER_FILTER (VFLIP, vflip, vf);
REGISTER_FILTER (YADIF, yadif, vf);
REGISTER_FILTER (BUFFER, buffer, vsrc);
REGISTER_FILTER (CELLAUTO, cellauto, vsrc);
REGISTER_FILTER (COLOR, color, vsrc);
REGISTER_FILTER (FREI0R, frei0r_src, vsrc);
@ -108,4 +107,10 @@ void avfilter_register_all(void)
REGISTER_FILTER (BUFFERSINK, buffersink, vsink);
REGISTER_FILTER (NULLSINK, nullsink, vsink);
/* vsrc_buffer is a part of public API => registered unconditionally */
{
extern avfilter_vsrc_buffer;
avfilter_register(&avfilter_vsrc_buffer);
}
}

View File

@ -56,7 +56,8 @@ OBJS-$(CONFIG_BIT_DEMUXER) += bit.o
OBJS-$(CONFIG_BIT_MUXER) += bit.o
OBJS-$(CONFIG_BMV_DEMUXER) += bmv.o
OBJS-$(CONFIG_C93_DEMUXER) += c93.o vocdec.o voc.o
OBJS-$(CONFIG_CAF_DEMUXER) += cafdec.o caf.o mov.o riff.o isom.o
OBJS-$(CONFIG_CAF_DEMUXER) += cafdec.o caf.o mov.o mov_chan.o \
riff.o isom.o
OBJS-$(CONFIG_CAF_MUXER) += cafenc.o caf.o riff.o isom.o
OBJS-$(CONFIG_CAVSVIDEO_DEMUXER) += cavsvideodec.o rawdec.o
OBJS-$(CONFIG_CAVSVIDEO_MUXER) += rawenc.o
@ -195,7 +196,7 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \
OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \
vorbiscomment.o
OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o
OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o
OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o
OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += pcmdec.o pcm.o rawdec.o
OBJS-$(CONFIG_PCM_ALAW_MUXER) += pcmenc.o rawenc.o
OBJS-$(CONFIG_PCM_F32BE_DEMUXER) += pcmdec.o pcm.o rawdec.o
@ -331,7 +332,7 @@ OBJS-$(CONFIG_WTV_MUXER) += wtvenc.o wtv.o asf.o asfenc.o riff.o
OBJS-$(CONFIG_WV_DEMUXER) += wv.o apetag.o
OBJS-$(CONFIG_XA_DEMUXER) += xa.o
OBJS-$(CONFIG_XBIN_DEMUXER) += bintext.o sauce.o
OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o
OBJS-$(CONFIG_XMV_DEMUXER) += xmv.o riff.o
OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o riff.o
OBJS-$(CONFIG_YOP_DEMUXER) += yop.o
OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg.o

View File

@ -857,6 +857,40 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
unsigned mov_field_order;
enum AVFieldOrder decoded_field_order = AV_FIELD_UNKNOWN;
if (c->fc->nb_streams < 1) // will happen with jp2 files
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if (atom.size < 2)
return AVERROR_INVALIDDATA;
mov_field_order = avio_rb16(pb);
if ((mov_field_order & 0xFF00) == 0x0100)
decoded_field_order = AV_FIELD_PROGRESSIVE;
else if ((mov_field_order & 0xFF00) == 0x0200) {
switch (mov_field_order & 0xFF) {
case 0x01: decoded_field_order = AV_FIELD_TT;
break;
case 0x06: decoded_field_order = AV_FIELD_BB;
break;
case 0x09: decoded_field_order = AV_FIELD_TB;
break;
case 0x0E: decoded_field_order = AV_FIELD_BT;
break;
}
}
if (decoded_field_order == AV_FIELD_UNKNOWN && mov_field_order) {
av_log(NULL, AV_LOG_ERROR, "Unknown MOV field order 0x%04x\n", mov_field_order);
}
st->codec->field_order = decoded_field_order;
return 0;
}
/* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom,
enum CodecID codec_id)
@ -898,11 +932,6 @@ static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return mov_read_extradata(c, pb, atom, CODEC_ID_AVS);
}
static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return mov_read_extradata(c, pb, atom, CODEC_ID_MJPEG);
}
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return mov_read_extradata(c, pb, atom, CODEC_ID_JPEG2000);
@ -950,6 +979,15 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if ((uint64_t)atom.size > (1<<30))
return -1;
if (atom.size >= 10) {
// Broken files created by legacy versions of Libav and FFmpeg will
// wrap a whole fiel atom inside of a glbl atom.
unsigned size = avio_rb32(pb);
unsigned type = avio_rl32(pb);
avio_seek(pb, -8, SEEK_CUR);
if (type == MKTAG('f','i','e','l') && size == atom.size)
return mov_read_default(c, pb, atom);
}
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)

View File

@ -799,6 +799,23 @@ static int mov_write_uuid_tag_ipod(AVIOContext *pb)
return 28;
}
static const uint16_t fiel_data[] = {
0x0000, 0x0100, 0x0201, 0x0206, 0x0209, 0x020e
};
static int mov_write_fiel_tag(AVIOContext *pb, MOVTrack *track)
{
unsigned mov_field_order = 0;
if (track->enc->field_order < FF_ARRAY_ELEMS(fiel_data))
mov_field_order = fiel_data[track->enc->field_order];
else
return 0;
avio_wb32(pb, 10);
ffio_wfourcc(pb, "fiel");
avio_wb16(pb, mov_field_order);
return 10;
}
static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
@ -885,7 +902,9 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
mov_write_avcc_tag(pb, track);
if(track->mode == MODE_IPOD)
mov_write_uuid_tag_ipod(pb);
} else if(track->vosLen > 0)
} else if (track->enc->field_order != AV_FIELD_UNKNOWN)
mov_write_fiel_tag(pb, track);
else if(track->vosLen > 0)
mov_write_glbl_tag(pb, track);
if (track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num &&

View File

@ -655,9 +655,11 @@ const char *sws_format_name(enum PixelFormat format);
|| isBGRinInt(x) \
)
#else
#define isPacked(x) \
#define isPacked(x) (\
(av_pix_fmt_descriptors[x].nb_components >= 2 && \
!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR)) || \
(x) == PIX_FMT_PAL8\
)
#endif
#define isPlanar(x) \