/*
- * FFplay : Simple Media Player based on the Libav libraries
+ * ffplay : Simple Media Player based on the Libav libraries
* Copyright (c) 2003 Fabrice Bellard
*
* This file is part of Libav.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _XOPEN_SOURCE 600
-
#include "config.h"
#include <inttypes.h>
#include <math.h>
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavcodec/audioconvert.h"
-#include "libavcodec/opt.h"
+#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#if CONFIG_AVFILTER
#include <unistd.h>
#include <assert.h>
-const char program_name[] = "FFplay";
+const char program_name[] = "ffplay";
const int program_birth_year = 2003;
//#define DEBUG
} VideoState;
static void show_help(void);
-static int audio_write_get_buf_size(VideoState *is);
/* options specified by the user */
static AVInputFormat *file_iformat;
}
}
+/* get the current audio output buffer size, in samples. With SDL, we
+ cannot have a precise information */
+static int audio_write_get_buf_size(VideoState *is)
+{
+ return is->audio_buf_size - is->audio_buf_index;
+}
+
static inline int compute_mod(int a, int b)
{
a = a % b;
#if defined(DEBUG_SYNC) && 0
printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
- av_get_pict_type_char(src_frame->pict_type), pts, pts1);
+ av_get_picture_type_char(src_frame->pict_type), pts, pts1);
#endif
return queue_picture(is, src_frame, pts, pos);
}
int perms = AV_PERM_WRITE;
int i, w, h, stride[4];
unsigned edge;
+ int pixel_size;
if (codec->codec->capabilities & CODEC_CAP_NEG_LINESIZES)
perms |= AV_PERM_NEG_LINESIZES;
if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h)))
return -1;
+ pixel_size = av_pix_fmt_descriptors[ref->format].comp[0].step_minus1+1;
ref->video->w = codec->width;
ref->video->h = codec->height;
for(i = 0; i < 4; i ++) {
unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;
if (ref->data[i]) {
- ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift);
+ ref->data[i] += ((edge * pixel_size) >> hshift) + ((edge * ref->linesize[i]) >> vshift);
}
pic->data[i] = ref->data[i];
pic->linesize[i] = ref->linesize[i];
samples_size = wanted_size;
}
}
-#if 0
- printf("diff=%f adiff=%f sample_diff=%d apts=%0.3f vpts=%0.3f %f\n",
- diff, avg_diff, samples_size - samples_size1,
- is->audio_clock, is->video_clock, is->audio_diff_threshold);
-#endif
+ av_dlog(NULL, "diff=%f adiff=%f sample_diff=%d apts=%0.3f vpts=%0.3f %f\n",
+ diff, avg_diff, samples_size - samples_size1,
+ is->audio_clock, is->video_clock, is->audio_diff_threshold);
}
} else {
/* too big difference : may be initial PTS errors, so
}
}
-/* get the current audio output buffer size, in samples. With SDL, we
- cannot have a precise information */
-static int audio_write_get_buf_size(VideoState *is)
-{
- return is->audio_buf_size - is->audio_buf_index;
-}
-
-
/* prepare a new audio buffer */
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{
is->subtitle_stream = -1;
global_video_state = is;
- url_set_interrupt_cb(decode_interrupt_cb);
+ avio_set_interrupt_cb(decode_interrupt_cb);
memset(ap, 0, sizeof(*ap));
if(genpts)
ic->flags |= AVFMT_FLAG_GENPTS;
+ /* Set AVCodecContext options so they will be seen by av_find_stream_info() */
+ for (i = 0; i < ic->nb_streams; i++) {
+ AVCodecContext *dec = ic->streams[i]->codec;
+ switch (dec->codec_type) {
+ case AVMEDIA_TYPE_AUDIO:
+ set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO],
+ AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM,
+ NULL);
+ break;
+ case AVMEDIA_TYPE_VIDEO:
+ set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO],
+ AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM,
+ NULL);
+ break;
+ }
+ }
+
err = av_find_stream_info(ic);
if (err < 0) {
fprintf(stderr, "%s: could not find codec parameters\n", is->filename);
av_close_input_file(is->ic);
is->ic = NULL; /* safety */
}
- url_set_interrupt_cb(NULL);
+ avio_set_interrupt_cb(NULL);
if (ret != 0) {
SDL_Event event;
#endif
{ "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, {(void*)&rdftspeed}, "rdft speed", "msecs" },
{ "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
+ { "i", 0, {NULL}, "ffmpeg compatibility dummy option", ""},
{ NULL, },
};