History

Add sample_aspect_ratio fields to vsrc_buffer arguments. This fixes aspect handling in ffmpeg This is based on a patch by baptiste

Michael Niedermayer committed 15 years ago

Commit 7b3ea551 parent 14b171c5 files · +33 −8Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. doc/filters.texi +8 −3
  3. ffmpeg.c +16 −2
  4. libavfilter/avfilter.h +1 −1
  5. libavfilter/vsrc_buffer.c +5 −2
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2009-03-08 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162011-01-31 - X - lavfi 1.76.0 - vsrc_buffer
17 Add sample_aspect_ratio fields to vsrc_buffer arguments
18
162011-01-31 - X - lavfi 1.75.0 - AVFilterLink sample_aspect_ratio192011-01-31 - X - lavfi 1.75.0 - AVFilterLink sample_aspect_ratio
17 Add sample_aspect_ratio field to AVFilterLink.20 Add sample_aspect_ratio field to AVFilterLink.
18 21
doc/filters.texi+8−3
@@ -1014,7 +1014,7 @@ This source is mainly intended for a programmatic use, in particular · 1013 unmodified lines
1014through the interface defined in @file{libavfilter/vsrc_buffer.h}.1014through the interface defined in @file{libavfilter/vsrc_buffer.h}.
1015 1015
1016It accepts the following parameters:1016It accepts the following parameters:
1017@var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}1017@var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}:@var{sample_aspect_ratio_num}:@var{sample_aspect_ratio.den}
1018 1018
1019All the parameters need to be explicitely defined.1019All the parameters need to be explicitely defined.
1020 1020
@@ -1033,15 +1033,20 @@ name. · 12 unmodified lines
1033@item timebase_num, timebase_den1033@item timebase_num, timebase_den
1034Specify numerator and denomitor of the timebase assumed by the1034Specify numerator and denomitor of the timebase assumed by the
1035timestamps of the buffered frames.1035timestamps of the buffered frames.
1036
1037@item sample_aspect_ratio.num, sample_aspect_ratio.den
1038Specify numerator and denominator of the sample aspect ratio assumed
1039by the video frames.
1036@end table1040@end table
1037 1041
1038For example:1042For example:
1039@example1043@example
1040buffer=320:240:yuv410p:1:241044buffer=320:240:yuv410p:1:24:1:1
1041@end example1045@end example
1042 1046
1043will instruct the source to accept video frames with size 320x240 and1047will instruct the source to accept video frames with size 320x240 and
1044with format "yuv410p" and assuming 1/24 as the timestamps timebase.1048with format "yuv410p", assuming 1/24 as the timestamps timebase and
1049square pixels (1:1 sample aspect ratio).
1045Since the pixel format with name "yuv410p" corresponds to the number 61050Since the pixel format with name "yuv410p" corresponds to the number 6
1046(check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),1051(check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),
1047this example corresponds to:1052this example corresponds to:
ffmpeg.c+16−2
@@ -355,13 +355,21 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) · 354 unmodified lines
355 AVCodecContext *codec = ost->st->codec;355 AVCodecContext *codec = ost->st->codec;
356 AVCodecContext *icodec = ist->st->codec;356 AVCodecContext *icodec = ist->st->codec;
357 FFSinkContext ffsink_ctx = { .pix_fmt = codec->pix_fmt };357 FFSinkContext ffsink_ctx = { .pix_fmt = codec->pix_fmt };
358 AVRational sample_aspect_ratio;
358 char args[255];359 char args[255];
359 int ret;360 int ret;
360 361
361 graph = avfilter_graph_alloc();362 graph = avfilter_graph_alloc();
362 363
363 snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width,364 if (ist->st->sample_aspect_ratio.num){
364 ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE);365 sample_aspect_ratio = ist->st->sample_aspect_ratio;
366 }else
367 sample_aspect_ratio = ist->st->codec->sample_aspect_ratio;
368
369 snprintf(args, 255, "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width,
370 ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,
371 sample_aspect_ratio.num, sample_aspect_ratio.den);
372
365 ret = avfilter_graph_create_filter(&ist->input_video_filter, avfilter_get_by_name("buffer"),373 ret = avfilter_graph_create_filter(&ist->input_video_filter, avfilter_get_by_name("buffer"),
366 "src", args, NULL, graph);374 "src", args, NULL, graph);
367 if (ret < 0)375 if (ret < 0)
@@ -415,6 +423,8 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) · 47 unmodified lines
415 423
416 codec->width = ist->output_video_filter->inputs[0]->w;424 codec->width = ist->output_video_filter->inputs[0]->w;
417 codec->height = ist->output_video_filter->inputs[0]->h;425 codec->height = ist->output_video_filter->inputs[0]->h;
426 codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
427 ist->output_video_filter->inputs[0]->sample_aspect_ratio;
418 428
419 return 0;429 return 0;
420}430}
@@ -2845,6 +2855,10 @@ static void opt_frame_aspect_ratio(const char *arg) · 2424 unmodified lines
2845 ffmpeg_exit(1);2855 ffmpeg_exit(1);
2846 }2856 }
2847 frame_aspect_ratio = ar;2857 frame_aspect_ratio = ar;
2858
2859 x = vfilters ? strlen(vfilters) : 0;
2860 vfilters = av_realloc(vfilters, x+100);
2861 snprintf(vfilters+x, x+100, "%csetdar=%f\n", x?',':' ', ar);
2848}2862}
2849 2863
2850static int opt_metadata(const char *opt, const char *arg)2864static int opt_metadata(const char *opt, const char *arg)
libavfilter/avfilter.h+1−1
@@ -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, \
libavfilter/vsrc_buffer.c+5−2
@@ -68,8 +68,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 67 unmodified lines
68 int n = 0;68 int n = 0;
69 69
70 if (!args ||70 if (!args ||
71 (n = sscanf(args, "%d:%d:%127[^:]:%d:%d", &c->w, &c->h, pix_fmt_str, &c->time_base.num, &c->time_base.den)) != 5) {71 (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d", &c->w, &c->h, pix_fmt_str,
72 av_log(ctx, AV_LOG_ERROR, "Expected 5 arguments, but only %d found in '%s'\n", n, args);72 &c->time_base.num, &c->time_base.den,
73 &c->pixel_aspect.num, &c->pixel_aspect.den)) != 7) {
74 av_log(ctx, AV_LOG_ERROR, "Expected 7 arguments, but only %d found in '%s'\n", n, args);
73 return AVERROR(EINVAL);75 return AVERROR(EINVAL);
74 }76 }
75 if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) {77 if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) {
@@ -100,6 +102,7 @@ static int config_props(AVFilterLink *link) · 24 unmodified lines
100 102
101 link->w = c->w;103 link->w = c->w;
102 link->h = c->h;104 link->h = c->h;
105 link->sample_aspect_ratio = c->pixel_aspect;
103 link->time_base = c->time_base;106 link->time_base = c->time_base;
104 107
105 return 0;108 return 0;

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