+ "Pixel formats:\n"
+ "I.... = Supported Input format for conversion\n"
+ ".O... = Supported Output format for conversion\n"
+ "..H.. = Hardware accelerated format\n"
+ "...P. = Paletted format\n"
+ "....B = Bitstream format\n"
+ "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
+ "-----\n");
+
+#if !CONFIG_SWSCALE
+# define sws_isSupportedInput(x) 0
+# define sws_isSupportedOutput(x) 0
+#endif
+
+ for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) {
+ const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt];
+ printf("%c%c%c%c%c %-16s %d %2d\n",
+ sws_isSupportedInput (pix_fmt) ? 'I' : '.',
+ sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
+ pix_desc->flags & PIX_FMT_HWACCEL ? 'H' : '.',
+ pix_desc->flags & PIX_FMT_PAL ? 'P' : '.',
+ pix_desc->flags & PIX_FMT_BITSTREAM ? 'B' : '.',
+ pix_desc->name,
+ pix_desc->nb_components,
+ av_get_bits_per_pixel(pix_desc));
+ }
+}
+
+int read_yesno(void)
+{
+ int c = getchar();
+ int yesno = (toupper(c) == 'Y');
+
+ while (c != '\n' && c != EOF)
+ c = getchar();
+
+ return yesno;
+}
+
+int read_file(const char *filename, char **bufptr, size_t *size)
+{
+ FILE *f = fopen(filename, "rb");
+
+ if (!f) {
+ fprintf(stderr, "Cannot read file '%s': %s\n", filename, strerror(errno));
+ return AVERROR(errno);
+ }
+ fseek(f, 0, SEEK_END);
+ *size = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ *bufptr = av_malloc(*size + 1);
+ if (!*bufptr) {
+ fprintf(stderr, "Could not allocate file buffer\n");
+ fclose(f);
+ return AVERROR(ENOMEM);
+ }
+ fread(*bufptr, 1, *size, f);
+ (*bufptr)[*size++] = '\0';
+
+ fclose(f);
+ return 0;
+}
+
+void init_pts_correction(PtsCorrectionContext *ctx)
+{
+ ctx->num_faulty_pts = ctx->num_faulty_dts = 0;
+ ctx->last_pts = ctx->last_dts = INT64_MIN;
+}
+
+int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int64_t dts)
+{
+ int64_t pts = AV_NOPTS_VALUE;
+
+ if (dts != AV_NOPTS_VALUE) {
+ ctx->num_faulty_dts += dts <= ctx->last_dts;
+ ctx->last_dts = dts;
+ }
+ if (reordered_pts != AV_NOPTS_VALUE) {
+ ctx->num_faulty_pts += reordered_pts <= ctx->last_pts;
+ ctx->last_pts = reordered_pts;
+ }
+ if ((ctx->num_faulty_pts<=ctx->num_faulty_dts || dts == AV_NOPTS_VALUE)
+ && reordered_pts != AV_NOPTS_VALUE)
+ pts = reordered_pts;
+ else
+ pts = dts;
+
+ return pts;
+}
+
+FILE *get_preset_file(char *filename, size_t filename_size,
+ const char *preset_name, int is_path, const char *codec_name)
+{
+ FILE *f = NULL;
+ int i;
+ const char *base[3]= { getenv("FFMPEG_DATADIR"),
+ getenv("HOME"),
+ FFMPEG_DATADIR,
+ };
+
+ if (is_path) {
+ av_strlcpy(filename, preset_name, filename_size);
+ f = fopen(filename, "r");
+ } else {
+ for (i = 0; i < 3 && !f; i++) {
+ if (!base[i])
+ continue;
+ snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", preset_name);
+ f = fopen(filename, "r");
+ if (!f && codec_name) {
+ snprintf(filename, filename_size,
+ "%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec_name, preset_name);
+ f = fopen(filename, "r");
+ }
+ }
+ }
+
+ return f;