57 #include <SDL_thread.h>
66 #define MAX_QUEUE_SIZE (15 * 1024 * 1024)
68 #define EXTERNAL_CLOCK_MIN_FRAMES 2
69 #define EXTERNAL_CLOCK_MAX_FRAMES 10
72 #define SDL_AUDIO_MIN_BUFFER_SIZE 512
74 #define SDL_AUDIO_MAX_CALLBACKS_PER_SEC 30
77 #define SDL_VOLUME_STEP (SDL_MIX_MAXVOLUME / 50)
80 #define AV_SYNC_THRESHOLD_MIN 0.04
82 #define AV_SYNC_THRESHOLD_MAX 0.1
84 #define AV_SYNC_FRAMEDUP_THRESHOLD 0.1
86 #define AV_NOSYNC_THRESHOLD 10.0
89 #define SAMPLE_CORRECTION_PERCENT_MAX 10
92 #define EXTERNAL_CLOCK_SPEED_MIN 0.900
93 #define EXTERNAL_CLOCK_SPEED_MAX 1.010
94 #define EXTERNAL_CLOCK_SPEED_STEP 0.001
97 #define AUDIO_DIFF_AVG_NB 20
100 #define REFRESH_RATE 0.01
104 #define SAMPLE_ARRAY_SIZE (8 * 65536)
106 #define CURSOR_HIDE_DELAY 1000000
108 #define USE_ONEPASS_SUBTITLE_RENDER 1
129 #define VIDEO_PICTURE_QUEUE_SIZE 3
130 #define SUBPICTURE_QUEUE_SIZE 16
131 #define SAMPLE_QUEUE_SIZE 9
132 #define FRAME_QUEUE_SIZE FFMAX(SAMPLE_QUEUE_SIZE, FFMAX(VIDEO_PICTURE_QUEUE_SIZE, SUBPICTURE_QUEUE_SIZE))
346 static const char **vfilters_list =
NULL;
347 static int nb_vfilters = 0;
348 static char *afilters =
NULL;
358 #define FF_ALLOC_EVENT (SDL_USEREVENT)
359 #define FF_QUIT_EVENT (SDL_USEREVENT + 2)
365 static int opt_add_vfilter(
void *optctx,
const char *opt,
const char *
arg)
368 vfilters_list[nb_vfilters - 1] =
arg;
378 if (channel_count1 == 1 && channel_count2 == 1)
381 return channel_count1 != channel_count2 || fmt1 != fmt2;
388 return channel_layout;
407 if (pkt == &flush_pkt)
420 SDL_CondSignal(q->
cond);
428 SDL_LockMutex(q->
mutex);
430 SDL_UnlockMutex(q->
mutex);
432 if (pkt != &flush_pkt && ret < 0)
452 q->
mutex = SDL_CreateMutex();
457 q->
cond = SDL_CreateCond();
470 SDL_LockMutex(q->
mutex);
471 for (pkt = q->
first_pkt; pkt; pkt = pkt1) {
481 SDL_UnlockMutex(q->
mutex);
487 SDL_DestroyMutex(q->
mutex);
488 SDL_DestroyCond(q->
cond);
493 SDL_LockMutex(q->
mutex);
497 SDL_CondSignal(q->
cond);
499 SDL_UnlockMutex(q->
mutex);
504 SDL_LockMutex(q->
mutex);
507 SDL_UnlockMutex(q->
mutex);
516 SDL_LockMutex(q->
mutex);
545 SDL_UnlockMutex(q->
mutex);
634 }
while (!got_frame && !d->
finished);
654 if (!(f->
mutex = SDL_CreateMutex())) {
658 if (!(f->
cond = SDL_CreateCond())) {
680 SDL_DestroyMutex(f->
mutex);
681 SDL_DestroyCond(f->
cond);
686 SDL_LockMutex(f->
mutex);
687 SDL_CondSignal(f->
cond);
688 SDL_UnlockMutex(f->
mutex);
709 SDL_LockMutex(f->
mutex);
714 SDL_UnlockMutex(f->
mutex);
725 SDL_LockMutex(f->
mutex);
730 SDL_UnlockMutex(f->
mutex);
742 SDL_LockMutex(f->
mutex);
744 SDL_CondSignal(f->
cond);
745 SDL_UnlockMutex(f->
mutex);
757 SDL_LockMutex(f->
mutex);
759 SDL_CondSignal(f->
cond);
760 SDL_UnlockMutex(f->
mutex);
796 SDL_RenderFillRect(
renderer, &rect);
802 SDL_DestroyTexture(vp->
bmp);
807 static int realloc_texture(SDL_Texture **texture, Uint32 new_format,
int new_width,
int new_height, SDL_BlendMode blendmode,
int init_texture)
811 if (SDL_QueryTexture(*texture, &format, &access, &w, &h) < 0 || new_width != w || new_height != h || new_format != format) {
814 SDL_DestroyTexture(*texture);
815 if (!(*texture = SDL_CreateTexture(
renderer, new_format, SDL_TEXTUREACCESS_STREAMING, new_width, new_height)))
817 if (SDL_SetTextureBlendMode(*texture, blendmode) < 0)
820 if (SDL_LockTexture(*texture,
NULL, &pixels, &pitch) < 0)
822 memset(pixels, 0, pitch * new_height);
823 SDL_UnlockTexture(*texture);
830 int scr_xleft,
int scr_ytop,
int scr_width,
int scr_height,
831 int pic_width,
int pic_height,
AVRational pic_sar)
836 if (pic_sar.
num == 0)
839 aspect_ratio =
av_q2d(pic_sar);
841 if (aspect_ratio <= 0.0)
843 aspect_ratio *= (float)pic_width / (
float)pic_height;
847 width =
lrint(height * aspect_ratio) & ~1;
848 if (width > scr_width) {
850 height =
lrint(width / aspect_ratio) & ~1;
852 x = (scr_width -
width) / 2;
853 y = (scr_height -
height) / 2;
854 rect->x = scr_xleft + x;
855 rect->y = scr_ytop + y;
856 rect->w =
FFMAX(width, 1);
857 rect->h =
FFMAX(height, 1);
876 if (*img_convert_ctx !=
NULL) {
879 if (!SDL_LockTexture(tex,
NULL, (
void **)&pixels, &pitch)) {
881 0, frame->
height, &pixels, &pitch);
882 SDL_UnlockTexture(tex);
920 sub_rect->
x = av_clip(sub_rect->
x, 0, sp->
width );
921 sub_rect->
y = av_clip(sub_rect->
y, 0, sp->
height);
922 sub_rect->
w = av_clip(sub_rect->
w, 0, sp->
width - sub_rect->
x);
923 sub_rect->
h = av_clip(sub_rect->
h, 0, sp->
height - sub_rect->
y);
933 if (!SDL_LockTexture(is->
sub_texture, (SDL_Rect *)sub_rect, (
void **)&pixels, &pitch)) {
935 0, sub_rect->
h, &pixels, &pitch);
956 #if USE_ONEPASS_SUBTITLE_RENDER
960 double xratio = (double)rect.w / (
double)sp->
width;
961 double yratio = (double)rect.h / (
double)sp->
height;
963 SDL_Rect *sub_rect = (SDL_Rect*)sp->
sub.
rects[i];
964 SDL_Rect target = {.
x = rect.x + sub_rect->x * xratio,
965 .y = rect.y + sub_rect->y * yratio,
966 .w = sub_rect->w * xratio,
967 .h = sub_rect->h * yratio};
977 return a < 0 ? a%b + b : a%
b;
982 int i, i_start, x, y1, y, ys, delay,
n, nb_display_channels;
983 int ch, channels,
h, h2;
985 int rdft_bits, nb_freq;
987 for (rdft_bits = 1; (1 << rdft_bits) < 2 * s->
height; rdft_bits++)
989 nb_freq = 1 << (rdft_bits - 1);
993 nb_display_channels = channels;
995 int data_used= s->
show_mode == SHOW_MODE_WAVES ? s->
width : (2*nb_freq);
1007 delay += 2 * data_used;
1008 if (delay < data_used)
1014 for (i = 0; i < 1000; i += channels) {
1021 if (h < score && (b ^ c) < 0) {
1034 SDL_SetRenderDrawColor(
renderer, 255, 255, 255, 255);
1037 h = s->
height / nb_display_channels;
1040 for (ch = 0; ch < nb_display_channels; ch++) {
1042 y1 = s->
ytop + ch * h + (h / 2);
1043 for (x = 0; x < s->
width; x++) {
1058 SDL_SetRenderDrawColor(
renderer, 0, 0, 255, 255);
1060 for (ch = 1; ch < nb_display_channels; ch++) {
1061 y = s->
ytop + ch *
h;
1068 nb_display_channels=
FFMIN(nb_display_channels, 2);
1084 for (ch = 0; ch < nb_display_channels; ch++) {
1087 for (x = 0; x < 2 * nb_freq; x++) {
1088 double w = (x-nb_freq) * (1.0 / nb_freq);
1098 if (!SDL_LockTexture(s->
vis_texture, &rect, (
void **)&pixels, &pitch)) {
1100 pixels += pitch * s->
height;
1101 for (y = 0; y < s->
height; y++) {
1102 double w = 1 / sqrt(nb_freq);
1103 int a = sqrt(w * sqrt(data[0][2 * y + 0] * data[0][2 * y + 0] + data[0][2 * y + 1] * data[0][2 * y + 1]));
1104 int b = (nb_display_channels == 2 ) ? sqrt(w *
hypot(data[1][2 * y + 0], data[1][2 * y + 1]))
1109 *pixels = (a << 16) + (b << 8) + ((a+b) >> 1);
1127 if (stream_index < 0 || stream_index >= ic->
nb_streams)
1222 SDL_DestroyWindow(
window);
1253 if (vp && vp->
width)
1265 int flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
1269 flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
1270 window = SDL_CreateWindow(
window_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags);
1271 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,
"linear");
1273 SDL_RendererInfo info;
1274 renderer = SDL_CreateRenderer(
window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
1276 if (!SDL_GetRendererInfo(
renderer, &info))
1281 SDL_SetWindowSize(
window, w, h);
1301 SDL_SetRenderDrawColor(
renderer, 0, 0, 0, 255);
1461 double sync_threshold,
diff = 0;
1474 if (diff <= -sync_threshold)
1475 delay =
FFMAX(0, delay + diff);
1477 delay = delay +
diff;
1478 else if (diff >= sync_threshold)
1532 double last_duration,
duration, delay;
1555 if (time < is->frame_timer + delay) {
1599 if (!SDL_LockTexture(is->
sub_texture, (SDL_Rect *)sub_rect, (
void **)&pixels, &pitch)) {
1600 for (j = 0; j < sub_rect->
h; j++, pixels += pitch)
1601 memset(pixels, 0, sub_rect->
w << 2);
1626 static int64_t last_time;
1628 int aqsize, vqsize, sqsize;
1632 if (!last_time || (cur_time - last_time) >= 30000) {
1650 "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64
"/%"PRId64
" \r",
1678 sdl_format = SDL_PIXELFORMAT_YV12;
1680 sdl_format = SDL_PIXELFORMAT_ARGB8888;
1686 "Error: the video system does not support an image\n"
1687 "size of %dx%d pixels. Try using -lowres or -vf \"scale=w:h\"\n"
1688 "to reduce the image size.\n", vp->
width, vp->
height );
1702 #if defined(DEBUG_SYNC)
1703 printf(
"frame_type=%c pts=%0.3f\n",
1728 event.user.data1 = is;
1729 SDL_PushEvent(&event);
1805 if (!outputs || !inputs) {
1816 inputs->filter_ctx = sink_ctx;
1817 inputs->pad_idx = 0;
1818 inputs->next =
NULL;
1828 for (i = 0; i < graph->
nb_filters - nb_filters; i++)
1841 char sws_flags_str[512] =
"";
1842 char buffersrc_args[256];
1850 if (!strcmp(e->
key,
"sws_flags")) {
1851 av_strlcatf(sws_flags_str,
sizeof(sws_flags_str),
"%s=%s:",
"flags", e->
value);
1855 if (strlen(sws_flags_str))
1856 sws_flags_str[strlen(sws_flags_str)-1] =
'\0';
1860 snprintf(buffersrc_args,
sizeof(buffersrc_args),
1861 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
1866 av_strlcatf(buffersrc_args,
sizeof(buffersrc_args),
":frame_rate=%d/%d", fr.
num, fr.
den);
1870 "ffplay_buffer", buffersrc_args,
NULL,
1876 "ffplay_buffersink",
NULL,
NULL, graph);
1883 last_filter = filt_out;
1887 #define INSERT_FILT(name, arg) do { \
1888 AVFilterContext *filt_ctx; \
1890 ret = avfilter_graph_create_filter(&filt_ctx, \
1891 avfilter_get_by_name(name), \
1892 "ffplay_" name, arg, NULL, graph); \
1896 ret = avfilter_link(filt_ctx, 0, last_filter, 0); \
1900 last_filter = filt_ctx; \
1906 if (fabs(theta - 90) < 1.0) {
1907 INSERT_FILT(
"transpose",
"clock");
1908 }
else if (fabs(theta - 180) < 1.0) {
1909 INSERT_FILT(
"hflip",
NULL);
1910 INSERT_FILT(
"vflip",
NULL);
1911 }
else if (fabs(theta - 270) < 1.0) {
1912 INSERT_FILT(
"transpose",
"cclock");
1913 }
else if (fabs(theta) > 1.0) {
1914 char rotate_buf[64];
1915 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
1916 INSERT_FILT(
"rotate", rotate_buf);
1923 is->in_video_filter = filt_src;
1924 is->out_video_filter = filt_out;
1930 static int configure_audio_filters(
VideoState *is,
const char *afilters,
int force_output_format)
1935 int channels[2] = { 0, -1 };
1937 char aresample_swr_opts[512] =
"";
1939 char asrc_args[256];
1948 if (strlen(aresample_swr_opts))
1949 aresample_swr_opts[strlen(aresample_swr_opts)-1] =
'\0';
1950 av_opt_set(is->agraph,
"aresample_swr_opts", aresample_swr_opts, 0);
1952 ret =
snprintf(asrc_args,
sizeof(asrc_args),
1953 "sample_rate=%d:sample_fmt=%s:channels=%d:time_base=%d/%d",
1955 is->audio_filter_src.channels,
1956 1, is->audio_filter_src.freq);
1957 if (is->audio_filter_src.channel_layout)
1958 snprintf(asrc_args + ret,
sizeof(asrc_args) - ret,
1959 ":channel_layout=0x%"PRIx64, is->audio_filter_src.channel_layout);
1963 asrc_args,
NULL, is->agraph);
1979 if (force_output_format) {
1997 is->in_audio_filter = filt_asrc;
1998 is->out_audio_filter = filt_asink;
2013 int last_serial = -1;
2014 int64_t dec_channel_layout;
2035 cmp_audio_fmts(is->audio_filter_src.fmt, is->audio_filter_src.channels,
2037 is->audio_filter_src.channel_layout != dec_channel_layout ||
2038 is->audio_filter_src.freq != frame->
sample_rate ||
2042 char buf1[1024], buf2[1024];
2046 "Audio frame changed from rate:%d ch:%d fmt:%s layout:%s serial:%d to rate:%d ch:%d fmt:%s layout:%s serial:%d\n",
2047 is->audio_filter_src.freq, is->audio_filter_src.channels,
av_get_sample_fmt_name(is->audio_filter_src.fmt), buf1, last_serial,
2050 is->audio_filter_src.fmt = frame->
format;
2052 is->audio_filter_src.channel_layout = dec_channel_layout;
2056 if ((ret = configure_audio_filters(is, afilters, 1)) < 0)
2064 tb = is->out_audio_filter->inputs[0]->time_base;
2121 int last_serial = -1;
2122 int last_vfilter_idx = 0;
2145 if ( last_w != frame->
width
2146 || last_h != frame->
height
2147 || last_format != frame->
format
2149 || last_vfilter_idx != is->vfilter_idx) {
2151 "Video frame changed from size:%dx%d format:%s serial:%d to size:%dx%d format:%s serial:%d\n",
2158 if ((ret = configure_video_filters(graph, is, vfilters_list ? vfilters_list[is->vfilter_idx] :
NULL, frame)) < 0) {
2161 event.user.data1 = is;
2162 SDL_PushEvent(&event);
2165 filt_in = is->in_video_filter;
2166 filt_out = is->out_video_filter;
2167 last_w = frame->
width;
2169 last_format = frame->
format;
2171 last_vfilter_idx = is->vfilter_idx;
2230 if (got_subtitle && sp->
sub.
format == 0) {
2241 }
else if (got_subtitle) {
2253 size = samples_size /
sizeof(short);
2271 int wanted_nb_samples = nb_samples;
2275 double diff, avg_diff;
2276 int min_nb_samples, max_nb_samples;
2290 wanted_nb_samples = nb_samples + (int)(diff * is->
audio_src.
freq);
2293 wanted_nb_samples = av_clip(wanted_nb_samples, min_nb_samples, max_nb_samples);
2296 diff, avg_diff, wanted_nb_samples - nb_samples,
2307 return wanted_nb_samples;
2319 int data_size, resampled_data_size;
2320 int64_t dec_channel_layout;
2322 int wanted_nb_samples;
2345 dec_channel_layout =
2361 "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n",
2398 if (len2 == out_count) {
2407 resampled_data_size = data_size;
2419 static double last_clock;
2420 printf(
"audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n",
2426 return resampled_data_size;
2433 int audio_size, len1;
2440 if (audio_size < 0) {
2457 memset(stream, 0, len1);
2473 static int audio_open(
void *opaque, int64_t wanted_channel_layout,
int wanted_nb_channels,
int wanted_sample_rate,
struct AudioParams *audio_hw_params)
2475 SDL_AudioSpec wanted_spec, spec;
2477 static const int next_nb_channels[] = {0, 0, 1, 6, 2, 6, 4, 6};
2478 static const int next_sample_rates[] = {0, 44100, 48000, 96000, 192000};
2479 int next_sample_rate_idx =
FF_ARRAY_ELEMS(next_sample_rates) - 1;
2481 env = SDL_getenv(
"SDL_AUDIO_CHANNELS");
2483 wanted_nb_channels = atoi(env);
2491 wanted_spec.channels = wanted_nb_channels;
2492 wanted_spec.freq = wanted_sample_rate;
2493 if (wanted_spec.freq <= 0 || wanted_spec.channels <= 0) {
2497 while (next_sample_rate_idx && next_sample_rates[next_sample_rate_idx] >= wanted_spec.freq)
2498 next_sample_rate_idx--;
2499 wanted_spec.format = AUDIO_S16SYS;
2500 wanted_spec.silence = 0;
2503 wanted_spec.userdata = opaque;
2504 while (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
2506 wanted_spec.channels, wanted_spec.freq, SDL_GetError());
2507 wanted_spec.channels = next_nb_channels[
FFMIN(7, wanted_spec.channels)];
2508 if (!wanted_spec.channels) {
2509 wanted_spec.freq = next_sample_rates[next_sample_rate_idx--];
2510 wanted_spec.channels = wanted_nb_channels;
2511 if (!wanted_spec.freq) {
2513 "No more combinations to try, audio open failed\n");
2519 if (spec.format != AUDIO_S16SYS) {
2521 "SDL advised audio format %d is not supported!\n", spec.format);
2524 if (spec.channels != wanted_spec.channels) {
2526 if (!wanted_channel_layout) {
2528 "SDL advised channel count %d is not supported!\n", spec.channels);
2534 audio_hw_params->
freq = spec.freq;
2536 audio_hw_params->
channels = spec.channels;
2552 const char *forced_codec_name =
NULL;
2556 int64_t channel_layout;
2558 int stream_lowres =
lowres;
2560 if (stream_index < 0 || stream_index >= ic->
nb_streams)
2579 if (forced_codec_name)
2583 "No codec could be found with name '%s'\n", forced_codec_name);
2585 "No codec could be found with id %d\n", avctx->
codec_id);
2633 is->audio_filter_src.channels = avctx->
channels;
2635 is->audio_filter_src.fmt = avctx->
sample_fmt;
2636 if ((ret = configure_audio_filters(is, afilters, 0)) < 0)
2638 link = is->out_audio_filter->inputs[0];
2713 return stream_id < 0 ||
2727 if(s->
pb && ( !strncmp(s->
filename,
"rtp:", 4)
2728 || !strncmp(s->
filename,
"udp:", 4)
2743 int64_t stream_start_time;
2744 int pkt_in_play_range = 0;
2747 int orig_nb_streams;
2748 SDL_mutex *wait_mutex = SDL_CreateMutex();
2749 int scan_all_pmts_set = 0;
2758 memset(st_index, -1,
sizeof(st_index));
2774 scan_all_pmts_set = 1;
2782 if (scan_all_pmts_set)
2802 for (i = 0; i < orig_nb_streams; i++)
2808 "%s: could not find codec parameters\n", is->
filename);
2855 st_index[i] = INT_MAX;
2867 st_index[AVMEDIA_TYPE_VIDEO],
2873 (st_index[AVMEDIA_TYPE_AUDIO] >= 0 ?
2874 st_index[AVMEDIA_TYPE_AUDIO] :
2875 st_index[AVMEDIA_TYPE_VIDEO]),
2879 if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) {
2883 if (codecpar->
width)
2888 if (st_index[AVMEDIA_TYPE_AUDIO] >= 0) {
2893 if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) {
2897 is->
show_mode = ret >= 0 ? SHOW_MODE_VIDEO : SHOW_MODE_RDFT;
2899 if (st_index[AVMEDIA_TYPE_SUBTITLE] >= 0) {
2910 if (infinite_buffer < 0 && is->realtime)
2923 #if CONFIG_RTSP_DEMUXER || CONFIG_MMSH_PROTOCOL
2934 int64_t seek_target = is->
seek_pos;
2935 int64_t seek_min = is->
seek_rel > 0 ? seek_target - is->
seek_rel + 2: INT64_MIN;
2936 int64_t seek_max = is->
seek_rel < 0 ? seek_target - is->
seek_rel - 2: INT64_MAX;
2943 "%s: error while seeking\n", is->
ic->
filename);
2987 SDL_LockMutex(wait_mutex);
2989 SDL_UnlockMutex(wait_mutex);
3015 SDL_LockMutex(wait_mutex);
3017 SDL_UnlockMutex(wait_mutex);
3026 (pkt_ts - (stream_start_time !=
AV_NOPTS_VALUE ? stream_start_time : 0)) *
3051 event.user.data1 = is;
3052 SDL_PushEvent(&event);
3054 SDL_DestroyMutex(wait_mutex);
3110 int start_index, stream_index;
3126 stream_index = start_index;
3132 for (start_index = 0; start_index <
nb_streams; start_index++)
3135 if (start_index == nb_streams)
3137 stream_index = start_index;
3142 if (++stream_index >= nb_streams)
3150 if (start_index == -1)
3154 if (stream_index == start_index)
3159 switch (codec_type) {
3174 if (p && stream_index != -1)
3196 next = (next + 1) % SHOW_MODE_NB;
3197 }
while (next != is->
show_mode && (next == SHOW_MODE_VIDEO && !is->
video_st || next != SHOW_MODE_VIDEO && !is->
audio_st));
3205 double remaining_time = 0.0;
3207 while (!SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
3212 if (remaining_time > 0.0)
3213 av_usleep((int64_t)(remaining_time * 1000000.0));
3252 double incr, pos, frac;
3257 switch (event.type) {
3263 switch (event.key.keysym.sym) {
3279 case SDLK_KP_MULTIPLY:
3283 case SDLK_KP_DIVIDE:
3306 if (cur_stream->
show_mode == SHOW_MODE_VIDEO && cur_stream->vfilter_idx < nb_vfilters - 1) {
3307 if (++cur_stream->vfilter_idx >= nb_vfilters)
3308 cur_stream->vfilter_idx = 0;
3310 cur_stream->vfilter_idx = 0;
3371 case SDL_MOUSEBUTTONDOWN:
3376 if (event.button.button == SDL_BUTTON_LEFT) {
3377 static int64_t last_mouse_left_click = 0;
3381 last_mouse_left_click = 0;
3386 case SDL_MOUSEMOTION:
3392 if (event.type == SDL_MOUSEBUTTONDOWN) {
3393 if (event.button.button != SDL_BUTTON_RIGHT)
3397 if (!(event.motion.state & SDL_BUTTON_RMASK))
3407 int tns, thh, tmm, tss;
3410 tmm = (tns % 3600) / 60;
3412 frac = x / cur_stream->
width;
3415 mm = (ns % 3600) / 60;
3418 "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d) \n", frac*100,
3419 hh, mm, ss, thh, tmm, tss);
3426 case SDL_WINDOWEVENT:
3427 switch (event.window.event) {
3428 case SDL_WINDOWEVENT_RESIZED:
3435 case SDL_WINDOWEVENT_EXPOSED:
3473 if (!file_iformat) {
3488 if (!strcmp(arg,
"audio"))
3490 else if (!strcmp(arg,
"video"))
3492 else if (!strcmp(arg,
"ext"))
3515 show_mode = !strcmp(arg,
"video") ? SHOW_MODE_VIDEO :
3516 !strcmp(arg,
"waves") ? SHOW_MODE_WAVES :
3517 !strcmp(arg,
"rdft" ) ? SHOW_MODE_RDFT :
3526 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3530 if (!strcmp(filename,
"-"))
3537 const char *spec = strchr(opt,
':');
3540 "No media specifier was specified in '%s' in option '%s'\n",
3551 "Invalid media specifier '%s' in option '%s'\n", spec, opt);
3561 {
"x",
HAS_ARG, { .func_arg =
opt_width },
"force displayed width",
"width" },
3562 {
"y",
HAS_ARG, { .func_arg =
opt_height },
"force displayed height",
"height" },
3571 {
"ss",
HAS_ARG, { .func_arg =
opt_seek },
"seek to a given position in seconds",
"pos" },
3572 {
"t",
HAS_ARG, { .func_arg =
opt_duration },
"play \"duration\" seconds of audio/video",
"duration" },
3582 {
"sync",
HAS_ARG |
OPT_EXPERT, { .func_arg =
opt_sync },
"set audio-video sync. type (type=audio/video/ext)",
"type" },
3591 {
"vf",
OPT_EXPERT |
HAS_ARG, { .func_arg = opt_add_vfilter },
"set video filters",
"filter_graph" },
3592 {
"af",
OPT_STRING |
HAS_ARG, { &afilters },
"set audio filters",
"filter_graph" },
3595 {
"showmode",
HAS_ARG, { .func_arg =
opt_show_mode},
"select show mode (0 = video, 1 = waves, 2 = RDFT)",
"mode" },
3597 {
"i",
OPT_BOOL, { &dummy},
"read specified file",
"input_file"},
3598 {
"codec",
HAS_ARG, { .func_arg =
opt_codec},
"force decoder",
"decoder_name" },
3622 #if !CONFIG_AVFILTER
3627 printf(
"\nWhile playing:\n"
3629 "f toggle full screen\n"
3632 "9, 0 decrease and increase volume respectively\n"
3633 "/, * decrease and increase volume respectively\n"
3634 "a cycle audio channel in the current program\n"
3635 "v cycle video channel\n"
3636 "t cycle subtitle channel in the current program\n"
3638 "w cycle video filters or show modes\n"
3639 "s activate frame-step mode\n"
3640 "left/right seek backward/forward 10 seconds\n"
3641 "down/up seek backward/forward 1 minute\n"
3642 "page down/page up seek backward/forward 10 minutes\n"
3643 "right mouse click seek to percentage in file corresponding to fraction of width\n"
3644 "left double-click toggle full screen\n"
3652 *mtx = SDL_CreateMutex();
3659 return !!SDL_LockMutex(*mtx);
3661 return !!SDL_UnlockMutex(*mtx);
3663 SDL_DestroyMutex(*mtx);
3703 "Use -h to get full help or, even better, run 'man %s'\n",
program_name);
3710 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
3712 flags &= ~SDL_INIT_AUDIO;
3716 if (!SDL_getenv(
"SDL_AUDIO_ALSA_SET_BUFFER_SIZE"))
3717 SDL_setenv(
"SDL_AUDIO_ALSA_SET_BUFFER_SIZE",
"1", 1);
3720 flags &= ~SDL_INIT_VIDEO;
3721 if (SDL_Init (flags)) {
3727 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
3728 SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
unsigned int nb_chapters
Number of chapters in AVChapter array.
#define EXTERNAL_CLOCK_SPEED_STEP
AVFilterContext ** filters
static void packet_queue_abort(PacketQueue *q)
static int opt_show_mode(void *optctx, const char *opt, const char *arg)
void init_dynload(void)
Initialize dynamic library loading.
static void frame_queue_push(FrameQueue *f)
static void video_image_display(VideoState *is)
const char const char void * val
static void packet_queue_flush(PacketQueue *q)
static int upload_texture(SDL_Texture *tex, AVFrame *frame, struct SwsContext **img_convert_ctx)
static double get_clock(Clock *c)
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int opt_height(void *optctx, const char *opt, const char *arg)
const int program_birth_year
program birth year, defined by the program for show_banner()
static void copy(const float *p1, float *p2, const int length)
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb_channels, int wanted_sample_rate, struct AudioParams *audio_hw_params)
#define EXTERNAL_CLOCK_SPEED_MIN
This structure describes decoded (raw) audio or video data.
#define VIDEO_PICTURE_QUEUE_SIZE
static SDL_Renderer * renderer
int x
top left corner of pict, undefined when pict is not set
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
ptrdiff_t const GLvoid * data
static AVInputFormat * file_iformat
static void opt_input_file(void *optctx, const char *filename)
double get_rotation(AVStream *st)
int av_lockmgr_register(int(*cb)(void **mutex, enum AVLockOp op))
Register a user provided lock manager supporting the operations specified by AVLockOp.
static int opt_format(void *optctx, const char *opt, const char *arg)
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int get_master_sync_type(VideoState *is)
Main libavfilter public API header.
#define AV_SYNC_FRAMEDUP_THRESHOLD
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
static int default_height
Memory buffer source API.
double frame_last_filter_delay
enum VideoState::ShowMode show_mode
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
AVRational sample_aspect_ratio
Video only.
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
#define av_opt_set_int_list(obj, name, val, term, flags)
Set a binary option to an integer list.
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio...
static void stream_cycle_channel(VideoState *is, int codec_type)
void av_codec_set_pkt_timebase(AVCodecContext *avctx, AVRational val)
static int opt_frame_pix_fmt(void *optctx, const char *opt, const char *arg)
static void stream_toggle_pause(VideoState *is)
MyAVPacketList * first_pkt
static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_bytes)
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
enum AVMediaType codec_type
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
static int opt_codec(void *optctx, const char *opt, const char *arg)
static AVStream * video_stream
static unsigned sws_flags
AVS_VideoFrame int int int int new_height
attribute_deprecated int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
static void set_clock_at(Clock *c, double pts, int serial, double time)
static void toggle_pause(VideoState *is)
double audio_diff_threshold
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_usleep(unsigned usec)
Sleep for a period of time.
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
static const char * audio_codec_name
static void seek_chapter(VideoState *is, int incr)
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, AVCodec *codec)
Filter out options for given codec.
This struct describes the properties of an encoded stream.
AVLockOp
Lock operation used by lockmgr.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
static VideoState * stream_open(const char *filename, AVInputFormat *iformat)
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
struct SwsContext * img_convert_ctx
static void toggle_audio_display(VideoState *is)
AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
memory buffer sink API for audio and video
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
unsigned int nb_stream_indexes
#define AV_LOG_QUIET
Print no output.
int w
width of pict, undefined when pict is not set
AVFilterLink ** inputs
array of pointers to input links
static AVFilter ** last_filter
double audio_diff_avg_coef
static int read_thread(void *arg)
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance)
Activate resampling compensation ("soft" compensation).
static Frame * frame_queue_peek(FrameQueue *f)
static int64_t start_time
enum AVSampleFormat sample_fmt
audio sample format
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions...
8 bits with AV_PIX_FMT_RGB32 palette
static void stream_component_close(VideoState *is, int stream_index)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static int decode_interrupt_cb(void *ctx)
struct SwrContext * swr_ctx
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static void event_loop(VideoState *cur_stream)
static int cmp_audio_fmts(enum AVSampleFormat fmt1, int64_t channel_count1, enum AVSampleFormat fmt2, int64_t channel_count2)
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static void packet_queue_destroy(PacketQueue *q)
SDL_Texture * vis_texture
static void alloc_picture(VideoState *is)
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
AVStream ** streams
A list of all streams in the file.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
void avfilter_register_all(void)
Initialize the filter system.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
void av_codec_set_lowres(AVCodecContext *avctx, int val)
static int64_t audio_callback_time
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static int64_t get_valid_channel_layout(int64_t channel_layout, int channels)
int flags
Flags modifying the (de)muxer behaviour.
static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *serial)
static void sigterm_handler(int sig)
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int avformat_network_init(void)
Do global initialization of network components.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
Frame queue[FRAME_QUEUE_SIZE]
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
#define AV_NOSYNC_THRESHOLD
int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame)
Accessors for some AVFrame fields.
int h
height of pict, undefined when pict is not set
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
unsigned int * stream_index
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
AVDictionary * format_opts
static int realloc_texture(SDL_Texture **texture, Uint32 new_format, int new_width, int new_height, SDL_BlendMode blendmode, int init_texture)
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
#define SAMPLE_ARRAY_SIZE
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static void toggle_mute(VideoState *is)
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
Main libavdevice API header.
A link between two filters.
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)
Find the "best" stream in the file.
libswresample public header
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
AVDictionary * metadata
Metadata that applies to the whole file.
static void video_refresh(void *opaque, double *remaining_time)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
int sample_rate
samples per second
#define AV_OPT_FLAG_FILTERING_PARAM
a generic parameter which can be set by the user for filtering
int y
top left corner of pict, undefined when pict is not set
static AVStream * audio_stream
static void frame_queue_next(FrameQueue *f)
int avfilter_link_get_channels(AVFilterLink *link)
Get the number of channels of a link.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
The libswresample context.
static int decoder_start(Decoder *d, int(*fn)(void *), void *arg)
static int frame_queue_nb_remaining(FrameQueue *f)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
#define EXTERNAL_CLOCK_MAX_FRAMES
static int packet_queue_put_nullpacket(PacketQueue *q, int stream_index)
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define CURSOR_HIDE_DELAY
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
static double compute_target_delay(double delay, VideoState *is)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
enum AVMediaType codec_type
General type of the encoded data.
int flags
AV_CODEC_FLAG_*.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
static void stream_close(VideoState *is)
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
static void init_clock(Clock *c, int *queue_serial)
static enum ShowMode show_mode
New fields can be added to the end with minor version bumps.
static void packet_queue_start(PacketQueue *q)
static const OptionDef options[]
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
static const int sample_rates[]
uint64_t channel_layout
Audio channel layout.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
static int opt_sync(void *optctx, const char *opt, const char *arg)
struct SwsContext * sws_getCachedContext(struct SwsContext *context, int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Check if context can be reused, otherwise reallocate a new one.
static void update_sample_display(VideoState *is, short *samples, int samples_size)
void av_rdft_calc(RDFTContext *s, FFTSample *data)
uint32_t end_display_time
static void decoder_destroy(Decoder *d)
int64_t pts
Same as packet pts, in AV_TIME_BASE.
static AVPacket flush_pkt
uint64_t channel_layout
Channel layout of the audio data.
double frame_last_returned_time
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
char * av_asprintf(const char *fmt,...)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static const char * subtitle_codec_name
static int subtitle_disable
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static SDL_Window * window
const char program_name[]
program name, defined by the program for show_version().
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
static av_const double hypot(double x, double y)
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
#define SAMPLE_QUEUE_SIZE
#define SUBPICTURE_QUEUE_SIZE
enum AVPictureType pict_type
Picture type of the frame.
struct MyAVPacketList * next
#define AV_CH_LAYOUT_STEREO_DOWNMIX
char filename[1024]
input or output filename
#define AV_TIME_BASE
Internal time base represented as integer.
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static void decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue, SDL_cond *empty_queue_cond)
static int lockmgr(void **mtx, enum AVLockOp op)
int width
picture width / height.
int main(int argc, char **argv)
static void show_usage(void)
static int opt_width(void *optctx, const char *opt, const char *arg)
static int get_video_frame(VideoState *is, AVFrame *frame)
struct AudioParams audio_src
static void refresh_loop_wait_event(VideoState *is, SDL_Event *event)
static void set_clock_speed(Clock *c, double speed)
#define SDL_AUDIO_MAX_CALLBACKS_PER_SEC
struct SwrContext * swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)
Allocate SwrContext if needed and set/reset common parameters.
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
MyAVPacketList * last_pkt
void av_rdft_end(RDFTContext *s)
static void step_to_next_frame(VideoState *is)
static int audio_decode_frame(VideoState *is)
Decode one audio frame and return its uncompressed size.
RDFTContext * av_rdft_init(int nbits, enum RDFTransformType trans)
Set up a real FFT.
static int is_full_screen
#define AV_SYNC_THRESHOLD_MAX
static void fill_rectangle(int x, int y, int w, int h)
static int stream_has_enough_packets(AVStream *st, int stream_id, PacketQueue *queue)
static const AVFilterPad outputs[]
#define SDL_AUDIO_MIN_BUFFER_SIZE
static int packet_queue_init(PacketQueue *q)
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
static int decoder_reorder_pts
#define AUDIO_DIFF_AVG_NB
static void set_clock(Clock *c, double pts, int serial)
int16_t sample_array[SAMPLE_ARRAY_SIZE]
AVFilterContext * filter_ctx
filter context associated to this input/output
static const char * input_filename
#define FF_ARRAY_ELEMS(a)
static Frame * frame_queue_peek_last(FrameQueue *f)
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
int av_codec_get_max_lowres(const AVCodec *codec)
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal decoder state / flush internal buffers.
const AVClass * avfilter_get_class(void)
A linked-list of the inputs/outputs of the filter chain.
#define SAMPLE_CORRECTION_PERCENT_MAX
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
static int opt_duration(void *optctx, const char *opt, const char *arg)
static AVInputFormat * iformat
#define AV_LOG_INFO
Standard information.
static const AVFilterPad inputs[]
char * av_strdup(const char *s)
Duplicate a string.
enum AVMediaType codec_type
static void calculate_display_rect(SDL_Rect *rect, int scr_xleft, int scr_ytop, int scr_width, int scr_height, int pic_width, int pic_height, AVRational pic_sar)
attribute_deprecated int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
AVSampleFormat
Audio sample formats.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
static void do_exit(VideoState *is)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int sample_rate
samples per second
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVIOContext * pb
I/O context.
#define AV_CODEC_FLAG2_FAST
Allow non spec compliant speedup tricks.
static int exit_on_keydown
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Copy packet, including contents.
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
double max_frame_duration
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
swscale wrapper, so we don't need to export the SwsContext.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static double vp_duration(VideoState *is, Frame *vp, Frame *nextvp)
static const char * window_title
static Frame * frame_queue_peek_next(FrameQueue *f)
static int audio_thread(void *arg)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static void frame_queue_signal(FrameQueue *f)
static const char * format
static const uint16_t channel_layouts[7]
int sample_rate
Sample rate of the audio data.
int configure_filtergraph(FilterGraph *fg)
static void free_picture(Frame *vp)
int av_frame_get_channels(const AVFrame *frame)
int pad_idx
index of the filt_ctx pad to use for linking
static int video_open(VideoState *is, Frame *vp)
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
Rational number (pair of numerator and denominator).
#define AV_SYNC_THRESHOLD_MIN
struct SwsContext * sub_convert_ctx
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
Parse a string specifying a time and return its corresponding value as a number of microseconds...
static void video_audio_display(VideoState *s)
#define EXTERNAL_CLOCK_SPEED_MAX
static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub)
discard useless packets like 0 size packets in avi
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static int is_realtime(AVFormatContext *s)
static void check_external_clock_speed(VideoState *is)
int queue_attachments_req
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
static void frame_queue_unref_item(Frame *vp)
int error
contains the error code or 0 if no error happened
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg[SWR_CH_MAX], int in_count)
SDL_cond * empty_queue_cond
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
static enum AVPixelFormat pix_fmts[]
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
Parse a string and return its corresponding value as a double.
static int stream_component_open(VideoState *is, int stream_index)
char * name
unique name for this input/output in the list
static int64_t cursor_last_shown
static int frame_queue_init(FrameQueue *f, PacketQueue *pktq, int max_size, int keep_last)
static int opt_frame_size(void *optctx, const char *opt, const char *arg)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static int64_t pts
Global timestamp for the audio frames.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, double duration, int64_t pos, int serial)
SDL_Texture * sub_texture
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
static int synchronize_audio(VideoState *is, int nb_samples)
#define EXTERNAL_CLOCK_MIN_FRAMES
SDL_cond * continue_read_thread
static void frame_queue_destory(FrameQueue *f)
int sample_rate
Audio only.
static int64_t frame_queue_last_pos(FrameQueue *f)
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
static int exit_on_mousedown
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
#define CODEC_FLAG_EMU_EDGE
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int video_thread(void *arg)
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
static void set_default_window_size(int width, int height, AVRational sar)
AVDictionary * codec_opts
struct AudioParams audio_tgt
AVRational av_codec_get_pkt_timebase(const AVCodecContext *avctx)
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
static int display_disable
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
static int opt_seek(void *optctx, const char *opt, const char *arg)
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it...
int disposition
AV_DISPOSITION_* bit field.
uint32_t start_display_time
static void update_video_pts(VideoState *is, double pts, int64_t pos, int serial)
AVRational time_base
time base in which the start/end timestamps are specified
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
struct AVInputFormat * iformat
The input container format.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
#define GROW_ARRAY(array, nb_elems)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static int infinite_buffer
#define AVERROR_OPTION_NOT_FOUND
Option not found.
int eof_reached
true if eof reached
int channels
number of audio channels
int64_t av_frame_get_pkt_pos(const AVFrame *frame)
unsigned int audio_buf1_size
void av_log_set_flags(int arg)
static void decoder_abort(Decoder *d, FrameQueue *fq)
static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
int avformat_open_input(AVFormatContext **ps, const char *url, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
int flags2
AV_CODEC_FLAG2_*.
static void update_volume(VideoState *is, int sign, int step)
int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
Add a graph described by a string to a graph.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
static enum AVSampleFormat sample_fmts[]
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
static const char * video_codec_name
int64_t pts_correction_num_faulty_pts
Current statistics for PTS correction.
static Frame * frame_queue_peek_writable(FrameQueue *f)
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
static int subtitle_thread(void *arg)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
AVCodecParameters * codecpar
static double get_master_clock(VideoState *is)
#define av_malloc_array(a, b)
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
#define FFSWAP(type, a, b)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
unsigned int audio_buf_size
uint8_t ** extended_data
pointers to the data planes/channels.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static void video_display(VideoState *is)
static const char * wanted_stream_spec[AVMEDIA_TYPE_NB]
static int compute_mod(int a, int b)
AVPixelFormat
Pixel format.
This structure stores compressed data.
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
int nb_samples
number of audio samples (per channel) described by this frame
static void sync_clock_to_slave(Clock *c, Clock *slave)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static void toggle_full_screen(VideoState *is)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
#define AV_NOPTS_VALUE
Undefined timestamp value.
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
simple arithmetic expression evaluator
static Frame * frame_queue_peek_readable(FrameQueue *f)