#include <limits.h>
#include "libavutil/avstring.h"
#include "libavformat/avformat.h"
-#include "libavformat/rtsp.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavcodec/audioconvert.h"
+#include "libavcodec/colorspace.h"
#include "libavcodec/opt.h"
#include "cmdutils.h"
//#define DEBUG_SYNC
#define MAX_VIDEOQ_SIZE (5 * 256 * 1024)
-#define MAX_AUDIOQ_SIZE (5 * 16 * 1024)
+#define MAX_AUDIOQ_SIZE (20 * 16 * 1024)
#define MAX_SUBTITLEQ_SIZE (5 * 16 * 1024)
/* SDL audio buffer size, in samples. Should be small to have precise
int pictq_size, pictq_rindex, pictq_windex;
SDL_mutex *pictq_mutex;
SDL_cond *pictq_cond;
+ struct SwsContext *img_convert_ctx;
// QETimer *video_timer;
char filename[1024];
static int wanted_subtitle_stream= -1;
static int seek_by_bytes;
static int display_disable;
-static int show_status;
+static int show_status = 1;
static int av_sync_type = AV_SYNC_AUDIO_MASTER;
static int64_t start_time = AV_NOPTS_VALUE;
static int debug = 0;
}
#endif
-
-
-#define SCALEBITS 10
-#define ONE_HALF (1 << (SCALEBITS - 1))
-#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define RGB_TO_Y_CCIR(r, g, b) \
-((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
- FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
-
-#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
-(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
- FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
-(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
- FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
#define ALPHA_BLEND(a, oldp, newp, s)\
((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s))
double av_diff;
cur_time = av_gettime();
- if (!last_time || (cur_time - last_time) >= 500 * 1000) {
+ if (!last_time || (cur_time - last_time) >= 30000) {
aqsize = 0;
vqsize = 0;
sqsize = 0;
if (vp->bmp)
SDL_FreeYUVOverlay(vp->bmp);
-#if 0
- /* XXX: use generic function */
- /* XXX: disable overlay if no hardware acceleration or if RGB format */
- switch(is->video_st->codec->pix_fmt) {
- case PIX_FMT_YUV420P:
- case PIX_FMT_YUV422P:
- case PIX_FMT_YUV444P:
- case PIX_FMT_YUYV422:
- case PIX_FMT_YUV410P:
- case PIX_FMT_YUV411P:
- is_yuv = 1;
- break;
- default:
- is_yuv = 0;
- break;
- }
-#endif
vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec->width,
is->video_st->codec->height,
SDL_YV12_OVERLAY,
{
VideoPicture *vp;
int dst_pix_fmt;
- static struct SwsContext *img_convert_ctx;
/* wait until we have space to put a new picture */
SDL_LockMutex(is->pictq_mutex);
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
- img_convert_ctx = sws_getCachedContext(img_convert_ctx,
+ is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
is->video_st->codec->width, is->video_st->codec->height,
is->video_st->codec->pix_fmt,
is->video_st->codec->width, is->video_st->codec->height,
dst_pix_fmt, sws_flags, NULL, NULL, NULL);
- if (img_convert_ctx == NULL) {
+ if (is->img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
}
- sws_scale(img_convert_ctx, src_frame->data, src_frame->linesize,
+ sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
0, is->video_st->codec->height, pict.data, pict.linesize);
/* update the bitmap content */
SDL_UnlockYUVOverlay(vp->bmp);
}
}
-static void dump_stream_info(const AVFormatContext *s)
-{
- AVMetadataTag *tag = NULL;
- while ((tag=av_metadata_get(s->metadata,"",tag,AV_METADATA_IGNORE_SUFFIX)))
- fprintf(stderr, "%s: %s\n", tag->key, tag->value);
-}
-
/* since we have only one decoding thread, we can use a global
variable instead of a thread local variable */
static VideoState *global_video_state;
}
if (show_status) {
dump_format(ic, 0, is->filename, 0);
- dump_stream_info(ic);
}
/* open the streams */
}
}
is->seek_req = 0;
+ eof= 0;
}
/* if the queue are full, no need to read more */
}
if(url_feof(ic->pb) || eof) {
if(is->video_stream >= 0){
- av_init_packet(pkt);
- pkt->data=NULL;
- pkt->size=0;
- pkt->stream_index= is->video_stream;
- packet_queue_put(&is->videoq, pkt);
+ av_init_packet(pkt);
+ pkt->data=NULL;
+ pkt->size=0;
+ pkt->stream_index= is->video_stream;
+ packet_queue_put(&is->videoq, pkt);
}
SDL_Delay(10);
continue;
SDL_DestroyCond(is->pictq_cond);
SDL_DestroyMutex(is->subpq_mutex);
SDL_DestroyCond(is->subpq_cond);
+ if (is->img_convert_ctx)
+ sws_freeContext(is->img_convert_ctx);
+ av_free(is);
}
static void stream_cycle_channel(VideoState *is, int codec_type)
static void do_exit(void)
{
+ int i;
if (cur_stream) {
stream_close(cur_stream);
cur_stream = NULL;
}
+ for (i = 0; i < CODEC_TYPE_NB; i++)
+ av_free(avcodec_opts[i]);
+ av_free(avformat_opts);
+ av_free(sws_opts);
if (show_status)
printf("\n");
SDL_Quit();
break;
case SDL_MOUSEBUTTONDOWN:
if (cur_stream) {
+ int64_t ts;
int ns, hh, mm, ss;
int tns, thh, tmm, tss;
tns = cur_stream->ic->duration/1000000LL;
ss = (ns%60);
fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d) \n", frac*100,
hh, mm, ss, thh, tmm, tss);
- stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+frac*cur_stream->ic->duration), 0);
+ ts = frac*cur_stream->ic->duration;
+ if (cur_stream->ic->start_time != AV_NOPTS_VALUE)
+ ts += cur_stream->ic->start_time;
+ stream_seek(cur_stream, ts, 0);
}
break;
case SDL_VIDEORESIZE:
{ "sync", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
{ "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
{ "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
+ { "loglevel", HAS_ARG | OPT_FUNC2, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
{ NULL, },
};