Go to the documentation of this file.
27 #include "config_components.h"
55 #include <SDL_thread.h>
64 #define MAX_QUEUE_SIZE (15 * 1024 * 1024)
66 #define EXTERNAL_CLOCK_MIN_FRAMES 2
67 #define EXTERNAL_CLOCK_MAX_FRAMES 10
70 #define SDL_AUDIO_MIN_BUFFER_SIZE 512
72 #define SDL_AUDIO_MAX_CALLBACKS_PER_SEC 30
75 #define SDL_VOLUME_STEP (0.75)
78 #define AV_SYNC_THRESHOLD_MIN 0.04
80 #define AV_SYNC_THRESHOLD_MAX 0.1
82 #define AV_SYNC_FRAMEDUP_THRESHOLD 0.1
84 #define AV_NOSYNC_THRESHOLD 10.0
87 #define SAMPLE_CORRECTION_PERCENT_MAX 10
90 #define EXTERNAL_CLOCK_SPEED_MIN 0.900
91 #define EXTERNAL_CLOCK_SPEED_MAX 1.010
92 #define EXTERNAL_CLOCK_SPEED_STEP 0.001
95 #define AUDIO_DIFF_AVG_NB 20
98 #define REFRESH_RATE 0.01
102 #define SAMPLE_ARRAY_SIZE (8 * 65536)
104 #define CURSOR_HIDE_DELAY 1000000
106 #define USE_ONEPASS_SUBTITLE_RENDER 1
124 #define VIDEO_PICTURE_QUEUE_SIZE 3
125 #define SUBPICTURE_QUEUE_SIZE 16
126 #define SAMPLE_QUEUE_SIZE 9
127 #define FRAME_QUEUE_SIZE FFMAX(SAMPLE_QUEUE_SIZE, FFMAX(VIDEO_PICTURE_QUEUE_SIZE, SUBPICTURE_QUEUE_SIZE))
359 #define FF_QUIT_EVENT (SDL_USEREVENT + 2)
412 if (channel_count1 == 1 && channel_count2 == 1)
415 return channel_count1 != channel_count2 || fmt1 != fmt2;
437 SDL_CondSignal(q->
cond);
453 SDL_LockMutex(q->
mutex);
455 SDL_UnlockMutex(q->
mutex);
476 q->
mutex = SDL_CreateMutex();
481 q->
cond = SDL_CreateCond();
494 SDL_LockMutex(q->
mutex);
501 SDL_UnlockMutex(q->
mutex);
508 SDL_DestroyMutex(q->
mutex);
509 SDL_DestroyCond(q->
cond);
514 SDL_LockMutex(q->
mutex);
518 SDL_CondSignal(q->
cond);
520 SDL_UnlockMutex(q->
mutex);
525 SDL_LockMutex(q->
mutex);
528 SDL_UnlockMutex(q->
mutex);
537 SDL_LockMutex(q->
mutex);
562 SDL_UnlockMutex(q->
mutex);
573 d->empty_queue_cond = empty_queue_cond;
583 if (
d->queue->serial ==
d->pkt_serial) {
585 if (
d->queue->abort_request)
588 switch (
d->avctx->codec_type) {
615 d->finished =
d->pkt_serial;
625 if (
d->queue->nb_packets == 0)
626 SDL_CondSignal(
d->empty_queue_cond);
627 if (
d->packet_pending) {
628 d->packet_pending = 0;
630 int old_serial =
d->pkt_serial;
633 if (old_serial !=
d->pkt_serial) {
636 d->next_pts =
d->start_pts;
637 d->next_pts_tb =
d->start_pts_tb;
640 if (
d->queue->serial ==
d->pkt_serial)
651 if (got_frame && !
d->pkt->data) {
652 d->packet_pending = 1;
658 if (
d->pkt->buf && !
d->pkt->opaque_ref) {
662 if (!
d->pkt->opaque_ref)
669 av_log(
d->avctx,
AV_LOG_ERROR,
"Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n");
670 d->packet_pending = 1;
693 if (!(
f->mutex = SDL_CreateMutex())) {
697 if (!(
f->cond = SDL_CreateCond())) {
703 f->keep_last = !!keep_last;
704 for (
i = 0;
i <
f->max_size;
i++)
713 for (
i = 0;
i <
f->max_size;
i++) {
718 SDL_DestroyMutex(
f->mutex);
719 SDL_DestroyCond(
f->cond);
724 SDL_LockMutex(
f->mutex);
725 SDL_CondSignal(
f->cond);
726 SDL_UnlockMutex(
f->mutex);
731 return &
f->queue[(
f->rindex +
f->rindex_shown) %
f->max_size];
736 return &
f->queue[(
f->rindex +
f->rindex_shown + 1) %
f->max_size];
741 return &
f->queue[
f->rindex];
747 SDL_LockMutex(
f->mutex);
748 while (
f->size >=
f->max_size &&
749 !
f->pktq->abort_request) {
750 SDL_CondWait(
f->cond,
f->mutex);
752 SDL_UnlockMutex(
f->mutex);
754 if (
f->pktq->abort_request)
757 return &
f->queue[
f->windex];
763 SDL_LockMutex(
f->mutex);
764 while (
f->size -
f->rindex_shown <= 0 &&
765 !
f->pktq->abort_request) {
766 SDL_CondWait(
f->cond,
f->mutex);
768 SDL_UnlockMutex(
f->mutex);
770 if (
f->pktq->abort_request)
773 return &
f->queue[(
f->rindex +
f->rindex_shown) %
f->max_size];
778 if (++
f->windex ==
f->max_size)
780 SDL_LockMutex(
f->mutex);
782 SDL_CondSignal(
f->cond);
783 SDL_UnlockMutex(
f->mutex);
788 if (
f->keep_last && !
f->rindex_shown) {
793 if (++
f->rindex ==
f->max_size)
795 SDL_LockMutex(
f->mutex);
797 SDL_CondSignal(
f->cond);
798 SDL_UnlockMutex(
f->mutex);
804 return f->size -
f->rindex_shown;
811 if (
f->rindex_shown &&
fp->serial ==
f->pktq->serial)
821 SDL_WaitThread(
d->decoder_tid,
NULL);
822 d->decoder_tid =
NULL;
837 static int realloc_texture(SDL_Texture **texture, Uint32 new_format,
int new_width,
int new_height, SDL_BlendMode blendmode,
int init_texture)
841 if (!*texture || SDL_QueryTexture(*texture, &
format, &access, &
w, &
h) < 0 || new_width !=
w || new_height !=
h || new_format !=
format) {
845 SDL_DestroyTexture(*texture);
846 if (!(*texture = SDL_CreateTexture(
renderer, new_format, SDL_TEXTUREACCESS_STREAMING, new_width, new_height)))
848 if (SDL_SetTextureBlendMode(*texture, blendmode) < 0)
851 if (SDL_LockTexture(*texture,
NULL, &pixels, &pitch) < 0)
853 memset(pixels, 0, pitch * new_height);
854 SDL_UnlockTexture(*texture);
856 av_log(
NULL,
AV_LOG_VERBOSE,
"Created %dx%d texture with %s.\n", new_width, new_height, SDL_GetPixelFormatName(new_format));
862 int scr_xleft,
int scr_ytop,
int scr_width,
int scr_height,
863 int pic_width,
int pic_height,
AVRational pic_sar)
876 if (
width > scr_width) {
880 x = (scr_width -
width) / 2;
881 y = (scr_height -
height) / 2;
882 rect->
x = scr_xleft + x;
883 rect->
y = scr_ytop + y;
891 *sdl_blendmode = SDL_BLENDMODE_NONE;
892 *sdl_pix_fmt = SDL_PIXELFORMAT_UNKNOWN;
897 *sdl_blendmode = SDL_BLENDMODE_BLEND;
910 SDL_BlendMode sdl_blendmode;
912 if (
realloc_texture(tex, sdl_pix_fmt == SDL_PIXELFORMAT_UNKNOWN ? SDL_PIXELFORMAT_ARGB8888 : sdl_pix_fmt,
frame->width,
frame->height, sdl_blendmode, 0) < 0)
914 switch (sdl_pix_fmt) {
915 case SDL_PIXELFORMAT_IYUV:
916 if (
frame->linesize[0] > 0 &&
frame->linesize[1] > 0 &&
frame->linesize[2] > 0) {
920 }
else if (
frame->linesize[0] < 0 &&
frame->linesize[1] < 0 &&
frame->linesize[2] < 0) {
930 if (
frame->linesize[0] < 0) {
949 #if SDL_VERSION_ATLEAST(2,0,8)
950 SDL_YUV_CONVERSION_MODE
mode = SDL_YUV_CONVERSION_AUTOMATIC;
953 mode = SDL_YUV_CONVERSION_JPEG;
955 mode = SDL_YUV_CONVERSION_BT709;
957 mode = SDL_YUV_CONVERSION_BT601;
959 SDL_SetYUVConversionMode(
mode);
975 if (
is->subtitle_st) {
979 if (vp->
pts >=
sp->pts + ((
float)
sp->sub.start_display_time / 1000)) {
984 if (!
sp->width || !
sp->height) {
988 if (
realloc_texture(&
is->sub_texture, SDL_PIXELFORMAT_ARGB8888,
sp->width,
sp->height, SDL_BLENDMODE_BLEND, 1) < 0)
991 for (
i = 0;
i <
sp->sub.num_rects;
i++) {
996 sub_rect->
w =
av_clip(sub_rect->
w, 0,
sp->width - sub_rect->
x);
997 sub_rect->
h =
av_clip(sub_rect->
h, 0,
sp->height - sub_rect->
y);
1003 if (!
is->sub_convert_ctx) {
1007 if (!SDL_LockTexture(
is->sub_texture, (SDL_Rect *)sub_rect, (
void **)pixels, pitch)) {
1008 sws_scale(
is->sub_convert_ctx, (
const uint8_t *
const *)sub_rect->data, sub_rect->linesize,
1009 0, sub_rect->h, pixels, pitch);
1010 SDL_UnlockTexture(
is->sub_texture);
1035 #if USE_ONEPASS_SUBTITLE_RENDER
1041 for (
i = 0;
i <
sp->sub.num_rects;
i++) {
1042 SDL_Rect *sub_rect = (SDL_Rect*)
sp->sub.rects[
i];
1043 SDL_Rect target = {.x =
rect.
x + sub_rect->x * xratio,
1044 .y =
rect.
y + sub_rect->y * yratio,
1045 .w = sub_rect->w * xratio,
1046 .h = sub_rect->h * yratio};
1047 SDL_RenderCopy(
renderer,
is->sub_texture, sub_rect, &target);
1055 return a < 0 ?
a%
b +
b :
a%
b;
1060 int i, i_start, x, y1, y, ys, delay, n, nb_display_channels;
1063 int rdft_bits, nb_freq;
1065 for (rdft_bits = 1; (1 << rdft_bits) < 2 *
s->height; rdft_bits++)
1067 nb_freq = 1 << (rdft_bits - 1);
1070 channels =
s->audio_tgt.ch_layout.nb_channels;
1073 int data_used=
s->show_mode == SHOW_MODE_WAVES ?
s->width : (2*nb_freq);
1075 delay =
s->audio_write_buf_size;
1082 delay -= (time_diff *
s->audio_tgt.freq) / 1000000;
1085 delay += 2 * data_used;
1086 if (delay < data_used)
1090 if (
s->show_mode == SHOW_MODE_WAVES) {
1094 int a =
s->sample_array[idx];
1099 if (
h < score && (
b ^
c) < 0) {
1106 s->last_i_start = i_start;
1108 i_start =
s->last_i_start;
1111 if (
s->show_mode == SHOW_MODE_WAVES) {
1112 SDL_SetRenderDrawColor(
renderer, 255, 255, 255, 255);
1115 h =
s->height / nb_display_channels;
1118 for (ch = 0; ch < nb_display_channels; ch++) {
1120 y1 =
s->ytop + ch *
h + (
h / 2);
1121 for (x = 0; x <
s->width; x++) {
1122 y = (
s->sample_array[
i] * h2) >> 15;
1136 SDL_SetRenderDrawColor(
renderer, 0, 0, 255, 255);
1138 for (ch = 1; ch < nb_display_channels; ch++) {
1139 y =
s->ytop + ch *
h;
1144 if (
realloc_texture(&
s->vis_texture, SDL_PIXELFORMAT_ARGB8888,
s->width,
s->height, SDL_BLENDMODE_NONE, 1) < 0)
1147 if (
s->xpos >=
s->width)
1149 nb_display_channels=
FFMIN(nb_display_channels, 2);
1150 if (rdft_bits !=
s->rdft_bits) {
1151 const float rdft_scale = 1.0;
1155 s->rdft_bits = rdft_bits;
1159 0, 1 << rdft_bits, &rdft_scale, 0);
1161 if (err < 0 || !s->rdft_data) {
1163 s->show_mode = SHOW_MODE_WAVES;
1167 SDL_Rect
rect = {.
x =
s->xpos, .y = 0, .w = 1, .h =
s->height};
1170 for (ch = 0; ch < nb_display_channels; ch++) {
1171 data_in[ch] =
s->real_data + 2 * nb_freq * ch;
1172 data[ch] =
s->rdft_data + nb_freq * ch;
1174 for (x = 0; x < 2 * nb_freq; x++) {
1175 double w = (x-nb_freq) * (1.0 / nb_freq);
1176 data_in[ch][x] =
s->sample_array[
i] * (1.0 -
w *
w);
1181 s->rdft_fn(
s->rdft,
data[ch], data_in[ch],
sizeof(
float));
1182 data[ch][0].im =
data[ch][nb_freq].re;
1183 data[ch][nb_freq].re = 0;
1187 if (!SDL_LockTexture(
s->vis_texture, &
rect, (
void **)&pixels, &pitch)) {
1189 pixels += pitch *
s->height;
1190 for (y = 0; y <
s->height; y++) {
1191 double w = 1 / sqrt(nb_freq);
1192 int a = sqrt(
w * sqrt(
data[0][y].re *
data[0][y].re +
data[0][y].im *
data[0][y].im));
1193 int b = (nb_display_channels == 2 ) ? sqrt(
w *
hypot(
data[1][y].re,
data[1][y].im))
1198 *pixels = (
a << 16) + (
b << 8) + ((
a+
b) >> 1);
1200 SDL_UnlockTexture(
s->vis_texture);
1214 if (stream_index < 0 || stream_index >= ic->
nb_streams)
1225 is->audio_buf1_size = 0;
1252 is->audio_stream = -1;
1256 is->video_stream = -1;
1260 is->subtitle_stream = -1;
1270 is->abort_request = 1;
1271 SDL_WaitThread(
is->read_tid,
NULL);
1274 if (
is->audio_stream >= 0)
1276 if (
is->video_stream >= 0)
1278 if (
is->subtitle_stream >= 0)
1291 SDL_DestroyCond(
is->continue_read_thread);
1294 if (
is->vis_texture)
1295 SDL_DestroyTexture(
is->vis_texture);
1296 if (
is->vid_texture)
1297 SDL_DestroyTexture(
is->vid_texture);
1298 if (
is->sub_texture)
1299 SDL_DestroyTexture(
is->sub_texture);
1313 SDL_DestroyWindow(
window);
1340 if (max_width == INT_MAX && max_height == INT_MAX)
1361 SDL_SetWindowFullscreen(
window, SDL_WINDOW_FULLSCREEN_DESKTOP);
1376 SDL_SetRenderDrawColor(
renderer, 0, 0, 0, 255);
1378 if (
is->audio_st &&
is->show_mode != SHOW_MODE_VIDEO)
1380 else if (
is->video_st)
1387 if (*
c->queue_serial !=
c->serial)
1393 return c->pts_drift + time - (time -
c->last_updated) * (1.0 -
c->speed);
1400 c->last_updated = time;
1401 c->pts_drift =
c->pts - time;
1421 c->queue_serial = queue_serial;
1476 double speed =
is->extclk.speed;
1485 if (!
is->seek_req) {
1492 SDL_CondSignal(
is->continue_read_thread);
1501 if (
is->read_pause_return !=
AVERROR(ENOSYS)) {
1502 is->vidclk.paused = 0;
1507 is->paused =
is->audclk.paused =
is->vidclk.paused =
is->extclk.paused = !
is->paused;
1518 is->muted = !
is->muted;
1523 double volume_level =
is->audio_volume ? (20 *
log(
is->audio_volume / (
double)SDL_MIX_MAXVOLUME) /
log(10)) : -1000.0;
1524 int new_volume =
lrint(SDL_MIX_MAXVOLUME * pow(10.0, (volume_level + sign *
step) / 20.0));
1525 is->audio_volume =
av_clip(
is->audio_volume == new_volume ? (
is->audio_volume + sign) : new_volume, 0, SDL_MIX_MAXVOLUME);
1538 double sync_threshold,
diff = 0;
1551 if (
diff <= -sync_threshold)
1554 delay = delay +
diff;
1555 else if (
diff >= sync_threshold)
1569 if (
isnan(
duration) || duration <= 0 || duration >
is->max_frame_duration)
1598 if (
is->force_refresh ||
is->last_vis_time +
rdftspeed < time) {
1600 is->last_vis_time = time;
1602 *remaining_time =
FFMIN(*remaining_time,
is->last_vis_time +
rdftspeed - time);
1610 double last_duration,
duration, delay;
1617 if (vp->
serial !=
is->videoq.serial) {
1633 if (time < is->frame_timer + delay) {
1634 *remaining_time =
FFMIN(
is->frame_timer + delay - time, *remaining_time);
1638 is->frame_timer += delay;
1640 is->frame_timer = time;
1642 SDL_LockMutex(
is->pictq.mutex);
1645 SDL_UnlockMutex(
is->pictq.mutex);
1651 is->frame_drops_late++;
1657 if (
is->subtitle_st) {
1666 if (
sp->serial !=
is->subtitleq.serial
1667 || (
is->vidclk.pts > (
sp->pts + ((
float)
sp->sub.end_display_time / 1000)))
1672 for (
i = 0;
i <
sp->sub.num_rects;
i++) {
1677 if (!SDL_LockTexture(
is->sub_texture, (SDL_Rect *)sub_rect, (
void **)&pixels, &pitch)) {
1678 for (j = 0; j < sub_rect->h; j++, pixels += pitch)
1679 memset(pixels, 0, sub_rect->w << 2);
1680 SDL_UnlockTexture(
is->sub_texture);
1692 is->force_refresh = 1;
1694 if (
is->step && !
is->paused)
1699 if (!
display_disable &&
is->force_refresh &&
is->show_mode == SHOW_MODE_VIDEO &&
is->pictq.rindex_shown)
1702 is->force_refresh = 0;
1705 static int64_t last_time;
1707 int aqsize, vqsize, sqsize;
1711 if (!last_time || (cur_time - last_time) >= 30000) {
1716 aqsize =
is->audioq.size;
1718 vqsize =
is->videoq.size;
1719 if (
is->subtitle_st)
1720 sqsize =
is->subtitleq.size;
1722 if (
is->audio_st &&
is->video_st)
1724 else if (
is->video_st)
1726 else if (
is->audio_st)
1731 "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB \r",
1733 (
is->audio_st &&
is->video_st) ?
"A-V" : (
is->video_st ?
"M-V" : (
is->audio_st ?
"M-A" :
" ")),
1735 is->frame_drops_early +
is->frame_drops_late,
1741 fprintf(stderr,
"%s", buf.str);
1748 last_time = cur_time;
1757 #if defined(DEBUG_SYNC)
1758 printf(
"frame_type=%c pts=%0.3f\n",
1803 diff -
is->frame_last_filter_delay < 0 &&
1804 is->viddec.pkt_serial ==
is->vidclk.serial &&
1805 is->videoq.nb_packets) {
1806 is->frame_drops_early++;
1833 outputs->filter_ctx = source_ctx;
1838 inputs->filter_ctx = sink_ctx;
1863 char sws_flags_str[512] =
"";
1864 char buffersrc_args[256];
1870 int nb_pix_fmts = 0;
1888 if (!strcmp(e->
key,
"sws_flags")) {
1889 av_strlcatf(sws_flags_str,
sizeof(sws_flags_str),
"%s=%s:",
"flags", e->
value);
1893 if (strlen(sws_flags_str))
1894 sws_flags_str[strlen(sws_flags_str)-1] =
'\0';
1898 snprintf(buffersrc_args,
sizeof(buffersrc_args),
1899 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d:"
1900 "colorspace=%d:range=%d",
1902 is->video_st->time_base.num,
is->video_st->time_base.den,
1906 av_strlcatf(buffersrc_args,
sizeof(buffersrc_args),
":frame_rate=%d/%d", fr.
num, fr.
den);
1910 "ffplay_buffer", buffersrc_args,
NULL,
1920 "ffplay_buffersink",
NULL,
NULL, graph);
1930 last_filter = filt_out;
1934 #define INSERT_FILT(name, arg) do { \
1935 AVFilterContext *filt_ctx; \
1937 ret = avfilter_graph_create_filter(&filt_ctx, \
1938 avfilter_get_by_name(name), \
1939 "ffplay_" name, arg, NULL, graph); \
1943 ret = avfilter_link(filt_ctx, 0, last_filter, 0); \
1947 last_filter = filt_ctx; \
1956 if (!displaymatrix) {
1958 is->video_st->codecpar->nb_coded_side_data,
1965 if (
fabs(theta - 90) < 1.0) {
1967 }
else if (
fabs(theta - 180) < 1.0) {
1970 }
else if (
fabs(theta - 270) < 1.0) {
1972 }
else if (
fabs(theta) > 1.0) {
1973 char rotate_buf[64];
1974 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
1982 is->in_video_filter = filt_src;
1983 is->out_video_filter = filt_out;
1995 char aresample_swr_opts[512] =
"";
1998 char asrc_args[256];
2010 if (strlen(aresample_swr_opts))
2011 aresample_swr_opts[strlen(aresample_swr_opts)-1] =
'\0';
2012 av_opt_set(
is->agraph,
"aresample_swr_opts", aresample_swr_opts, 0);
2017 "sample_rate=%d:sample_fmt=%s:time_base=%d/%d:channel_layout=%s",
2019 1,
is->audio_filter_src.freq, bp.str);
2023 asrc_args,
NULL,
is->agraph);
2039 if (force_output_format) {
2055 is->in_audio_filter = filt_asrc;
2056 is->out_audio_filter = filt_asink;
2071 int last_serial = -1;
2089 frame->format,
frame->ch_layout.nb_channels) ||
2091 is->audio_filter_src.freq !=
frame->sample_rate ||
2092 is->auddec.pkt_serial != last_serial;
2095 char buf1[1024], buf2[1024];
2099 "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",
2100 is->audio_filter_src.freq,
is->audio_filter_src.ch_layout.nb_channels,
av_get_sample_fmt_name(
is->audio_filter_src.fmt), buf1, last_serial,
2103 is->audio_filter_src.fmt =
frame->format;
2107 is->audio_filter_src.freq =
frame->sample_rate;
2108 last_serial =
is->auddec.pkt_serial;
2125 af->
serial =
is->auddec.pkt_serial;
2131 if (
is->audioq.serial !=
is->auddec.pkt_serial)
2135 is->auddec.finished =
is->auddec.pkt_serial;
2147 d->decoder_tid = SDL_CreateThread(
fn, thread_name,
arg);
2148 if (!
d->decoder_tid) {
2170 int last_serial = -1;
2171 int last_vfilter_idx = 0;
2183 if ( last_w !=
frame->width
2184 || last_h !=
frame->height
2185 || last_format !=
frame->format
2186 || last_serial !=
is->viddec.pkt_serial
2187 || last_vfilter_idx !=
is->vfilter_idx) {
2189 "Video frame changed from size:%dx%d format:%s serial:%d to size:%dx%d format:%s serial:%d\n",
2204 event.user.data1 =
is;
2205 SDL_PushEvent(&event);
2208 filt_in =
is->in_video_filter;
2209 filt_out =
is->out_video_filter;
2210 last_w =
frame->width;
2211 last_h =
frame->height;
2212 last_format =
frame->format;
2213 last_serial =
is->viddec.pkt_serial;
2214 last_vfilter_idx =
is->vfilter_idx;
2230 is->viddec.finished =
is->viddec.pkt_serial;
2239 is->frame_last_filter_delay = 0;
2245 if (
is->videoq.serial !=
is->viddec.pkt_serial)
2274 if (got_subtitle &&
sp->sub.format == 0) {
2278 sp->serial =
is->subdec.pkt_serial;
2279 sp->width =
is->subdec.avctx->width;
2280 sp->height =
is->subdec.avctx->height;
2285 }
else if (got_subtitle) {
2302 memcpy(
is->sample_array +
is->sample_array_index,
samples,
len *
sizeof(
short));
2304 is->sample_array_index +=
len;
2306 is->sample_array_index = 0;
2315 int wanted_nb_samples = nb_samples;
2319 double diff, avg_diff;
2320 int min_nb_samples, max_nb_samples;
2325 is->audio_diff_cum =
diff +
is->audio_diff_avg_coef *
is->audio_diff_cum;
2328 is->audio_diff_avg_count++;
2331 avg_diff =
is->audio_diff_cum * (1.0 -
is->audio_diff_avg_coef);
2333 if (
fabs(avg_diff) >=
is->audio_diff_threshold) {
2334 wanted_nb_samples = nb_samples + (
int)(
diff *
is->audio_src.freq);
2337 wanted_nb_samples =
av_clip(wanted_nb_samples, min_nb_samples, max_nb_samples);
2340 diff, avg_diff, wanted_nb_samples - nb_samples,
2341 is->audio_clock,
is->audio_diff_threshold);
2346 is->audio_diff_avg_count = 0;
2347 is->audio_diff_cum = 0;
2351 return wanted_nb_samples;
2363 int data_size, resampled_data_size;
2365 int wanted_nb_samples;
2382 }
while (af->
serial !=
is->audioq.serial);
2396 &
is->audio_tgt.ch_layout,
is->audio_tgt.fmt,
is->audio_tgt.freq,
2401 "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n",
2415 uint8_t **
out = &
is->audio_buf1;
2416 int out_count = (int64_t)wanted_nb_samples *
is->audio_tgt.freq / af->
frame->
sample_rate + 256;
2431 if (!
is->audio_buf1)
2438 if (len2 == out_count) {
2443 is->audio_buf =
is->audio_buf1;
2447 resampled_data_size = data_size;
2450 audio_clock0 =
is->audio_clock;
2455 is->audio_clock =
NAN;
2456 is->audio_clock_serial = af->
serial;
2459 static double last_clock;
2460 printf(
"audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n",
2461 is->audio_clock - last_clock,
2462 is->audio_clock, audio_clock0);
2463 last_clock =
is->audio_clock;
2466 return resampled_data_size;
2473 int audio_size, len1;
2478 if (
is->audio_buf_index >=
is->audio_buf_size) {
2480 if (audio_size < 0) {
2485 if (
is->show_mode != SHOW_MODE_VIDEO)
2487 is->audio_buf_size = audio_size;
2489 is->audio_buf_index = 0;
2491 len1 =
is->audio_buf_size -
is->audio_buf_index;
2494 if (!
is->muted &&
is->audio_buf &&
is->audio_volume == SDL_MIX_MAXVOLUME)
2495 memcpy(stream, (uint8_t *)
is->audio_buf +
is->audio_buf_index, len1);
2497 memset(stream, 0, len1);
2498 if (!
is->muted &&
is->audio_buf)
2499 SDL_MixAudioFormat(stream, (uint8_t *)
is->audio_buf +
is->audio_buf_index, AUDIO_S16SYS, len1,
is->audio_volume);
2503 is->audio_buf_index += len1;
2505 is->audio_write_buf_size =
is->audio_buf_size -
is->audio_buf_index;
2507 if (!
isnan(
is->audio_clock)) {
2515 SDL_AudioSpec wanted_spec, spec;
2517 static const int next_nb_channels[] = {0, 0, 1, 6, 2, 6, 4, 6};
2518 static const int next_sample_rates[] = {0, 44100, 48000, 96000, 192000};
2519 int next_sample_rate_idx =
FF_ARRAY_ELEMS(next_sample_rates) - 1;
2520 int wanted_nb_channels = wanted_channel_layout->
nb_channels;
2522 env = SDL_getenv(
"SDL_AUDIO_CHANNELS");
2524 wanted_nb_channels = atoi(env);
2532 wanted_nb_channels = wanted_channel_layout->
nb_channels;
2533 wanted_spec.channels = wanted_nb_channels;
2534 wanted_spec.freq = wanted_sample_rate;
2535 if (wanted_spec.freq <= 0 || wanted_spec.channels <= 0) {
2539 while (next_sample_rate_idx && next_sample_rates[next_sample_rate_idx] >= wanted_spec.freq)
2540 next_sample_rate_idx--;
2541 wanted_spec.format = AUDIO_S16SYS;
2542 wanted_spec.silence = 0;
2545 wanted_spec.userdata = opaque;
2546 while (!(
audio_dev = SDL_OpenAudioDevice(
NULL, 0, &wanted_spec, &spec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE))) {
2548 wanted_spec.channels, wanted_spec.freq, SDL_GetError());
2549 wanted_spec.channels = next_nb_channels[
FFMIN(7, wanted_spec.channels)];
2550 if (!wanted_spec.channels) {
2551 wanted_spec.freq = next_sample_rates[next_sample_rate_idx--];
2552 wanted_spec.channels = wanted_nb_channels;
2553 if (!wanted_spec.freq) {
2555 "No more combinations to try, audio open failed\n");
2561 if (spec.format != AUDIO_S16SYS) {
2563 "SDL advised audio format %d is not supported!\n", spec.format);
2566 if (spec.channels != wanted_spec.channels) {
2571 "SDL advised channel count %d is not supported!\n", spec.channels);
2577 audio_hw_params->
freq = spec.freq;
2626 const char *forced_codec_name =
NULL;
2632 int stream_lowres =
lowres;
2634 if (stream_index < 0 || stream_index >= ic->
nb_streams)
2653 if (forced_codec_name)
2657 "No codec could be found with name '%s'\n", forced_codec_name);
2670 avctx->
lowres = stream_lowres;
2716 sink =
is->out_audio_filter;
2726 is->audio_hw_buf_size =
ret;
2727 is->audio_src =
is->audio_tgt;
2728 is->audio_buf_size = 0;
2729 is->audio_buf_index = 0;
2733 is->audio_diff_avg_count = 0;
2736 is->audio_diff_threshold = (
double)(
is->audio_hw_buf_size) /
is->audio_tgt.bytes_per_sec;
2738 is->audio_stream = stream_index;
2739 is->audio_st = ic->
streams[stream_index];
2744 is->auddec.start_pts =
is->audio_st->start_time;
2745 is->auddec.start_pts_tb =
is->audio_st->time_base;
2752 is->video_stream = stream_index;
2753 is->video_st = ic->
streams[stream_index];
2759 is->queue_attachments_req = 1;
2762 is->subtitle_stream = stream_index;
2763 is->subtitle_st = ic->
streams[stream_index];
2787 return is->abort_request;
2791 return stream_id < 0 ||
2799 if( !strcmp(
s->iformat->name,
"rtp")
2800 || !strcmp(
s->iformat->name,
"rtsp")
2801 || !strcmp(
s->iformat->name,
"sdp")
2805 if(
s->pb && ( !strncmp(
s->url,
"rtp:", 4)
2806 || !strncmp(
s->url,
"udp:", 4)
2821 int64_t stream_start_time;
2822 int pkt_in_play_range = 0;
2824 SDL_mutex *wait_mutex = SDL_CreateMutex();
2825 int scan_all_pmts_set = 0;
2834 memset(st_index, -1,
sizeof(st_index));
2853 scan_all_pmts_set = 1;
2861 if (scan_all_pmts_set)
2881 "Error setting up avformat_find_stream_info() options\n");
2888 for (
i = 0;
i < orig_nb_streams;
i++)
2894 "%s: could not find codec parameters\n",
is->filename);
2944 st_index[
i] = INT_MAX;
2972 if (codecpar->
width)
2985 if (
is->show_mode == SHOW_MODE_NONE)
2986 is->show_mode =
ret >= 0 ? SHOW_MODE_VIDEO : SHOW_MODE_RDFT;
2992 if (
is->video_stream < 0 &&
is->audio_stream < 0) {
2999 if (infinite_buffer < 0 && is->realtime)
3003 if (
is->abort_request)
3005 if (
is->paused !=
is->last_paused) {
3006 is->last_paused =
is->paused;
3012 #if CONFIG_RTSP_DEMUXER || CONFIG_MMSH_PROTOCOL
3023 int64_t seek_target =
is->seek_pos;
3024 int64_t seek_min =
is->seek_rel > 0 ? seek_target -
is->seek_rel + 2: INT64_MIN;
3025 int64_t seek_max =
is->seek_rel < 0 ? seek_target -
is->seek_rel - 2: INT64_MAX;
3032 "%s: error while seeking\n",
is->ic->url);
3034 if (
is->audio_stream >= 0)
3036 if (
is->subtitle_stream >= 0)
3038 if (
is->video_stream >= 0)
3047 is->queue_attachments_req = 1;
3052 if (
is->queue_attachments_req) {
3059 is->queue_attachments_req = 0;
3069 SDL_LockMutex(wait_mutex);
3070 SDL_CondWaitTimeout(
is->continue_read_thread, wait_mutex, 10);
3071 SDL_UnlockMutex(wait_mutex);
3087 if (
is->video_stream >= 0)
3089 if (
is->audio_stream >= 0)
3091 if (
is->subtitle_stream >= 0)
3101 SDL_LockMutex(wait_mutex);
3102 SDL_CondWaitTimeout(
is->continue_read_thread, wait_mutex, 10);
3103 SDL_UnlockMutex(wait_mutex);
3112 (pkt_ts - (stream_start_time !=
AV_NOPTS_VALUE ? stream_start_time : 0)) *
3138 event.user.data1 =
is;
3139 SDL_PushEvent(&event);
3141 SDL_DestroyMutex(wait_mutex);
3153 is->last_video_stream =
is->video_stream = -1;
3154 is->last_audio_stream =
is->audio_stream = -1;
3155 is->last_subtitle_stream =
is->subtitle_stream = -1;
3176 if (!(
is->continue_read_thread = SDL_CreateCond())) {
3184 is->audio_clock_serial = -1;
3195 if (!
is->read_tid) {
3207 int start_index, stream_index;
3214 start_index =
is->last_video_stream;
3215 old_index =
is->video_stream;
3217 start_index =
is->last_audio_stream;
3218 old_index =
is->audio_stream;
3220 start_index =
is->last_subtitle_stream;
3221 old_index =
is->subtitle_stream;
3223 stream_index = start_index;
3229 for (start_index = 0; start_index <
nb_streams; start_index++)
3234 stream_index = start_index;
3244 is->last_subtitle_stream = -1;
3247 if (start_index == -1)
3251 if (stream_index == start_index)
3253 st =
is->ic->streams[p ? p->
stream_index[stream_index] : stream_index];
3271 if (p && stream_index != -1)
3291 int next =
is->show_mode;
3293 next = (next + 1) % SHOW_MODE_NB;
3294 }
while (next !=
is->show_mode && (next == SHOW_MODE_VIDEO && !
is->video_st || next != SHOW_MODE_VIDEO && !
is->audio_st));
3295 if (
is->show_mode != next) {
3296 is->force_refresh = 1;
3297 is->show_mode = next;
3302 double remaining_time = 0.0;
3304 while (!SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
3309 if (remaining_time > 0.0)
3310 av_usleep((int64_t)(remaining_time * 1000000.0));
3312 if (
is->show_mode != SHOW_MODE_NONE && (!
is->paused ||
is->force_refresh))
3323 if (!
is->ic->nb_chapters)
3327 for (
i = 0;
i <
is->ic->nb_chapters;
i++) {
3337 if (
i >=
is->ic->nb_chapters)
3349 double incr,
pos, frac;
3354 switch (event.type) {
3356 if (
exit_on_keydown || event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_q) {
3361 if (!cur_stream->
width)
3363 switch (event.key.keysym.sym) {
3375 case SDLK_KP_MULTIPLY:
3379 case SDLK_KP_DIVIDE:
3463 case SDL_MOUSEBUTTONDOWN:
3468 if (event.button.button == SDL_BUTTON_LEFT) {
3469 static int64_t last_mouse_left_click = 0;
3473 last_mouse_left_click = 0;
3478 case SDL_MOUSEMOTION:
3484 if (event.type == SDL_MOUSEBUTTONDOWN) {
3485 if (event.button.button != SDL_BUTTON_RIGHT)
3489 if (!(event.motion.state & SDL_BUTTON_RMASK))
3499 int tns, thh, tmm, tss;
3502 tmm = (tns % 3600) / 60;
3504 frac = x / cur_stream->
width;
3507 mm = (
ns % 3600) / 60;
3510 "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d) \n", frac*100,
3511 hh, mm,
ss, thh, tmm, tss);
3518 case SDL_WINDOWEVENT:
3519 switch (event.window.event) {
3520 case SDL_WINDOWEVENT_SIZE_CHANGED:
3529 case SDL_WINDOWEVENT_EXPOSED:
3577 if (!strcmp(
arg,
"audio"))
3579 else if (!strcmp(
arg,
"video"))
3581 else if (!strcmp(
arg,
"ext"))
3593 !strcmp(
arg,
"waves") ? SHOW_MODE_WAVES :
3594 !strcmp(
arg,
"rdft" ) ? SHOW_MODE_RDFT : SHOW_MODE_NONE;
3610 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3614 if (!strcmp(filename,
"-"))
3625 const char *spec = strchr(opt,
':');
3629 "No media specifier was specified in '%s' in option '%s'\n",
3641 "Invalid media specifier '%s' in option '%s'\n", spec, opt);
3698 "read and decode the streams to fill missing information with heuristics" },
3723 printf(
"\nWhile playing:\n"
3725 "f toggle full screen\n"
3728 "9, 0 decrease and increase volume respectively\n"
3729 "/, * decrease and increase volume respectively\n"
3730 "a cycle audio channel in the current program\n"
3731 "v cycle video channel\n"
3732 "t cycle subtitle channel in the current program\n"
3734 "w cycle video filters or show modes\n"
3735 "s activate frame-step mode\n"
3736 "left/right seek backward/forward 10 seconds or to custom interval if -seek_interval is set\n"
3737 "down/up seek backward/forward 1 minute\n"
3738 "page down/page up seek backward/forward 10 minutes\n"
3739 "right mouse click seek to percentage in file corresponding to fraction of width\n"
3740 "left double-click toggle full screen\n"
3774 "Use -h to get full help or, even better, run 'man %s'\n",
program_name);
3781 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
3783 flags &= ~SDL_INIT_AUDIO;
3787 if (!SDL_getenv(
"SDL_AUDIO_ALSA_SET_BUFFER_SIZE"))
3788 SDL_setenv(
"SDL_AUDIO_ALSA_SET_BUFFER_SIZE",
"1", 1);
3791 flags &= ~SDL_INIT_VIDEO;
3792 if (SDL_Init (
flags)) {
3798 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
3799 SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
3802 int flags = SDL_WINDOW_HIDDEN;
3804 #if SDL_VERSION_ATLEAST(2,0,5)
3805 flags |= SDL_WINDOW_ALWAYS_ON_TOP;
3807 av_log(
NULL,
AV_LOG_WARNING,
"Your SDL version doesn't support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n");
3810 flags |= SDL_WINDOW_BORDERLESS;
3812 flags |= SDL_WINDOW_RESIZABLE;
3814 #ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
3815 SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR,
"0");
3824 #if SDL_VERSION_ATLEAST(2, 0, 6)
3825 flags |= SDL_WINDOW_VULKAN;
3833 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,
"linear");
3851 renderer = SDL_CreateRenderer(
window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
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 do_exit(VideoState *is)
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags)
Print help for all options matching specified flags.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
#define AV_LOG_WARNING
Something somehow does not look correct.
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
AVPixelFormat
Pixel format.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static SDL_RendererInfo renderer_info
double get_rotation(const int32_t *displaymatrix)
static int frame_queue_nb_remaining(FrameQueue *f)
static int configure_audio_filters(VideoState *is, const char *afilters, int force_output_format)
static int opt_add_vfilter(void *optctx, const char *opt, const char *arg)
static void frame_queue_next(FrameQueue *f)
enum AVMediaType codec_type
General type of the encoded data.
int nb_threads
Maximum number of threads used by filters in this graph.
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.
unsigned int nb_stream_indexes
static int64_t frame_queue_last_pos(FrameQueue *f)
int sample_rate
samples per second
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
static int video_thread(void *arg)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
The official guide to swscale for confused that is
static void set_default_window_size(int width, int height, AVRational sar)
#define AV_NOSYNC_THRESHOLD
unsigned int nb_chapters
Number of chapters in AVChapter array.
This struct describes the properties of an encoded stream.
#define AV_LOG_QUIET
Print no output.
static enum AVSampleFormat sample_fmts[]
static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub)
#define AVERROR_EOF
End of file.
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.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
static int display_disable
int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance)
Activate resampling compensation ("soft" compensation).
#define SAMPLE_ARRAY_SIZE
static void update_volume(VideoState *is, int sign, double step)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define av_opt_set_int_list(obj, name, val, term, flags)
Set a binary option to an integer list.
char * av_asprintf(const char *fmt,...)
static int decoder_start(Decoder *d, int(*fn)(void *), const char *thread_name, void *arg)
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
SDL_Texture * vis_texture
static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, double duration, int64_t pos, int serial)
This structure describes decoded (raw) audio or video data.
struct AudioParams audio_filter_src
AVStream ** streams
A list of all streams in the file.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
double frame_last_filter_delay
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
@ AVCOL_RANGE_JPEG
Full range content.
static int frame_queue_init(FrameQueue *f, PacketQueue *pktq, int max_size, int keep_last)
static const char * subtitle_codec_name
int parse_number(const char *context, const char *numstr, enum OptionType type, double min, double max, double *dst)
Parse a string and return its corresponding value as a double.
#define EXTERNAL_CLOCK_MIN_FRAMES
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
int vk_renderer_create(VkRenderer *renderer, SDL_Window *window, AVDictionary *opt)
#define SAMPLE_QUEUE_SIZE
const char program_name[]
program name, defined by the program for show_version().
AVDictionary * format_opts
int error
contains the error code or 0 if no error happened
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define AV_PIX_FMT_RGB32_1
double audio_diff_avg_coef
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
#define AV_LOG_VERBOSE
Detailed information.
#define CURSOR_HIDE_DELAY
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
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.
enum AVChannelOrder order
Channel order used in this layout.
static double compute_target_delay(double delay, VideoState *is)
static int opt_input_file(void *optctx, const char *filename)
static void stream_close(VideoState *is)
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
#define SDL_AUDIO_MAX_CALLBACKS_PER_SEC
void vk_renderer_destroy(VkRenderer *renderer)
int nb_channels
Number of channels in this layout.
static void init_clock(Clock *c, int *queue_serial)
enum AVMediaType codec_type
int64_t avio_size(AVIOContext *s)
Get the filesize.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static double get_master_clock(VideoState *is)
static const AVInputFormat * file_iformat
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
static int subtitle_thread(void *arg)
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
static int audio_decode_frame(VideoState *is)
Decode one audio frame and return its uncompressed size.
static int subtitle_disable
struct SwrContext * swr_ctx
static int opt_sync(void *optctx, const char *opt, const char *arg)
static void step_to_next_frame(VideoState *is)
static int upload_texture(SDL_Texture **tex, AVFrame *frame)
enum AVPixelFormat format
static void video_display(VideoState *is)
uint8_t max_lowres
maximum value for lowres supported by the decoder
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
#define SDL_AUDIO_MIN_BUFFER_SIZE
static int startup_volume
static SDL_Window * window
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.
static void toggle_full_screen(VideoState *is)
static int packet_queue_init(PacketQueue *q)
#define AUDIO_DIFF_AVG_NB
AVChannelLayout ch_layout
Audio channel layout.
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
int x
top left corner of pict, undefined when pict is not set
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define AV_BPRINT_SIZE_AUTOMATIC
static void video_image_display(VideoState *is)
static double val(void *priv, double ch)
AVChannelLayout ch_layout
Channel layout of the audio data.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static int opt_show_mode(void *optctx, const char *opt, const char *arg)
SDL_cond * empty_queue_cond
static void set_clock_speed(Clock *c, double speed)
double audio_diff_threshold
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
#define ss(width, name, subs,...)
int avformat_network_init(void)
Do global initialization of network libraries.
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *const *out_arg, int out_count, const uint8_t *const *in_arg, int in_count)
Convert audio.
static int opt_height(void *optctx, const char *opt, const char *arg)
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static const struct TextureFormatEntry sdl_texture_format_map[]
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
static int is_full_screen
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Decode a subtitle message.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
static void set_sdl_yuv_conversion_mode(AVFrame *frame)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
VkRenderer * vk_get_renderer(void)
#define FF_ARRAY_ELEMS(a)
static int audio_thread(void *arg)
static void set_clock(Clock *c, double pts, int serial)
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,...
static Frame * frame_queue_peek_next(FrameQueue *f)
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
static void sync_clock_to_slave(Clock *c, Clock *slave)
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static void frame_queue_signal(FrameQueue *f)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
#define AV_CEIL_RSHIFT(a, b)
static int default_height
int flags
Flags modifying the (de)muxer behaviour.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AVRational sample_aspect_ratio
Video only.
const struct AVInputFormat * iformat
The input container format.
#define AV_PIX_FMT_0BGR32
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
int y
top left corner of pict, undefined when pict is not set
static AVStream * video_stream
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)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define EXTERNAL_CLOCK_SPEED_STEP
static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters, AVFrame *frame)
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
static enum AVPixelFormat pix_fmts[]
int setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts, AVDictionary ***dst)
Setup AVCodecContext options for avformat_find_stream_info().
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int opt_codec(void *optctx, const char *opt, const char *arg)
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.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int vk_renderer_get_hw_dev(VkRenderer *renderer, AVBufferRef **dev)
static double get_clock(Clock *c)
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame)
#define EXTERNAL_CLOCK_SPEED_MIN
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
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 SDL_Renderer * renderer
int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec, AVDictionary **dst)
Filter out options for given codec.
int av_usleep(unsigned usec)
Sleep for a period of time.
The libswresample context.
static double vp_duration(VideoState *is, Frame *vp, Frame *nextvp)
#define AV_PIX_FMT_BGR32_1
static int synchronize_audio(VideoState *is, int nb_samples)
static const char * window_title
@ AVDISCARD_ALL
discard all
int av_log_get_level(void)
Get the current log level.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
void init_dynload(void)
Initialize dynamic library loading.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avcodec_parameters_to_context(AVCodecContext *codec, const struct AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
int w
width of pict, undefined when pict is not set
static void seek_chapter(VideoState *is, int incr)
static int get_master_sync_type(VideoState *is)
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
static __device__ float fabs(float a)
static void frame_queue_destroy(FrameQueue *f)
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
const AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
#define AV_DICT_MULTIKEY
Allow to store several equal keys in the dictionary.
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Rational number (pair of numerator and denominator).
AVChannelLayout ch_layout
static int audio_open(void *opaque, AVChannelLayout *wanted_channel_layout, int wanted_sample_rate, struct AudioParams *audio_hw_params)
AVFilterContext ** filters
static void stream_cycle_channel(VideoState *is, int codec_type)
#define AV_CODEC_FLAG2_FAST
Allow non spec compliant speedup tricks.
AVIOContext * pb
I/O context.
void av_log_set_flags(int arg)
static void frame_queue_unref_item(Frame *vp)
Frame queue[FRAME_QUEUE_SIZE]
static int64_t cursor_last_shown
unsigned int * stream_index
static Frame * frame_queue_peek(FrameQueue *f)
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
double frame_last_returned_time
static void set_clock_at(Clock *c, double pts, int serial, double time)
static void toggle_pause(VideoState *is)
static int stream_component_open(VideoState *is, int stream_index)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
AVChannelLayout ch_layout
Audio only.
AVComplexFloat * rdft_data
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
#define AV_PIX_FMT_NE(be, le)
static void event_loop(VideoState *cur_stream)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int sample_rate
Audio only.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int16_t sample_array[SAMPLE_ARRAY_SIZE]
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static int exit_on_mousedown
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
const AVInputFormat * iformat
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
AVDictionary * codec_opts
static int64_t audio_callback_time
#define AV_OPT_FLAG_FILTERING_PARAM
A generic parameter which can be set by the user for filtering.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
#define INSERT_FILT(name, arg)
int swr_alloc_set_opts2(struct SwrContext **ps, const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, const AVChannelLayout *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.
int flags2
AV_CODEC_FLAG2_*.
enum AVPictureType pict_type
Picture type of the frame.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
AVFilterContext * in_audio_filter
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.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
@ AVDISCARD_DEFAULT
discard useless packets like 0 size packets in avi
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
An AVChannelLayout holds information about the channel layout of audio data.
static Frame * frame_queue_peek_writable(FrameQueue *f)
AVBufferSrcParameters * av_buffersrc_parameters_alloc(void)
Allocate a new AVBufferSrcParameters instance.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static const char ** vfilters_list
int sample_rate
Sample rate of the audio data.
static int create_hwaccel(AVBufferRef **device_ctx)
static int decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue, SDL_cond *empty_queue_cond)
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
AVBufferRef * hw_frames_ctx
Video with a hwaccel pixel format only.
static enum AVColorSpace sdl_supported_color_spaces[]
static int64_t start_time
static AVStream * audio_stream
enum AVSampleFormat sample_fmt
audio sample format
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
static av_const double hypot(double x, double y)
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static int read_thread(void *arg)
#define AV_PIX_FMT_BGR555
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
SDL_Texture * sub_texture
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
SDL_Texture * vid_texture
printf("static const uint8_t my_array[100] = {\n")
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static const char * wanted_stream_spec[AVMEDIA_TYPE_NB]
static int infinite_buffer
double max_frame_duration
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
static void packet_queue_destroy(PacketQueue *q)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
static void update_video_pts(VideoState *is, double pts, int serial)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static void toggle_mute(VideoState *is)
static void decoder_abort(Decoder *d, FrameQueue *fq)
static void video_refresh(void *opaque, double *remaining_time)
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
#define ns(max_value, name, subs,...)
static float seek_interval
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static void frame_queue_push(FrameQueue *f)
static SDL_AudioDeviceID audio_dev
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
static void sigterm_handler(int sig)
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define AV_LOG_INFO
Standard information.
static void packet_queue_abort(PacketQueue *q)
static const char * video_codec_name
static const AVInputFormat * iformat
static void packet_queue_flush(PacketQueue *q)
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *serial)
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int queue_attachments_req
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
int nb_samples
number of audio samples (per channel) described by this frame
int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
Initialize the buffersrc or abuffersrc filter with the provided parameters.
int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr, enum AVHWDeviceType type, AVBufferRef *src_ref, int flags)
Create a new device of the specified type from an existing device.
#define VIDEO_PICTURE_QUEUE_SIZE
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
enum VideoState::ShowMode show_mode
struct AudioParams audio_src
const int program_birth_year
program birth year, defined by the program for show_banner()
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
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.
static int compute_mod(int a, int b)
#define AV_TIME_BASE
Internal time base represented as integer.
uint8_t ** extended_data
pointers to the data planes/channels.
#define av_malloc_array(a, b)
static int video_open(VideoState *is)
AVColorSpace
YUV colorspace type.
static void get_sdl_pix_fmt_and_blendmode(int format, Uint32 *sdl_pix_fmt, SDL_BlendMode *sdl_blendmode)
static int opt_format(void *optctx, const char *opt, const char *arg)
AVSampleFormat
Audio sample formats.
int parse_options(void *optctx, int argc, char **argv, const OptionDef *options, int(*parse_arg_function)(void *, const char *))
#define AV_PIX_FMT_RGB555
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
int vk_renderer_resize(VkRenderer *renderer, int width, int height)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static void update_sample_display(VideoState *is, short *samples, int samples_size)
@ AV_SAMPLE_FMT_S16
signed 16 bits
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
New fields can be added to the end with minor version bumps.
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
#define AV_PIX_FMT_BGR565
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.
const char * name
Pad name.
static VkRenderer * vk_renderer
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static Frame * frame_queue_peek_readable(FrameQueue *f)
static const AVFilterPad outputs[]
#define AV_PIX_FMT_RGB565
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define EXTERNAL_CLOCK_MAX_FRAMES
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
int h
height of pict, undefined when pict is not set
static VideoState * stream_open(const char *filename, const AVInputFormat *iformat)
#define FFSWAP(type, a, b)
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_PIX_FMT_0RGB32
static int filter_nbthreads
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
static int find_stream_info
static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
static const char * hwaccel
void av_bprintf(AVBPrint *buf, const char *fmt,...)
AVFilterContext * out_video_filter
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
#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...
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define CMDUTILS_COMMON_OPTIONS
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
static int opt_width(void *optctx, const char *opt, const char *arg)
int main(int argc, char **argv)
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
static void show_usage(void)
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.
main external API structure.
static void packet_queue_start(PacketQueue *q)
static const char * audio_codec_name
This structure contains the parameters describing the frames that will be passed to this filter.
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
#define AV_SYNC_FRAMEDUP_THRESHOLD
static enum ShowMode show_mode
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
static const OptionDef options[]
AVFilterContext * in_video_filter
static void fill_rectangle(int x, int y, int w, int h)
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
unsigned int audio_buf1_size
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
#define AV_SYNC_THRESHOLD_MAX
static void decoder_destroy(Decoder *d)
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
int eof_reached
true if was unable to read due to error or eof
static int stream_has_enough_packets(AVStream *st, int stream_id, PacketQueue *queue)
Filter the word “frame” indicates either a video frame or a group of audio samples
AVFilterContext * out_audio_filter
const AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define GROW_ARRAY(array, nb_elems)
#define SUBPICTURE_QUEUE_SIZE
static const char * input_filename
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
static void stream_toggle_pause(VideoState *is)
SDL_cond * continue_read_thread
static char * vulkan_params
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.
static void toggle_audio_display(VideoState *is)
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate a string.
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
A reference to a data buffer.
static int get_video_frame(VideoState *is, AVFrame *frame)
Structure to hold side data for an AVFrame.
static int configure_filtergraph(AVFilterGraph *graph, const char *filtergraph, AVFilterContext *source_ctx, AVFilterContext *sink_ctx)
struct SwsContext * sub_convert_ctx
This structure stores compressed data.
static void refresh_loop_wait_event(VideoState *is, SDL_Event *event)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static void stream_component_close(VideoState *is, int stream_index)
static int cmp_audio_fmts(enum AVSampleFormat fmt1, int64_t channel_count1, enum AVSampleFormat fmt2, int64_t channel_count2)
unsigned int audio_buf_size
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
The exact code depends on how similar the blocks are and how related they are to the block
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
static Frame * frame_queue_peek_last(FrameQueue *f)
static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int by_bytes)
static int decoder_reorder_pts
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
struct AudioParams audio_tgt
AVRational time_base
time base in which the start/end timestamps are specified
const AVClass * avfilter_get_class(void)
A linked-list of the inputs/outputs of the filter chain.
static 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...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are short
static void video_audio_display(VideoState *s)
#define AV_SYNC_THRESHOLD_MIN
static void check_external_clock_speed(VideoState *is)
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
uint32_t start_display_time
#define SAMPLE_CORRECTION_PERCENT_MAX
#define EXTERNAL_CLOCK_SPEED_MAX
static int packet_queue_put_nullpacket(PacketQueue *q, AVPacket *pkt, int stream_index)
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
static int is_realtime(AVFormatContext *s)
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
static int decode_interrupt_cb(void *ctx)
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.
FF_VISIBILITY_POP_HIDDEN av_cold void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static int realloc_texture(SDL_Texture **texture, Uint32 new_format, int new_width, int new_height, SDL_BlendMode blendmode, int init_texture)
#define AV_PIX_FMT_RGB444
static int exit_on_keydown