#include "libavutil/avstring.h"
#include "libavutil/colorspace.h"
+#include "libavutil/display.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
static double compute_target_delay(double delay, VideoState *is)
{
- double sync_threshold, diff;
+ double sync_threshold, diff = 0;
/* update delay to follow master synchronisation source */
if (get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER) {
}
}
- av_dlog(NULL, "video: delay=%0.3f A-V=%f\n",
+ av_log(NULL, AV_LOG_TRACE, "video: delay=%0.3f A-V=%f\n",
delay, -diff);
return delay;
/* Note: this macro adds a filter before the lastly added filter, so the
* processing order of the filters is in reverse */
-#define INSERT_FILT(name, arg) do { \
- AVFilterContext *filt_ctx; \
- \
- ret = avfilter_graph_create_filter(&filt_ctx, \
- avfilter_get_by_name(name), \
- "ffplay_" name, arg, NULL, graph); \
- if (ret < 0) \
- goto fail; \
- \
- ret = avfilter_link(filt_ctx, 0, last_filter, 0); \
- if (ret < 0) \
- goto fail; \
- \
- last_filter = filt_ctx; \
+#define INSERT_FILT(name, arg) do { \
+ AVFilterContext *filt_ctx; \
+ \
+ ret = avfilter_graph_create_filter(&filt_ctx, \
+ avfilter_get_by_name(name), \
+ "ffplay_" name, arg, NULL, graph); \
+ if (ret < 0) \
+ goto fail; \
+ \
+ ret = avfilter_link(filt_ctx, 0, last_filter, 0); \
+ if (ret < 0) \
+ goto fail; \
+ \
+ last_filter = filt_ctx; \
} while (0)
/* SDL YUV code is not handling odd width/height for some driver
if (autorotate) {
AVDictionaryEntry *rotate_tag = av_dict_get(is->video_st->metadata, "rotate", NULL, 0);
+ uint8_t* displaymatrix = av_stream_get_side_data(is->video_st,
+ AV_PKT_DATA_DISPLAYMATRIX, NULL);
+
if (rotate_tag && *rotate_tag->value && strcmp(rotate_tag->value, "0")) {
if (!strcmp(rotate_tag->value, "90")) {
INSERT_FILT("transpose", "clock");
snprintf(rotate_buf, sizeof(rotate_buf), "%s*PI/180", rotate_tag->value);
INSERT_FILT("rotate", rotate_buf);
}
+ } else if (displaymatrix) {
+ double rot = av_display_rotation_get((int32_t*) displaymatrix);
+ if (rot < -135 || rot > 135) {
+ INSERT_FILT("vflip", NULL);
+ INSERT_FILT("hflip", NULL);
+ } else if (rot < -45) {
+ INSERT_FILT("transpose", "dir=clock");
+ } else if (rot > 45) {
+ INSERT_FILT("transpose", "dir=cclock");
+ }
}
}
enum AVPixelFormat last_format = -2;
int last_serial = -1;
int last_vfilter_idx = 0;
- if (!graph)
+ if (!graph) {
+ av_frame_free(&frame);
return AVERROR(ENOMEM);
+ }
#endif
- if (!frame)
+ if (!frame) {
+#if CONFIG_AVFILTER
+ avfilter_graph_free(&graph);
+#endif
return AVERROR(ENOMEM);
+ }
for (;;) {
ret = get_video_frame(is, frame);
max_nb_samples = ((nb_samples * (100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100));
wanted_nb_samples = FFMIN(FFMAX(wanted_nb_samples, min_nb_samples), max_nb_samples);
}
- av_dlog(NULL, "diff=%f adiff=%f sample_diff=%d apts=%0.3f %f\n",
+ av_log(NULL, AV_LOG_TRACE, "diff=%f adiff=%f sample_diff=%d apts=%0.3f %f\n",
diff, avg_diff, wanted_nb_samples - nb_samples,
is->audio_clock, is->audio_diff_threshold);
}