Пример #1
0
static av_cold int ff_libde265dec_ctx_init(AVCodecContext *avctx)
{
    DE265Context *ctx = (DE265Context *) avctx->priv_data;
    ctx->decoder = de265_new_decoder();
    // XXX: always decode multiple threads for now
    if (1 || avctx->active_thread_type & FF_THREAD_SLICE) {
        int threads = avctx->thread_count;
        if (threads <= 0) {
            threads = av_cpu_count();
        }
        if (threads > 0) {
            // XXX: We start more threads than cores for now, as some threads
            // might get blocked while waiting for dependent data. Having more
            // threads increases decoding speed by about 10%
            threads *= 2;
            if (threads > 32) {
                // TODO: this limit should come from the libde265 headers
                threads = 32;
            }
            de265_start_worker_threads(ctx->decoder, threads);
        }
    }
#if LIBDE265_NUMERIC_VERSION < 0x00050000
    ctx->pts_queue_len = 0;
    ctx->pts_min_queue_len = 0;
#endif

    avctx->pix_fmt = AV_PIX_FMT_YUV420P;
    return 0;
}
Пример #2
0
static gboolean
gst_libde265_dec_start (VIDEO_DECODER_BASE * parse)
{
    GstLibde265Dec *dec = GST_LIBDE265_DEC (parse);
    
    _gst_libde265_dec_free_decoder(dec);
    dec->ctx = de265_new_decoder();
    if (dec->ctx == NULL) {
        return FALSE;
    }
    
    int threads;
#if defined(_SC_NPROC_ONLN)
    threads = sysconf(_SC_NPROC_ONLN);
#elif defined(_SC_NPROCESSORS_ONLN)
    threads = sysconf(_SC_NPROCESSORS_ONLN);
#else
    #warning "Don't know how to get number of CPU cores, will use the default thread count"
    threads = DEFAULT_THREAD_COUNT;
#endif
    if (threads <= 0) {
        threads = DEFAULT_THREAD_COUNT;
    }

    // XXX: We start more threads than cores for now, as some threads
    // might get blocked while waiting for dependent data. Having more
    // threads increases decoding speed by about 10%
    threads *= 2;
    if (threads > 32) {
        // TODO: this limit should come from the libde265 headers
        threads = 32;
    }
    de265_start_worker_threads(dec->ctx, threads);
    GST_INFO ("Starting %d worker threads\n", threads);
    
    // NOTE: we explicitly disable hash checks for now
    de265_set_parameter_bool(dec->ctx, DE265_DECODER_PARAM_BOOL_SEI_CHECK_HASH, 0);
    return TRUE;
}
Пример #3
0
static gboolean
gst_libde265_dec_start (GstVideoDecoder * decoder)
{
  GstLibde265Dec *dec = GST_LIBDE265_DEC (decoder);
  int threads = dec->max_threads;
  struct de265_image_allocation allocation;

  _gst_libde265_dec_free_decoder (dec);
  dec->ctx = de265_new_decoder ();
  if (dec->ctx == NULL) {
    return FALSE;
  }
  if (threads == 0) {
    threads = g_get_num_processors ();

    /* NOTE: We start more threads than cores for now, as some threads
     * might get blocked while waiting for dependent data. Having more
     * threads increases decoding speed by about 10% */
    threads *= 2;
  }
  if (threads > 1) {
    if (threads > 32) {
      /* TODO: this limit should come from the libde265 headers */
      threads = 32;
    }
    de265_start_worker_threads (dec->ctx, threads);
  }
  GST_INFO_OBJECT (dec, "Using libde265 %s with %d worker threads",
      de265_get_version (), threads);

  allocation.get_buffer = gst_libde265_dec_get_buffer;
  allocation.release_buffer = gst_libde265_dec_release_buffer;
  de265_set_image_allocation_functions (dec->ctx, &allocation, decoder);
  /* NOTE: we explicitly disable hash checks for now */
  de265_set_parameter_bool (dec->ctx, DE265_DECODER_PARAM_BOOL_SEI_CHECK_HASH,
      0);
  return TRUE;
}