Revision 7b3ea550

View differences:

doc/APIchanges
13 13

  
14 14
API changes, most recent first:
15 15

  
16
2011-01-31 - X - lavfi 1.76.0 - vsrc_buffer
17
  Add sample_aspect_ratio fields to vsrc_buffer arguments
18

  
16 19
2011-01-31 - X - lavfi 1.75.0 - AVFilterLink sample_aspect_ratio
17 20
  Add sample_aspect_ratio field to AVFilterLink.
18 21

  
doc/filters.texi
1014 1014
through the interface defined in @file{libavfilter/vsrc_buffer.h}.
1015 1015

  
1016 1016
It 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

  
1019 1019
All the parameters need to be explicitely defined.
1020 1020

  
......
1033 1033
@item timebase_num, timebase_den
1034 1034
Specify numerator and denomitor of the timebase assumed by the
1035 1035
timestamps of the buffered frames.
1036

  
1037
@item sample_aspect_ratio.num, sample_aspect_ratio.den
1038
Specify numerator and denominator of the sample aspect ratio assumed
1039
by the video frames.
1036 1040
@end table
1037 1041

  
1038 1042
For example:
1039 1043
@example
1040
buffer=320:240:yuv410p:1:24
1044
buffer=320:240:yuv410p:1:24:1:1
1041 1045
@end example
1042 1046

  
1043 1047
will instruct the source to accept video frames with size 320x240 and
1044
with format "yuv410p" and assuming 1/24 as the timestamps timebase.
1048
with format "yuv410p", assuming 1/24 as the timestamps timebase and
1049
square pixels (1:1 sample aspect ratio).
1045 1050
Since the pixel format with name "yuv410p" corresponds to the number 6
1046 1051
(check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),
1047 1052
this example corresponds to:
ffmpeg.c
355 355
    AVCodecContext *codec = ost->st->codec;
356 356
    AVCodecContext *icodec = ist->st->codec;
357 357
    FFSinkContext ffsink_ctx = { .pix_fmt = codec->pix_fmt };
358
    AVRational sample_aspect_ratio;
358 359
    char args[255];
359 360
    int ret;
360 361

  
361 362
    graph = avfilter_graph_alloc();
362 363

  
363
    snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width,
364
             ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE);
364
    if (ist->st->sample_aspect_ratio.num){
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 373
    ret = avfilter_graph_create_filter(&ist->input_video_filter, avfilter_get_by_name("buffer"),
366 374
                                       "src", args, NULL, graph);
367 375
    if (ret < 0)
......
415 423

  
416 424
    codec->width  = ist->output_video_filter->inputs[0]->w;
417 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 429
    return 0;
420 430
}
......
2845 2855
        ffmpeg_exit(1);
2846 2856
    }
2847 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

  
2850 2864
static int opt_metadata(const char *opt, const char *arg)
libavfilter/avfilter.h
27 27
#include "libavcore/samplefmt.h"
28 28

  
29 29
#define LIBAVFILTER_VERSION_MAJOR  1
30
#define LIBAVFILTER_VERSION_MINOR 75
30
#define LIBAVFILTER_VERSION_MINOR 76
31 31
#define LIBAVFILTER_VERSION_MICRO  0
32 32

  
33 33
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
libavfilter/vsrc_buffer.c
68 68
    int n = 0;
69 69

  
70 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) {
72
        av_log(ctx, AV_LOG_ERROR, "Expected 5 arguments, but only %d found in '%s'\n", n, args);
71
        (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d", &c->w, &c->h, pix_fmt_str,
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 75
        return AVERROR(EINVAL);
74 76
    }
75 77
    if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) {
......
100 102

  
101 103
    link->w = c->w;
102 104
    link->h = c->h;
105
    link->sample_aspect_ratio = c->pixel_aspect;
103 106
    link->time_base = c->time_base;
104 107

  
105 108
    return 0;

Also available in: Unified diff