[FFmpeg-devel] [PATCH] lavfi: rename AVFilterBufferRefVideoProps.pixel_aspect to sample_aspect_ratio

Stefano Sabatini stefano.sabatini-lala at poste.it
Fri Apr 29 13:14:13 CEST 2011


Improve consistency with libavcodec.

This breaks libavfilter API/ABI.
---
 cmdutils.c                 |    2 +-
 ffmpeg.c                   |    2 +-
 ffplay.c                   |    6 +++---
 libavfilter/avfilter.c     |    2 +-
 libavfilter/avfilter.h     |    2 +-
 libavfilter/vf_aspect.c    |    2 +-
 libavfilter/vf_frei0r.c    |    2 +-
 libavfilter/vf_scale.c     |    6 +++---
 libavfilter/vf_showinfo.c  |    2 +-
 libavfilter/vf_transpose.c |    8 ++++----
 libavfilter/vsrc_buffer.c  |    8 ++++----
 libavfilter/vsrc_color.c   |    2 +-
 libavfilter/vsrc_movie.c   |    5 +++--
 13 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 21238be..c35e1fa 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -902,7 +902,7 @@ int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
     frame->top_field_first  = picref->video->top_field_first;
     frame->key_frame        = picref->video->key_frame;
     frame->pict_type        = picref->video->pict_type;
-    frame->sample_aspect_ratio = picref->video->pixel_aspect;
+    frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
 
     return 1;
 }
diff --git a/ffmpeg.c b/ffmpeg.c
index 52e4764..f887c22 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1696,7 +1696,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
                         case AVMEDIA_TYPE_VIDEO:
 #if CONFIG_AVFILTER
                             if (ost->picref->video && !ost->frame_aspect_ratio)
-                                ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect;
+                                ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
 #endif
                             do_video_out(os, ost, ist, &picture, &frame_size);
                             if (vstats_filename && frame_size)
diff --git a/ffplay.c b/ffplay.c
index fcb9418..945e08f 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -692,10 +692,10 @@ static void video_image_display(VideoState *is)
     vp = &is->pictq[is->pictq_rindex];
     if (vp->bmp) {
 #if CONFIG_AVFILTER
-         if (vp->picref->video->pixel_aspect.num == 0)
+         if (vp->picref->video->sample_aspect_ratio.num == 0)
              aspect_ratio = 0;
          else
-             aspect_ratio = av_q2d(vp->picref->video->pixel_aspect);
+             aspect_ratio = av_q2d(vp->picref->video->sample_aspect_ratio);
 #else
 
         /* XXX: use variable in the frame */
@@ -1688,7 +1688,7 @@ static int input_request_frame(AVFilterLink *link)
 
     picref->pts = pts;
     picref->pos = priv->frame->pkt_pos;
-    picref->video->pixel_aspect = priv->frame->sample_aspect_ratio;
+    picref->video->sample_aspect_ratio = priv->frame->sample_aspect_ratio;
     avfilter_start_frame(link, picref);
     avfilter_draw_slice(link, 0, link->h, 1);
     avfilter_end_frame(link);
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 443562b..49d84e0 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -238,7 +238,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end)
 
     if (ref->video) {
         av_dlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c",
-                ref->video->pixel_aspect.num, ref->video->pixel_aspect.den,
+                ref->video->sample_aspect_ratio.num, ref->video->sample_aspect_ratio.den,
                 ref->video->w, ref->video->h,
                 !ref->video->interlaced     ? 'P' :         /* Progressive  */
                 ref->video->top_field_first ? 'T' : 'B',    /* Top / Bottom */
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 48a42ac..b12fe22 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -112,7 +112,7 @@ typedef struct AVFilterBufferRefAudioProps {
 typedef struct AVFilterBufferRefVideoProps {
     int w;                      ///< image width
     int h;                      ///< image height
-    AVRational pixel_aspect;    ///< pixel aspect ratio
+    AVRational sample_aspect_ratio; ///< sample aspect ratio
     int interlaced;             ///< is frame interlaced
     int top_field_first;        ///< field order
     enum AVPictureType pict_type; ///< picture type of the frame
diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c
index 95900d1..3b4a57c 100644
--- a/libavfilter/vf_aspect.c
+++ b/libavfilter/vf_aspect.c
@@ -65,7 +65,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
 {
     AspectContext *aspect = link->dst->priv;
 
-    picref->video->pixel_aspect = aspect->aspect;
+    picref->video->sample_aspect_ratio = aspect->aspect;
     avfilter_start_frame(link->dst->outputs[0], picref);
 }
 
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index adccccb..0cb5fd3 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -430,7 +430,7 @@ static int source_request_frame(AVFilterLink *outlink)
 {
     Frei0rContext *frei0r = outlink->src->priv;
     AVFilterBufferRef *picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
-    picref->video->pixel_aspect = (AVRational) {1, 1};
+    picref->video->sample_aspect_ratio = (AVRational) {1, 1};
     picref->pts = frei0r->pts++;
     picref->pos = -1;
 
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 27214a6..da84efc 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -252,9 +252,9 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
 
     outlink->out_buf = outpicref;
 
-    av_reduce(&outpicref->video->pixel_aspect.num, &outpicref->video->pixel_aspect.den,
-              (int64_t)picref->video->pixel_aspect.num * outlink->h * link->w,
-              (int64_t)picref->video->pixel_aspect.den * outlink->w * link->h,
+    av_reduce(&outpicref->video->sample_aspect_ratio.num, &outpicref->video->sample_aspect_ratio.den,
+              (int64_t)picref->video->sample_aspect_ratio.num * outlink->h * link->w,
+              (int64_t)picref->video->sample_aspect_ratio.den * outlink->w * link->h,
               INT_MAX);
 
     scale->slice_y = 0;
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index d2483d5..d512199 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -59,7 +59,7 @@ static void end_frame(AVFilterLink *inlink)
            showinfo->frame,
            picref->pts, picref ->pts * av_q2d(inlink->time_base), picref->pos,
            av_pix_fmt_descriptors[picref->format].name,
-           picref->video->pixel_aspect.num, picref->video->pixel_aspect.den,
+           picref->video->sample_aspect_ratio.num, picref->video->sample_aspect_ratio.den,
            picref->video->w, picref->video->h,
            !picref->video->interlaced     ? 'P' :         /* Progressive  */
            picref->video->top_field_first ? 'T' : 'B',    /* Top / Bottom */
diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index ed91aaa..a5247c9 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -122,11 +122,11 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
                                                  outlink->w, outlink->h);
     outlink->out_buf->pts = picref->pts;
 
-    if (picref->video->pixel_aspect.num == 0) {
-        outlink->out_buf->video->pixel_aspect = picref->video->pixel_aspect;
+    if (picref->video->sample_aspect_ratio.num == 0) {
+        outlink->out_buf->video->sample_aspect_ratio = picref->video->sample_aspect_ratio;
     } else {
-        outlink->out_buf->video->pixel_aspect.num = picref->video->pixel_aspect.den;
-        outlink->out_buf->video->pixel_aspect.den = picref->video->pixel_aspect.num;
+        outlink->out_buf->video->sample_aspect_ratio.num = picref->video->sample_aspect_ratio.den;
+        outlink->out_buf->video->sample_aspect_ratio.den = picref->video->sample_aspect_ratio.num;
     }
 
     avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 48c2f23..906cb5d 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -34,7 +34,7 @@ typedef struct {
     int               h, w;
     enum PixelFormat  pix_fmt;
     AVRational        time_base;     ///< time_base to set in the output link
-    AVRational        pixel_aspect;
+    AVRational        sample_aspect_ratio;
     char              sws_param[256];
 } BufferSourceContext;
 
@@ -130,7 +130,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
     if (!args ||
         (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d", &c->w, &c->h, pix_fmt_str,
                     &c->time_base.num, &c->time_base.den,
-                    &c->pixel_aspect.num, &c->pixel_aspect.den)) != 7) {
+                    &c->sample_aspect_ratio.num, &c->sample_aspect_ratio.den)) != 7) {
         av_log(ctx, AV_LOG_ERROR, "Expected 7 arguments, but only %d found in '%s'\n", n, args);
         return AVERROR(EINVAL);
     }
@@ -162,7 +162,7 @@ static int config_props(AVFilterLink *link)
 
     link->w = c->w;
     link->h = c->h;
-    link->sample_aspect_ratio = c->pixel_aspect;
+    link->sample_aspect_ratio = c->sample_aspect_ratio;
     link->time_base = c->time_base;
 
     return 0;
@@ -190,7 +190,7 @@ static int request_frame(AVFilterLink *link)
                   picref->format, link->w, link->h);
 
     picref->pts                    = c->pts;
-    picref->video->pixel_aspect    = c->frame.sample_aspect_ratio;
+    picref->video->sample_aspect_ratio = c->frame.sample_aspect_ratio;
     picref->video->interlaced      = c->frame.interlaced_frame;
     picref->video->top_field_first = c->frame.top_field_first;
     picref->video->key_frame       = c->frame.key_frame;
diff --git a/libavfilter/vsrc_color.c b/libavfilter/vsrc_color.c
index 3fab260..dc73e1b 100644
--- a/libavfilter/vsrc_color.c
+++ b/libavfilter/vsrc_color.c
@@ -132,7 +132,7 @@ static int color_request_frame(AVFilterLink *link)
 {
     ColorContext *color = link->src->priv;
     AVFilterBufferRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h);
-    picref->video->pixel_aspect = (AVRational) {1, 1};
+    picref->video->sample_aspect_ratio = (AVRational) {1, 1};
     picref->pts                 = av_rescale_q(color->pts++, color->time_base, AV_TIME_BASE_Q);
     picref->pos                 = 0;
 
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
index 19536a9..9b22d2d 100644
--- a/libavfilter/vsrc_movie.c
+++ b/libavfilter/vsrc_movie.c
@@ -248,7 +248,7 @@ static int movie_get_frame(AVFilterLink *outlink)
 
                 movie->picref->pos                    = movie->frame->pkt_pos;
                 if (!movie->frame->sample_aspect_ratio.num)
-                    movie->picref->video->pixel_aspect = st->sample_aspect_ratio;
+                    movie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio;
                 movie->picref->video->interlaced      = movie->frame->interlaced_frame;
                 movie->picref->video->top_field_first = movie->frame->top_field_first;
                 movie->picref->video->key_frame       = movie->frame->key_frame;
@@ -258,7 +258,8 @@ static int movie_get_frame(AVFilterLink *outlink)
                         movie->file_name, movie->picref->pts,
                         (double)movie->picref->pts * av_q2d(st->time_base),
                         movie->picref->pos,
-                        movie->picref->video->pixel_aspect.num, movie->picref->video->pixel_aspect.den);
+                        movie->picref->video->sample_aspect_ratio.num,
+                        movie->picref->video->sample_aspect_ratio.den);
                 // We got it. Free the packet since we are returning
                 av_free_packet(&pkt);
 
-- 
1.7.2.3



More information about the ffmpeg-devel mailing list