]> git.sesse.net Git - ffmpeg/blobdiff - ffplay.c
Add CONFIG_SRAM to allow use of on-chip SRAM on some systems
[ffmpeg] / ffplay.c
index 69588d6465239ea6619f86f7d61e124fdae9276e..8a346867de6ee50b5eea2e3713cf5732dd4fd907 100644 (file)
--- a/ffplay.c
+++ b/ffplay.c
@@ -971,7 +971,7 @@ static double get_master_clock(VideoState *is)
 }
 
 /* seek in the stream */
-static void stream_seek(VideoState *is, int64_t pos, int64_t rel)
+static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_bytes)
 {
     if (!is->seek_req) {
         is->seek_pos = pos;
@@ -1881,6 +1881,8 @@ static int decode_thread(void *arg)
     AVFormatParameters params, *ap = &params;
     int eof=0;
 
+    ic = avformat_alloc_context();
+
     video_index = -1;
     audio_index = -1;
     subtitle_index = -1;
@@ -1893,11 +1895,14 @@ static int decode_thread(void *arg)
 
     memset(ap, 0, sizeof(*ap));
 
+    ap->prealloced_context = 1;
     ap->width = frame_width;
     ap->height= frame_height;
     ap->time_base= (AVRational){1, 25};
     ap->pix_fmt = frame_pix_fmt;
 
+    set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM);
+
     err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
     if (err < 0) {
         print_error(is->filename, err);
@@ -2314,11 +2319,11 @@ static void event_loop(void)
                         else
                             incr *= 180000.0;
                         pos += incr;
-                        stream_seek(cur_stream, pos, incr);
+                        stream_seek(cur_stream, pos, incr, 1);
                     } else {
                         pos = get_master_clock(cur_stream);
                         pos += incr;
-                        stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE));
+                        stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0);
                     }
                 }
                 break;
@@ -2328,6 +2333,10 @@ static void event_loop(void)
             break;
         case SDL_MOUSEBUTTONDOWN:
             if (cur_stream) {
+                if(seek_by_bytes || cur_stream->ic->duration<=0){
+                    uint64_t size=  url_fsize(cur_stream->ic->pb);
+                    stream_seek(cur_stream, size*(double)event.button.x/(double)cur_stream->width, 0, 1);
+                }else{
                 int64_t ts;
                 int ns, hh, mm, ss;
                 int tns, thh, tmm, tss;
@@ -2345,7 +2354,8 @@ static void event_loop(void)
                 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);
+                stream_seek(cur_stream, ts, 0, 0);
+                }
             }
             break;
         case SDL_VIDEORESIZE: