[FFmpeg-devel] [PATCH] Add loop option to ffplay
Michael Niedermayer
michaelni
Tue Mar 23 16:24:23 CET 2010
On Tue, Mar 23, 2010 at 08:19:09AM +0100, Robert Kr?ger wrote:
>
> On 23.03.2010, at 01:06, Michael Niedermayer wrote:
>
> > On Sun, Mar 21, 2010 at 08:35:55PM +0100, Robert Kr?ger wrote:
> >>
> >> On 21.03.2010, at 18:55, Michael Niedermayer wrote:
> >>
> >>> On Sun, Mar 21, 2010 at 06:47:43PM +0100, Robert Kr?ger wrote:
> >>>>
> >>>> On 21.03.2010, at 16:51, Michael Niedermayer wrote:
> >>>>
> >>>>> On Sat, Mar 20, 2010 at 01:58:08PM +0100, Robert Kr?ger wrote:
> >>>>>>
> >>>>>> On 20.03.2010, at 12:54, Stefano Sabatini wrote:
> >>>>>>
> >>>>>>> On date Saturday 2010-03-20 12:08:32 +0100, Stefano Sabatini encoded:
> >>>>>>>> On date Saturday 2010-03-20 08:53:16 +0100, Robert Kr?ger encoded:
> >>>>>>>>>
> >>>>>>>>> On 19.03.2010, at 21:07, Michael Niedermayer wrote:
> >>>>>>> [...]
> >>>> option 1: Keep mplayer semantics (0 == forever) and keep OPT_INT. That would mean when decrementing the counter to zero, I would add a special case to set it to -1.
> >>>>
> >>>> option 2: Kick mplayer semantics, keep OPT_INT and have -1 mean loop forever
> >>>>
> >>>> option 3: Keep mplayer semantics and kick OPT_INT and make it a function that sets it to -1 when 0 is specified as a value.
> >>>>
> >>>> Which one do you prefer?
> >>>
> >>> not 2
> >>> otherwise what you think is cleaner
> >>>
> >>
> >>
> >> updated patch attached.
> >>
> >> Regards,
> >>
> >> Robert
> >>
> >
> >> doc/ffplay-doc.texi | 2 ++
> >> ffplay.c | 27 ++++++++++++++++++++++++---
> >> 2 files changed, 26 insertions(+), 3 deletions(-)
> >> da233bc799f181fbf0815fa86720bc30b95b571d ffplay-loop-option.patch
> >> Index: ffplay.c
> >> ===================================================================
> >> --- ffplay.c (revision 22627)
> >> +++ ffplay.c (working copy)
> >> @@ -260,6 +260,9 @@
> >> static int error_concealment = 3;
> >> static int decoder_reorder_pts= -1;
> >> static int autoexit;
> >> +#define LOOP_FOREVER -1
> >> +#define NO_LOOP 0
> >> +static int loop= NO_LOOP;
> >> static int framedrop=1;
> >>
> >> static int rdftspeed=20;
> >> @@ -2301,6 +2304,7 @@
> >> AVPacket pkt1, *pkt = &pkt1;
> >> AVFormatParameters params, *ap = ¶ms;
> >> int eof=0;
> >> + int64_t start= 0;
> >>
> >> ic = avformat_alloc_context();
> >>
> >> @@ -2481,9 +2485,15 @@
> >> packet_queue_put(&is->videoq, pkt);
> >> }
> >> SDL_Delay(10);
> >> - if(autoexit && is->audioq.size + is->videoq.size + is->subtitleq.size ==0){
> >> - ret=AVERROR_EOF;
> >> - goto fail;
> >> + if(is->audioq.size + is->videoq.size + is->subtitleq.size ==0){
> >> + if(loop == LOOP_FOREVER || --loop > 0){
> >> + if (start_time != AV_NOPTS_VALUE)
> >> + start = start_time;
> >> + stream_seek(cur_stream, start, (int64_t)0, 0);
> >
> > the cast is useless
> > and "int64_t start= 0;" can be closer to where its used
> >
> >
> >> + }else if(autoexit){
> >> + ret=AVERROR_EOF;
> >> + goto fail;
> >> + }
> >> }
> >> continue;
> >> }
> >> @@ -2930,6 +2940,16 @@
> >> return 0;
> >> }
> >>
> >> +static int opt_loop(const char *opt, const char *arg)
> >> +{
> >> + loop = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
> >> + /* translate from external semantics (0 == forever) to internal value (-1 == forever) */
> >> + if(!loop){
> >> + loop = LOOP_FOREVER;
> >> + }
> >
> > hmmm, thats quite a bit more complex than just reading as is
> > and
> >
> > if(loop<0 || (loop && !--loop))
> >
>
>
> updated patch attached.
>
> Regards,
>
> Robert
>
>
> doc/ffplay-doc.texi | 2 ++
> ffplay.c | 12 +++++++++---
> 2 files changed, 11 insertions(+), 3 deletions(-)
> c8014ef7f205956929fdeb73319976d325ca61bb ffplay-loop-option.patch
> Index: ffplay.c
> ===================================================================
> --- ffplay.c (revision 22627)
> +++ ffplay.c (working copy)
> @@ -260,6 +260,7 @@
> static int error_concealment = 3;
> static int decoder_reorder_pts= -1;
> static int autoexit;
> +static int loop=-1;
=1
> static int framedrop=1;
>
> static int rdftspeed=20;
> @@ -2481,9 +2482,13 @@
> packet_queue_put(&is->videoq, pkt);
> }
> SDL_Delay(10);
> - if(autoexit && is->audioq.size + is->videoq.size + is->subtitleq.size ==0){
> - ret=AVERROR_EOF;
> - goto fail;
> + if(is->audioq.size + is->videoq.size + is->subtitleq.size ==0){
> + if(loop>=0 && (!loop || --loop)){
if(loop!=1 && (!loop || --loop)){
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100323/de69b53d/attachment.pgp>
More information about the ffmpeg-devel
mailing list