[FFmpeg-devel] FW: RFQ on patch for decklink warnings

2017-05-29 Thread Felt, Patrick
bump

From: ffmpeg-devel  on behalf of 
"ffmpeg-devel-boun...@ffmpeg.org" 
Reply-To: FFmpeg development discussions and patches 
Date: Tuesday, May 23, 2017 at 4:06 PM
To: FFmpeg development discussions and patches 
Subject: [FFmpeg-devel] RFQ on patch for decklink warnings

Afternoon all,
  I’m looking at fixing some warnings on deprecated api calls in the decklink 
drivers.  I’ve got a patch ready, but it looks like I might be leaking memory 
somewhere. In the old code using the av_dup_packet() is a free() of some kind 
required in code that I might be able to look for and unref() ?

Here is the current patch, not looking for a commit on it, just discussion in 
what I’m missing.

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 39974e3..47cef29 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -122,16 +122,16 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket 
*pkt)
 av_log(q->avctx, AV_LOG_WARNING,  "Decklink input buffer overrun!\n");
 return -1;
 }
-/* duplicate the packet */
-if (av_dup_packet(pkt) < 0) {
+
+pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList));
+if (!pkt1) {
 return -1;
 }

-pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
-if (!pkt1) {
+/* duplicate the packet */
+if (av_packet_ref(&pkt1->pkt, pkt) < 0) {
 return -1;
 }
-pkt1->pkt  = *pkt;
 pkt1->next = NULL;

 pthread_mutex_lock(&q->mutex);


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] RFQ on patch for decklink warnings

2017-05-24 Thread Felt, Patrick
Afternoon all,
  I’m looking at fixing some warnings on deprecated api calls in the decklink 
drivers.  I’ve got a patch ready, but it looks like I might be leaking memory 
somewhere. In the old code using the av_dup_packet() is a free() of some kind 
required in code that I might be able to look for and unref() ?

Here is the current patch, not looking for a commit on it, just discussion in 
what I’m missing.

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 39974e3..47cef29 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -122,16 +122,16 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket 
*pkt)
 av_log(q->avctx, AV_LOG_WARNING,  "Decklink input buffer overrun!\n");
 return -1;
 }
-/* duplicate the packet */
-if (av_dup_packet(pkt) < 0) {
+
+pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList));
+if (!pkt1) {
 return -1;
 }

-pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
-if (!pkt1) {
+/* duplicate the packet */
+if (av_packet_ref(&pkt1->pkt, pkt) < 0) {
 return -1;
 }
-pkt1->pkt  = *pkt;
 pkt1->next = NULL;

 pthread_mutex_lock(&q->mutex);


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] - libavdevices/decklink_*.cpp: formatting change to remove uneeded spaces in initializers

2016-08-03 Thread Felt, Patrick
Sadly the server I’m deving on doesn’t have availability through an mta.  I 
generated the email by using [devuser@tst009 ~]$ git format-patch HEAD^ 
--stdout > /tmp/cosmetic2.txtand then manually creating a new email of 
similar format in my mua.  I had to attach the diff on that last cosmetic fix I 
did so I tried that here.  Is there some step I missed to where I can use this 
method?  If not, I can try running git off my laptop and then copy the diff and 
apply locally then commit off my laptop instead.



From: ffmpeg-devel  on behalf of Timothy Gu 

Reply-To: FFmpeg development discussions and patches 
Date: Tuesday, August 2, 2016 at 11:49 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH] - libavdevices/decklink_*.cpp: formatting 
change to remove uneeded spaces in initializers

On Tue, Aug 2, 2016 at 10:17 PM Felt, Patrick 
mailto:patrick.f...@echostar.com>>
wrote:

---
libavdevice/decklink_common.cpp | 10 +-
libavdevice/decklink_dec.cpp| 18 +-
libavdevice/decklink_enc.cpp| 26 +-
3 files changed, 27 insertions(+), 27 deletions(-)


Pushed. If you could use git send-email to send patches, or at least send a
git formatted patch with a commit message and an author, that would be the
best.

Thanks,

Timothy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org<mailto:ffmpeg-devel@ffmpeg.org>
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] - libavdevices/decklink_*.cpp: formatting change to remove uneeded spaces in initializers

2016-08-02 Thread Felt, Patrick
---
libavdevice/decklink_common.cpp | 10 +-
libavdevice/decklink_dec.cpp| 18 +-
libavdevice/decklink_enc.cpp| 26 +-
3 files changed, 27 insertions(+), 27 deletions(-)


cosmetic2.diff
Description: cosmetic2.diff
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] - cosmetic: the decklink_dec* files are used for input from the decklink cards. update the header to reflect that

2016-08-02 Thread Felt, Patrick
That’s really odd.  Has to be something stupid from my MUA.  Let me attach it 
as a file and it should go.  (I wrote this off a brand new fresh clone).


From: ffmpeg-devel  on behalf of Michael 
Niedermayer 
Reply-To: FFmpeg development discussions and patches 
Date: Tuesday, August 2, 2016 at 1:08 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH] - cosmetic: the decklink_dec* files are 
used for input from the decklink cards. update the header to reflect that

On Tue, Aug 02, 2016 at 06:44:14PM +, Felt, Patrick wrote:
This is a cosmetic patch only to update the header of decklink files to be 
indicative of data flow direction.
---
libavdevice/decklink_dec.cpp | 4 ++--
libavdevice/decklink_dec.h   | 2 +-
libavdevice/decklink_dec_c.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

Applying: - cosmetic: the decklink_dec* files are used for input from the 
decklink cards. update the header to reflect that
fatal: corrupt patch at line 12
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 - cosmetic: the decklink_dec* files are used for input 
from the decklink cards. update the header to reflect that
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".


diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index fcb024e..fc81d4d 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1,5 +1,5 @@
/*
- * Blackmagic DeckLink output

patch is oddly corrupted here

[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.





cosmetic.diff
Description: cosmetic.diff
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] - cosmetic: the decklink_dec* files are used for input from the decklink cards. update the header to reflect that

2016-08-02 Thread Felt, Patrick
This is a cosmetic patch only to update the header of decklink files to be 
indicative of data flow direction.


---
libavdevice/decklink_dec.cpp | 4 ++--
libavdevice/decklink_dec.h   | 2 +-
libavdevice/decklink_dec_c.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index fcb024e..fc81d4d 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1,5 +1,5 @@
/*
- * Blackmagic DeckLink output
+ * Blackmagic DeckLink input
  * Copyright (c) 2013-2014 Luca Barbato, Deti Fliegl
  *
  * This file is part of FFmpeg.
@@ -524,7 +524,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)

 /* Get input device. */
 if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != 
S_OK) {
-av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
+av_log(avctx, AV_LOG_ERROR, "Could not open input device from '%s'\n",
avctx->filename);
 ret = AVERROR(EIO);
 goto error;
diff --git a/libavdevice/decklink_dec.h b/libavdevice/decklink_dec.h
index c02344e..9b71870 100644
--- a/libavdevice/decklink_dec.h
+++ b/libavdevice/decklink_dec.h
@@ -1,5 +1,5 @@
/*
- * Blackmagic DeckLink output
+ * Blackmagic DeckLink input
  * Copyright (c) 2013-2014 Ramiro Polla
  *
  * This file is part of FFmpeg.
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 523be66..56bc439 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -1,5 +1,5 @@
/*
- * Blackmagic DeckLink output
+ * Blackmagic DeckLink input
  * Copyright (c) 2014 Deti Fliegl
  *
  * This file is part of FFmpeg.
--
1.8.3.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Remove last deprecated calls

2016-06-27 Thread Felt, Patrick


From: ffmpeg-devel  on behalf of Marton Balint 

Reply-To: FFmpeg development discussions and patches 
Date: Monday, June 27, 2016 at 6:01 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH] Remove last deprecated calls


On Mon, 27 Jun 2016, Felt, Patrick wrote:

---
libavdevice/decklink_dec.cpp | 17 ++---
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 7412727..9c5d5f9 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -120,10 +120,6 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket 
*pkt)
 av_log(q->avctx, AV_LOG_WARNING,  "Decklink input buffer overrun!\n");
 return -1;
 }
-/* duplicate the packet */
-if (av_dup_packet(pkt) < 0) {
-return -1;
-}

I don't think you can remove this, pkt.data needs to be memcpy-ed to a
newly allocated buffer.

It appears to run cleanly on my test system, but I’d be happy to put it back.  
Would the following be the right thing in this case?  (I don’t fully understand 
what that function was intending to do originally; the replacement makes a bit 
more sense to me).

if (av_packet_ref(pkt, pkt) < 0) {
  return -1;
}

though it seems that might only be valid if the whole of decklink was using 
reference counted packets?  Does that function do the memcpy() you were 
thinking we needed?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Remove last deprecated calls

2016-06-27 Thread Felt, Patrick
Agreed.  I was headed to fixing up the input mode autodetection next as that’s 
still outstanding in my queue.  I wanted/needed to clean up those errors first 
though so i didn’t have to wrap those calls in FF_DISABLE_DEPRECATION_WARNINGS 
and subsequently forgetting to remove them when I submit my patch to the list.

On 6/27/16, 3:17 PM, "ffmpeg-devel on behalf of Hendrik Leppkes" 
 wrote:

decklink should probably be updated eventually to use wrapped_avframe
output or something like that, then you could properly output
interlaced and field order flags on a per-frame basis.
Especially since the AVFMT_RAWPICTURE mode it uses is deprecated.

This applies to both decklink_dec and decklink_enc, fwiw.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Remove last deprecated calls

2016-06-27 Thread Felt, Patrick
---
libavdevice/decklink_dec.cpp | 17 ++---
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 7412727..9c5d5f9 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -120,10 +120,6 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket 
*pkt)
 av_log(q->avctx, AV_LOG_WARNING,  "Decklink input buffer overrun!\n");
 return -1;
 }
-/* duplicate the packet */
-if (av_dup_packet(pkt) < 0) {
-return -1;
-}

 pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
 if (!pkt1) {
@@ -582,6 +578,12 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
 st->codecpar->codec_tag   = MKTAG('U', 'Y', 'V', 'Y');
 st->codecpar->bit_rate= av_rescale(ctx->bmd_width * 
ctx->bmd_height * 16, st->time_base.den, st->time_base.num);
 }
+/* set up the interlacing settings */
+if (ctx->bmd_field_dominance == bmdLowerFieldFirst) {
+st->codecpar->field_order = AV_FIELD_BB;
+} else if (ctx->bmd_field_dominance == bmdUpperFieldFirst) {
+st->codecpar->field_order = AV_FIELD_TT;
+}

 avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */

@@ -640,15 +642,8 @@ int ff_decklink_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
{
 struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
 struct decklink_ctx *ctx = (struct decklink_ctx *) cctx->ctx;
-AVFrame *frame = ctx->video_st->codec->coded_frame;

 avpacket_queue_get(&ctx->queue, pkt, 1);
-if (frame && (ctx->bmd_field_dominance == bmdUpperFieldFirst || 
ctx->bmd_field_dominance == bmdLowerFieldFirst)) {
-frame->interlaced_frame = 1;
-if (ctx->bmd_field_dominance == bmdUpperFieldFirst) {
-frame->top_field_first = 1;
-}
-}

 return 0;
}
--
1.8.3.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Change the decklink_dec file header to reflect that this module is used for input from decklink and not output

2016-06-27 Thread Felt, Patrick
---
libavdevice/decklink_dec.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index fcb024e..7412727 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1,5 +1,5 @@
/*
- * Blackmagic DeckLink output
+ * Blackmagic DeckLink input
  * Copyright (c) 2013-2014 Luca Barbato, Deti Fliegl
  *
  * This file is part of FFmpeg.
--
1.8.3.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] bans

2016-06-15 Thread Felt, Patrick


On 6/15/16, 7:50 AM, "ffmpeg-devel on behalf of James Almer" 
 wrote:

>On 6/15/2016 10:14 AM, Michael Niedermayer wrote:
>> After writing this mail i will
>> 
>> 1. ban carl for 24h from the ML due to
>> causing  derek to leave the project. (24h was suggested in the IRC
>> meeting)
>
>This is useless IMO. While four months is too much, 24 hours is
>insignificant.

Might I throw in an exponential backoff algorithm?  Perhaps every incident 
incurs a 24 hour ban with a one month half-life or some such thing.  Once a 
person passes above a 24h ban they are actually banned for some time.  It’s 
worked for BGP for a lot of years.

>
>> 2. ban derek for ~24h from the ML
>> 
>> 3. ban myself for ~24h from the ML

>And this is silly. It's old history and nobody requested such action in
>any what whatsoever. It will only derail the discussion and again, bans
>without discussion or vote are a big no.
>

I also think all the current bans are silly.  Retroactively applying rules that 
were voted on today to issues that happened in the past, for any value of past, 
is not something that I think is appropriate.  What’s happened on all fronts is 
a horrible shame, but it seems that a consistent set of rules going forward and 
water under the bridge presently is a better way to go of it.  Don’t we all 
have better things to do that squabble over this?  I see a lot of amazing stuff 
coming in patches.



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] IRC meeting

2016-06-06 Thread Felt, Patrick


On 6/4/16, 4:33 AM, "ffmpeg-devel on behalf of Michael Niedermayer" 
 wrote:

>On Sat, Jun 04, 2016 at 10:30:32AM +0200, Piotr Bandurski wrote:
>> Hi,
>> 
>> The problem with this project is that it has not enough active developers. 
>> It looks like most of the devs swiched into "stand-by" mode or something
>> and sadly no new people are joining in to push development forward ;)
>
>There where new developers but i have the feeling many of them where
>treated rather hostile by the community until they decreased activity
>or disappeared examples are lukasz, ganesh and andreas
>but maybe iam misinterpreting things, iam much more a technical guy
>than a sozial one

I’m no star developer by any stretch of the imagination, nor was I treated 
poorly, but..  being a new guy in these parts, having come in right amidst all 
this excitement, has given me pause to question if I just stepped into a crazy 
minefield.

>but i have the hope that with the higherh awareness about hostilities
>we have now and less the CoC (its people not paper that makes a
>difference) this could be prevented and maybe undone in the future.

Personally.  I think this will make a bit of difference for a lot of people if 
it’s made well known.  Perhaps add a link to the ratified COC in the topic in 
the irc channel, and add it as required reading to the mailman subscribe?  (if 
that’s even possible; I’ve never administered mailman before).

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Updated (v3) -- Add input mode autodetect to the decklink module.

2016-05-21 Thread Felt, Patrick
On 5/21/16, 3:38 AM, "ffmpeg-devel on behalf of Marton Balint" 
 wrote:

>> --- a/libavdevice/decklink_common.cpp
>> +++ b/libavdevice/decklink_common.cpp
>> @@ -98,6 +98,90 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, 
>> const char **displayName)
>> return hr;
>> }
>>
>> +long ff_decklink_mode_to_bm(AVFormatContext *avctx,
>
>Should be BMDDisplayMode, not long.
>
>> +   decklink_direction_t direction,
>> +   int ffmpeg_mode,
>> +   IDeckLinkDisplayMode **mode)
>
>As far a I see you do not use **mode with a non-NULL arugment in your 
>code, so you can get rid of it and its functionality.

True, in this patch I do not use **mode, however I noticed that elsewhere we 
did a similar loop.  This could consolidate the code into one fuction so we 
don’t have duplicate code.  That would definitely be an unrelated change so I 
left it open enough to hopefully suffice.  We can take it out if we need to.
 
>
>> +{
>> +struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>
>unnecessary space before avctx

most of the spaces here are because I copied and pasted those lines from other, 
previously defined functions.  I removed from where I was seeing them, however 
I may have removed some extras.  Please don’t consider those a formatting 
change.

>> +break;
>> +}
>> +
>> +internal_mode->Release();
>> +}
>> +
>> +itermode->Release();
>> +if (internal_mode) {
>
>What if there is no match for ffmpeg_mode? Is it documented in the 
>Decklink SDK that internal_mode will be overwritten to NULL on the last 
>iteration?

Good catch.  I’ll rework this loop.

>> +int ff_decklink_mode_to_ffmpeg(AVFormatContext *avctx,
>> +   decklink_direction_t direction,
>> +   IDeckLinkDisplayMode **mode)
>
>should use *mode, not **mode, because *mode is not overwritten in this 
>function

modified this one as there really isn’t a need to send back mode information

>> +int ff_decklink_device_autodetect(AVFormatContext *avctx)
>
>Probably worth remaining to somehting like 
>ff_decklink_can_detect_input_format otherwise somebody may be 
>under the impression that this function will do the autodetection.

I’ve modified this to ff_decklink_device_supports_autodetect

>> @@ -244,6 +245,12 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
>> BMDTimeValue frameTime;
>> BMDTimeValue frameDuration;
>>
>> +/* if we don't have video, we are in the autodetect phase.  skip 
>> everything and let
>> + * autodetect do its magic */
>> +if (!ctx->video) {
>> +return S_OK;
>> +}
>> +
>> ctx->frameCount++;
>>
>> // Handle Video Frame
>> @@ -393,6 +400,14 @@ HRESULT 
>> decklink_input_callback::VideoInputFormatChanged(
>> BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode,
>> BMDDetectedVideoInputFormatFlags)
>> {
>> +
>> +/* undo all the autodetect stuff so we can move on with life */
>> +ctx->dli->PauseStreams();
>> +ctx->dli->FlushStreams();
>> +
>> +ctx->mode_num = ff_decklink_mode_to_ffmpeg(avctx, DIRECTION_IN, &mode);
>> +ctx->video = 1;
>
>I would only do anything in this function, if ctx->auto_detect is set 
>to 1, and I would also set ctx->auto_detect to 0, so you don't have to 
>use a separate ->video variable for signalling a successful autodetection.
>
>Also don't you want to StopStreams and DisableAudio/VideoInput here? 
>Because you will be re-doing the whole initialization stuff later, and I 
>am not sure you are supposed to call ff_decklink_set_format when the 
>streams are already running.
>

The decklink sdk specifically states that there should be a pause here and not 
a stop/start.  Also, ff_decklink_set_format() only checks that a mode is 
supported.  It doesn’t actually do anything else with the decklink api.

>> @@ -510,34 +525,74 @@ av_cold int ff_decklink_read_header(AVFormatContext 
>> *avctx)
>>
>> /* Get input device. */
>> if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != 
>> S_OK) {
>> -av_log(avctx, AV_LOG_ERROR, "Could not open output device from 
>> '%s'\n",
>> +av_log(avctx, AV_LOG_ERROR, "Could not open input device from 
>> '%s'\n",
>>avctx->filename);
>> ctx->dl->Release();
>> return AVERROR(EIO);
>> }
>>
>> +auto_detect = ff_decklink_device_autodetect(avctx);
>> +
>> /* List supported formats. */
>> -if (ctx->list_formats) {
>> +if (ctx->list_formats || (ctx->mode_num <= 0 && !auto_detect)) {
>
>This seems like an unrelated change, i'd drop it for now.

If the user specifies they want auto detection, and their card doesn’t support 
it, I display the supported modes and exit.  This is related.

>> +
>> +result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, 
>> bmdAudioSampleType16bitInteger, cctx->audio_cha

Re: [FFmpeg-devel] Tee improvement - discussion

2016-05-21 Thread Felt, Patrick


On 5/20/16, 9:32 PM, "ffmpeg-devel on behalf of Michael Niedermayer" 
 wrote:

>On Fri, May 20, 2016 at 12:06:34AM +0200, Marton Balint wrote:
>> 
>> On Thu, 19 May 2016, Nicolas George wrote:
>> 
>> >Le tridi 23 floréal, an CCXXIV, Jan Sebechlebsky a écrit :
>> >>My current idea is to create queue for each output (as Marton suggested) 
>> >>and
>> >>process each output in separate thread. I was also considering using just
>> >>single queue, but since the AVPackets are referenced counted, the memory
>> >>overhead is negligible and using multiple queues will simplify the code.
>> >>Apart from getting advantage of non-blocking processing with multiple slave
>> >>muxers, error handling will also be improved.
>> >
>> >>Another question is what to do when some of the queues becomes full,
>> >>discussed options were so far:
>> >>- Block write_packet call until the queue frees - this might be useful
>> >>when producer is faster than consumer, and we don't want to drop any 
>> >>packets
>> >>when recording to file.
>> >>- Drop some yet unprocessed packets (until next keyframe, or free some
>> >>portion of queue) to free the queue - this might be useful for network
>> >>outputs.
>> >
>> >I must say, I am not very happy with the direction this project takes.
>> >
>> >Non-blocking muxers (and demuxers, and protocols) is a white whale for our
>> >API: we really really want it, but it huge and very hard to catch.
>> >
>> >It is something that needs to be implemented globally with a very careful
>> >design. Definitely not something that can be added in a corner of an obscure
>> >muxer. We already went down that path twice, with the thread for the UDP
>> >protocol and with running demuxer in threads in FFmpeg. Both did lead to
>> >endless complications: bugs, inconsistencies, portability trouble.
>> 
>> What caused these complications? Do you have some references?
>
>i dont know, what i remember as udp problems are things that shouldnt
>affect tee like:
>
>some UDP "users" like RT*P
>bypass the public API and pull the UDP fd out of the demuxer and
>then try to use it polling and stuff (ffurl_get_file_handle)
>this doesnt work so well, as teh fd is on the input side of the que
>and what came out of the udp code is on  the output side and in
>different threads
>
>another issue with udp i remember is timing
>packets should have "transmit times" from the muxer in them so
>they get sent at the correct time, thats not done even though muxers
>like mpeg-ps calculate these times correctly

there was discussion on this just today in the #ffmpeg channel.  Mpeg-ts over 
udp users using hardware decoders could use this functionality.

>
>
>[...]
>
>-- 
>Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
>Everything should be made as simple as possible, but not simpler.
>-- Albert Einstein

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] FW: [PATCH] -- Add input swap functionality to movie filter(src_movie.c)

2016-05-20 Thread Felt, Patrick
bump

On 5/16/16, 2:15 PM, "ffmpeg-devel on behalf of Felt, Patrick" 
 wrote:

>This is a rework of the previously submitted patch to not require globals.  
>I’ve also renamed variables per standard.  Attached is the output of git 
>format-patch (let me know if I should just paste contents into the body in the 
>future.  This just felt a little cleaner).
>
>
>



swap-official-patch
Description: swap-official-patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Updated (v3) -- Add input mode autodetect to the decklink module.

2016-05-20 Thread Felt, Patrick
bump

On 5/16/16, 9:28 AM, "ffmpeg-devel on behalf of Felt, Patrick" 
 wrote:

>bump
>
>On 5/12/16, 4:07 PM, "ffmpeg-devel on behalf of Felt, Patrick" 
> wrote:
>
>>I hang my head in shame.  I neglected to notice that time wasn’t already 
>>included and so I had to modify the patch.  Apologies for the noise.
>>
>>-- Add input mode autodetect to the decklink module. Previously users had to 
>>supply the input format like this 'DeckLink Device@modenum'.  This patch 
>>allows users to either leave it off completely, or supply 0 or negative 
>>number to indicate autodetect is requested. Autodetect only works the first 
>>time so if the mode changes mid stream you'll die
>>
>>---
>> libavdevice/decklink_common.cpp | 110 
>> 
>> libavdevice/decklink_common.h   |   5 ++
>> libavdevice/decklink_common_c.h |   1 +
>> libavdevice/decklink_dec.cpp|  86 +--
>> libavdevice/decklink_dec_c.c|   1 +
>> 5 files changed, 188 insertions(+), 15 deletions(-)
>>
>>diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
>>index ac7964c..1d51294 100644
>>--- a/libavdevice/decklink_common.cpp
>>+++ b/libavdevice/decklink_common.cpp
>>@@ -98,6 +98,90 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, 
>>const char **displayName)
>> return hr;
>> }
>> 
>>+long ff_decklink_mode_to_bm(AVFormatContext *avctx,
>>+   decklink_direction_t direction,
>>+   int ffmpeg_mode,
>>+   IDeckLinkDisplayMode **mode)
>>+{
>>+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>>+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>>+IDeckLinkDisplayModeIterator *itermode;
>>+IDeckLinkDisplayMode *internal_mode;
>>+
>>+int result=0;
>>+HRESULT res;
>>+
>>+if (direction == DIRECTION_IN) {
>>+res = ctx->dli->GetDisplayModeIterator (&itermode);
>>+} else {
>>+res = ctx->dlo->GetDisplayModeIterator (&itermode);
>>+}
>>+
>>+if (res != S_OK) {
>>+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
>>+return -1;
>>+}
>>+
>>+while (itermode->Next(&internal_mode) == S_OK) {
>>+if (++result == ffmpeg_mode) {
>>+break;
>>+}
>>+
>>+internal_mode->Release();
>>+}
>>+
>>+itermode->Release();
>>+if (internal_mode) {
>>+result = internal_mode->GetDisplayMode();
>>+if (mode) {
>>+*mode = internal_mode;
>>+} else {
>>+internal_mode->Release();
>>+}
>>+
>>+return result;
>>+}
>>+
>>+return 0;
>>+}
>>+
>>+int ff_decklink_mode_to_ffmpeg(AVFormatContext *avctx,
>>+   decklink_direction_t direction,
>>+   IDeckLinkDisplayMode **mode)
>>+{
>>+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>>+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>>+IDeckLinkDisplayModeIterator *itermode;
>>+IDeckLinkDisplayMode *internal_mode;
>>+long bdm_mode_number = (*mode)->GetDisplayMode();
>>+int result=1, found=0;
>>+HRESULT res;
>>+
>>+if (direction == DIRECTION_IN) {
>>+res = ctx->dli->GetDisplayModeIterator (&itermode);
>>+} else {
>>+res = ctx->dlo->GetDisplayModeIterator (&itermode);
>>+}
>>+
>>+if (res != S_OK) {
>>+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
>>+return -1;
>>+}
>>+
>>+while (itermode->Next(&internal_mode) == S_OK) {
>>+if (internal_mode->GetDisplayMode() == bdm_mode_number) {
>>+internal_mode->Release();
>>+found = 1;
>>+break;
>>+}
>>+internal_mode->Release();
>>+result++;
>>+}
>>+
>>+itermode->Release();
>>+return (found) ? result : -1;
>>+}
>>+
>> int ff_decklink_set_format(AVFormatContext *avctx,
>>int width, int height,
>>int tb_num, int tb_den,
>>@@ -197,6 +2

Re: [FFmpeg-devel] [PATCH] Updated (v3) -- Add input mode autodetect to the decklink module.

2016-05-20 Thread Felt, Patrick
bump

On 5/16/16, 9:28 AM, "ffmpeg-devel on behalf of Felt, Patrick" 
 wrote:

>bump
>
>On 5/12/16, 4:07 PM, "ffmpeg-devel on behalf of Felt, Patrick" 
> wrote:
>
>>I hang my head in shame.  I neglected to notice that time wasn’t already 
>>included and so I had to modify the patch.  Apologies for the noise.
>>
>>-- Add input mode autodetect to the decklink module. Previously users had to 
>>supply the input format like this 'DeckLink Device@modenum'.  This patch 
>>allows users to either leave it off completely, or supply 0 or negative 
>>number to indicate autodetect is requested. Autodetect only works the first 
>>time so if the mode changes mid stream you'll die
>>
>>---
>> libavdevice/decklink_common.cpp | 110 
>> 
>> libavdevice/decklink_common.h   |   5 ++
>> libavdevice/decklink_common_c.h |   1 +
>> libavdevice/decklink_dec.cpp|  86 +--
>> libavdevice/decklink_dec_c.c|   1 +
>> 5 files changed, 188 insertions(+), 15 deletions(-)
>>
>>diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
>>index ac7964c..1d51294 100644
>>--- a/libavdevice/decklink_common.cpp
>>+++ b/libavdevice/decklink_common.cpp
>>@@ -98,6 +98,90 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, 
>>const char **displayName)
>> return hr;
>> }
>> 
>>+long ff_decklink_mode_to_bm(AVFormatContext *avctx,
>>+   decklink_direction_t direction,
>>+   int ffmpeg_mode,
>>+   IDeckLinkDisplayMode **mode)
>>+{
>>+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>>+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>>+IDeckLinkDisplayModeIterator *itermode;
>>+IDeckLinkDisplayMode *internal_mode;
>>+
>>+int result=0;
>>+HRESULT res;
>>+
>>+if (direction == DIRECTION_IN) {
>>+res = ctx->dli->GetDisplayModeIterator (&itermode);
>>+} else {
>>+res = ctx->dlo->GetDisplayModeIterator (&itermode);
>>+}
>>+
>>+if (res != S_OK) {
>>+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
>>+return -1;
>>+}
>>+
>>+while (itermode->Next(&internal_mode) == S_OK) {
>>+if (++result == ffmpeg_mode) {
>>+break;
>>+}
>>+
>>+internal_mode->Release();
>>+}
>>+
>>+itermode->Release();
>>+if (internal_mode) {
>>+result = internal_mode->GetDisplayMode();
>>+if (mode) {
>>+*mode = internal_mode;
>>+} else {
>>+internal_mode->Release();
>>+}
>>+
>>+return result;
>>+}
>>+
>>+return 0;
>>+}
>>+
>>+int ff_decklink_mode_to_ffmpeg(AVFormatContext *avctx,
>>+   decklink_direction_t direction,
>>+   IDeckLinkDisplayMode **mode)
>>+{
>>+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>>+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>>+IDeckLinkDisplayModeIterator *itermode;
>>+IDeckLinkDisplayMode *internal_mode;
>>+long bdm_mode_number = (*mode)->GetDisplayMode();
>>+int result=1, found=0;
>>+HRESULT res;
>>+
>>+if (direction == DIRECTION_IN) {
>>+res = ctx->dli->GetDisplayModeIterator (&itermode);
>>+} else {
>>+res = ctx->dlo->GetDisplayModeIterator (&itermode);
>>+}
>>+
>>+if (res != S_OK) {
>>+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
>>+return -1;
>>+}
>>+
>>+while (itermode->Next(&internal_mode) == S_OK) {
>>+if (internal_mode->GetDisplayMode() == bdm_mode_number) {
>>+internal_mode->Release();
>>+found = 1;
>>+break;
>>+}
>>+internal_mode->Release();
>>+result++;
>>+}
>>+
>>+itermode->Release();
>>+return (found) ? result : -1;
>>+}
>>+
>> int ff_decklink_set_format(AVFormatContext *avctx,
>>int width, int height,
>>int tb_num, int tb_den,
>>@@ -197,6 +2

[FFmpeg-devel] [PATCH] -- Add input swap functionality to movie filter(src_movie.c)

2016-05-16 Thread Felt, Patrick
This is a rework of the previously submitted patch to not require globals.  
I’ve also renamed variables per standard.  Attached is the output of git 
format-patch (let me know if I should just paste contents into the body in the 
future.  This just felt a little cleaner).





swap-official-patch
Description: swap-official-patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Updated (v3) -- Add input mode autodetect to the decklink module.

2016-05-16 Thread Felt, Patrick
bump

On 5/12/16, 4:07 PM, "ffmpeg-devel on behalf of Felt, Patrick" 
 wrote:

>I hang my head in shame.  I neglected to notice that time wasn’t already 
>included and so I had to modify the patch.  Apologies for the noise.
>
>-- Add input mode autodetect to the decklink module. Previously users had to 
>supply the input format like this 'DeckLink Device@modenum'.  This patch 
>allows users to either leave it off completely, or supply 0 or negative number 
>to indicate autodetect is requested. Autodetect only works the first time so 
>if the mode changes mid stream you'll die
>
>---
> libavdevice/decklink_common.cpp | 110 
> libavdevice/decklink_common.h   |   5 ++
> libavdevice/decklink_common_c.h |   1 +
> libavdevice/decklink_dec.cpp|  86 +--
> libavdevice/decklink_dec_c.c|   1 +
> 5 files changed, 188 insertions(+), 15 deletions(-)
>
>diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
>index ac7964c..1d51294 100644
>--- a/libavdevice/decklink_common.cpp
>+++ b/libavdevice/decklink_common.cpp
>@@ -98,6 +98,90 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, const 
>char **displayName)
> return hr;
> }
> 
>+long ff_decklink_mode_to_bm(AVFormatContext *avctx,
>+   decklink_direction_t direction,
>+   int ffmpeg_mode,
>+   IDeckLinkDisplayMode **mode)
>+{
>+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>+IDeckLinkDisplayModeIterator *itermode;
>+IDeckLinkDisplayMode *internal_mode;
>+
>+int result=0;
>+HRESULT res;
>+
>+if (direction == DIRECTION_IN) {
>+res = ctx->dli->GetDisplayModeIterator (&itermode);
>+} else {
>+res = ctx->dlo->GetDisplayModeIterator (&itermode);
>+}
>+
>+if (res != S_OK) {
>+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
>+return -1;
>+}
>+
>+while (itermode->Next(&internal_mode) == S_OK) {
>+if (++result == ffmpeg_mode) {
>+break;
>+}
>+
>+internal_mode->Release();
>+}
>+
>+itermode->Release();
>+if (internal_mode) {
>+result = internal_mode->GetDisplayMode();
>+if (mode) {
>+*mode = internal_mode;
>+} else {
>+internal_mode->Release();
>+}
>+
>+return result;
>+}
>+
>+return 0;
>+}
>+
>+int ff_decklink_mode_to_ffmpeg(AVFormatContext *avctx,
>+   decklink_direction_t direction,
>+   IDeckLinkDisplayMode **mode)
>+{
>+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>+IDeckLinkDisplayModeIterator *itermode;
>+IDeckLinkDisplayMode *internal_mode;
>+long bdm_mode_number = (*mode)->GetDisplayMode();
>+int result=1, found=0;
>+HRESULT res;
>+
>+if (direction == DIRECTION_IN) {
>+res = ctx->dli->GetDisplayModeIterator (&itermode);
>+} else {
>+res = ctx->dlo->GetDisplayModeIterator (&itermode);
>+}
>+
>+if (res != S_OK) {
>+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
>+return -1;
>+}
>+
>+while (itermode->Next(&internal_mode) == S_OK) {
>+if (internal_mode->GetDisplayMode() == bdm_mode_number) {
>+internal_mode->Release();
>+found = 1;
>+break;
>+}
>+internal_mode->Release();
>+result++;
>+}
>+
>+itermode->Release();
>+return (found) ? result : -1;
>+}
>+
> int ff_decklink_set_format(AVFormatContext *avctx,
>int width, int height,
>int tb_num, int tb_den,
>@@ -197,6 +281,29 @@ int ff_decklink_list_devices(AVFormatContext *avctx)
> return 0;
> }
> 
>+int ff_decklink_device_autodetect(AVFormatContext *avctx)
>+{
>+HRESULT res;
>+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
>+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
>+IDeckLinkAttributes *attrs = NULL;
>+bool auto_detect;
>+
>+res = ctx->dl->QueryInterface(IID_IDeckLinkAttributes, (void**)&attrs);
>+if (res != S_OK) {
>+av_log(avc

Re: [FFmpeg-devel] [PATCH] Updated (v3) -- Add input mode autodetect to the decklink module.

2016-05-12 Thread Felt, Patrick
 AVERROR_EXIT;
 }
 
-if (ctx->dli->GetDisplayModeIterator(&itermode) != S_OK) {
-av_log(avctx, AV_LOG_ERROR, "Could not get Display Mode Iterator\n");
-ctx->dl->Release();
-return AVERROR(EIO);
-}
+if (ctx->mode_num <= 0 && auto_detect) {
+/* the user is wanting to auto detect the mode. we need to fake out 
the api and not start ffmpeg fully in this mode!*/
+ctx->auto_detect = 1;
+ctx->mode_num = 1; /* it is assumed that there is at least one mode 
supported on a decklink card. */
+
+if (ff_decklink_set_format(avctx, DIRECTION_IN, ctx->mode_num) < 0) {
+av_log(avctx, AV_LOG_ERROR, "Could not set mode %d\n", 
ctx->mode_num);
+goto error;
+}
 
-if (mode_num > 0) {
-if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
-av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", 
mode_num, fname);
+ctx->bmd_mode = ff_decklink_mode_to_bm(avctx, DIRECTION_IN, 
ctx->mode_num, NULL);
+result = ctx->dli->EnableVideoInput(ctx->bmd_mode,
+cctx->v210 ? bmdFormat10BitYUV : 
bmdFormat8BitYUV,
+bmdVideoInputFlagDefault | 
bmdVideoInputEnableFormatDetection);
+if (result != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not enable video in the 
pre-startup autodectect mode\n");
 goto error;
 }
+
+result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, 
bmdAudioSampleType16bitInteger, cctx->audio_channels);
+if (result != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not enable audio in the 
pre-startup autodetect mode\n");
+goto error;
+}
+
+result = decklink_start_input(avctx);
+if (result != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not start input in the 
pre-startup autodetect mode\n");
+goto error;
+}
+
+/* we need to give the auto detect code some time to figure out what 
mode we are really in */
+autodetect_delay = cctx->autodetect_delay;
+while (!ctx->video) {
+if (autodetect_delay--) {
+/* this could indicate we are in the right mode.  let's assume 
so */
+break;
+}
+/* sleep for 1 second */
+av_usleep(10);
+}
 }
 
-itermode->Release();
+/* regardless as to if we did autodetect or not, we should now be in a 
position to
+ * continue on as before with all the right setup to ensure we get the 
right mode */
+ctx->video = 1;
+if (ctx->mode_num > 0) {
+if (ff_decklink_set_format(avctx, DIRECTION_IN, ctx->mode_num) < 0) {
+av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", 
ctx->mode_num, fname);
+goto error;
+}
+}
 
 /* Setup streams. */
 st = avformat_new_stream(avctx, NULL);
@@ -618,6 +673,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
 
 return 0;
 
+
 error:
 
 ctx->dli->Release();
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 40c21a7..3f83f8f 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -36,6 +36,7 @@ static const AVOption options[] = {
 { "standard", NULL,   0,  
AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0,DEC, "teletext_lines"},
 { "all",  NULL,   0,  
AV_OPT_TYPE_CONST, { .i64 = 0x7LL}, 0, 0,DEC, "teletext_lines"},
 { "channels", "number of audio channels", OFFSET(audio_channels), 
AV_OPT_TYPE_INT , { .i64 = 2   }, 2, 16, DEC },
+{ "autodetect_delay", "number of seconds to wait for autodetect to 
complete", OFFSET(autodetect_delay), AV_OPT_TYPE_INT , { .i64 = 5   }, 1, 30, 
DEC },
 { NULL },
 };
 
-- 
2.7.4



On 5/12/16, 3:21 PM, "ffmpeg-devel on behalf of Felt, Patrick" 
 wrote:

>-- Add input mode autodetect to the decklink module. Previously users had to 
>supply the input format like this 'DeckLink Device@modenum'.  This patch 
>allows users to either leave it off completely, or supply 0 or negative number 
>to indicate autodetect is requested. Autodetect only works the first time so 
>if the mode changes mid stream you'll die
>
>
>---
> libavdevice/decklink_common.cpp | 110 
> libavdevice/decklink_common.h   |   5 ++
> libavdevice/decklink_common_c.h |   1 +
> libavdevice/decklink_dec.cpp|  85 +--
> li

Re: [FFmpeg-devel] [PATCH] Updated -- Add input mode autodetect to the decklink module.

2016-05-12 Thread Felt, Patrick
_detect) {
+/* the user is wanting to auto detect the mode. we need to fake out 
the api and not start ffmpeg fully in this mode!*/
+ctx->auto_detect = 1;
+ctx->mode_num = 1; /* it is assumed that there is at least one mode 
supported on a decklink card. */
+
+if (ff_decklink_set_format(avctx, DIRECTION_IN, ctx->mode_num) < 0) {
+av_log(avctx, AV_LOG_ERROR, "Could not set mode %d\n", 
ctx->mode_num);
+goto error;
+}
 
-if (mode_num > 0) {
-if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
-av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", 
mode_num, fname);
+ctx->bmd_mode = ff_decklink_mode_to_bm(avctx, DIRECTION_IN, 
ctx->mode_num, NULL);
+result = ctx->dli->EnableVideoInput(ctx->bmd_mode,
+cctx->v210 ? bmdFormat10BitYUV : 
bmdFormat8BitYUV,
+bmdVideoInputFlagDefault | 
bmdVideoInputEnableFormatDetection);
+if (result != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not enable video in the 
pre-startup autodectect mode\n");
 goto error;
 }
+
+result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, 
bmdAudioSampleType16bitInteger, cctx->audio_channels);
+if (result != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not enable audio in the 
pre-startup autodetect mode\n");
+goto error;
+}
+
+result = decklink_start_input(avctx);
+if (result != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not start input in the 
pre-startup autodetect mode\n");
+goto error;
+}
+
+/* we need to give the auto detect code some time to figure out what 
mode we are really in */
+autodetect_delay = cctx->autodetect_delay;
+while (!ctx->video) {
+if (autodetect_delay--) {
+/* this could indicate we are in the right mode.  let's assume 
so */
+break;
+}
+/* sleep for 1 second */
+av_usleep(10);
+}
 }
 
-itermode->Release();
+/* regardless as to if we did autodetect or not, we should now be in a 
position to
+ * continue on as before with all the right setup to ensure we get the 
right mode */
+ctx->video = 1;
+if (ctx->mode_num > 0) {
+if (ff_decklink_set_format(avctx, DIRECTION_IN, ctx->mode_num) < 0) {
+av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", 
ctx->mode_num, fname);
+goto error;
+}
+}
 
 /* Setup streams. */
 st = avformat_new_stream(avctx, NULL);
@@ -618,6 +672,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
 
 return 0;
 
+
 error:
 
 ctx->dli->Release();
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 40c21a7..3f83f8f 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -36,6 +36,7 @@ static const AVOption options[] = {
 { "standard", NULL,   0,  
AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0,DEC, "teletext_lines"},
 { "all",  NULL,   0,  
AV_OPT_TYPE_CONST, { .i64 = 0x7LL}, 0, 0,DEC, "teletext_lines"},
 { "channels", "number of audio channels", OFFSET(audio_channels), 
AV_OPT_TYPE_INT , { .i64 = 2   }, 2, 16, DEC },
+{ "autodetect_delay", "number of seconds to wait for autodetect to 
complete", OFFSET(autodetect_delay), AV_OPT_TYPE_INT , { .i64 = 5   }, 1, 30, 
DEC },
 { NULL },
 };
 
-- 
2.7.4




On 5/12/16, 3:10 PM, "ffmpeg-devel on behalf of Felt, Patrick" 
 wrote:

>Ah…  I see a bug.  I should either be setting ctx->video in the if block or I 
>should be breaking instead of continuing.  Good catch!
>
> 
>On 5/12/16, 1:32 PM, "ffmpeg-devel on behalf of Matthias Hunstock" 
> wrote:
>
>>Am 12.05.2016 um 19:16 schrieb Felt, Patrick:
>>> +while (!ctx->video) {
>>> +if (autodetect_delay--) {
>>> +/* this could indicate we are in the right mode.  let's 
>>> assume so */
>>> +continue;
>>> +}
>>> +sleep(1);
>>> +}
>>
>>I don't get it. How does this loop sleep for autodetect_delay seconds? I
>>read it like "spin-loop for autodetect_delay times and then probe
>>ctx->video each second, possibly forever".
>>
>>
>>
>>___
>>ffmpeg-devel mailing list
>>ffmpeg-devel@ffmpeg.org
>>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] -- Add input mode autodetect to the decklink module.

2016-05-12 Thread Felt, Patrick
Ah…  I see a bug.  I should either be setting ctx->video in the if block or I 
should be breaking instead of continuing.  Good catch!

 
On 5/12/16, 1:32 PM, "ffmpeg-devel on behalf of Matthias Hunstock" 
 wrote:

>Am 12.05.2016 um 19:16 schrieb Felt, Patrick:
>> +while (!ctx->video) {
>> +if (autodetect_delay--) {
>> +/* this could indicate we are in the right mode.  let's 
>> assume so */
>> +continue;
>> +}
>> +sleep(1);
>> +}
>
>I don't get it. How does this loop sleep for autodetect_delay seconds? I
>read it like "spin-loop for autodetect_delay times and then probe
>ctx->video each second, possibly forever".
>
>
>
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] -- Add input mode autodetect to the decklink module.

2016-05-12 Thread Felt, Patrick
Ah.  Didn’t realize we had that.  Will do.

On 5/12/16, 1:37 PM, "ffmpeg-devel on behalf of Marton Balint" 
 wrote:

>
>
>On Thu, 12 May 2016, Matthias Hunstock wrote:
>
>> Am 12.05.2016 um 19:16 schrieb Felt, Patrick:
>>> +while (!ctx->video) {
>>> +if (autodetect_delay--) {
>>> +/* this could indicate we are in the right mode.  let's 
>>> assume so */
>>> +continue;
>>> +}
>>> +sleep(1);
>>> +}
>>
>> I don't get it. How does this loop sleep for autodetect_delay seconds? I
>> read it like "spin-loop for autodetect_delay times and then probe
>> ctx->video each second, possibly forever".
>>
>
>Also get rid of sleep and unistd.h, use av_usleep instead...
>
>Regards,
>Marton
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] -- Add input mode autodetect to the decklink module.

2016-05-12 Thread Felt, Patrick
Previously users had to supply the input format like this 'DeckLink 
Device@modenum'.  This patch allows users to either leave it off completely, or 
supply 0 or negative number to indicate autodetect is requested.
 Autodetect only works the first time so if the mode changes mid stream you'll 
die.

---
 libavdevice/decklink_common.cpp | 110 
 libavdevice/decklink_common.h   |   5 ++
 libavdevice/decklink_common_c.h |   1 +
 libavdevice/decklink_dec.cpp|  85 +--
 libavdevice/decklink_dec_c.c|   1 +
 5 files changed, 187 insertions(+), 15 deletions(-)

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index ac7964c..1d51294 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -98,6 +98,90 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, const 
char **displayName)
 return hr;
 }

+long ff_decklink_mode_to_bm(AVFormatContext *avctx,
+   decklink_direction_t direction,
+   int ffmpeg_mode,
+   IDeckLinkDisplayMode **mode)
+{
+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
+IDeckLinkDisplayModeIterator *itermode;
+IDeckLinkDisplayMode *internal_mode;
+
+int result=0;
+HRESULT res;
+
+if (direction == DIRECTION_IN) {
+res = ctx->dli->GetDisplayModeIterator (&itermode);
+} else {
+res = ctx->dlo->GetDisplayModeIterator (&itermode);
+}
+
+if (res != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
+return -1;
+}
+
+while (itermode->Next(&internal_mode) == S_OK) {
+if (++result == ffmpeg_mode) {
+break;
+}
+
+internal_mode->Release();
+}
+
+itermode->Release();
+if (internal_mode) {
+result = internal_mode->GetDisplayMode();
+if (mode) {
+*mode = internal_mode;
+} else {
+internal_mode->Release();
+}
+
+return result;
+}
+
+return 0;
+}
+
+int ff_decklink_mode_to_ffmpeg(AVFormatContext *avctx,
+   decklink_direction_t direction,
+   IDeckLinkDisplayMode **mode)
+{
+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
+IDeckLinkDisplayModeIterator *itermode;
+IDeckLinkDisplayMode *internal_mode;
+long bdm_mode_number = (*mode)->GetDisplayMode();
+int result=1, found=0;
+HRESULT res;
+
+if (direction == DIRECTION_IN) {
+res = ctx->dli->GetDisplayModeIterator (&itermode);
+} else {
+res = ctx->dlo->GetDisplayModeIterator (&itermode);
+}
+
+if (res != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not get the mode iterator\n");
+return -1;
+}
+
+while (itermode->Next(&internal_mode) == S_OK) {
+if (internal_mode->GetDisplayMode() == bdm_mode_number) {
+internal_mode->Release();
+found = 1;
+break;
+}
+internal_mode->Release();
+result++;
+}
+
+itermode->Release();
+return (found) ? result : -1;
+}
+
 int ff_decklink_set_format(AVFormatContext *avctx,
int width, int height,
int tb_num, int tb_den,
@@ -197,6 +281,29 @@ int ff_decklink_list_devices(AVFormatContext *avctx)
 return 0;
 }

+int ff_decklink_device_autodetect(AVFormatContext *avctx)
+{
+HRESULT res;
+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
+IDeckLinkAttributes *attrs = NULL;
+bool auto_detect;
+
+res = ctx->dl->QueryInterface(IID_IDeckLinkAttributes, (void**)&attrs);
+if (res != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Could not get decklink attributes\n");
+return -1;
+}
+
+res = attrs->GetFlag(BMDDeckLinkSupportsInputFormatDetection, 
&auto_detect);
+if (res != S_OK) {
+av_log(avctx, AV_LOG_ERROR, "Attribute fetch failed\n");
+return -1;
+}
+
+return (auto_detect) ? 1 : 0;
+}
+
 int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t 
direction)
 {
 struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
@@ -219,6 +326,9 @@ int ff_decklink_list_formats(AVFormatContext *avctx, 
decklink_direction_t direct

 av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n",
avctx->filename);
+if (ff_decklink_device_autodetect(avctx)) {
+av_log(avctx, AV_LOG_INFO, "\t-1\tAuto detection supported\n");
+}
 while (itermode->Next(&mode) == S_OK) {
 BMDTimeValue tb_num, tb_den;
 mode->GetFrameRate(&tb_num, &tb_den);
d

Re: [FFmpeg-devel] [PATCH] -- Convert decklink input module to use codecpar

2016-05-10 Thread Felt, Patrick
Bump




On 5/7/16, 10:02 PM, "ffmpeg-devel on behalf of Felt, Patrick" 
 wrote:

>This patch converts decklink input to use codecpar.  There are still a couple 
>of deprecated calls that I’m not sure what to do with.  They are both related 
>to some logic around AVCodecContext.coded_frame.   I couldn’t find anywhere 
>that really documented what that was, or where it was intended to move to.  I 
>left the warnings on.
>
>
>---
> libavdevice/decklink_dec.cpp | 50 +++-
> 1 file changed, 22 insertions(+), 28 deletions(-)
>
>diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
>index 9d7dc97..1c305f3 100644
>--- a/libavdevice/decklink_dec.cpp
>+++ b/libavdevice/decklink_dec.cpp
>@@ -249,9 +249,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
> // Handle Video Frame
> if (videoFrame) {
> AVPacket pkt;
>-AVCodecContext *c;
> av_init_packet(&pkt);
>-c = ctx->video_st->codec;
> if (ctx->frameCount % 25 == 0) {
> unsigned long long qsize = avpacket_queue_size(&ctx->queue);
> av_log(avctx, AV_LOG_DEBUG,
>@@ -354,7 +352,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
> }
> #endif
>
>-c->frame_number++;
> if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
> ++ctx->dropped;
> }
>@@ -362,14 +359,12 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
>
> // Handle Audio Frame
> if (audioFrame) {
>-AVCodecContext *c;
> AVPacket pkt;
> BMDTimeValue audio_pts;
> av_init_packet(&pkt);
>
>-c = ctx->audio_st->codec;
> //hack among hacks
>-pkt.size = audioFrame->GetSampleFrameCount() * 
>ctx->audio_st->codec->channels * (16 / 8);
>+pkt.size = audioFrame->GetSampleFrameCount() * 
>ctx->audio_st->codecpar->channels * (16 / 8);
> audioFrame->GetBytes(&audioFrameBytes);
> audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);
> pkt.pts = audio_pts / ctx->audio_st->time_base.num;
>@@ -386,7 +381,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
> pkt.stream_index = ctx->audio_st->index;
> pkt.data = (uint8_t *)audioFrameBytes;
>
>-c->frame_number++;
> if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
> ++ctx->dropped;
> }
>@@ -551,10 +545,10 @@ av_cold int ff_decklink_read_header(AVFormatContext 
>*avctx)
> av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
> goto error;
> }
>-st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
>-st->codec->codec_id= AV_CODEC_ID_PCM_S16LE;
>-st->codec->sample_rate = bmdAudioSampleRate48kHz;
>-st->codec->channels= cctx->audio_channels;
>+st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
>+st->codecpar->codec_id= AV_CODEC_ID_PCM_S16LE;
>+st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
>+st->codecpar->channels= cctx->audio_channels;
> avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */
> ctx->audio_st=st;
>
>@@ -563,21 +557,21 @@ av_cold int ff_decklink_read_header(AVFormatContext 
>*avctx)
> av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
> goto error;
> }
>-st->codec->codec_type  = AVMEDIA_TYPE_VIDEO;
>-st->codec->width   = ctx->bmd_width;
>-st->codec->height  = ctx->bmd_height;
>+st->codecpar->codec_type  = AVMEDIA_TYPE_VIDEO;
>+st->codecpar->width   = ctx->bmd_width;
>+st->codecpar->height  = ctx->bmd_height;
>
>-st->codec->time_base.den  = ctx->bmd_tb_den;
>-st->codec->time_base.num  = ctx->bmd_tb_num;
>-st->codec->bit_rate= av_image_get_buffer_size(st->codec->pix_fmt, 
>ctx->bmd_width, ctx->bmd_height, 1) * 1/av_q2d(st->codec->time_base) * 8;
>+st->time_base.den  = ctx->bmd_tb_den;
>+st->time_base.num  = ctx->bmd_tb_num;
>+st->codecpar->bit_rate= 
>av_image_get_buffer_size((AVPixelFormat)st->codecpar->format, ctx->bmd_width, 
>ctx->bmd_height, 1) * 1/av_q2d(st->time_base) * 8;
>
> if (cctx->v210) {
>-st->codec->codec_id= AV_CODEC_ID_V210;
>-st->codec->codec_tag   = MKTAG('V', '2', '1', '0');
>+st->co

[FFmpeg-devel] [PATCH] -- Convert decklink input module to use codecpar

2016-05-07 Thread Felt, Patrick
This patch converts decklink input to use codecpar.  There are still a couple 
of deprecated calls that I’m not sure what to do with.  They are both related 
to some logic around AVCodecContext.coded_frame.   I couldn’t find anywhere 
that really documented what that was, or where it was intended to move to.  I 
left the warnings on.


---
 libavdevice/decklink_dec.cpp | 50 +++-
 1 file changed, 22 insertions(+), 28 deletions(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 9d7dc97..1c305f3 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -249,9 +249,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 // Handle Video Frame
 if (videoFrame) {
 AVPacket pkt;
-AVCodecContext *c;
 av_init_packet(&pkt);
-c = ctx->video_st->codec;
 if (ctx->frameCount % 25 == 0) {
 unsigned long long qsize = avpacket_queue_size(&ctx->queue);
 av_log(avctx, AV_LOG_DEBUG,
@@ -354,7 +352,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 }
 #endif

-c->frame_number++;
 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
 ++ctx->dropped;
 }
@@ -362,14 +359,12 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(

 // Handle Audio Frame
 if (audioFrame) {
-AVCodecContext *c;
 AVPacket pkt;
 BMDTimeValue audio_pts;
 av_init_packet(&pkt);

-c = ctx->audio_st->codec;
 //hack among hacks
-pkt.size = audioFrame->GetSampleFrameCount() * 
ctx->audio_st->codec->channels * (16 / 8);
+pkt.size = audioFrame->GetSampleFrameCount() * 
ctx->audio_st->codecpar->channels * (16 / 8);
 audioFrame->GetBytes(&audioFrameBytes);
 audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);
 pkt.pts = audio_pts / ctx->audio_st->time_base.num;
@@ -386,7 +381,6 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 pkt.stream_index = ctx->audio_st->index;
 pkt.data = (uint8_t *)audioFrameBytes;

-c->frame_number++;
 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
 ++ctx->dropped;
 }
@@ -551,10 +545,10 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
 goto error;
 }
-st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-st->codec->codec_id= AV_CODEC_ID_PCM_S16LE;
-st->codec->sample_rate = bmdAudioSampleRate48kHz;
-st->codec->channels= cctx->audio_channels;
+st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id= AV_CODEC_ID_PCM_S16LE;
+st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
+st->codecpar->channels= cctx->audio_channels;
 avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */
 ctx->audio_st=st;

@@ -563,21 +557,21 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
 goto error;
 }
-st->codec->codec_type  = AVMEDIA_TYPE_VIDEO;
-st->codec->width   = ctx->bmd_width;
-st->codec->height  = ctx->bmd_height;
+st->codecpar->codec_type  = AVMEDIA_TYPE_VIDEO;
+st->codecpar->width   = ctx->bmd_width;
+st->codecpar->height  = ctx->bmd_height;

-st->codec->time_base.den  = ctx->bmd_tb_den;
-st->codec->time_base.num  = ctx->bmd_tb_num;
-st->codec->bit_rate= av_image_get_buffer_size(st->codec->pix_fmt, 
ctx->bmd_width, ctx->bmd_height, 1) * 1/av_q2d(st->codec->time_base) * 8;
+st->time_base.den  = ctx->bmd_tb_den;
+st->time_base.num  = ctx->bmd_tb_num;
+st->codecpar->bit_rate= 
av_image_get_buffer_size((AVPixelFormat)st->codecpar->format, ctx->bmd_width, 
ctx->bmd_height, 1) * 1/av_q2d(st->time_base) * 8;

 if (cctx->v210) {
-st->codec->codec_id= AV_CODEC_ID_V210;
-st->codec->codec_tag   = MKTAG('V', '2', '1', '0');
+st->codecpar->codec_id= AV_CODEC_ID_V210;
+st->codecpar->codec_tag   = MKTAG('V', '2', '1', '0');
 } else {
-st->codec->codec_id= AV_CODEC_ID_RAWVIDEO;
-st->codec->pix_fmt = AV_PIX_FMT_UYVY422;
-st->codec->codec_tag   = MKTAG('U', 'Y', 'V', 'Y');
+st->codecpar->codec_id= AV_CODEC_ID_RAWVIDEO;
+st->codecpar->format  = AV_PIX_FMT_UYVY422;
+st->codecpar->codec_tag   = MKTAG('U', 'Y', 'V', 'Y');
 }

 avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */
@@ -590,16 +584,16 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
 goto error;
 }
-st->codec->codec_type  = AVMEDIA_TYPE_SUBTITLE;
-st->codec->time_base.den  = ctx->bmd_tb_den;
-st->codec->time_base.num   

Re: [FFmpeg-devel] [Patch] Add input swap functionality to movie filter (src_movie.c)

2016-05-04 Thread Felt, Patrick
On 5/4/16, 9:12 AM, "ffmpeg-devel on behalf of Hendrik Leppkes" 
 wrote:


>On Wed, May 4, 2016 at 5:01 PM, Felt, Patrick  
>wrote:
>>>
>>>[...]
>>>> +/* libavfilter documentation says that filter init will be called only 
>>>> once.  ffmpeg calls the init twice to enable it to validate
>>>> + * the complex filtering has the right input and output pads. this allows 
>>>> us to bypass the first call if we've specified a stream
>>>> + * specifier string */
>>>> +static int initRun=0;
>>>> +static int uninitRun=0;
>>>
>>>You're not allowed to do this, it belongs in the local context.
>>
>> I did realize that there will be issues if I tried to load the filter twice. 
>>  It wouldn’t function as expected with the current solution.  The problem is 
>> that ffmpeg calls init twice with two different contexts so any values I set 
>> in the context are cleared on the second run.  Indeed, the uninit() function 
>> is called after the first round.  Named Pipes don’t like being opened and 
>> closed; the ffmpeg process on the other end terminates because the reader 
>> left and sent an EOF.  I need a reasonable way to prevent opening a pipe 
>> twice.
>>
>
>Global state is one of the things we will not allow under any
>circumstances, however.
>Its dangerous and usually a sign of trying to fix something on the
>wrong side of a problem.

Fair statement that I can fully understand (and get behind).  That said, should 
I look at trying to patch ffmpeg then?  I’m not sure the best place to fix this 
or the best way to even start tackling it.

>
>- Hendrik
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [Patch] Add input swap functionality to movie filter (src_movie.c)

2016-05-04 Thread Felt, Patrick





On 5/4/16, 5:52 AM, "ffmpeg-devel on behalf of Clément Bœsch" 
 wrote:

>On Wed, May 04, 2016 at 12:15:26AM +, Felt, Patrick wrote:
>> Afternoon all,
>>   I apologize if this isn’t right way to submit a patch.
>
>You're supposed to git commit and use git format-patch.

Mind throwing some pointers on where to read up on this?  As I said, I’m fairly 
green with git

>
>[...]
>> +/* libavfilter documentation says that filter init will be called only 
>> once.  ffmpeg calls the init twice to enable it to validate
>> + * the complex filtering has the right input and output pads. this allows 
>> us to bypass the first call if we've specified a stream
>> + * specifier string */
>> +static int initRun=0;
>> +static int uninitRun=0;
>
>You're not allowed to do this, it belongs in the local context.

I did realize that there will be issues if I tried to load the filter twice.  
It wouldn’t function as expected with the current solution.  The problem is 
that ffmpeg calls init twice with two different contexts so any values I set in 
the context are cleared on the second run.  Indeed, the uninit() function is 
called after the first round.  Named Pipes don’t like being opened and closed; 
the ffmpeg process on the other end terminates because the reader left and sent 
an EOF.  I need a reasonable way to prevent opening a pipe twice.

Breakpoint 1, movie_common_init (ctx=0x106bbdb ) at 
libavfilter/src_movie.c:216
216 {
(gdb) n
217 MovieContext *movie = ctx->priv;
(gdb)
218 AVInputFormat *iformat = NULL;
(gdb) p movie
$1 = (MovieContext *) 0x2413b80
(gdb) c
Breakpoint 1, movie_common_init (ctx=0x106bbdb ) at 
libavfilter/src_movie.c:216
216 {
(gdb) n
217 MovieContext *movie = ctx->priv;
(gdb)
218 AVInputFormat *iformat = NULL;
(gdb) p movie
$2 = (MovieContext *) 0x240e160





>
>> +
>>  typedef struct MovieStream {
>>  AVStream *st;
>>  AVCodecContext *codec_ctx;
>>  int done;
>> +int64_t lastPts;/* this is used exclusively by the reset code */
>> +int64_t basePts;/* idem */
>
>Here and many times below, keep the naming convention.

Good point, I did name my variables a bit differently. I’ll rename then.


>
>[...]
>
>-- 
>Clément B.
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [Patch] Add input swap functionality to movie filter (src_movie.c)

2016-05-03 Thread Felt, Patrick
Odd.  I know I’m not doing this right, I’m not versed in git yet, I’m stuck in 
oldschool land with svn and cvs ideals..

[administrator@dev ffmpeg]$ git pull
Already up-to-date.

[administrator@dev ffmpeg]$ git diff > ../src_movie.c.diff.new
[administrator@dev ffmpeg]$ rm libavfilter/src_movie.c
[administrator@dev ffmpeg]$ git checkout -- libavfilter/src_movie.c
[administrator@dev ffmpeg]$ patch -p1 < ../src_movie.c.diff.new
patching file libavfilter/src_movie.c
[administrator@dev ffmpeg]$


Maybe my email client snarfed it or something.  Let me attach as an attachment 
instead of trying include it in the body






On 5/3/16, 8:34 PM, "ffmpeg-devel on behalf of Michael Niedermayer" 
 wrote:

>On Wed, May 04, 2016 at 12:15:26AM +, Felt, Patrick wrote:
>> Afternoon all,
>>   I apologize if this isn’t right way to submit a patch. Attached is a patch 
>> for src_movie.c that modifies it to allow for one to use the 
>> process_command() infrastructure to swap the input file on the fly.  I’ve 
>> added a few options to the filter and exposed filename to the 
>> process_command subsystem.  Useful for live streaming and “changing the 
>> channel”.
>> 
>
>patch doest apply:
>
>Applying: Add input swap functionality to movie filter (src_movie.c)
>fatal: corrupt patch at line 8
>Repository lacks necessary blobs to fall back on 3-way merge.
>Cannot fall back to three-way merge.
>Patch failed at 0001 Add input swap functionality to movie filter (src_movie.c)
>When you have resolved this problem run "git am --resolved".
>If you would prefer to skip this patch, instead run "git am --skip".
>To restore the original branch and stop patching run "git am --abort".
>
>[...]
>-- 
>Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
>Everything should be made as simple as possible, but not simpler.
>-- Albert Einstein


src_movie.c.diff
Description: src_movie.c.diff
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [Patch] Add input swap functionality to movie filter (src_movie.c)

2016-05-03 Thread Felt, Patrick
Afternoon all,
  I apologize if this isn’t right way to submit a patch. Attached is a patch 
for src_movie.c that modifies it to allow for one to use the process_command() 
infrastructure to swap the input file on the fly.  I’ve added a few options to 
the filter and exposed filename to the process_command subsystem.  Useful for 
live streaming and “changing the channel”.


diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 0bdcad4..604d4f6 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -44,10 +44,18 @@
 #include "internal.h"
 #include "video.h"

+/* libavfilter documentation says that filter init will be called only once.  
ffmpeg calls the init twice to enable it to validate
+ * the complex filtering has the right input and output pads. this allows us 
to bypass the first call if we've specified a stream
+ * specifier string */
+static int initRun=0;
+static int uninitRun=0;
+
 typedef struct MovieStream {
 AVStream *st;
 AVCodecContext *codec_ctx;
 int done;
+int64_t lastPts;/* this is used exclusively by the reset code */
+int64_t basePts;/* idem */
 } MovieStream;

 typedef struct MovieContext {
@@ -68,6 +76,10 @@ typedef struct MovieContext {
 int max_stream_index; /**< max stream # actually used for output */
 MovieStream *st; /**< array of all streams, one per output */
 int *out_index; /**< stream number -> output number map, or -1 */
+
+int isInitialized; /* allows us to determine if we've initialized already 
so when we reset to a new file we don't try to allocate pads again */
+int ptsMode; /* determine how we handle pts when we reset to a new file */
+int restartMode; /* some stream types (eg: pipes) don't like being opened 
more than once.  see the note with the global statics */
 } MovieContext;

 #define OFFSET(x) offsetof(MovieContext, x)
@@ -84,6 +96,10 @@ static const AVOption movie_options[]= {
 { "streams",  "set streams", OFFSET(stream_specs), 
AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MAX, CHAR_MAX, FLAGS },
 { "s","set streams", OFFSET(stream_specs), 
AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MAX, CHAR_MAX, FLAGS },
 { "loop", "set loop count",  OFFSET(loop_count),   
AV_OPT_TYPE_INT,{.i64 =  1},  0,INT_MAX, FLAGS },
+{ "pts_mode", "set pts mode",OFFSET(ptsMode),  
AV_OPT_TYPE_INT,{.i64 =  1},  1,INT_MAX, FLAGS },
+{ "pm",   "set pts mode",OFFSET(ptsMode),  
AV_OPT_TYPE_INT,{.i64 =  1},  1,INT_MAX, FLAGS },
+{ "restart_mode", "set restart mode",OFFSET(restartMode),  
AV_OPT_TYPE_INT,{.i64 =  1},  0,INT_MAX, FLAGS },
+{ "rm",   "set restart mode",OFFSET(restartMode),  
AV_OPT_TYPE_INT,{.i64 =  1},  0,INT_MAX, FLAGS },
 { NULL },
 };

@@ -200,26 +216,35 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
 {
 MovieContext *movie = ctx->priv;
 AVInputFormat *iformat = NULL;
-int64_t timestamp;
-int nb_streams = 1, ret, i;
-char default_streams[16], *stream_specs, *spec, *cursor;
+int64_t timestamp, maxPts=0;
+int nb_streams = 1, ret, i, result=0;
+char *stream_specs = NULL, *spec, *cursor, *ptr;
 char name[16];
 AVStream *st;

 if (!movie->file_name) {
 av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
-return AVERROR(EINVAL);
+result = AVERROR(EINVAL);
+goto done;
 }

 movie->seek_point = movie->seek_point_d * 100 + 0.5;

-stream_specs = movie->stream_specs;
-if (!stream_specs) {
-snprintf(default_streams, sizeof(default_streams), "d%c%d",
+if (!movie->stream_specs) {
+/* we don't have a stream_spec specified by the user, let's default to 
either audio or video based on filter name */
+stream_specs = (char *)av_malloc(16);
+snprintf(stream_specs, 16, "d%c%d",
  !strcmp(ctx->filter->name, "amovie") ? 'a' : 'v',
  movie->stream_index);
-stream_specs = default_streams;
+} else {
+stream_specs = av_strdup(movie->stream_specs);
+}
+
+if (!stream_specs) {
+result = AVERROR(ENOMEM);
+goto done;
 }
+
 for (cursor = stream_specs; *cursor; cursor++)
 if (*cursor == '+')
 nb_streams++;
@@ -227,7 +252,42 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
 if (movie->loop_count != 1 && nb_streams != 1) {
 av_log(ctx, AV_LOG_ERROR,
"Loop with several streams is currently unsupported\n");
-return AVERROR_PATCHWELCOME;
+result = AVERROR_PATCHWELCOME;
+goto done;
+}
+
+/* if this is the first time we've ever gone through the init function, 
let's just fake the pad creation
+ * for what we'll end up doing long term */
+if ((movie->restartMode == 2) && (!initRun)) {
+i