[FFmpeg-devel] [PATCH] ffmpeg: use intermediary variables in reap_filters, increase readability
Nicolas George
george at nsup.org
Sat Jan 25 17:41:46 CET 2014
Le quintidi 5 pluviôse, an CCXXII, Stefano Sabatini a écrit :
> ---
> ffmpeg.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 0685ff5..b9ed875 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -1091,6 +1091,8 @@ static int reap_filters(void)
> for (i = 0; i < nb_output_streams; i++) {
> OutputStream *ost = output_streams[i];
> OutputFile *of = output_files[ost->file_index];
> + AVFilterContext *filt_ctx = ost->filter->filter;
> + AVCodecContext *enc_ctx = ost->st->codec;
I find the names rather ugly. "filter" and "enc" or "encoder" would please
my eyes more.
But I agree that both version increase readability.
> int ret = 0;
>
> if (!ost->filter)
> @@ -1102,7 +1104,7 @@ static int reap_filters(void)
> filtered_frame = ost->filtered_frame;
>
> while (1) {
> - ret = av_buffersink_get_frame_flags(ost->filter->filter, filtered_frame,
> + ret = av_buffersink_get_frame_flags(filt_ctx, filtered_frame,
> AV_BUFFERSINK_FLAG_NO_REQUEST);
> if (ret < 0) {
> if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
> @@ -1118,29 +1120,26 @@ static int reap_filters(void)
> frame_pts = AV_NOPTS_VALUE;
> if (filtered_frame->pts != AV_NOPTS_VALUE) {
> int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time;
> - filtered_frame->pts = frame_pts = av_rescale_q(filtered_frame->pts,
> - ost->filter->filter->inputs[0]->time_base,
> - ost->st->codec->time_base) -
> - av_rescale_q(start_time,
> - AV_TIME_BASE_Q,
> - ost->st->codec->time_base);
> + filtered_frame->pts = frame_pts =
> + av_rescale_q(filtered_frame->pts, filt_ctx->inputs[0]->time_base, enc_ctx->time_base) -
> + av_rescale_q(start_time, AV_TIME_BASE_Q, enc_ctx->time_base);
> }
> +
> //if (ost->source_index >= 0)
> // *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold
>
> -
> - switch (ost->filter->filter->inputs[0]->type) {
> + switch (filt_ctx->inputs[0]->type) {
> case AVMEDIA_TYPE_VIDEO:
> filtered_frame->pts = frame_pts;
> if (!ost->frame_aspect_ratio.num)
> - ost->st->codec->sample_aspect_ratio = filtered_frame->sample_aspect_ratio;
> + enc_ctx->sample_aspect_ratio = filtered_frame->sample_aspect_ratio;
>
> do_video_out(of->ctx, ost, filtered_frame);
> break;
> case AVMEDIA_TYPE_AUDIO:
> filtered_frame->pts = frame_pts;
> - if (!(ost->st->codec->codec->capabilities & CODEC_CAP_PARAM_CHANGE) &&
> - ost->st->codec->channels != av_frame_get_channels(filtered_frame)) {
> + if (!(enc_ctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE) &&
> + enc_ctx->channels != av_frame_get_channels(filtered_frame)) {
> av_log(NULL, AV_LOG_ERROR,
> "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
> break;
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140125/2bb59274/attachment.asc>
More information about the ffmpeg-devel
mailing list