Revision ff0652e5

View differences:

cmdutils.c
787 787
    .outputs   = (AVFilterPad[]) {{ .name = NULL }},
788 788
};
789 789

  
790
int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
791
                             AVFilterBufferRef **picref_ptr, AVRational *tb)
792
{
793
    int ret;
794
    AVFilterBufferRef *picref;
795

  
796
    if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
797
        return ret;
798
    if (!(picref = ctx->inputs[0]->cur_buf))
799
        return AVERROR(ENOENT);
800
    *picref_ptr = picref;
801
    ctx->inputs[0]->cur_buf = NULL;
802
    *tb = ctx->inputs[0]->time_base;
803

  
804
    memcpy(frame->data,     picref->data,     sizeof(frame->data));
805
    memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
806
    frame->interlaced_frame = picref->video->interlaced;
807
    frame->top_field_first  = picref->video->top_field_first;
808

  
809
    return 1;
810
}
811

  
790 812
#endif /* CONFIG_AVFILTER */
cmdutils.h
270 270

  
271 271
extern AVFilter ffsink;
272 272

  
273
/**
274
 * Extract a frame from sink.
275
 *
276
 * @return a negative error in case of failure, 1 if one frame has
277
 * been extracted successfully.
278
 */
279
int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
280
                             AVFilterBufferRef **picref, AVRational *pts_tb);
281

  
273 282
#endif /* CONFIG_AVFILTER */
274 283

  
275 284
#endif /* FFMPEG_CMDUTILS_H */
ffmpeg.c
324 324

  
325 325
#if CONFIG_AVFILTER
326 326

  
327
static int get_filtered_video_pic(AVFilterContext *ctx,
328
                                  AVFilterBufferRef **picref, AVFrame *pic2,
329
                                  uint64_t *pts)
330
{
331
    AVFilterBufferRef *pic;
332

  
333
    if(avfilter_request_frame(ctx->inputs[0]))
334
        return -1;
335
    if(!(pic = ctx->inputs[0]->cur_buf))
336
        return -1;
337
    *picref = pic;
338
    ctx->inputs[0]->cur_buf = NULL;
339

  
340
    *pts          = pic->pts;
341

  
342
    memcpy(pic2->data,     pic->data,     sizeof(pic->data));
343
    memcpy(pic2->linesize, pic->linesize, sizeof(pic->linesize));
344
    pic2->interlaced_frame = pic->video->interlaced;
345
    pic2->top_field_first  = pic->video->top_field_first;
346

  
347
    return 1;
348
}
349

  
350 327
static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
351 328
{
352 329
    AVFilterContext *last_filter, *filter;
......
1600 1577
        if (start_time == 0 || ist->pts >= start_time)
1601 1578
#if CONFIG_AVFILTER
1602 1579
        while (frame_available) {
1580
            AVRational ist_pts_tb;
1603 1581
            if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ist->output_video_filter)
1604
                get_filtered_video_pic(ist->output_video_filter, &ist->picref, &picture, &ist->pts);
1582
                get_filtered_video_frame(ist->output_video_filter, &picture, &ist->picref, &ist_pts_tb);
1583
            if (ist->picref)
1584
                ist->pts = ist->picref->pts;
1605 1585
#endif
1606 1586
            for(i=0;i<nb_ostreams;i++) {
1607 1587
                int frame_size;
ffplay.c
1779 1779
                                  { .name = NULL }},
1780 1780
};
1781 1781

  
1782
static int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
1783
                                    int64_t *pts, AVRational *tb, int64_t *pos)
1784
{
1785
    AVFilterBufferRef *pic;
1786

  
1787
    if(avfilter_request_frame(ctx->inputs[0]))
1788
        return -1;
1789
    if(!(pic = ctx->inputs[0]->cur_buf))
1790
        return -1;
1791
    ctx->inputs[0]->cur_buf = NULL;
1792

  
1793
    frame->opaque = pic;
1794
    *pts          = pic->pts;
1795
    *pos          = pic->pos;
1796
    *tb           = ctx->inputs[0]->time_base;
1797

  
1798
    memcpy(frame->data,     pic->data,     sizeof(frame->data));
1799
    memcpy(frame->linesize, pic->linesize, sizeof(frame->linesize));
1800

  
1801
    return 1;
1802
}
1803 1782
#endif  /* CONFIG_AVFILTER */
1804 1783

  
1805 1784
static int video_thread(void *arg)
......
1859 1838
#if !CONFIG_AVFILTER
1860 1839
        AVPacket pkt;
1861 1840
#else
1841
        AVFilterBufferRef *picref;
1862 1842
        AVRational tb;
1863 1843
#endif
1864 1844
        while (is->paused && !is->videoq.abort_request)
1865 1845
            SDL_Delay(10);
1866 1846
#if CONFIG_AVFILTER
1867
        ret = get_filtered_video_frame(filt_out, frame, &pts_int, &tb, &pos);
1847
        ret = get_filtered_video_frame(filt_out, frame, &picref, &tb);
1848
        if (picref) {
1849
            pts_int = picref->pts;
1850
            pos     = picref->pos;
1851
            frame->opaque = picref;
1852
        }
1868 1853

  
1869 1854
        if (av_cmp_q(tb, is->video_st->time_base)) {
1870 1855
            int64_t pts1 = pts_int;

Also available in: Unified diff