[FFmpeg-devel] [PATCH 7/9] ffmpeg: move filtered_frame to the CONFIG_AVFILTER scope.

Clément Bœsch ubitux at gmail.com
Wed Feb 8 18:18:30 CET 2012


From: Clément Bœsch <clement.boesch at smartjog.com>

This simplifies a bit the #ifdefery.
---
 ffmpeg.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 85855a0..6977e79 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2123,7 +2123,6 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
     rate_emu_sleep(ist);
 
     for (i = 0; i < nb_output_streams; i++) {
-        AVFrame *filtered_frame = NULL;
         OutputStream *ost = &output_streams[i];
 
         if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
@@ -2132,6 +2131,8 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
 #if CONFIG_AVFILTER
         while (av_buffersink_poll_frame(ost->output_video_filter)) {
             AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;
+            AVFrame *filtered_frame;
+
             if (av_buffersink_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0){
                 av_log(0, AV_LOG_WARNING, "AV Filter told us it has a frame available but failed to output one\n");
                 goto cont;
@@ -2142,23 +2143,21 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
             } else
                 avcodec_get_frame_defaults(ist->filtered_frame);
             filtered_frame = ist->filtered_frame;
-            *filtered_frame= *decoded_frame; //for me_threshold
+            *filtered_frame = *decoded_frame; // for me_threshold
             if (ost->picref) {
                 avfilter_fill_frame_from_video_buffer_ref(filtered_frame, ost->picref);
                 filtered_frame->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
             }
             if (ost->picref->video && !ost->frame_aspect_ratio)
                 ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
-#else
-            filtered_frame = decoded_frame;
-#endif
-
             do_video_out(output_files[ost->file_index].ctx, ost, ist, filtered_frame,
                          same_quant ? quality : ost->st->codec->global_quality);
-#if CONFIG_AVFILTER
             cont:
             avfilter_unref_buffer(ost->picref);
         }
+#else
+        do_video_out(output_files[ost->file_index].ctx, ost, ist, decoded_frame,
+                     same_quant ? quality : ost->st->codec->global_quality);
 #endif
     }
 
-- 
1.7.8.3



More information about the ffmpeg-devel mailing list