History

Add sample_aspect_ratio to AVFilterLink

Michael Niedermayer committed 15 years ago

Commit 910b5b81 parent b7ec5cc4 files · +26 −2Browse files

Unified · Split

4 files
  1. libavfilter/avfilter.c +4 −0
  2. libavfilter/avfilter.h +3 −2
  3. libavfilter/vf_aspect.c +14 −0
  4. libavfilter/vf_transpose.c +5 −0
libavfilter/avfilter.c+4−0
@@ -194,6 +194,10 @@ int avfilter_config_links(AVFilterContext *filter) · 193 unmodified lines
194194 link->time_base = link->src && link->src->input_count ?
195195 link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
196196
197+ if (link->sample_aspect_ratio.num == 0 && link->sample_aspect_ratio.den == 0)
198+ link->sample_aspect_ratio = link->src->input_count ?
199+ link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1};
200+
197201 if ((config_link = link->dstpad->config_props))
198202 if ((ret = config_link(link)) < 0)
199203 return ret;
libavfilter/avfilter.h+3−2
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 #include "libavcore/samplefmt.h"
2828
2929 #define LIBAVFILTER_VERSION_MAJOR 1
30−#define LIBAVFILTER_VERSION_MINOR 75
30+#define LIBAVFILTER_VERSION_MINOR 76
3131 #define LIBAVFILTER_VERSION_MICRO 0
3232
3333 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -580,9 +580,10 @@ struct AVFilterLink { · 546 unmodified lines
580580
581581 enum AVMediaType type; ///< filter media type
582582
583− /* These two parameters apply only to video */
583+ /* These parameters apply only to video */
584584 int w; ///< agreed upon image width
585585 int h; ///< agreed upon image height
586+ AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
586587 /* These two parameters apply only to audio */
587588 int64_t channel_layout; ///< channel layout of current buffer (see libavcore/audioconvert.h)
588589 int64_t sample_rate; ///< samples per second
libavfilter/vf_aspect.c+14−0
@@ -82,6 +82,9 @@ static int setdar_config_props(AVFilterLink *inlink) · 81 unmodified lines
8282
8383 av_log(inlink->dst, AV_LOG_INFO, "w:%d h:%d -> dar:%d/%d par:%d/%d\n",
8484 inlink->w, inlink->h, dar.num, dar.den, aspect->aspect.num, aspect->aspect.den);
85+
86+ inlink->sample_aspect_ratio = aspect->aspect;
87+
8588 return 0;
8689 }
8790
@@ -108,6 +111,16 @@ AVFilter avfilter_vf_setdar = { · 20 unmodified lines
108111 #endif /* CONFIG_SETDAR_FILTER */
109112
110113 #if CONFIG_SETSAR_FILTER
114+/* for setdar filter, convert from frame aspect ratio to pixel aspect ratio */
115+static int setsar_config_props(AVFilterLink *inlink)
116+{
117+ AspectContext *aspect = inlink->dst->priv;
118+
119+ inlink->sample_aspect_ratio = aspect->aspect;
120+
121+ return 0;
122+}
123+
111124 AVFilter avfilter_vf_setsar = {
112125 .name = "setsar",
113126 .description = NULL_IF_CONFIG_SMALL("Set the pixel sample aspect ratio."),
@@ -118,6 +131,7 @@ AVFilter avfilter_vf_setsar = { · 4 unmodified lines
118131
119132 .inputs = (AVFilterPad[]) {{ .name = "default",
120133 .type = AVMEDIA_TYPE_VIDEO,
134+ .config_props = setsar_config_props,
121135 .get_video_buffer = avfilter_null_get_video_buffer,
122136 .start_frame = start_frame,
123137 .end_frame = avfilter_null_end_frame },
libavfilter/vf_transpose.c+5−0
@@ -102,6 +102,11 @@ static int config_props_output(AVFilterLink *outlink) · 101 unmodified lines
102102 outlink->w = inlink->h;
103103 outlink->h = inlink->w;
104104
105+ if (inlink->sample_aspect_ratio.num){
106+ outlink->sample_aspect_ratio = av_div_q((AVRational){1,1}, inlink->sample_aspect_ratio);
107+ } else
108+ outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
109+
105110 av_log(ctx, AV_LOG_INFO, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
106111 inlink->w, inlink->h, trans->dir, outlink->w, outlink->h,
107112 trans->dir == 1 || trans->dir == 3 ? "clockwise" : "counterclockwise",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t