diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-02 02:48:34 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-02 03:10:30 +0100 |
commit | 4121148388f4fd02ace89eca364904d3ea8bcfe7 (patch) | |
tree | c346f6906942b7a12c5c1f06e9d11205ea5660ab /libavcodec | |
parent | ef611095f0d0c1256cbb6654f94cae61a60f2736 (diff) | |
parent | f15f02c204e5fe355e084923c34dda1c6c3a66ec (diff) | |
download | ffmpeg-4121148388f4fd02ace89eca364904d3ea8bcfe7.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
avconv: make -frames work for all types of streams, not just video.
bfi: K&R cosmetics
bgmc: K&R cleanup
rawdec: Set start_time to 0 for raw audio files.
Detect 'yuv2' as rawvideo also in avi.
rawdec: propagate pict_type information to the output frame
rawdec: Support more QT 1bpp rawvideo files.
avconv: free bitstream filters
threads: limit the number of automatic threads to MAX_AUTO_THREADS
avplay: K&R cleanup
fate: use rgb24 as output format for dfa tests
threads: set thread_count to 1 when thread support is disabled
threads: introduce CODEC_CAP_AUTO_THREADS and add it to libx264
Conflicts:
ffplay.c
libavcodec/avcodec.h
libavcodec/pthread.c
libavcodec/version.h
tests/ref/fate/dfa1
tests/ref/fate/dfa10
tests/ref/fate/dfa11
tests/ref/fate/dfa2
tests/ref/fate/dfa3
tests/ref/fate/dfa4
tests/ref/fate/dfa5
tests/ref/fate/dfa6
tests/ref/fate/dfa7
tests/ref/fate/dfa8
tests/ref/fate/dfa9
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 4 | ||||
-rw-r--r-- | libavcodec/bfi.c | 23 | ||||
-rw-r--r-- | libavcodec/bgmc.c | 12 | ||||
-rw-r--r-- | libavcodec/libx264.c | 2 | ||||
-rw-r--r-- | libavcodec/pthread.c | 17 | ||||
-rw-r--r-- | libavcodec/utils.c | 2 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
7 files changed, 38 insertions, 24 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 690ea385ee..b366674c7c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -796,6 +796,10 @@ typedef struct RcOverride{ */ #define CODEC_CAP_PARAM_CHANGE 0x4000 /** + * Codec supports avctx->thread_count == 0 (auto). + */ +#define CODEC_CAP_AUTO_THREADS 0x8000 +/** * Codec is lossless. */ #define CODEC_CAP_LOSSLESS 0x80000000 diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c index 25863cb7d5..2aa1a4cb65 100644 --- a/libavcodec/bfi.c +++ b/libavcodec/bfi.c @@ -37,7 +37,7 @@ typedef struct BFIContext { uint32_t pal[256]; } BFIContext; -static av_cold int bfi_decode_init(AVCodecContext * avctx) +static av_cold int bfi_decode_init(AVCodecContext *avctx) { BFIContext *bfi = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; @@ -46,7 +46,7 @@ static av_cold int bfi_decode_init(AVCodecContext * avctx) return 0; } -static int bfi_decode_frame(AVCodecContext * avctx, void *data, +static int bfi_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data, *buf_end = avpkt->data + avpkt->size; @@ -73,11 +73,11 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data, bfi->frame.pict_type = AV_PICTURE_TYPE_I; bfi->frame.key_frame = 1; /* Setting the palette */ - if(avctx->extradata_size>768) { + if (avctx->extradata_size > 768) { av_log(NULL, AV_LOG_ERROR, "Palette is too large.\n"); return -1; } - pal = (uint32_t *) bfi->frame.data[1]; + pal = (uint32_t *)bfi->frame.data[1]; for (i = 0; i < avctx->extradata_size / 3; i++) { int shift = 16; *pal = 0xFF << 24; @@ -96,16 +96,17 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data, memcpy(bfi->frame.data[1], bfi->pal, sizeof(bfi->pal)); } - buf += 4; //Unpacked size, not required. + buf += 4; // Unpacked size, not required. while (dst != frame_end) { - static const uint8_t lentab[4]={0,2,0,1}; - unsigned int byte = *buf++, av_uninit(offset); - unsigned int code = byte >> 6; + static const uint8_t lentab[4] = { 0, 2, 0, 1 }; + unsigned int byte = *buf++, av_uninit(offset); + unsigned int code = byte >> 6; unsigned int length = byte & ~0xC0; if (buf >= buf_end) { - av_log(avctx, AV_LOG_ERROR, "Input resolution larger than actual frame.\n"); + av_log(avctx, AV_LOG_ERROR, + "Input resolution larger than actual frame.\n"); return -1; } @@ -125,7 +126,7 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data, } /* Do boundary check */ - if (dst + (length<<lentab[code]) > frame_end) + if (dst + (length << lentab[code]) > frame_end) break; switch (code) { @@ -172,7 +173,7 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data, dst += bfi->frame.linesize[0]; } *data_size = sizeof(AVFrame); - *(AVFrame *) data = bfi->frame; + *(AVFrame *)data = bfi->frame; return buf_size; } diff --git a/libavcodec/bgmc.c b/libavcodec/bgmc.c index b9041d080e..772a0af254 100644 --- a/libavcodec/bgmc.c +++ b/libavcodec/bgmc.c @@ -474,7 +474,8 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status) av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); return AVERROR(ENOMEM); } else { - // initialize lut_status buffer to a value never used to compare against + // initialize lut_status buffer to a value never used to compare + // against memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF); } @@ -494,7 +495,7 @@ void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status) /** Initialize decoding and reads the first value */ void ff_bgmc_decode_init(GetBitContext *gb, - unsigned int *h, unsigned int *l, unsigned int *v) + unsigned int *h, unsigned int *l, unsigned int *v) { *h = TOP_VALUE; *l = 0; @@ -513,9 +514,9 @@ void ff_bgmc_decode_end(GetBitContext *gb) /** Read and decode a block Gilbert-Moore coded symbol */ void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst, - int delta, unsigned int sx, - unsigned int *h, unsigned int *l, unsigned int *v, - uint8_t *cf_lut, int *cf_lut_status) + int delta, unsigned int sx, + unsigned int *h, unsigned int *l, unsigned int *v, + uint8_t *cf_lut, int *cf_lut_status) { unsigned int i; uint8_t *lut = bgmc_lut_getp(cf_lut, cf_lut_status, delta); @@ -567,4 +568,3 @@ void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst, *l = low; *v = value; } - diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 499c9536df..f23b3fa9ae 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -696,7 +696,7 @@ AVCodec ff_libx264_encoder = { .init = X264_init, .encode = X264_frame, .close = X264_close, - .capabilities = CODEC_CAP_DELAY, + .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS, .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .priv_class = &class, .defaults = x264_defaults, diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index cdf3a391cc..717b865bae 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -193,7 +193,7 @@ static int get_logical_cpus(AVCodecContext *avctx) if (avctx->height) nb_cpus = FFMIN(nb_cpus, (avctx->height+15)/16); - return FFMIN(nb_cpus, MAX_AUTO_THREADS); + return nb_cpus; } @@ -303,9 +303,11 @@ static int thread_init(AVCodecContext *avctx) if (!thread_count) { int nb_cpus = get_logical_cpus(avctx); - // use number of cores + 1 as thread count if there is motre than one + // use number of cores + 1 as thread count if there is more than one if (nb_cpus > 1) - thread_count = avctx->thread_count = nb_cpus + 1; + thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS); + else + thread_count = avctx->thread_count = 1; } if (thread_count <= 1) { @@ -783,9 +785,11 @@ static int frame_thread_init(AVCodecContext *avctx) int nb_cpus = get_logical_cpus(avctx); if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || avctx->debug_mv) nb_cpus = 1; - // use number of cores + 1 as thread count if there is motre than one + // use number of cores + 1 as thread count if there is more than one if (nb_cpus > 1) - thread_count = avctx->thread_count = nb_cpus + 1; + thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS); + else + thread_count = avctx->thread_count = 1; } if (thread_count <= 1) { @@ -1002,6 +1006,9 @@ static void validate_thread_parameters(AVCodecContext *avctx) } else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS && avctx->thread_type & FF_THREAD_SLICE) { avctx->active_thread_type = FF_THREAD_SLICE; + } else if (!(avctx->codec->capabilities & CODEC_CAP_AUTO_THREADS)) { + avctx->thread_count = 1; + avctx->active_thread_type = 0; } } diff --git a/libavcodec/utils.c b/libavcodec/utils.c index d152ec2ae3..619b70f3fb 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -765,6 +765,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD goto free_and_end; } } + if (!HAVE_THREADS && !(codec->capabilities & CODEC_CAP_AUTO_THREADS)) + avctx->thread_count = 1; if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) { av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n", diff --git a/libavcodec/version.h b/libavcodec/version.h index 1a6e3300ef..932bacdbb9 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -22,7 +22,7 @@ #define LIBAVCODEC_VERSION_MAJOR 53 #define LIBAVCODEC_VERSION_MINOR 49 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ |