Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
transcoding: Remove deprecated bandwith property. Code cosmetics
  • Loading branch information
tajson authored and perexg committed Jan 13, 2015
1 parent baec61b commit b2132d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
17 changes: 8 additions & 9 deletions src/plumbing/transcoding.c
Expand Up @@ -1046,11 +1046,11 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
octx->rc_max_rate = 4 * octx->bit_rate;
}

if (t->t_props.tp_vbitrate >0 && t->t_props.tp_vbitrate <64) { // CRF
if (t->t_props.tp_vbitrate > 0 && t->t_props.tp_vbitrate < 64) { // CRF
octx->qmin = t->t_props.tp_vbitrate;
}

if (t->t_props.tp_vbitrate >=64) { // CBR
if (t->t_props.tp_vbitrate >= 64) { // CBR
octx->rc_max_rate = t->t_props.tp_vbitrate * 1000;
octx->bit_rate = ceil(octx->rc_max_rate / 1.15);
}
Expand All @@ -1075,13 +1075,13 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
}

// Stream profile vbitrate 1-63 is used for user specified qmin quantizer (CRF mode).
if (t->t_props.tp_vbitrate >0 && t->t_props.tp_vbitrate <64) {
if (t->t_props.tp_vbitrate > 0 && t->t_props.tp_vbitrate < 64) {
octx->qmin = t->t_props.tp_vbitrate;
octx->qmax = octx->qmin + 30 <= 63 ? octx->qmin + 30 : 63;
octx->rc_max_rate = 16 * octx->width * octx->height;
}

if (t->t_props.tp_vbitrate >=64) { // CBR mode.
if (t->t_props.tp_vbitrate >= 64) { // CBR mode.
octx->rc_max_rate = t->t_props.tp_vbitrate * 1000;
octx->bit_rate = ceil(octx->rc_max_rate / 1.15);
}
Expand Down Expand Up @@ -1113,7 +1113,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
av_dict_set(&opts, "tune", "zerolatency", 0);

// If we are encoding HD, upgrade the profile to high.
if (octx->height >= 720 && t->t_props.tp_resolution >=720) {
if (octx->height >= 720 && t->t_props.tp_resolution >= 720) {
av_dict_set(&opts, "profile", "high", 0); // L3.1
}

Expand All @@ -1124,11 +1124,11 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
}

// Stream profile vbitrate 1-63 is used for user specified qmin quantizer (CRF mode).
if (t->t_props.tp_vbitrate >0 && t->t_props.tp_vbitrate <64) {
if (t->t_props.tp_vbitrate > 0 && t->t_props.tp_vbitrate < 64) {
octx->qmin = t->t_props.tp_vbitrate; // qmax = 51 in all default profiles, let's stick with it for now.
}

if (t->t_props.tp_vbitrate >=64) { // Bitrate limited encoding (CBR mode).
if (t->t_props.tp_vbitrate >= 64) { // Bitrate limited encoding (CBR mode).
octx->rc_max_rate = t->t_props.tp_vbitrate * 1000;
octx->bit_rate = ceil(octx->rc_max_rate / 1.15);
}
Expand Down Expand Up @@ -1442,7 +1442,7 @@ transcoder_init_audio(transcoder_t *t, streaming_start_component_t *ssc)
sct = codec_id2streaming_component_type(ocodec->id);

// Don't transcode to identical output codec unless the streaming profile specifies a bitrate limiter.
if (sct == ssc->ssc_type && t->t_props.tp_abitrate <16 ) {
if (sct == ssc->ssc_type && t->t_props.tp_abitrate < 16 ) {
return transcoder_init_stream(t, ssc);
}

Expand Down Expand Up @@ -1802,7 +1802,6 @@ transcoder_set_properties(streaming_target_t *st,
strncpy(tp->tp_acodec, props->tp_acodec, sizeof(tp->tp_acodec)-1);
strncpy(tp->tp_scodec, props->tp_scodec, sizeof(tp->tp_scodec)-1);
tp->tp_channels = props->tp_channels;
tp->tp_bandwidth = props->tp_bandwidth;
tp->tp_vbitrate = props->tp_vbitrate;
tp->tp_abitrate = props->tp_abitrate;
tp->tp_resolution = props->tp_resolution;
Expand Down
1 change: 0 additions & 1 deletion src/plumbing/transcoding.h 100644 → 100755
Expand Up @@ -26,7 +26,6 @@ typedef struct transcoder_prop {
char tp_scodec[32];

int8_t tp_channels;
int32_t tp_bandwidth;
int32_t tp_vbitrate;
int32_t tp_abitrate;
char tp_language[4];
Expand Down
10 changes: 0 additions & 10 deletions src/profile.c 100644 → 100755
Expand Up @@ -1018,7 +1018,6 @@ typedef struct profile_transcode {
int pro_mc;
uint32_t pro_resolution;
uint32_t pro_channels;
uint32_t pro_bandwidth;
uint32_t pro_vbitrate;
uint32_t pro_abitrate;
char *pro_language;
Expand Down Expand Up @@ -1256,12 +1255,6 @@ profile_transcode_resolution(profile_transcode_t *pro)
return pro->pro_resolution >= 240 ? pro->pro_resolution : 240;
}

static int
profile_transcode_bandwidth(profile_transcode_t *pro)
{
return pro->pro_bandwidth >= 64 ? pro->pro_bandwidth : 64;
}

static int
profile_transcode_vbitrate(profile_transcode_t *pro)
{
Expand Down Expand Up @@ -1296,8 +1289,6 @@ profile_transcode_can_share(profile_chain_t *prch,
return 0;
if (profile_transcode_resolution(pro1) != profile_transcode_resolution(pro2))
return 0;
if (profile_transcode_bandwidth(pro1) != profile_transcode_bandwidth(pro2))
return 0;
if (profile_transcode_vbitrate(pro1) != profile_transcode_vbitrate(pro2))
return 0;
if (profile_transcode_abitrate(pro1) != profile_transcode_abitrate(pro2))
Expand Down Expand Up @@ -1328,7 +1319,6 @@ profile_transcode_work(profile_chain_t *prch,
strncpy(props.tp_scodec, pro->pro_scodec ?: "", sizeof(props.tp_scodec)-1);
props.tp_resolution = profile_transcode_resolution(pro);
props.tp_channels = pro->pro_channels;
props.tp_bandwidth = profile_transcode_bandwidth(pro);
props.tp_vbitrate = profile_transcode_vbitrate(pro);
props.tp_abitrate = profile_transcode_abitrate(pro);
strncpy(props.tp_language, pro->pro_language ?: "", 3);
Expand Down

0 comments on commit b2132d7

Please sign in to comment.