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
194 link->time_base = link->src && link->src->input_count ?194 link->time_base = link->src && link->src->input_count ?
195 link->src->inputs[0]->time_base : AV_TIME_BASE_Q;195 link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
196 196
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
197 if ((config_link = link->dstpad->config_props))201 if ((config_link = link->dstpad->config_props))
198 if ((ret = config_link(link)) < 0)202 if ((ret = config_link(link)) < 0)
199 return ret;203 return ret;
libavfilter/avfilter.h+3−2
@@ -27,7 +27,7 @@ · 26 unmodified lines
27#include "libavcore/samplefmt.h"27#include "libavcore/samplefmt.h"
28 28
29#define LIBAVFILTER_VERSION_MAJOR 129#define LIBAVFILTER_VERSION_MAJOR 1
30#define LIBAVFILTER_VERSION_MINOR 7530#define LIBAVFILTER_VERSION_MINOR 76
31#define LIBAVFILTER_VERSION_MICRO 031#define LIBAVFILTER_VERSION_MICRO 0
32 32
33#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \33#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -580,9 +580,10 @@ struct AVFilterLink { · 546 unmodified lines
580 580
581 enum AVMediaType type; ///< filter media type581 enum AVMediaType type; ///< filter media type
582 582
583 /* These two parameters apply only to video */583 /* These parameters apply only to video */
584 int w; ///< agreed upon image width584 int w; ///< agreed upon image width
585 int h; ///< agreed upon image height585 int h; ///< agreed upon image height
586 AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
586 /* These two parameters apply only to audio */587 /* These two parameters apply only to audio */
587 int64_t channel_layout; ///< channel layout of current buffer (see libavcore/audioconvert.h)588 int64_t channel_layout; ///< channel layout of current buffer (see libavcore/audioconvert.h)
588 int64_t sample_rate; ///< samples per second589 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
82 82
83 av_log(inlink->dst, AV_LOG_INFO, "w:%d h:%d -> dar:%d/%d par:%d/%d\n",83 av_log(inlink->dst, AV_LOG_INFO, "w:%d h:%d -> dar:%d/%d par:%d/%d\n",
84 inlink->w, inlink->h, dar.num, dar.den, aspect->aspect.num, aspect->aspect.den);84 inlink->w, inlink->h, dar.num, dar.den, aspect->aspect.num, aspect->aspect.den);
85
86 inlink->sample_aspect_ratio = aspect->aspect;
87
85 return 0;88 return 0;
86}89}
87 90
@@ -108,6 +111,16 @@ AVFilter avfilter_vf_setdar = { · 20 unmodified lines
108#endif /* CONFIG_SETDAR_FILTER */111#endif /* CONFIG_SETDAR_FILTER */
109 112
110#if CONFIG_SETSAR_FILTER113#if CONFIG_SETSAR_FILTER
114/* for setdar filter, convert from frame aspect ratio to pixel aspect ratio */
115static 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
111AVFilter avfilter_vf_setsar = {124AVFilter avfilter_vf_setsar = {
112 .name = "setsar",125 .name = "setsar",
113 .description = NULL_IF_CONFIG_SMALL("Set the pixel sample aspect ratio."),126 .description = NULL_IF_CONFIG_SMALL("Set the pixel sample aspect ratio."),
@@ -118,6 +131,7 @@ AVFilter avfilter_vf_setsar = { · 4 unmodified lines
118 131
119 .inputs = (AVFilterPad[]) {{ .name = "default",132 .inputs = (AVFilterPad[]) {{ .name = "default",
120 .type = AVMEDIA_TYPE_VIDEO,133 .type = AVMEDIA_TYPE_VIDEO,
134 .config_props = setsar_config_props,
121 .get_video_buffer = avfilter_null_get_video_buffer,135 .get_video_buffer = avfilter_null_get_video_buffer,
122 .start_frame = start_frame,136 .start_frame = start_frame,
123 .end_frame = avfilter_null_end_frame },137 .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
102 outlink->w = inlink->h;102 outlink->w = inlink->h;
103 outlink->h = inlink->w;103 outlink->h = inlink->w;
104 104
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
105 av_log(ctx, AV_LOG_INFO, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",110 av_log(ctx, AV_LOG_INFO, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
106 inlink->w, inlink->h, trans->dir, outlink->w, outlink->h,111 inlink->w, inlink->h, trans->dir, outlink->w, outlink->h,
107 trans->dir == 1 || trans->dir == 3 ? "clockwise" : "counterclockwise",112 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