typedef struct VideoState {
SDL_Thread *read_tid;
- AVInputFormat *iformat;
+ const AVInputFormat *iformat;
int abort_request;
int force_refresh;
int paused;
} VideoState;
/* options specified by the user */
-static AVInputFormat *file_iformat;
+static const AVInputFormat *file_iformat;
static const char *input_filename;
static const char *window_title;
static int default_width = 640;
av_packet_unref(d->pkt);
} while (1);
- {
- if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
- int got_frame = 0;
- ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, d->pkt);
- if (ret < 0) {
- ret = AVERROR(EAGAIN);
- } else {
- if (got_frame && !d->pkt->data) {
- d->packet_pending = 1;
- }
- ret = got_frame ? 0 : (d->pkt->data ? AVERROR(EAGAIN) : AVERROR_EOF);
- }
- av_packet_unref(d->pkt);
+ if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ int got_frame = 0;
+ ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, d->pkt);
+ if (ret < 0) {
+ ret = AVERROR(EAGAIN);
} else {
- if (avcodec_send_packet(d->avctx, d->pkt) == AVERROR(EAGAIN)) {
- av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n");
+ if (got_frame && !d->pkt->data) {
d->packet_pending = 1;
- } else {
- av_packet_unref(d->pkt);
}
+ ret = got_frame ? 0 : (d->pkt->data ? AVERROR(EAGAIN) : AVERROR_EOF);
+ }
+ av_packet_unref(d->pkt);
+ } else {
+ if (avcodec_send_packet(d->avctx, d->pkt) == AVERROR(EAGAIN)) {
+ av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n");
+ d->packet_pending = 1;
+ } else {
+ av_packet_unref(d->pkt);
}
}
}
if (realloc_texture(&s->vis_texture, SDL_PIXELFORMAT_ARGB8888, s->width, s->height, SDL_BLENDMODE_NONE, 1) < 0)
return;
+ if (s->xpos >= s->width)
+ s->xpos = 0;
nb_display_channels= FFMIN(nb_display_channels, 2);
if (rdft_bits != s->rdft_bits) {
av_rdft_end(s->rdft);
}
if (!s->paused)
s->xpos++;
- if (s->xpos >= s->width)
- s->xpos= s->xleft;
}
}
}
if (is->subtitle_st) {
- while (frame_queue_nb_remaining(&is->subpq) > 0) {
- sp = frame_queue_peek(&is->subpq);
-
- if (frame_queue_nb_remaining(&is->subpq) > 1)
- sp2 = frame_queue_peek_next(&is->subpq);
- else
- sp2 = NULL;
-
- if (sp->serial != is->subtitleq.serial
- || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
- || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
- {
- if (sp->uploaded) {
- int i;
- for (i = 0; i < sp->sub.num_rects; i++) {
- AVSubtitleRect *sub_rect = sp->sub.rects[i];
- uint8_t *pixels;
- int pitch, j;
-
- if (!SDL_LockTexture(is->sub_texture, (SDL_Rect *)sub_rect, (void **)&pixels, &pitch)) {
- for (j = 0; j < sub_rect->h; j++, pixels += pitch)
- memset(pixels, 0, sub_rect->w << 2);
- SDL_UnlockTexture(is->sub_texture);
- }
+ while (frame_queue_nb_remaining(&is->subpq) > 0) {
+ sp = frame_queue_peek(&is->subpq);
+
+ if (frame_queue_nb_remaining(&is->subpq) > 1)
+ sp2 = frame_queue_peek_next(&is->subpq);
+ else
+ sp2 = NULL;
+
+ if (sp->serial != is->subtitleq.serial
+ || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
+ || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
+ {
+ if (sp->uploaded) {
+ int i;
+ for (i = 0; i < sp->sub.num_rects; i++) {
+ AVSubtitleRect *sub_rect = sp->sub.rects[i];
+ uint8_t *pixels;
+ int pitch, j;
+
+ if (!SDL_LockTexture(is->sub_texture, (SDL_Rect *)sub_rect, (void **)&pixels, &pitch)) {
+ for (j = 0; j < sub_rect->h; j++, pixels += pitch)
+ memset(pixels, 0, sub_rect->w << 2);
+ SDL_UnlockTexture(is->sub_texture);
}
}
- frame_queue_next(&is->subpq);
- } else {
- break;
}
+ frame_queue_next(&is->subpq);
+ } else {
+ break;
}
+ }
}
frame_queue_next(&is->pictq);
{
AVFormatContext *ic = is->ic;
AVCodecContext *avctx;
- AVCodec *codec;
+ const AVCodec *codec;
const char *forced_codec_name = NULL;
AVDictionary *opts = NULL;
AVDictionaryEntry *t = NULL;
av_dict_set(&opts, "threads", "auto", 0);
if (stream_lowres)
av_dict_set_int(&opts, "lowres", stream_lowres, 0);
- if (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
- av_dict_set(&opts, "refcounted_frames", "1", 0);
if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) {
goto fail;
}
av_log(NULL, AV_LOG_ERROR,
"%s: error while seeking\n", is->ic->url);
} else {
- if (is->audio_stream >= 0) {
+ if (is->audio_stream >= 0)
packet_queue_flush(&is->audioq);
- }
- if (is->subtitle_stream >= 0) {
+ if (is->subtitle_stream >= 0)
packet_queue_flush(&is->subtitleq);
- }
- if (is->video_stream >= 0) {
+ if (is->video_stream >= 0)
packet_queue_flush(&is->videoq);
- }
if (is->seek_flags & AVSEEK_FLAG_BYTE) {
set_clock(&is->extclk, NAN, 0);
} else {
return 0;
}
-static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
+static VideoState *stream_open(const char *filename,
+ const AVInputFormat *iformat)
{
VideoState *is;