mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-27 09:52:17 +00:00
h264: remove an artificial restriction on the number of slice threads
This limit is now unnecessary, we can easily support an arbitrary number of threads.
This commit is contained in:
parent
4fd34e639d
commit
e065279529
@ -285,7 +285,6 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
|
||||
h->avctx = avctx;
|
||||
|
||||
h->picture_structure = PICT_FRAME;
|
||||
h->slice_context_count = 1;
|
||||
h->workaround_bugs = avctx->workaround_bugs;
|
||||
h->flags = avctx->flags;
|
||||
h->poc.prev_poc_msb = 1 << 16;
|
||||
@ -300,7 +299,7 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
|
||||
|
||||
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
|
||||
|
||||
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;
|
||||
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? avctx->thread_count : 1;
|
||||
h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
|
||||
if (!h->slice_ctx) {
|
||||
h->nb_slice_ctx = 0;
|
||||
@ -809,7 +808,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
|
||||
int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
|
||||
int i, ret = 0;
|
||||
|
||||
h->max_contexts = h->slice_context_count;
|
||||
h->max_contexts = h->nb_slice_ctx;
|
||||
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
|
||||
h->current_slice = 0;
|
||||
if (!h->first_field)
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "videodsp.h"
|
||||
|
||||
#define H264_MAX_PICTURE_COUNT 32
|
||||
#define H264_MAX_THREADS 16
|
||||
|
||||
#define MAX_SPS_COUNT 32
|
||||
#define MAX_PPS_COUNT 256
|
||||
@ -593,8 +592,6 @@ typedef struct H264Context {
|
||||
*/
|
||||
int max_contexts;
|
||||
|
||||
int slice_context_count;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
@ -829,9 +829,6 @@ static int init_dimensions(H264Context *h)
|
||||
static int h264_slice_header_init(H264Context *h)
|
||||
{
|
||||
const SPS *sps = h->ps.sps;
|
||||
int nb_slices = (HAVE_THREADS &&
|
||||
h->avctx->active_thread_type & FF_THREAD_SLICE) ?
|
||||
h->avctx->thread_count : 1;
|
||||
int i, ret;
|
||||
|
||||
ff_set_sar(h->avctx, sps->sar);
|
||||
@ -877,18 +874,6 @@ static int h264_slice_header_init(H264Context *h)
|
||||
sps->chroma_format_idc);
|
||||
ff_videodsp_init(&h->vdsp, sps->bit_depth_luma);
|
||||
|
||||
if (nb_slices > H264_MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) {
|
||||
int max_slices;
|
||||
if (h->mb_height)
|
||||
max_slices = FFMIN(H264_MAX_THREADS, h->mb_height);
|
||||
else
|
||||
max_slices = H264_MAX_THREADS;
|
||||
av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices %d,"
|
||||
" reducing to %d\n", nb_slices, max_slices);
|
||||
nb_slices = max_slices;
|
||||
}
|
||||
h->slice_context_count = nb_slices;
|
||||
|
||||
if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
|
||||
ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
|
||||
if (ret < 0) {
|
||||
@ -896,7 +881,7 @@ static int h264_slice_header_init(H264Context *h)
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < h->slice_context_count; i++) {
|
||||
for (i = 0; i < h->nb_slice_ctx; i++) {
|
||||
H264SliceContext *sl = &h->slice_ctx[i];
|
||||
|
||||
sl->h264 = h;
|
||||
|
Loading…
Reference in New Issue
Block a user