[FFmpeg-cvslog] ffmpeg: use a rational for -aspect option.

Nicolas George git at videolan.org
Wed Apr 10 01:55:43 CEST 2013


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Tue Apr  9 11:43:08 2013 +0200| [de38e7c8c3dff23e24d6718c115711747cbff949] | committer: Nicolas George

ffmpeg: use a rational for -aspect option.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de38e7c8c3dff23e24d6718c115711747cbff949
---

 ffmpeg.c     |    6 +++---
 ffmpeg.h     |    2 +-
 ffmpeg_opt.c |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index effb042..7866196 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1071,7 +1071,7 @@ static int reap_filters(void)
             switch (ost->filter->filter->inputs[0]->type) {
             case AVMEDIA_TYPE_VIDEO:
                 filtered_frame->pts = frame_pts;
-                if (!ost->frame_aspect_ratio)
+                if (!ost->frame_aspect_ratio.num)
                     ost->st->codec->sample_aspect_ratio = filtered_frame->sample_aspect_ratio;
 
                 do_video_out(of->ctx, ost, filtered_frame);
@@ -2300,8 +2300,8 @@ static int transcode_init(void)
                 codec->width  = ost->filter->filter->inputs[0]->w;
                 codec->height = ost->filter->filter->inputs[0]->h;
                 codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
-                    ost->frame_aspect_ratio ? // overridden by the -aspect cli option
-                    av_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) :
+                    ost->frame_aspect_ratio.num ? // overridden by the -aspect cli option
+                    av_mul_q(ost->frame_aspect_ratio, (AVRational){ codec->height, codec->width }) :
                     ost->filter->filter->inputs[0]->sample_aspect_ratio;
                 if (!strncmp(ost->enc->name, "libx264", 7) &&
                     codec->pix_fmt == AV_PIX_FMT_NONE &&
diff --git a/ffmpeg.h b/ffmpeg.h
index 4b93ab1..7698595 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -331,7 +331,7 @@ typedef struct OutputStream {
     int force_fps;
     int top_field_first;
 
-    float frame_aspect_ratio;
+    AVRational frame_aspect_ratio;
 
     /* forced key frames */
     int64_t *forced_kf_pts;
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 1f4d89e..6ce965e 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1203,7 +1203,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
                 av_log(NULL, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio);
                 exit(1);
             }
-            ost->frame_aspect_ratio = av_q2d(q);
+            ost->frame_aspect_ratio = q;
         }
 
         video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;



More information about the ffmpeg-cvslog mailing list