#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
-#include "libavcodec/audioconvert.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "libswresample/swresample.h"
int ret = 1;
if (decoder_reorder_pts == -1) {
- *pts = *(int64_t*)av_opt_ptr(avcodec_get_frame_class(), frame, "best_effort_timestamp");
+ *pts = av_frame_get_best_effort_timestamp(frame);
} else if (decoder_reorder_pts) {
*pts = frame->pkt_pts;
} else {
char sws_flags_str[128];
int ret;
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
- AVFilterContext *filt_src = NULL, *filt_out = NULL;
+ AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format;;
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
graph->scale_sws_opts = av_strdup(sws_flags_str);
return ret;
#if FF_API_OLD_VSINK_API
- ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out",
- NULL, pix_fmts, graph);
+ ret = avfilter_graph_create_filter(&filt_out,
+ avfilter_get_by_name("buffersink"),
+ "out", NULL, pix_fmts, graph);
#else
buffersink_params->pixel_fmts = pix_fmts;
- ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out",
- NULL, buffersink_params, graph);
+ ret = avfilter_graph_create_filter(&filt_out,
+ avfilter_get_by_name("buffersink"),
+ "out", NULL, buffersink_params, graph);
#endif
av_freep(&buffersink_params);
if (ret < 0)
return ret;
+ if ((ret = avfilter_graph_create_filter(&filt_format,
+ avfilter_get_by_name("format"),
+ "format", "yuv420p", NULL, graph)) < 0)
+ return ret;
+ if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
+ return ret;
+
+
if (vfilters) {
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
outputs->next = NULL;
inputs->name = av_strdup("out");
- inputs->filter_ctx = filt_out;
+ inputs->filter_ctx = filt_format;
inputs->pad_idx = 0;
inputs->next = NULL;
if ((ret = avfilter_graph_parse(graph, vfilters, &inputs, &outputs, NULL)) < 0)
return ret;
} else {
- if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0)
+ if ((ret = avfilter_link(filt_src, 0, filt_format, 0)) < 0)
return ret;
}
if (picref) {
avfilter_fill_frame_from_video_buffer_ref(frame, picref);
pts_int = picref->pts;
+ tb = filt_out->inputs[0]->time_base;
pos = picref->pos;
frame->opaque = picref;
+
+ ret = 1;
}
if (ret >= 0 && av_cmp_q(tb, is->video_st->time_base)) {
/* if no pts, then compute it */
pts = is->audio_clock;
*pts_ptr = pts;
- is->audio_clock += (double)data_size / (dec->channels * dec->sample_rate * av_get_bytes_per_sample(dec->sample_fmt));
+ is->audio_clock += (double)data_size /
+ (dec->channels * dec->sample_rate * av_get_bytes_per_sample(dec->sample_fmt));
#ifdef DEBUG
{
static double last_clock;
SDL_CloseAudio();
packet_queue_end(&is->audioq);
+ av_free_packet(&is->audio_pkt);
if (is->swr_ctx)
swr_free(&is->swr_ctx);
- av_free_packet(&is->audio_pkt);
av_freep(&is->audio_buf1);
is->audio_buf = NULL;
av_freep(&is->frame);