Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
transcoding: let ffmpeg decide the number of threads by itself
  • Loading branch information
stbenz authored and perexg committed Jun 8, 2015
1 parent 9ab3801 commit 688c42f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
2 changes: 2 additions & 0 deletions src/libav.c
@@ -1,3 +1,4 @@
#include "plumbing/transcoding.h"
#include "libav.h"

/**
Expand Down Expand Up @@ -207,4 +208,5 @@ libav_init(void)
av_log_set_callback(libav_log_callback);
libav_set_loglevel();
av_register_all();
transcoding_init();
}
26 changes: 2 additions & 24 deletions src/plumbing/transcoding.c
Expand Up @@ -40,8 +40,6 @@
#include "parsers/bitstream.h"
#include "parsers/parser_avc.h"

static long transcoder_nrprocessors;

LIST_HEAD(transcoder_stream_list, transcoder_stream);

struct transcoder;
Expand Down Expand Up @@ -184,20 +182,6 @@ transcode_opt_set_int(transcoder_t *t, transcoder_stream_t *ts,
return 0;
}

/**
*
*/
static long
transcoder_thread_count(transcoder_t *t, streaming_component_type_t ty)
{
long r = LONG_MAX;
if (SCT_ISAUDIO(ty))
return 1;
if (t->t_props.tp_nrprocessors)
r = t->t_props.tp_nrprocessors;
return MIN(r, transcoder_nrprocessors);
}

/**
*
*/
Expand Down Expand Up @@ -1527,9 +1511,6 @@ transcoder_init_audio(transcoder_t *t, streaming_start_component_t *ssc)
as->aud_ictx = avcodec_alloc_context3_tvh(icodec);
as->aud_octx = avcodec_alloc_context3_tvh(ocodec);

as->aud_ictx->thread_count =
as->aud_octx->thread_count = transcoder_thread_count(t, sct);

LIST_INSERT_HEAD(&t->t_stream_list, (transcoder_stream_t*)as, ts_link);

tvhinfo("transcode", "%04X: %d:%s ==> %s (%s)",
Expand Down Expand Up @@ -1629,8 +1610,8 @@ transcoder_init_video(transcoder_t *t, streaming_start_component_t *ssc)
vs->vid_ictx = avcodec_alloc_context3_tvh(icodec);
vs->vid_octx = avcodec_alloc_context3_tvh(ocodec);

vs->vid_ictx->thread_count =
vs->vid_octx->thread_count = transcoder_thread_count(t, sct);
if (t->t_props.tp_nrprocessors)
vs->vid_octx->thread_count = t->t_props.tp_nrprocessors;

vs->vid_dec_frame = avcodec_alloc_frame();
vs->vid_enc_frame = avcodec_alloc_frame();
Expand Down Expand Up @@ -1940,7 +1921,4 @@ transcoder_get_capabilities(int experimental)
*/
void transcoding_init(void)
{
transcoder_nrprocessors = sysconf(_SC_NPROCESSORS_ONLN);
if (transcoder_nrprocessors <= 0)
transcoder_nrprocessors = LONG_MAX;
}

0 comments on commit 688c42f

Please sign in to comment.