Unified · Split
| @@ -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; |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "libavcore/samplefmt.h" | 27 | #include "libavcore/samplefmt.h" |
| 28 | 28 | ||
| 29 | #define LIBAVFILTER_VERSION_MAJOR 1 | 29 | #define LIBAVFILTER_VERSION_MAJOR 1 |
| 30 | #define LIBAVFILTER_VERSION_MINOR 75 | 30 | #define LIBAVFILTER_VERSION_MINOR 76 |
| 31 | #define LIBAVFILTER_VERSION_MICRO 0 | 31 | #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 type | 581 | 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 width | 584 | int w; ///< agreed upon image width |
| 585 | int h; ///< agreed upon image height | 585 | 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 second | 589 | int64_t sample_rate; ///< samples per second |
| @@ -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_FILTER | 113 | #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 | |||
| 111 | AVFilter avfilter_vf_setsar = { | 124 | AVFilter 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 }, |
| @@ -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", |