• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/libav-0.8.8/

Lines Matching refs:is

5  * This file is part of Libav.
7 * Libav is free software; you can redistribute it and/or
12 * Libav is distributed in the hope that it will be useful,
69 /* no AV sync correction is done if below the AV sync threshold */
71 /* no AV correction is done if too big error */
644 static void video_image_display(VideoState *is)
654 vp = &is->pictq[is->pictq_rindex];
664 if (is->video_st->sample_aspect_ratio.num)
665 aspect_ratio = av_q2d(is->video_st->sample_aspect_ratio);
666 else if (is->video_st->codec->sample_aspect_ratio.num)
667 aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio);
675 if (is->subtitle_st)
677 if (is->subpq_size > 0)
679 sp = &is->subpq[is->subpq_rindex];
704 height = is->height;
706 if (width > is->width) {
707 width = is->width;
710 x = (is->width - width) / 2;
711 y = (is->height - height) / 2;
712 is->no_background = 0;
713 rect.x = is->xleft + x;
714 rect.y = is->ytop + y;
723 static int audio_write_get_buf_size(VideoState *is)
725 return is->audio_buf_size - is->audio_buf_index;
876 static int video_open(VideoState *is)
891 } else if (is->out_video_filter && is->out_video_filter->inputs[0]) {
892 w = is->out_video_filter->inputs[0]->w;
893 h = is->out_video_filter->inputs[0]->h;
895 } else if (is->video_st && is->video_st->codec->width) {
896 w = is->video_st->codec->width;
897 h = is->video_st->codec->height;
903 if (screen && is->width == screen->w && screen->w == w
904 && is->height== screen->h && screen->h == h)
921 is->width = screen->w;
922 is->height = screen->h;
928 static void video_display(VideoState *is)
932 if (is->audio_st && is->show_audio)
933 video_audio_display(is);
934 else if (is->video_st)
935 video_image_display(is);
940 VideoState *is= opaque;
941 while (!is->abort_request) {
945 if (!is->refresh) {
946 is->refresh = 1;
949 usleep(is->audio_st && is->show_audio ? rdftspeed * 1000 : 5000); // FIXME ideally we should wait the correct time but SDLs event passing is so slow it would be silly
955 static double get_audio_clock(VideoState *is)
959 pts = is->audio_clock;
960 hw_buf_size = audio_write_get_buf_size(is);
962 if (is->audio_st) {
963 bytes_per_sec = is->audio_st->codec->sample_rate *
964 2 * is->audio_st->codec->channels;
972 static double get_video_clock(VideoState *is)
974 if (is->paused) {
975 return is->video_current_pts;
977 return is->video_current_pts_drift + av_gettime() / 1000000.0;
982 static double get_external_clock(VideoState *is)
986 return is->external_clock + ((ti - is->external_clock_time) * 1e-6);
990 static double get_master_clock(VideoState *is)
994 if (is->av_sync_type == AV_SYNC_VIDEO_MASTER) {
995 if (is->video_st)
996 val = get_video_clock(is);
998 val = get_audio_clock(is);
999 } else if (is->av_sync_type == AV_SYNC_AUDIO_MASTER) {
1000 if (is->audio_st)
1001 val = get_audio_clock(is);
1003 val = get_video_clock(is);
1005 val = get_external_clock(is);
1011 static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_bytes)
1013 if (!is->seek_req) {
1014 is->seek_pos = pos;
1015 is->seek_rel = rel;
1016 is->seek_flags &= ~AVSEEK_FLAG_BYTE;
1018 is->seek_flags |= AVSEEK_FLAG_BYTE;
1019 is->seek_req = 1;
1024 static void stream_pause(VideoState *is)
1026 if (is->paused) {
1027 is->frame_timer += av_gettime() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts;
1028 if (is->read_pause_return != AVERROR(ENOSYS)) {
1029 is->video_current_pts = is->video_current_pts_drift + av_gettime() / 1000000.0;
1031 is->video_current_pts_drift = is->video_current_pts - av_gettime() / 1000000.0;
1033 is->paused = !is->paused;
1036 static double compute_target_time(double frame_current_pts, VideoState *is)
1041 delay = frame_current_pts - is->frame_last_pts;
1044 delay = is->frame_last_delay;
1046 is->frame_last_delay = delay;
1048 is->frame_last_pts = frame_current_pts;
1051 if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) ||
1052 is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) {
1053 /* if video is slave, we try to correct big delays by
1055 diff = get_video_clock(is) - get_master_clock(is);
1059 if it is the best guess */
1068 is->frame_timer += delay;
1073 return is->frame_timer;
1079 VideoState *is = opaque;
1084 if (is->video_st) {
1086 if (is->pictq_size == 0) {
1092 vp = &is->pictq[is->pictq_rindex];
1097 is->video_current_pts = vp->pts;
1098 is->video_current_pts_drift = is->video_current_pts - time;
1099 is->video_current_pos = vp->pos;
1100 if (is->pictq_size > 1) {
1101 VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE];
1105 next_target = vp->target_clock + is->video_clock - vp->pts; // FIXME pass durations cleanly
1108 is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR;
1109 if (is->pictq_size > 1 || time > next_target + 0.5) {
1111 if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)
1112 is->pictq_rindex = 0;
1114 SDL_LockMutex(is->pictq_mutex);
1115 is->pictq_size--;
1116 SDL_CondSignal(is->pictq_cond);
1117 SDL_UnlockMutex(is->pictq_mutex);
1122 if (is->subtitle_st) {
1123 if (is->subtitle_stream_changed) {
1124 SDL_LockMutex(is->subpq_mutex);
1126 while (is->subpq_size) {
1127 free_subpicture(&is->subpq[is->subpq_rindex]);
1130 if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
1131 is->subpq_rindex = 0;
1133 is->subpq_size--;
1135 is->subtitle_stream_changed = 0;
1137 SDL_CondSignal(is->subpq_cond);
1138 SDL_UnlockMutex(is->subpq_mutex);
1140 if (is->subpq_size > 0) {
1141 sp = &is->subpq[is->subpq_rindex];
1143 if (is->subpq_size > 1)
1144 sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];
1148 if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
1149 || (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
1154 if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
1155 is->subpq_rindex = 0;
1157 SDL_LockMutex(is->subpq_mutex);
1158 is->subpq_size--;
1159 SDL_CondSignal(is->subpq_cond);
1160 SDL_UnlockMutex(is->subpq_mutex);
1168 video_display(is);
1171 if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)
1172 is->pictq_rindex = 0;
1174 SDL_LockMutex(is->pictq_mutex);
1175 is->pictq_size--;
1176 SDL_CondSignal(is->pictq_cond);
1177 SDL_UnlockMutex(is->pictq_mutex);
1179 } else if (is->audio_st) {
1187 video_display(is);
1200 if (is->audio_st)
1201 aqsize = is->audioq.size;
1202 if (is->video_st)
1203 vqsize = is->videoq.size;
1204 if (is->subtitle_st)
1205 sqsize = is->subtitleq.size;
1207 if (is->audio_st && is->video_st)
1208 av_diff = get_audio_clock(is) - get_video_clock(is);
1210 get_master_clock(is), av_diff, FFMAX(is->skip_frames - 1, 0), aqsize / 1024,
1211 vqsize / 1024, sqsize, is->pts_ctx.num_faulty_dts, is->pts_ctx.num_faulty_pts);
1218 static void stream_close(VideoState *is)
1223 is->abort_request = 1;
1224 SDL_WaitThread(is->parse_tid, NULL);
1225 SDL_WaitThread(is->refresh_tid, NULL);
1229 vp = &is->pictq[i];
1241 SDL_DestroyMutex(is->pictq_mutex);
1242 SDL_DestroyCond(is->pictq_cond);
1243 SDL_DestroyMutex(is->subpq_mutex);
1244 SDL_DestroyCond(is->subpq_cond);
1246 if (is->img_convert_ctx)
1247 sws_freeContext(is->img_convert_ctx);
1249 av_free(is);
1274 VideoState *is = opaque;
1277 vp = &is->pictq[is->pictq_windex];
1287 vp->width = is->out_video_filter->inputs[0]->w;
1288 vp->height = is->out_video_filter->inputs[0]->h;
1289 vp->pix_fmt = is->out_video_filter->inputs[0]->format;
1291 vp->width = is->video_st->codec->width;
1292 vp->height = is->video_st->codec->height;
1293 vp->pix_fmt = is->video_st->codec->pix_fmt;
1301 * overlay hardware is unable to support the requested size. */
1308 SDL_LockMutex(is->pictq_mutex);
1310 SDL_CondSignal(is->pictq_cond);
1311 SDL_UnlockMutex(is->pictq_mutex);
1318 static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos)
1327 SDL_LockMutex(is->pictq_mutex);
1329 if (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->refresh)
1330 is->skip_frames = FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0 - FRAME_SKIP_FACTOR));
1332 while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
1333 !is->videoq.abort_request) {
1334 SDL_CondWait(is->pictq_cond, is->pictq_mutex);
1336 SDL_UnlockMutex(is->pictq_mutex);
1338 if (is->videoq.abort_request)
1341 vp = &is->pictq[is->pictq_windex];
1346 vp->width != is->out_video_filter->inputs[0]->w ||
1347 vp->height != is->out_video_filter->inputs[0]->h) {
1349 vp->width != is->video_st->codec->width ||
1350 vp->height != is->video_st->codec->height) {
1360 event.user.data1 = is;
1363 /* wait until the picture is allocated */
1364 SDL_LockMutex(is->pictq_mutex);
1365 while (!vp->allocated && !is->videoq.abort_request) {
1366 SDL_CondWait(is->pictq_cond, is->pictq_mutex);
1368 SDL_UnlockMutex(is->pictq_mutex);
1370 if (is->videoq.abort_request)
1374 /* if the frame is not skipped, then display it */
1409 is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
1412 if (is->img_convert_ctx == NULL) {
1416 sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
1426 if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)
1427 is->pictq_windex = 0;
1428 SDL_LockMutex(is->pictq_mutex);
1429 vp->target_clock = compute_target_time(vp->pts, is);
1431 is->pictq_size++;
1432 SDL_UnlockMutex(is->pictq_mutex);
1438 * compute the exact PTS for the picture if it is omitted in the stream
1441 static int output_picture2(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
1449 is->video_clock = pts;
1451 pts = is->video_clock;
1454 frame_delay = av_q2d(is->video_st->codec->time_base);
1458 is->video_clock += frame_delay;
1460 return queue_picture(is, src_frame, pts, pos);
1463 static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt)
1467 if (packet_queue_get(&is->videoq, pkt, 1) < 0)
1471 avcodec_flush_buffers(is->video_st->codec);
1473 SDL_LockMutex(is->pictq_mutex);
1476 is->pictq[i].target_clock= 0;
1478 while (is->pictq_size && !is->videoq.abort_request) {
1479 SDL_CondWait(is->pictq_cond, is->pictq_mutex);
1481 is->video_current_pos = -1;
1482 SDL_UnlockMutex(is->pictq_mutex);
1484 init_pts_correction(&is->pts_ctx);
1485 is->frame_last_pts = AV_NOPTS_VALUE;
1486 is->frame_last_delay = 0;
1487 is->frame_timer = (double)av_gettime() / 1000000.0;
1488 is->skip_frames = 1;
1489 is->skip_frames_index = 0;
1493 avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt);
1497 *pts = guess_correct_pts(&is->pts_ctx, frame->pkt_pts, frame->pkt_dts);
1508 is->skip_frames_index += 1;
1509 if (is->skip_frames_index >= is->skip_frames) {
1510 is->skip_frames_index -= FFMAX(is->skip_frames, 1.0);
1520 VideoState *is;
1608 priv->is = opaque;
1609 codec = priv->is->video_st->codec;
1638 while (!(ret = get_video_frame(priv->is, priv->frame, &pts, &pkt)))
1667 priv->is->video_st->codec->pix_fmt, PIX_FMT_NONE
1677 AVCodecContext *c = priv->is->video_st->codec;
1681 link->time_base = priv->is->video_st->time_base;
1705 static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)
1715 NULL, is, graph)) < 0)
1746 is->out_video_filter = filt_out;
1755 VideoState *is = arg;
1765 int last_w = is->video_st->codec->width;
1766 int last_h = is->video_st->codec->height;
1768 if ((ret = configure_video_filters(graph, is, vfilters)) < 0)
1770 filt_out = is->out_video_filter;
1780 while (is->paused && !is->videoq.abort_request)
1783 if ( last_w != is->video_st->codec->width
1784 || last_h != is->video_st->codec->height) {
1786 is->video_st->codec->width, is->video_st->codec->height);
1789 if ((ret = configure_video_filters(graph, is, vfilters)) < 0)
1791 filt_out = is->out_video_filter;
1792 last_w = is->video_st->codec->width;
1793 last_h = is->video_st->codec->height;
1802 if (av_cmp_q(tb, is->video_st->time_base)) {
1804 pts_int = av_rescale_q(pts_int, tb, is->video_st->time_base);
1808 is->video_st->time_base.num, is->video_st->time_base.den, pts_int);
1811 ret = get_video_frame(is, frame, &pts_int, &pkt);
1820 pts = pts_int * av_q2d(is->video_st->time_base);
1823 ret = output_picture2(is, frame, pts, pos);
1825 ret = output_picture2(is, frame, pts, pkt.pos);
1845 VideoState *is = arg;
1854 while (is->paused && !is->subtitleq.abort_request) {
1857 if (packet_queue_get(&is->subtitleq, pkt, 1) < 0)
1861 avcodec_flush_buffers(is->subtitle_st->codec);
1864 SDL_LockMutex(is->subpq_mutex);
1865 while (is->subpq_size >= SUBPICTURE_QUEUE_SIZE &&
1866 !is->subtitleq.abort_request) {
1867 SDL_CondWait(is->subpq_cond, is->subpq_mutex);
1869 SDL_UnlockMutex(is->subpq_mutex);
1871 if (is->subtitleq.abort_request)
1874 sp = &is->subpq[is->subpq_windex];
1876 /* NOTE: ipts is the PTS of the _first_ picture beginning in
1880 pts = av_q2d(is->subtitle_st->time_base) * pkt->pts;
1882 avcodec_decode_subtitle2(is->subtitle_st->codec, &sp->sub,
1901 if (++is->subpq_windex == SUBPICTURE_QUEUE_SIZE)
1902 is->subpq_windex = 0;
1903 SDL_LockMutex(is->subpq_mutex);
1904 is->subpq_size++;
1905 SDL_UnlockMutex(is->subpq_mutex);
1913 static void update_sample_display(VideoState *is, short *samples, int samples_size)
1919 len = SAMPLE_ARRAY_SIZE - is->sample_array_index;
1922 memcpy(is->sample_array + is->sample_array_index, samples, len * sizeof(short));
1924 is->sample_array_index += len;
1925 if (is->sample_array_index >= SAMPLE_ARRAY_SIZE)
1926 is->sample_array_index = 0;
1933 static int synchronize_audio(VideoState *is, short *samples,
1939 n = 2 * is->audio_st->codec->channels;
1943 if (((is->av_sync_type == AV_SYNC_VIDEO_MASTER && is->video_st) ||
1944 is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) {
1948 ref_clock = get_master_clock(is);
1949 diff = get_audio_clock(is) - ref_clock;
1952 is->audio_diff_cum = diff + is->audio_diff_avg_coef * is->audio_diff_cum;
1953 if (is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) {
1955 is->audio_diff_avg_count++;
1958 avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
1960 if (fabs(avg_diff) >= is->audio_diff_threshold) {
1961 wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
1993 is->audio_clock, is->video_clock, is->audio_diff_threshold);
1998 is->audio_diff_avg_count = 0;
1999 is->audio_diff_cum = 0;
2007 static int audio_decode_frame(VideoState *is, double *pts_ptr)
2009 AVPacket *pkt_temp = &is->audio_pkt_temp;
2010 AVPacket *pkt = &is->audio_pkt;
2011 AVCodecContext *dec = is->audio_st->codec;
2020 if (!is->frame) {
2021 if (!(is->frame = avcodec_alloc_frame()))
2024 avcodec_get_frame_defaults(is->frame);
2029 len1 = avcodec_decode_audio4(dec, is->frame, &got_frame, pkt_temp);
2040 /* stop sending empty packets if the decoder is finished */
2046 is->frame->nb_samples,
2049 if (dec->sample_fmt != is->audio_src_fmt) {
2050 if (is->reformat_ctx)
2051 av_audio_convert_free(is->reformat_ctx);
2052 is->reformat_ctx= av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1,
2054 if (!is->reformat_ctx) {
2060 is->audio_src_fmt= dec->sample_fmt;
2063 if (is->reformat_ctx) {
2064 const void *ibuf[6] = { is->frame->data[0] };
2069 obuf[0] = av_realloc(is->audio_buf1, FFALIGN(len * ostride[0], 32));
2073 is->audio_buf1 = obuf[0];
2074 if (av_audio_convert(is->reformat_ctx, obuf, ostride, ibuf, istride, len) < 0) {
2078 is->audio_buf = is->audio_buf1;
2083 is->audio_buf = is->frame->data[0];
2087 pts = is->audio_clock;
2090 is->audio_clock += (double)data_size /
2096 is->audio_clock - last_clock,
2097 is->audio_clock, pts);
2098 last_clock = is->audio_clock;
2109 if (is->paused || is->audioq.abort_request) {
2114 if ((new_packet = packet_queue_get(&is->audioq, pkt, 1)) < 0)
2124 is->audio_clock = av_q2d(is->audio_st->time_base)*pkt->pts;
2132 VideoState *is = opaque;
2139 if (is->audio_buf_index >= is->audio_buf_size) {
2140 audio_size = audio_decode_frame(is, &pts);
2143 is->audio_buf = is->silence_buf;
2144 is->audio_buf_size = sizeof(is->silence_buf);
2146 if (is->show_audio)
2147 update_sample_display(is, (int16_t *)is->audio_buf, audio_size);
2148 audio_size = synchronize_audio(is, (int16_t *)is->audio_buf, audio_size,
2150 is->audio_buf_size = audio_size;
2152 is->audio_buf_index = 0;
2154 len1 = is->audio_buf_size - is->audio_buf_index;
2157 memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
2160 is->audio_buf_index += len1;
2165 static int stream_component_open(VideoState *is, int stream_index)
2167 AVFormatContext *ic = is->ic;
2213 wanted_spec.userdata = is;
2218 is->audio_hw_buf_size = spec.size;
2219 is->audio_src_fmt = AV_SAMPLE_FMT_S16;
2225 is->audio_stream = stream_index;
2226 is->audio_st = ic->streams[stream_index];
2227 is->audio_buf_size = 0;
2228 is->audio_buf_index = 0;
2231 is->audio_diff_avg_coef = exp(log(0.01) / AUDIO_DIFF_AVG_NB);
2232 is->audio_diff_avg_count = 0;
2235 is->audio_diff_threshold = 2.0 * SDL_AUDIO_BUFFER_SIZE / avctx->sample_rate;
2237 memset(&is->audio_pkt, 0, sizeof(is->audio_pkt));
2238 packet_queue_init(&is->audioq);
2242 is->video_stream = stream_index;
2243 is->video_st = ic->streams[stream_index];
2245 packet_queue_init(&is->videoq);
2246 is->video_tid = SDL_CreateThread(video_thread, is);
2249 is->subtitle_stream = stream_index;
2250 is->subtitle_st = ic->streams[stream_index];
2251 packet_queue_init(&is->subtitleq);
2253 is->subtitle_tid = SDL_CreateThread(subtitle_thread, is);
2261 static void stream_component_close(VideoState *is, int stream_index)
2263 AVFormatContext *ic = is->ic;
2272 packet_queue_abort(&is->audioq);
2276 packet_queue_end(&is->audioq);
2277 av_free_packet(&is->audio_pkt);
2278 if (is->reformat_ctx)
2279 av_audio_convert_free(is->reformat_ctx);
2280 is->reformat_ctx = NULL;
2281 av_freep(&is->audio_buf1);
2282 is->audio_buf = NULL;
2283 av_freep(&is->frame);
2285 if (is->rdft) {
2286 av_rdft_end(is->rdft);
2287 av_freep(&is->rdft_data);
2288 is->rdft = NULL;
2289 is->rdft_bits = 0;
2293 packet_queue_abort(&is->videoq);
2297 SDL_LockMutex(is->pictq_mutex);
2298 SDL_CondSignal(is->pictq_cond);
2299 SDL_UnlockMutex(is->pictq_mutex);
2301 SDL_WaitThread(is->video_tid, NULL);
2303 packet_queue_end(&is->videoq);
2306 packet_queue_abort(&is->subtitleq);
2310 SDL_LockMutex(is->subpq_mutex);
2311 is->subtitle_stream_changed = 1;
2313 SDL_CondSignal(is->subpq_cond);
2314 SDL_UnlockMutex(is->subpq_mutex);
2316 SDL_WaitThread(is->subtitle_tid, NULL);
2318 packet_queue_end(&is->subtitleq);
2328 is->audio_st = NULL;
2329 is->audio_stream = -1;
2332 is->video_st = NULL;
2333 is->video_stream = -1;
2336 is->subtitle_st = NULL;
2337 is->subtitle_stream = -1;
2356 VideoState *is = arg;
2368 is->video_stream = -1;
2369 is->audio_stream = -1;
2370 is->subtitle_stream = -1;
2372 global_video_state = is;
2376 err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
2378 print_error(is->filename, err);
2387 is->ic = ic;
2397 fprintf(stderr, "%s: could not find codec parameters\n", is->filename);
2422 is->filename, (double)timestamp / AV_TIME_BASE);
2447 av_dump_format(ic, 0, is->filename, 0);
2452 stream_component_open(is, st_index[AVMEDIA_TYPE_AUDIO]);
2457 ret = stream_component_open(is, st_index[AVMEDIA_TYPE_VIDEO]);
2459 is->refresh_tid = SDL_CreateThread(refresh_thread, is);
2462 is->show_audio = 2;
2466 stream_component_open(is, st_index[AVMEDIA_TYPE_SUBTITLE]);
2469 if (is->video_stream < 0 && is->audio_stream < 0) {
2470 fprintf(stderr, "%s: could not open codecs\n", is->filename);
2476 if (is->abort_request)
2478 if (is->paused != is->last_paused) {
2479 is->last_paused = is->paused;
2480 if (is->paused)
2481 is->read_pause_return = av_read_pause(ic);
2486 if (is->paused && !strcmp(ic->iformat->name, "rtsp")) {
2493 if (is->seek_req) {
2494 int64_t seek_target = is->seek_pos;
2495 int64_t seek_min = is->seek_rel > 0 ? seek_target - is->seek_rel + 2: INT64_MIN;
2496 int64_t seek_max = is->seek_rel < 0 ? seek_target - is->seek_rel - 2: INT64_MAX;
2497 // FIXME the +-2 is due to rounding being not done in the correct direction in generation
2500 ret = avformat_seek_file(is->ic, -1, seek_min, seek_target, seek_max, is->seek_flags);
2502 fprintf(stderr, "%s: error while seeking\n", is->ic->filename);
2504 if (is->audio_stream >= 0) {
2505 packet_queue_flush(&is->audioq);
2506 packet_queue_put(&is->audioq, &flush_pkt);
2508 if (is->subtitle_stream >= 0) {
2509 packet_queue_flush(&is->subtitleq);
2510 packet_queue_put(&is->subtitleq, &flush_pkt);
2512 if (is->video_stream >= 0) {
2513 packet_queue_flush(&is->videoq);
2514 packet_queue_put(&is->videoq, &flush_pkt);
2517 is->seek_req = 0;
2522 if ( is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE
2523 || ( (is->audioq .size > MIN_AUDIOQ_SIZE || is->audio_stream < 0)
2524 && (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0)
2525 && (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0))) {
2531 if (is->video_stream >= 0) {
2535 pkt->stream_index = is->video_stream;
2536 packet_queue_put(&is->videoq, pkt);
2538 if (is->audio_stream >= 0 &&
2539 is->audio_st->codec->codec->capabilities & CODEC_CAP_DELAY) {
2543 pkt->stream_index = is->audio_stream;
2544 packet_queue_put(&is->audioq, pkt);
2547 if (is->audioq.size + is->videoq.size + is->subtitleq.size == 0) {
2566 /* check if packet is in play range specified by user, then queue, otherwise discard */
2572 if (pkt->stream_index == is->audio_stream && pkt_in_play_range) {
2573 packet_queue_put(&is->audioq, pkt);
2574 } else if (pkt->stream_index == is->video_stream && pkt_in_play_range) {
2575 packet_queue_put(&is->videoq, pkt);
2576 } else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) {
2577 packet_queue_put(&is->subtitleq, pkt);
2583 while (!is->abort_request) {
2593 if (is->audio_stream >= 0)
2594 stream_component_close(is, is->audio_stream);
2595 if (is->video_stream >= 0)
2596 stream_component_close(is, is->video_stream);
2597 if (is->subtitle_stream >= 0)
2598 stream_component_close(is, is->subtitle_stream);
2599 if (is->ic) {
2600 avformat_close_input(&is->ic);
2607 event.user.data1 = is;
2615 VideoState *is;
2617 is = av_mallocz(sizeof(VideoState));
2618 if (!is)
2620 av_strlcpy(is->filename, filename, sizeof(is->filename));
2621 is->iformat = iformat;
2622 is->ytop = 0;
2623 is->xleft = 0;
2626 is->pictq_mutex = SDL_CreateMutex();
2627 is->pictq_cond = SDL_CreateCond();
2629 is->subpq_mutex = SDL_CreateMutex();
2630 is->subpq_cond = SDL_CreateCond();
2632 is->av_sync_type = av_sync_type;
2633 is->parse_tid = SDL_CreateThread(decode_thread, is);
2634 if (!is->parse_tid) {
2635 av_free(is);
2638 return is;
2641 static void stream_cycle_channel(VideoState *is, int codec_type)
2643 AVFormatContext *ic = is->ic;
2648 start_index = is->video_stream;
2650 start_index = is->audio_stream;
2652 start_index = is->subtitle_stream;
2657 if (++stream_index >= is->ic->nb_streams)
2686 stream_component_close(is, start_index);
2687 stream_component_open(is, stream_index);
2713 /* if the stream is paused unpause it, then step */
2991 { "framedrop", OPT_BOOL | OPT_EXPERT, { (void*)&framedrop }, "drop frames when cpu is too slow", "" },