From: "Ronald S. Bultje" <rsbul...@gmail.com> This way, the code looks less like spaghetti, and is easier to parse for external preprocessors. --- avconv.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/avconv.c b/avconv.c index 439672a..fcf2b69 100644 --- a/avconv.c +++ b/avconv.c @@ -797,14 +797,16 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterContext *first_filter = in->filter_ctx; AVFilter *filter = avfilter_get_by_name("buffer"); InputStream *ist = ifilter->ist; - AVRational tb = ist->framerate.num ? (AVRational){ist->framerate.den, - ist->framerate.num} : - ist->st->time_base; + AVRational tb = ist->st->time_base; AVRational sar; char args[255], name[255]; int pad_idx = in->pad_idx; int ret; + if (ist->framerate.num) { + tb.num = ist->framerate.den; + tb.den = ist->framerate.num; + } sar = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio; @@ -2196,11 +2198,10 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) ret = decode_video (ist, &avpkt, &got_output); if (avpkt.duration) ist->next_dts += av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q); - else if (ist->st->r_frame_rate.num) - ist->next_dts += av_rescale_q(1, (AVRational){ist->st->r_frame_rate.den, - ist->st->r_frame_rate.num}, - AV_TIME_BASE_Q); - else if (ist->st->codec->time_base.num != 0) { + else if (ist->st->r_frame_rate.num) { + AVRational ifps = { ist->st->r_frame_rate.den, ist->st->r_frame_rate.num }; + ist->next_dts += av_rescale_q(1, ifps, AV_TIME_BASE_Q); + } else if (ist->st->codec->time_base.num != 0) { int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->st->codec->ticks_per_frame; ist->next_dts += av_rescale_q(ticks, ist->st->codec->time_base, AV_TIME_BASE_Q); @@ -2479,11 +2480,14 @@ static int transcode_init(void) codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { - codec->sample_aspect_ratio = - ost->st->sample_aspect_ratio = - ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : - ist->st->codec->sample_aspect_ratio.num ? - ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; + if (ist->st->sample_aspect_ratio.num) { + codec->sample_aspect_ratio = ist->st->sample_aspect_ratio; + } else if (ist->st->codec->sample_aspect_ratio.num) { + codec->sample_aspect_ratio = ist->st->codec->sample_aspect_ratio; + } else { + codec->sample_aspect_ratio = (AVRational) { 0, 1 }; + } + ost->st->sample_aspect_ratio = codec->sample_aspect_ratio; } break; case AVMEDIA_TYPE_SUBTITLE: @@ -2526,7 +2530,11 @@ static int transcode_init(void) (video_sync_method == VSYNC_CFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS))))) { - ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1}; + if (ist->st->r_frame_rate.num) { + ost->frame_rate = ist->st->r_frame_rate; + } else { + ost->frame_rate = (AVRational) { 25, 1 }; + } if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; @@ -4095,9 +4103,13 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) AVChapter *in_ch = is->chapters[i], *out_ch; int64_t ts_off = av_rescale_q(ofile->start_time - ifile->ts_offset, AV_TIME_BASE_Q, in_ch->time_base); - int64_t rt = (ofile->recording_time == INT64_MAX) ? INT64_MAX : - av_rescale_q(ofile->recording_time, AV_TIME_BASE_Q, in_ch->time_base); + int64_t rt; + if (ofile->recording_time == INT64_MAX) { + rt = INT64_MAX; + } else { + rt = av_rescale_q(ofile->recording_time, AV_TIME_BASE_Q, in_ch->time_base); + } if (in_ch->end < ts_off) continue; -- 1.7.9.5 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel