Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace sub2video with subtitle frame filtering

2021-09-23 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Soft Works
> Sent: Thursday, 23 September 2021 08:51
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace
> sub2video with subtitle frame filtering
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of Andreas
> > Rheinhardt
> > Sent: Wednesday, 22 September 2021 06:07
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace
> > sub2video with subtitle frame filtering
> >
> > Soft Works:
> > > diff --git a/tests/ref/fate/sub2video b/tests/ref/fate/sub2video
> > > index 80abe9c905..b53c3d95ad 100644
> > > --- a/tests/ref/fate/sub2video
> > > +++ b/tests/ref/fate/sub2video
> > > @@ -10,7 +10,6 @@
> > >  0,  0,  0,1,   518400, 0x83c27b82
> > >  0,  1,  1,1,   518400, 0x4051c7f9
> > >  0,  2,  2,1,   518400, 0xfb00e17e
> > > -1, 499000, 499000,  496, 1015, 0x19e092d2
> > >  0,  3,  3,1,   518400, 0x192abb74
> > >  0,  4,  4,1,   518400, 0x4669a88b
> > >  0,  5,  5,1,   518400, 0xaababe00
> > > @@ -58,129 +57,86 @@
> > >  0, 47, 47,1,   518400, 0xde69683f
> > >  0, 48, 48,1,   518400, 0x7df08fba
> > >  0, 49, 49,1,   518400, 0xbab197ea
> > > -1,   15355000,   15355000,  4733000, 2094, 0x3c171425
> > >  0, 77, 77,1,   518400, 0x902285d9
> > >  0,100,100,1,   518400, 0xbab197ea
> > > -1,   48797000,   48797000,  256, 2480, 0x7c0edf21
> > >  0,244,244,1,   518400, 0x7a11c812
> > >  0,257,257,1,   518400, 0xbab197ea
> > > -1,   51433000,   51433000,  2366000, 3059, 0xc95b8a05
> > >  0,258,258,1,   518400, 0x34cdddee
> > >  0,269,269,1,   518400, 0xbab197ea
> > > -1,   5391,   5391,  2696000, 2095, 0x61bb15ed
> > >  0,270,270,1,   518400, 0x4db4ce51
> > >  0,283,283,1,   518400, 0xbab197ea
> > > -1,   56663000,   56663000,  1262000, 1013, 0xc9ae89b7
> > >  0,284,284,1,   518400, 0xe6bc0ea9
> > >  0,290,290,1,   518400, 0xbab197ea
> > > -1,   58014000,   58014000,  1661000,  969, 0xe01878f0
> > >  0,291,291,1,   518400, 0xa8643af7
> > >  0,298,298,1,   518400, 0xbab197ea
> > > -1,   67724000,   67724000,  1365000,  844, 0xe7db4fc1
> > >  0,339,339,1,   518400, 0xb1885c67
> > >  0,345,345,1,   518400, 0xbab197ea
> > > -1,   69175000,   69175000,  1558000,  802, 0xf48531ba
> > >  0,346,346,1,   518400, 0x378e3fd0
> > >  0,354,354,1,   518400, 0xbab197ea
> > > -1,   70819000,   70819000,  1865000, 1709, 0xb4d5a1bd
> > >  0,355,355,1,   518400, 0xa3782469
> > >  0,363,363,1,   518400, 0xbab197ea
> > > -1,   72762000,   72762000,  1968000, 2438, 0x99d7bc82
> > >  0,364,364,1,   518400, 0xba23a0d5
> > >  0,374,374,1,   518400, 0xbab197ea
> > > -1,   74806000,   74806000,  1831000, 2116, 0x96514097
> > >  0,375,375,1,   518400, 0x129de2f8
> > >  0,383,383,1,   518400, 0xbab197ea
> > > -1,   76716000,   76716000,  1262000, 1822, 0xefccc72e
> > >  0,384,384,1,   518400, 0x19772f0f
> > >  0,390,390,1,   518400, 0xbab197ea
> > > -1,   78051000,   78051000,  1524000,  987, 0x7b927a27
> > >  0,391,391,1,   518400, 0x56f54e73
> > >  0,398,398,1,   518400, 0xbab197ea
> > > -1,   79644000,   79644000,  2662000, 2956, 0x190778f7
> > >  0,399,399,1,   518400, 0x300b5247
> > > -1,   8238,   8238,  2764000, 3094, 0xc021b7d3
> > >  0,412,412,1,   518400, 0xbab197ea
> > >  0,413,413,1,   518400, 0x6fd028fa
> > >  0,426,426,1,   518400, 0xbab197ea
> > > -1,   85225000,   85225000,  2366000, 2585, 0x74d0048f
> > >  0,427,427,1,   518400, 0x01f80e9d
> > >  0,438,438,1,   518400, 0xbab197ea
> > > -1,   87652000,   87652000,  1831000,  634, 0x8832fda1
> > >  0,439,439,1,   518400, 0xb48d90c0
> > >  0,447,447,1,   518400, 0xbab197ea
> > > -1,   91531000,   91531000,  2332000, 2080, 0x97a1146f
> > >  0,458,458,1,   518400, 0xcb5a0173
> > >  0,469,469,1,   518400, 0xbab197ea
> > 

Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace sub2video with subtitle frame filtering

2021-09-23 Thread Nicolas George
Soft Works (12021-09-23):
> Given, that my implementations is supposed to be "not how it 
> works" and I would have "been going at it entirely wrong", this 
> must of course have happened by accidence - no matter how 
> minimal the probability. :-)

The fact that something works in the narrow test case that you designed
it for does not prove it works in all cases. Fact is your code breaks
assumptions that are fundamental to lavfi's working.

But as long as you express overt despise towards me, I will not spend
any time helping you figure it out.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace sub2video with subtitle frame filtering

2021-09-23 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Nicolas
> George
> Sent: Thursday, 23 September 2021 10:18
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace
> sub2video with subtitle frame filtering
> 
> Soft Works (12021-09-23):
> > Given, that my implementations is supposed to be "not how it
> > works" and I would have "been going at it entirely wrong", this
> > must of course have happened by accidence - no matter how
> > minimal the probability. :-)
> 
> The fact that something works in the narrow test case that you designed
> it for does not prove it works in all cases. Fact is your code breaks
> assumptions that are fundamental to lavfi's working.
> 
> But as long as you express overt despise towards me, I will not spend
> any time helping you figure it out.

Please don't. You have missed so many chances to reply something useful
at a technical level and provide proof of your self-assumed, 
self-praised and self-advertised expertise, that the only thing 
you have effectively proven is your own obsolescence in that matter.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 4/4] avfiler/framesync: Remove redundant setting of AVClass

2021-09-23 Thread Nicolas George
Andreas Rheinhardt (12021-09-19):
> Every filter exposing the framesync options via its child_next
> callback already calls framesync_preinit() in its preinit callback.
> So the filter is already preinited whenever its child_next is called.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/framesync.c | 5 -
>  libavfilter/framesync.h | 9 +++--
>  2 files changed, 3 insertions(+), 11 deletions(-)

That looks like a good change and you understand the logic of child
contexts better than me, so ok to both.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace sub2video with subtitle frame filtering

2021-09-23 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Nicolas
> George
> Sent: Thursday, 23 September 2021 10:18
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v8 07/13] fftools/ffmpeg: Replace
> sub2video with subtitle frame filtering
> 
> But as long as you express overt >> despise <<

I don't understand why you seem to be disappointed after you've been 
working so hard to earn it...

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 0/3] Detect field_order when probing MP4/H264

2021-09-23 Thread Nicolas Gaullier
>Envoyé : jeudi 16 septembre 2021 09:40
>
>>Nicolas Gaullier (3):
>>  avcodec/h264_parser: Set AVCodecContext.framerate
>>  avformat/utils: Use r_frame_rate in compute_frame_duration if 
>> codec_framerate is unknown
>>  avformat/mov: Set AVSTREAM_PARSE_HEADERS flag for H264
>
>Hello, I have received no feedback on this serie I posted last week.
>Could someone find some time for a review ?
>
>Thanks to you
>Nicolas
>(ngaullier@irc)

Ping ?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 3/5] avformat/matroskaenc: Write dvcC/dvvC block additional mapping

2021-09-23 Thread quietvoid


On 23/09/2021 01.33, Andreas Rheinhardt wrote:

diff --git a/libavformat/dovi_isom.h b/libavformat/dovi_isom.h
index 9d9a05bdb0..b58ab1bea0 100644
--- a/libavformat/dovi_isom.h
+++ b/libavformat/dovi_isom.h
@@ -23,7 +23,12 @@
  #define AVFORMAT_DOVI_ISOM_H
  
  #include "avformat.h"

+#include "libavutil/dovi_meta.h"
+
+#define ISOM_DVCC_DVVC_SIZE 24
  
  int ff_isom_parse_dvcc_dvvc(AVFormatContext *s, AVStream *st, const uint8_t *buf_ptr, uint64_t size);

+int ff_isom_put_dvcc_dvvc(AVFormatContext *s, uint8_t *out, int size, uint32_t 
*type,
+ AVDOVIDecoderConfigurationRecord *dovi);
  
  #endif /* AVFORMAT_DOVI_ISOM_H */

\ No newline at end of file
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 039f20988a..a54f7b5feb 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -54,6 +54,8 @@
  #include "libavcodec/xiph.h"
  #include "libavcodec/mpeg4audio.h"
  
+#include "libavformat/dovi_isom.h"

+
  /* Level 1 elements we create a SeekHead entry for:
   * Info, Tracks, Chapters, Attachments, Tags (potentially twice) and Cues */
  #define MAX_SEEKHEAD_ENTRIES 7
@@ -1115,6 +1117,33 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
AVIOContext *pb,
  return 0;
  }
  
+static int mkv_write_dovi(AVFormatContext *s, AVIOContext *pb, AVStream *st)

+{
+int ret;
+AVDOVIDecoderConfigurationRecord *dovi = (AVDOVIDecoderConfigurationRecord 
*)
+ av_stream_get_side_data(st, 
AV_PKT_DATA_DOVI_CONF, NULL);
+
+if (dovi) {
+ebml_master mapping;
+uint8_t buf[ISOM_DVCC_DVVC_SIZE];
+uint32_t type;
+int size;
+
+if ((ret = ff_isom_put_dvcc_dvvc(s, buf, sizeof(buf), &type, dovi)) < 
0)
+return ret;
+
+size = ret;
+
+mapping = start_ebml_master(pb, MATROSKA_ID_TRACKBLKADDMAPPING, 
ISOM_DVCC_DVVC_SIZE);

This is wrong: ISOM_DVCC_DVVC_SIZE need not be an upper bound for the
size of the blockgroup. (2 + 1 + strlen("Dolby Vision configuration")) +
(2 + 1 + 4) + (2 + 1 + ISOM_DVCC_DVVC_SIZE) is -- although I'd prefer if
you used sizeof("Dolby Vision configuration") - 1 instead of strlen.

Okay, I was confused on what you meant previously.
I have changed it to use this variable:
uint64_t expected_size = (2 + 1 + (sizeof("Dolby Vision configuration") 
- 1))
 + (2 + 1 + 4) + (2 + 1 + 
ISOM_DVCC_DVVC_SIZE);



+put_ebml_string(pb, MATROSKA_ID_BLKADDIDNAME, "Dolby Vision 
configuration");
+put_ebml_uint(pb, MATROSKA_ID_BLKADDIDTYPE, type);
+put_ebml_binary(pb, MATROSKA_ID_BLKADDIDEXTRADATA, buf, size);
+end_ebml_master(pb, mapping);
+}
+
+return 0;
+}
+
  static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
 AVStream *st, mkv_track *track, AVIOContext *pb,
 int is_default)
@@ -1380,6 +1409,9 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
  return AVERROR(EINVAL);
  }
  
+if ((ret = mkv_write_dovi(s, pb, st)) < 0)

+return ret;

Given that this is not part of WebM, there needs to be check for
mkv->mode != MODE_WEBM. Furthermore, this should also be moved to the
AVMEDIA_TYPE_VIDEO switch statement directly after the video master
element has been closed.


Corrected, thank you.


Is it OK to resend a new version or should I wait in case more
changes are necessary in the other patches?

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 0/3] Detect field_order when probing MP4/H264

2021-09-23 Thread James Almer

On 9/23/2021 7:54 AM, Nicolas Gaullier wrote:

Envoyé : jeudi 16 septembre 2021 09:40


Nicolas Gaullier (3):
  avcodec/h264_parser: Set AVCodecContext.framerate
  avformat/utils: Use r_frame_rate in compute_frame_duration if codec_framerate 
is unknown
  avformat/mov: Set AVSTREAM_PARSE_HEADERS flag for H264


Hello, I have received no feedback on this serie I posted last week.
Could someone find some time for a review ?

Thanks to you
Nicolas
(ngaullier@irc)


Ping ?


Sorry for the delay. Just applied it, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 6/6] avcodec/libsvtav1: support constant quality mode

2021-09-23 Thread Christopher Degawa
On Sun, Sep 19, 2021 at 2:02 PM Christopher Degawa 
wrote:

>
>
> On Fri, Sep 17, 2021 at 9:28 PM  wrote:
>
>> From: Limin Wang 
>>
>> Signed-off-by: Limin Wang 
>>
> As a note, I personally favor this patch over mine since I don't think
> `enable_tpl_la` is worth exposing to the user if its main role is to switch
> between crf and cqp
>

Ping on this patch, this has been requested on SVT-AV1's side as well
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 6/6] avcodec/libsvtav1: support constant quality mode

2021-09-23 Thread Jan Ekström
On Thu, Sep 23, 2021 at 4:46 PM Christopher Degawa  wrote:
>
> On Sun, Sep 19, 2021 at 2:02 PM Christopher Degawa 
> wrote:
>
> >
> >
> > On Fri, Sep 17, 2021 at 9:28 PM  wrote:
> >
> >> From: Limin Wang 
> >>
> >> Signed-off-by: Limin Wang 
> >>
> > As a note, I personally favor this patch over mine since I don't think
> > `enable_tpl_la` is worth exposing to the user if its main role is to switch
> > between crf and cqp
> >
>
> Ping on this patch, this has been requested on SVT-AV1's side as well

I think my further comments on the previous version were mostly to
move off from the rc option for rate control, which has become more
and more seemingly unnecessary (and different from most other encoders
for no obvious reason).

The only option that with a quick look doesn't match just setting
quantizer|bit rate|CRF is "cvbr", but it doesn't seem to be impossible
to either rework "rc" for it, or to utilize a separate option for it.

Basically the idea is to get it more or less to match other encoders,
so that the wrapper doesn't feel completely alien to the rest of
things.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 01/27] avformat/astenc: Simplify writing padding

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/astenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index cf75b48b21..a5792e0b07 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -118,9 +118,7 @@ static int ast_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_wb32(pb, size); /* Block size */
 
 /* padding */
-avio_wb64(pb, 0);
-avio_wb64(pb, 0);
-avio_wb64(pb, 0);
+ffio_fill(pb, 0, 24);
 
 avio_write(pb, pkt->data, pkt->size);
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 6/6] avcodec/libsvtav1: support constant quality mode

2021-09-23 Thread lance . lmwang
On Thu, Sep 23, 2021 at 05:11:49PM +0300, Jan Ekström wrote:
> On Thu, Sep 23, 2021 at 4:46 PM Christopher Degawa  
> wrote:
> >
> > On Sun, Sep 19, 2021 at 2:02 PM Christopher Degawa 
> > wrote:
> >
> > >
> > >
> > > On Fri, Sep 17, 2021 at 9:28 PM  wrote:
> > >
> > >> From: Limin Wang 
> > >>
> > >> Signed-off-by: Limin Wang 
> > >>
> > > As a note, I personally favor this patch over mine since I don't think
> > > `enable_tpl_la` is worth exposing to the user if its main role is to 
> > > switch
> > > between crf and cqp
> > >
> >
> > Ping on this patch, this has been requested on SVT-AV1's side as well
> 
> I think my further comments on the previous version were mostly to
> move off from the rc option for rate control, which has become more
> and more seemingly unnecessary (and different from most other encoders
> for no obvious reason).
> 
> The only option that with a quick look doesn't match just setting
> quantizer|bit rate|CRF is "cvbr", but it doesn't seem to be impossible
> to either rework "rc" for it, or to utilize a separate option for it.

Do you think it's OK to remove the rc option? to match other encoders, 
We can choose the rate control by the related parameters like:

if (crf >= 0)
choose crf rate control;
else if (bitrate > 0)
choose cvbr rate control;
else if (cqp >=0 )
choose cqp rate control;

> 
> Basically the idea is to get it more or less to match other encoders,
> so that the wrapper doesn't feel completely alien to the rest of
> things.
> 
> Jan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 01/27] avformat/astenc: Simplify writing padding

2021-09-23 Thread James Almer

On 9/23/2021 12:06 PM, Andreas Rheinhardt wrote:

Signed-off-by: Andreas Rheinhardt 
---
  libavformat/astenc.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index cf75b48b21..a5792e0b07 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -118,9 +118,7 @@ static int ast_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  avio_wb32(pb, size); /* Block size */
  
  /* padding */

-avio_wb64(pb, 0);
-avio_wb64(pb, 0);
-avio_wb64(pb, 0);
+ffio_fill(pb, 0, 24);


Should be ok.

  
  avio_write(pb, pkt->data, pkt->size);
  



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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 02/27] avformat/chromaprint: Add deinit function

2021-09-23 Thread Andreas Rheinhardt
Fixes memleaks in case the trailer is never written.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/chromaprint.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index 399de725d3..b7a943e126 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -47,8 +47,10 @@ typedef struct ChromaprintMuxContext {
 #endif
 } ChromaprintMuxContext;
 
-static void cleanup(ChromaprintMuxContext *cpr)
+static void deinit(AVFormatContext *s)
 {
+ChromaprintMuxContext *const cpr = s->priv_data;
+
 if (cpr->ctx) {
 ff_lock_avformat();
 chromaprint_free(cpr->ctx);
@@ -107,7 +109,6 @@ static int write_header(AVFormatContext *s)
 
 return 0;
 fail:
-cleanup(cpr);
 return AVERROR(EINVAL);
 }
 
@@ -156,7 +157,6 @@ fail:
 chromaprint_dealloc(fp);
 if (enc_fp)
 chromaprint_dealloc(enc_fp);
-cleanup(cpr);
 return ret;
 }
 
@@ -187,6 +187,7 @@ const AVOutputFormat ff_chromaprint_muxer = {
 .write_header  = write_header,
 .write_packet  = write_packet,
 .write_trailer = write_trailer,
+.deinit= deinit,
 .flags = AVFMT_NOTIMESTAMPS,
 .priv_class= &chromaprint_class,
 };
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 03/27] avformat/chromaprint: Improve returned error codes

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/chromaprint.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index b7a943e126..e4882c8e61 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -69,47 +69,45 @@ static int write_header(AVFormatContext *s)
 
 if (!cpr->ctx) {
 av_log(s, AV_LOG_ERROR, "Failed to create chromaprint context.\n");
-return AVERROR(ENOMEM);
+return AVERROR_EXTERNAL;
 }
 
 if (cpr->silence_threshold != -1) {
 #if CPR_VERSION_INT >= AV_VERSION_INT(0, 7, 0)
 if (!chromaprint_set_option(cpr->ctx, "silence_threshold", 
cpr->silence_threshold)) {
 av_log(s, AV_LOG_ERROR, "Failed to set silence threshold. Setting 
silence_threshold requires -algorithm 3 option.\n");
-goto fail;
+return AVERROR_EXTERNAL;
 }
 #else
 av_log(s, AV_LOG_ERROR, "Setting the silence threshold requires 
Chromaprint "
 "version 0.7.0 or later.\n");
-goto fail;
+return AVERROR(ENOSYS);
 #endif
 }
 
 if (s->nb_streams != 1) {
 av_log(s, AV_LOG_ERROR, "Only one stream is supported\n");
-goto fail;
+return AVERROR(EINVAL);
 }
 
 st = s->streams[0];
 
 if (st->codecpar->channels > 2) {
 av_log(s, AV_LOG_ERROR, "Only up to 2 channels are supported\n");
-goto fail;
+return AVERROR(EINVAL);
 }
 
 if (st->codecpar->sample_rate < 1000) {
 av_log(s, AV_LOG_ERROR, "Sampling rate must be at least 1000\n");
-goto fail;
+return AVERROR(EINVAL);
 }
 
 if (!chromaprint_start(cpr->ctx, st->codecpar->sample_rate, 
st->codecpar->channels)) {
 av_log(s, AV_LOG_ERROR, "Failed to start chromaprint\n");
-goto fail;
+return AVERROR_EXTERNAL;
 }
 
 return 0;
-fail:
-return AVERROR(EINVAL);
 }
 
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
@@ -124,7 +122,7 @@ static int write_trailer(AVFormatContext *s)
 AVIOContext *pb = s->pb;
 void *fp = NULL;
 char *enc_fp = NULL;
-int size, enc_size, ret = AVERROR(EINVAL);
+int size, enc_size, ret = AVERROR_EXTERNAL;
 
 if (!chromaprint_finish(cpr->ctx)) {
 av_log(s, AV_LOG_ERROR, "Failed to generate fingerprint\n");
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 04/27] avformat/filmstripenc: Simplify writing reserved elements

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/filmstripenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c
index 48f483bc90..ebb7294175 100644
--- a/libavformat/filmstripenc.c
+++ b/libavformat/filmstripenc.c
@@ -26,6 +26,7 @@
 
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "rawenc.h"
 
 #define RAND_TAG MKBETAG('R','a','n','d')
@@ -43,7 +44,6 @@ static int write_trailer(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 AVStream *st = s->streams[0];
-int i;
 
 avio_wb32(pb, RAND_TAG);
 avio_wb32(pb, st->nb_frames);
@@ -54,8 +54,7 @@ static int write_trailer(AVFormatContext *s)
 avio_wb16(pb, 0);  // leading
 // TODO: should be avg_frame_rate
 avio_wb16(pb, st->time_base.den / st->time_base.num);
-for (i = 0; i < 16; i++)
-avio_w8(pb, 0x00);  // reserved
+ffio_fill(pb, 0x00, 16);  // reserved
 
 return 0;
 }
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 05/27] avfilter/audio, video: Remove references to avfilter_unref_buffer()

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/audio.h | 3 +--
 libavfilter/video.h | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavfilter/audio.h b/libavfilter/audio.h
index 6bbe6ee9ef..90709a0ad0 100644
--- a/libavfilter/audio.h
+++ b/libavfilter/audio.h
@@ -37,8 +37,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int 
nb_samples);
  * @param link   the output link to the filter from which the buffer 
will
  *   be requested
  * @param nb_samples the number of samples per channel
- * @return   A reference to the samples. This must be unreferenced 
with
- *   avfilter_unref_buffer when you are finished with it.
+ * @return   on success an AVFrame owned by the caller, NULL on 
error
  */
 AVFrame *ff_get_audio_buffer(AVFilterLink *link, int nb_samples);
 
diff --git a/libavfilter/video.h b/libavfilter/video.h
index 56c58d6766..f448e4ada4 100644
--- a/libavfilter/video.h
+++ b/libavfilter/video.h
@@ -33,8 +33,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, 
int h);
  *  be requested
  * @param w the minimum width of the buffer to allocate
  * @param h the minimum height of the buffer to allocate
- * @return  A reference to the buffer. This must be unreferenced with
- *  avfilter_unref_buffer when you are finished with it.
+ * @return  on success, an AVFrame owned by the caller, NULL on error
  */
 AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h);
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 06/27] fate/demux: Move caf test to its own file

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 tests/Makefile| 1 +
 tests/fate/caf.mak| 5 +
 tests/fate/demux.mak  | 3 ---
 tests/ref/fate/{caf => caf-demux} | 0
 4 files changed, 6 insertions(+), 3 deletions(-)
 create mode 100644 tests/fate/caf.mak
 rename tests/ref/fate/{caf => caf-demux} (100%)

diff --git a/tests/Makefile b/tests/Makefile
index e42e66d81b..d5595908b8 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -121,6 +121,7 @@ include $(SRC_PATH)/tests/fate/atrac.mak
 include $(SRC_PATH)/tests/fate/audio.mak
 include $(SRC_PATH)/tests/fate/bmp.mak
 include $(SRC_PATH)/tests/fate/build.mak
+include $(SRC_PATH)/tests/fate/caf.mak
 include $(SRC_PATH)/tests/fate/canopus.mak
 include $(SRC_PATH)/tests/fate/cbs.mak
 include $(SRC_PATH)/tests/fate/cdxl.mak
diff --git a/tests/fate/caf.mak b/tests/fate/caf.mak
new file mode 100644
index 00..e921fcc297
--- /dev/null
+++ b/tests/fate/caf.mak
@@ -0,0 +1,5 @@
+FATE_CAF_FFMPEG-$(call ALLYES, CAF_DEMUXER CRC_MUXER) += fate-caf-demux
+fate-caf-demux: CMD = crc -i $(TARGET_SAMPLES)/caf/caf-pcm16.caf -c copy
+
+FATE_SAMPLES_FFMPEG += $(FATE_CAF_FFMPEG-yes)
+fate-caf: $(FATE_CAF_FFMPEG-yes)
diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index 6ddbbcbd4d..20aa90427b 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -29,9 +29,6 @@ fate-bcstm: CMD = crc -i 
$(TARGET_SAMPLES)/bfstm/loz-mm-mikau.bcstm -c:a copy
 FATE_SAMPLES_DEMUX-$(CONFIG_BRSTM_DEMUXER) += fate-brstm
 fate-brstm: CMD = crc -i $(TARGET_SAMPLES)/brstm/lozswd_partial.brstm -c:a copy
 
-FATE_SAMPLES_DEMUX-$(CONFIG_CAF_DEMUXER) += fate-caf
-fate-caf: CMD = crc -i $(TARGET_SAMPLES)/caf/caf-pcm16.caf -c copy
-
 FATE_SAMPLES_DEMUX-$(CONFIG_CDXL_DEMUXER) += fate-cdxl-demux
 fate-cdxl-demux: CMD = framecrc -i $(TARGET_SAMPLES)/cdxl/mirage.cdxl -c:v 
copy -c:a copy
 
diff --git a/tests/ref/fate/caf b/tests/ref/fate/caf-demux
similarity index 100%
rename from tests/ref/fate/caf
rename to tests/ref/fate/caf-demux
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 07/27] fate/caf: Add remux tests

2021-09-23 Thread Andreas Rheinhardt
These test both the muxer as well as the demuxer.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/caf.mak | 30 +-
 tests/ref/fate/caf-alac-remux  | 28 
 tests/ref/fate/caf-amr_nb-remux| 19 +++
 tests/ref/fate/caf-mace6-remux | 20 
 tests/ref/fate/caf-pcm_s24-remux   | 23 +++
 tests/ref/fate/caf-pcm_s24le-remux | 23 +++
 tests/ref/fate/caf-qdm2-remux  | 12 
 7 files changed, 154 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/caf-alac-remux
 create mode 100644 tests/ref/fate/caf-amr_nb-remux
 create mode 100644 tests/ref/fate/caf-mace6-remux
 create mode 100644 tests/ref/fate/caf-pcm_s24-remux
 create mode 100644 tests/ref/fate/caf-pcm_s24le-remux
 create mode 100644 tests/ref/fate/caf-qdm2-remux

diff --git a/tests/fate/caf.mak b/tests/fate/caf.mak
index e921fcc297..581128c670 100644
--- a/tests/fate/caf.mak
+++ b/tests/fate/caf.mak
@@ -1,5 +1,33 @@
 FATE_CAF_FFMPEG-$(call ALLYES, CAF_DEMUXER CRC_MUXER) += fate-caf-demux
 fate-caf-demux: CMD = crc -i $(TARGET_SAMPLES)/caf/caf-pcm16.caf -c copy
 
+FATE_CAF_REMUX_FFPROBE-$(CONFIG_MOV_DEMUXER) += fate-caf-alac-remux
+fate-caf-alac-remux: CMD = transcode m4a 
$(TARGET_SAMPLES)/lossless-audio/inside.m4a caf "-map 0:a -c copy" "-c copy -t 
0.2" "" "-show_entries format_tags"
+
+FATE_CAF_REMUX-$(CONFIG_AMR_DEMUXER) += fate-caf-amr_nb-remux
+fate-caf-amr_nb-remux: CMD = transcode amr $(TARGET_SAMPLES)/amrnb/4.75k.amr 
caf "-c copy" "-c copy -t 0.2"
+
+FATE_CAF_REMUX-$(CONFIG_MOV_DEMUXER) += fate-caf-qdm2-remux
+fate-caf-qdm2-remux: CMD = transcode mov 
$(TARGET_SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.mov caf "-c copy" "-c copy 
-t 0.2"
+
+FATE_CAF_REMUX-$(CONFIG_WAV_DEMUXER) += fate-caf-pcm_s24le-remux
+fate-caf-pcm_s24le-remux: CMD = transcode wav 
$(TARGET_SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav caf "-c copy" 
"-c copy -t 0.05"
+
+FATE_CAF_REMUX-$(call ALLYES, WAV_DEMUXER PCM_S24LE_DECODER \
+  PCM_S24BE_ENCODER)\
+  += fate-caf-pcm_s24-remux
+fate-caf-pcm_s24-remux: CMD = transcode wav 
$(TARGET_SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav caf "-c 
pcm_s24be" "-c copy -t 0.05"
+
+FATE_CAF_REMUX-$(CONFIG_MOV_DEMUXER) += fate-caf-mace6-remux
+fate-caf-mace6-remux: CMD = transcode mov 
$(TARGET_SAMPLES)/qtrle/Animation-16Greys.mov caf "-map 0:a -c copy" "-c copy 
-t 0.003"
+
+FATE_CAF_FFMPEG-$(call ALLYES, FILE_PROTOCOL CAF_MUXER CAF_DEMUXER \
+   FRAMECRC_MUXER PIPE_PROTOCOL)   \
+   += $(FATE_CAF_REMUX-yes)
+FATE_CAF_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL CAF_MUXER\
+   CAF_DEMUXER FRAMECRC_MUXER \
+   PIPE_PROTOCOL) \
+  += $(FATE_CAF_REMUX_FFPROBE-yes)
 FATE_SAMPLES_FFMPEG += $(FATE_CAF_FFMPEG-yes)
-fate-caf: $(FATE_CAF_FFMPEG-yes)
+FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_CAF_FFMPEG_FFPROBE-yes)
+fate-caf: $(FATE_CAF_FFMPEG-yes) $(FATE_CAF_FFMPEG_FFPROBE-yes)
diff --git a/tests/ref/fate/caf-alac-remux b/tests/ref/fate/caf-alac-remux
new file mode 100644
index 00..5c1b2d1eee
--- /dev/null
+++ b/tests/ref/fate/caf-alac-remux
@@ -0,0 +1,28 @@
+e0a94c78e9680398adce2ac72d682f48 *tests/data/fate/caf-alac-remux.caf
+1292701 tests/data/fate/caf-alac-remux.caf
+#extradata 0:   36, 0x562b05d8
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: alac
+#sample_rate 0: 44100
+#channel_layout 0: 3
+#channel_layout_name 0: stereo
+0,  0,  0,0,   32, 0xa0af0dfe
+0,   4096,   4096,0, 6701, 0xa9ddc14e
+0,   8192,   8192,0, 6639, 0x3ccda8d6
+[FORMAT]
+TAG:major_brand=M4A 
+TAG:minor_version=0
+TAG:compatible_brands=M4A mp42isom
+TAG:disc=1
+TAG:title=Inside
+TAG:compilation=1
+TAG:gapless_playback=0
+TAG:track=5/13
+TAG:Encoding Params=vers
+TAG:iTunNORM= 04DF 04C2 1E64 1AB3 0FB9 0FB9 6480 
6480 0FB9 0B52
+TAG:artist=Maxwell Strait
+TAG:album_artist=Maxwell Strait
+TAG:album=OpenMusic
+TAG:genre=Rock
+[/FORMAT]
diff --git a/tests/ref/fate/caf-amr_nb-remux b/tests/ref/fate/caf-amr_nb-remux
new file mode 100644
index 00..0eed36a5cb
--- /dev/null
+++ b/tests/ref/fate/caf-amr_nb-remux
@@ -0,0 +1,19 @@
+a00bd18f70b66286e67d84f0df034a48 *tests/data/fate/caf-amr_nb-remux.caf
+4145 tests/data/fate/caf-amr_nb-remux.caf
+#extradata 0:   29, 0x6b3407d3
+#tb 0: 1/8000
+#media_type 0: audio
+#codec_id 0: amr_nb
+#sample_rate 0: 8000
+#channel_layout 0: 4
+#channel_layout_name 0: mono
+0,  0,  0,  160,   13, 0x2bf906f6
+0,160,160,  160,   13, 0x28bd0756
+0,320,320,  160,   13, 0x2b2706f7
+0,480,480,

[FFmpeg-devel] [PATCH 08/27] avformat/cafenc: Fix potential integer overflow

2021-09-23 Thread Andreas Rheinhardt
(As long as avio_write() only accepts an int, it makes no sense
to try to support sizes that don't fit into an int.)

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/cafenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 816e978945..622ae14264 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -213,7 +213,7 @@ static int caf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_write(s->pb, pkt->data, pkt->size);
 if (!s->streams[0]->codecpar->block_align) {
 void *pkt_sizes = caf->pkt_sizes;
-int i, alloc_size = caf->size_entries_used + 5;
+int i, alloc_size = caf->size_entries_used + 5U;
 if (alloc_size < 0) {
 caf->pkt_sizes = NULL;
 } else {
@@ -257,7 +257,7 @@ static int caf_write_trailer(AVFormatContext *s)
 }
 avio_seek(pb, file_size, SEEK_SET);
 ffio_wfourcc(pb, "pakt");
-avio_wb64(pb, caf->size_entries_used + 24);
+avio_wb64(pb, caf->size_entries_used + 24U);
 avio_wb64(pb, caf->packets); ///< mNumberPackets
 avio_wb64(pb, caf->packets * packet_size); ///< mNumberValidFrames
 avio_wb32(pb, 0); ///< mPrimingFrames
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 09/27] avformat/cafenc: Don't segfault upon allocation error

2021-09-23 Thread Andreas Rheinhardt
If an array for the packet sizes could not be successfully reallocated
when writing a packet, the CAF muxer frees said array, but does not
reset the number of valid bytes. As a result, when the trailer is
written later, avio_write tries to read that many bytes from NULL,
which segfaults.

Fix this by not freeing the array in case of error; also, postpone
writing the packet data after having successfully (re)allocated the
array, so that even on allocation error the file can be correctly
finalized.

Also remove an unnecessary resetting of the number of size entries
used at the end.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/cafenc.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 622ae14264..b17d2397e9 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -210,21 +210,18 @@ static int caf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 {
 CAFContext *caf = s->priv_data;
 
-avio_write(s->pb, pkt->data, pkt->size);
 if (!s->streams[0]->codecpar->block_align) {
-void *pkt_sizes = caf->pkt_sizes;
+void *pkt_sizes;
 int i, alloc_size = caf->size_entries_used + 5U;
-if (alloc_size < 0) {
-caf->pkt_sizes = NULL;
-} else {
-caf->pkt_sizes = av_fast_realloc(caf->pkt_sizes,
- &caf->size_buffer_size,
- alloc_size);
-}
-if (!caf->pkt_sizes) {
-av_free(pkt_sizes);
+if (alloc_size < 0)
+return AVERROR(ERANGE);
+
+pkt_sizes = av_fast_realloc(caf->pkt_sizes,
+&caf->size_buffer_size,
+alloc_size);
+if (!pkt_sizes)
 return AVERROR(ENOMEM);
-}
+caf->pkt_sizes = pkt_sizes;
 for (i = 4; i > 0; i--) {
 unsigned top = pkt->size >> i * 7;
 if (top)
@@ -233,6 +230,7 @@ static int caf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 caf->pkt_sizes[caf->size_entries_used++] = pkt->size & 127;
 caf->packets++;
 }
+avio_write(s->pb, pkt->data, pkt->size);
 return 0;
 }
 
@@ -263,7 +261,6 @@ static int caf_write_trailer(AVFormatContext *s)
 avio_wb32(pb, 0); ///< mPrimingFrames
 avio_wb32(pb, 0); ///< mRemainderFrames
 avio_write(pb, caf->pkt_sizes, caf->size_entries_used);
-caf->size_buffer_size = 0;
 }
 }
 av_freep(&caf->pkt_sizes);
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 10/27] avformat/cafenc: Fix memleak when trailer is never written

2021-09-23 Thread Andreas Rheinhardt
Do this by using the AVStream's priv_data for the buffer holding
the packet size data.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/cafenc.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index b17d2397e9..412b3230e3 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -30,7 +30,6 @@
 
 typedef struct {
 int64_t data;
-uint8_t *pkt_sizes;
 int size_buffer_size;
 int size_entries_used;
 int packets;
@@ -209,25 +208,26 @@ static int caf_write_header(AVFormatContext *s)
 static int caf_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 CAFContext *caf = s->priv_data;
+AVStream *const st = s->streams[0];
 
-if (!s->streams[0]->codecpar->block_align) {
-void *pkt_sizes;
+if (!st->codecpar->block_align) {
+uint8_t *pkt_sizes;
 int i, alloc_size = caf->size_entries_used + 5U;
 if (alloc_size < 0)
 return AVERROR(ERANGE);
 
-pkt_sizes = av_fast_realloc(caf->pkt_sizes,
+pkt_sizes = av_fast_realloc(st->priv_data,
 &caf->size_buffer_size,
 alloc_size);
 if (!pkt_sizes)
 return AVERROR(ENOMEM);
-caf->pkt_sizes = pkt_sizes;
+st->priv_data = pkt_sizes;
 for (i = 4; i > 0; i--) {
 unsigned top = pkt->size >> i * 7;
 if (top)
-caf->pkt_sizes[caf->size_entries_used++] = 128 | top;
+pkt_sizes[caf->size_entries_used++] = 128 | top;
 }
-caf->pkt_sizes[caf->size_entries_used++] = pkt->size & 127;
+pkt_sizes[caf->size_entries_used++] = pkt->size & 127;
 caf->packets++;
 }
 avio_write(s->pb, pkt->data, pkt->size);
@@ -260,10 +260,9 @@ static int caf_write_trailer(AVFormatContext *s)
 avio_wb64(pb, caf->packets * packet_size); ///< mNumberValidFrames
 avio_wb32(pb, 0); ///< mPrimingFrames
 avio_wb32(pb, 0); ///< mRemainderFrames
-avio_write(pb, caf->pkt_sizes, caf->size_entries_used);
+avio_write(pb, st->priv_data, caf->size_entries_used);
 }
 }
-av_freep(&caf->pkt_sizes);
 return 0;
 }
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 11/27] avformat/icoenc: Simplify writing bitmask

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
I am pretty certain that the size of said bitmask should
be (par->height * par->width + 7) / 8 (or maybe
par->height * ((par->width + 7) / 8)), but not what it is now.

 libavformat/icoenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index ee793137fd..21966f3921 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -31,6 +31,7 @@
 #include "libavcodec/codec_id.h"
 
 #include "avformat.h"
+#include "avio_internal.h"
 
 typedef struct {
 int offset;
@@ -119,7 +120,6 @@ static int ico_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 IcoImage *image;
 AVIOContext *pb = s->pb;
 AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
-int i;
 
 if (ico->current_image >= ico->nb_images) {
 av_log(s, AV_LOG_ERROR, "ICO already contains %d images\n", 
ico->current_image);
@@ -150,8 +150,8 @@ static int ico_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_wl32(pb, AV_RL32(pkt->data + 22) * 2); // rewrite height as 2 * 
height
 avio_write(pb, pkt->data + 26, pkt->size - 26);
 
-for (i = 0; i < par->height * (par->width + 7) / 8; ++i)
-avio_w8(pb, 0x00); // Write bitmask (opaque)
+// Write bitmask (opaque)
+ffio_fill(pb, 0x00, par->height * (par->width + 7) / 8);
 }
 
 return 0;
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 12/27] avformat/icoenc: Use avcodec_get_name() instead of codec descriptor

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/icoenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index 21966f3921..d684f67707 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -27,7 +27,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/pixdesc.h"
 
-#include "libavcodec/codec_desc.h"
 #include "libavcodec/codec_id.h"
 
 #include "avformat.h"
@@ -66,8 +65,7 @@ static int ico_check_attributes(AVFormatContext *s, const 
AVCodecParameters *p)
 return AVERROR(EINVAL);
 }
 } else {
-const AVCodecDescriptor *codesc = avcodec_descriptor_get(p->codec_id);
-av_log(s, AV_LOG_ERROR, "Unsupported codec %s\n", codesc ? 
codesc->name : "");
+av_log(s, AV_LOG_ERROR, "Unsupported codec %s\n", 
avcodec_get_name(p->codec_id));
 return AVERROR(EINVAL);
 }
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 13/27] avformat/movenc: Limit ism_lookahead to a sane value

2021-09-23 Thread Andreas Rheinhardt
There can only be a maximum of 255 entries in a tfrf tag, so using
more makes no sense; moreover, several size computations can overflow
in this case. Fix this by limiting it to 255.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index cfb5a5c725..53c8ffadd5 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -94,7 +94,7 @@ static const AVOption options[] = {
 { "frag_duration", "Maximum fragment duration", offsetof(MOVMuxContext, 
max_fragment_duration), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM},
 { "min_frag_duration", "Minimum fragment duration", 
offsetof(MOVMuxContext, min_fragment_duration), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
 { "frag_size", "Maximum fragment size", offsetof(MOVMuxContext, 
max_fragment_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM},
-{ "ism_lookahead", "Number of lookahead entries for ISM files", 
offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
+{ "ism_lookahead", "Number of lookahead entries for ISM files", 
offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 255, 
AV_OPT_FLAG_ENCODING_PARAM},
 { "video_track_timescale", "set timescale of all video tracks", 
offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
 { "brand","Override major brand", offsetof(MOVMuxContext, 
major_brand),   AV_OPT_TYPE_STRING, {.str = NULL}, .flags = 
AV_OPT_FLAG_ENCODING_PARAM },
 { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), 
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM},
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 14/27] avformat/movenc: Simplify reserving space for tfrf tags

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenc.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 53c8ffadd5..7650ac5ed3 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1344,7 +1344,6 @@ static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack 
*track)
 /* also used by all avid codecs (dv, imx, meridien) and their variants */
 static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
 {
-int i;
 int interlaced;
 int cid;
 int display_width = track->par->width;
@@ -1419,8 +1418,7 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack 
*track)
 avio_wb32(pb, 6); /* unknown */
 }
 /* padding */
-for (i = 0; i < 10; i++)
-avio_wb64(pb, 0);
+ffio_fill(pb, 0, 10 * 8);
 
 return 0;
 }
@@ -1925,10 +1923,7 @@ static int mov_write_dvcc_dvvc_tag(AVFormatContext *s, 
AVIOContext *pb, AVDOVIDe
   dovi->bl_present_flag);
 avio_wb32(pb, (dovi->dv_bl_signal_compatibility_id << 28) | 0);
 
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 4 * 4); /* reserved */
 av_log(s, AV_LOG_DEBUG, "DOVI in %s box, version: %d.%d, profile: %d, 
level: %d, "
"rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
dovi->dv_profile > 7 ? "dvvC" : "dvcC",
@@ -2159,9 +2154,7 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 avio_wb32(pb, 0x200); /* Spatial Quality = normal */
 }
 } else {
-avio_wb32(pb, 0); /* Reserved */
-avio_wb32(pb, 0); /* Reserved */
-avio_wb32(pb, 0); /* Reserved */
+ffio_fill(pb, 0, 3 * 4); /* Reserved */
 }
 avio_wb16(pb, track->par->width); /* Video width */
 avio_wb16(pb, track->height); /* Video height */
@@ -3506,9 +3499,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb, 
MOVMuxContext *mov)
 
 avio_wb32(pb, 0x0001); /* reserved (preferred rate) 1.0 = normal */
 avio_wb16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
-avio_wb16(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 2 + 2 * 4); /* reserved */
 
 /* Matrix structure */
 write_matrix(pb, 1, 0, 0, 1, 0, 0);
@@ -4668,7 +4659,7 @@ static int mov_write_traf_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 mov_write_tfxd_tag(pb, track);
 
 if (mov->ism_lookahead) {
-int i, size = 16 + 4 + 1 + 16 * mov->ism_lookahead;
+int size = 16 + 4 + 1 + 16 * mov->ism_lookahead;
 
 if (track->nb_frag_info > 0) {
 MOVFragmentInfo *info = &track->frag_info[track->nb_frag_info 
- 1];
@@ -4677,8 +4668,7 @@ static int mov_write_traf_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 }
 avio_wb32(pb, 8 + size);
 ffio_wfourcc(pb, "free");
-for (i = 0; i < size; i++)
-avio_w8(pb, 0);
+ffio_fill(pb, 0, size);
 }
 }
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 15/27] avformat/matroskaenc: Simplify writing qt-compatibility header

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskaenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 039f20988a..f17665b0c1 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -785,11 +785,9 @@ static int mkv_write_codecprivate(AVFormatContext *s, 
AVIOContext *pb,
 if (   ff_codec_get_id(ff_codec_movvideo_tags, par->codec_tag) == 
par->codec_id
 && (!par->extradata_size || 
ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(par->extradata + 4)) != 
par->codec_id)
 ) {
-int i;
 avio_wb32(dyn_cp, 0x5a + par->extradata_size);
 avio_wl32(dyn_cp, par->codec_tag);
-for(i = 0; i < 0x5a - 8; i++)
-avio_w8(dyn_cp, 0);
+ffio_fill(dyn_cp, 0, 0x5a - 8);
 }
 avio_write(dyn_cp, par->extradata, par->extradata_size);
 } else {
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 16/27] avformat/mpegenc: Simplify writing padding/stuffing

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mpegenc.c | 26 +-
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 6aed527d50..b1d8bf9c38 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -30,6 +30,7 @@
 #include "libavcodec/put_bits.h"
 
 #include "avformat.h"
+#include "avio_internal.h"
 #include "internal.h"
 #include "mpeg.h"
 
@@ -598,7 +599,6 @@ static void put_padding_packet(AVFormatContext *ctx, 
AVIOContext *pb,
int packet_bytes)
 {
 MpegMuxContext *s = ctx->priv_data;
-int i;
 
 avio_wb32(pb, PADDING_STREAM);
 avio_wb16(pb, packet_bytes - 6);
@@ -608,8 +608,7 @@ static void put_padding_packet(AVFormatContext *ctx, 
AVIOContext *pb,
 } else
 packet_bytes -= 6;
 
-for (i = 0; i < packet_bytes; i++)
-avio_w8(pb, 0xff);
+ffio_fill(pb, 0xff, packet_bytes);
 }
 
 static int get_nb_frames(AVFormatContext *ctx, StreamInfo *stream, int len)
@@ -634,7 +633,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 MpegMuxContext *s  = ctx->priv_data;
 StreamInfo *stream = ctx->streams[stream_index]->priv_data;
 uint8_t *buf_ptr;
-int size, payload_size, startcode, id, stuffing_size, i, header_len;
+int size, payload_size, startcode, id, stuffing_size, header_len;
 int packet_size;
 uint8_t buffer[128];
 int zero_trail_bytes = 0;
@@ -685,14 +684,12 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 avio_wb32(ctx->pb, PRIVATE_STREAM_2);
 avio_wb16(ctx->pb, 0x03d4); // length
 avio_w8(ctx->pb, 0x00); // substream ID, 00=PCI
-for (i = 0; i < 979; i++)
-avio_w8(ctx->pb, 0x00);
+ffio_fill(ctx->pb, 0x00, 979);
 
 avio_wb32(ctx->pb, PRIVATE_STREAM_2);
 avio_wb16(ctx->pb, 0x03fa); // length
 avio_w8(ctx->pb, 0x01); // substream ID, 01=DSI
-for (i = 0; i < 1017; i++)
-avio_w8(ctx->pb, 0x00);
+ffio_fill(ctx->pb, 0x00, 1017);
 
 memset(buffer, 0, 128);
 buf_ptr = buffer;
@@ -835,8 +832,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 avio_wb16(ctx->pb, packet_size);
 
 if (!s->is_mpeg2)
-for (i = 0; i < stuffing_size; i++)
-avio_w8(ctx->pb, 0xff);
+ffio_fill(ctx->pb, 0xff, stuffing_size);
 
 if (s->is_mpeg2) {
 avio_w8(ctx->pb, 0x80); /* mpeg2 id */
@@ -891,8 +887,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
  * to prevent accidental generation of start codes. */
 avio_w8(ctx->pb, 0xff);
 
-for (i = 0; i < stuffing_size; i++)
-avio_w8(ctx->pb, 0xff);
+ffio_fill(ctx->pb, 0xff, stuffing_size);
 }
 
 if (startcode == PRIVATE_STREAM_1) {
@@ -925,8 +920,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 if (pad_packet_bytes > 0)
 put_padding_packet(ctx, ctx->pb, pad_packet_bytes);
 
-for (i = 0; i < zero_trail_bytes; i++)
-avio_w8(ctx->pb, 0x00);
+ffio_fill(ctx->pb, 0x00, zero_trail_bytes);
 
 avio_write_marker(ctx->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 
@@ -950,10 +944,8 @@ static void put_vcd_padding_sector(AVFormatContext *ctx)
  * So a 0-sector it is... */
 
 MpegMuxContext *s = ctx->priv_data;
-int i;
 
-for (i = 0; i < s->packet_size; i++)
-avio_w8(ctx->pb, 0);
+ffio_fill(ctx->pb, 0, s->packet_size);
 
 s->vcd_padding_bytes_written += s->packet_size;
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 19/27] avformat/riffenc: Fix indentation

2021-09-23 Thread Andreas Rheinhardt
Forgotten after bf9a8d183ddcc65b5ae473bb048a3d38bd6df9f3.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/riffenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 43c8bf957a..ffccfa3d48 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -191,10 +191,10 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
 if (par->codec_id == AV_CODEC_ID_EAC3) {
 ff_put_guid(pb, ff_get_codec_guid(par->codec_id, 
ff_codec_wav_guids));
 } else {
-avio_wl32(pb, par->codec_tag);
-avio_wl32(pb, 0x0010);
-avio_wl32(pb, 0xAA80);
-avio_wl32(pb, 0x719B3800);
+avio_wl32(pb, par->codec_tag);
+avio_wl32(pb, 0x0010);
+avio_wl32(pb, 0xAA80);
+avio_wl32(pb, 0x719B3800);
 }
 } else if ((flags & FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX) ||
par->codec_tag != 0x0001 /* PCM */ ||
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 20/27] fate/demux: Move Sony OpenMG audio (oma) test into a new file

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 tests/Makefile   | 1 +
 tests/fate/demux.mak | 3 ---
 tests/fate/oma.mak   | 5 +
 3 files changed, 6 insertions(+), 3 deletions(-)
 create mode 100644 tests/fate/oma.mak

diff --git a/tests/Makefile b/tests/Makefile
index d5595908b8..1e0345b163 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -173,6 +173,7 @@ include $(SRC_PATH)/tests/fate/mpeg4.mak
 include $(SRC_PATH)/tests/fate/mpegps.mak
 include $(SRC_PATH)/tests/fate/mpegts.mak
 include $(SRC_PATH)/tests/fate/mxf.mak
+include $(SRC_PATH)/tests/fate/oma.mak
 include $(SRC_PATH)/tests/fate/opus.mak
 include $(SRC_PATH)/tests/fate/pcm.mak
 include $(SRC_PATH)/tests/fate/pixfmt.mak
diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index 20aa90427b..2c508a42aa 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -103,9 +103,6 @@ fate-oggopus-demux: CMD = ffprobe_demux 
$(TARGET_SAMPLES)/ogg/intro-partial.opus
 FATE_SAMPLES_DEMUX-$(CONFIG_OGG_DEMUXER) += fate-oggvp8-demux
 fate-oggvp8-demux: CMD = framecrc -i $(TARGET_SAMPLES)/ogg/videotest.ogv -c:v 
copy
 
-FATE_SAMPLES_DEMUX-$(CONFIG_OMA_DEMUXER) += fate-oma-demux
-fate-oma-demux: CMD = crc -i $(TARGET_SAMPLES)/oma/01-Untitled-partial.oma 
-c:a copy
-
 FATE_SAMPLES_DEMUX-$(CONFIG_PAF_DEMUXER) += fate-paf-demux
 fate-paf-demux: CMD = framecrc -i $(TARGET_SAMPLES)/paf/hod1-partial.paf -c:v 
copy -c:a copy
 
diff --git a/tests/fate/oma.mak b/tests/fate/oma.mak
new file mode 100644
index 00..977dbd5c32
--- /dev/null
+++ b/tests/fate/oma.mak
@@ -0,0 +1,5 @@
+FATE_OMA_FFMPEG-$(call ALLYES, OMA_DEMUXER CRC_MUXER) += fate-oma-demux
+fate-oma-demux: CMD = crc -i $(TARGET_SAMPLES)/oma/01-Untitled-partial.oma 
-c:a copy
+
+FATE_SAMPLES_FFMPEG += $(FATE_OMA_FFMPEG-yes)
+fate-oma: $(FATE_OMA_FFMPEG-yes)
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 21/27] avformat/omadec: Don't output uninitialized values

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/omadec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index f6b7697a43..a727cc4d66 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -491,7 +491,7 @@ static int oma_read_header(AVFormatContext *s)
 AV_WL16(&edata[6],  jsflag);// coding mode
 AV_WL16(&edata[8],  jsflag);// coding mode
 AV_WL16(&edata[10], 1); // always 1
-// AV_WL16(&edata[12], 0);  // always 0
+AV_WL16(&edata[12], 0); // always 0
 
 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 break;
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 22/27] fate/oma: Add remux tests for ATRAC3 and ATRAC3P

2021-09-23 Thread Andreas Rheinhardt
They already uncovered an uninitialized-value bug in the ATRAC3 code
in the demuxer; and provide coverage for ID3v2.3.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/oma.mak   | 18 +-
 tests/ref/fate/oma-atrac3-remux  | 14 ++
 tests/ref/fate/oma-atrac3p-remux | 18 ++
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/oma-atrac3-remux
 create mode 100644 tests/ref/fate/oma-atrac3p-remux

diff --git a/tests/fate/oma.mak b/tests/fate/oma.mak
index 977dbd5c32..a088feff21 100644
--- a/tests/fate/oma.mak
+++ b/tests/fate/oma.mak
@@ -1,5 +1,21 @@
 FATE_OMA_FFMPEG-$(call ALLYES, OMA_DEMUXER CRC_MUXER) += fate-oma-demux
 fate-oma-demux: CMD = crc -i $(TARGET_SAMPLES)/oma/01-Untitled-partial.oma 
-c:a copy
 
+# Also tests splitting and joining the date into TYER and TDAT id3v2.3 tags.
+FATE_OMA_REMUX_FFPROBE-yes += fate-oma-atrac3p-remux
+fate-oma-atrac3p-remux: CMD = transcode oma 
$(TARGET_SAMPLES)/atrac3p/at3p_sample1.oma oma "-c copy -metadata 
date=2021-09-23 -metadata time=16:00 -metadata title=noise -metadata 
id3v2_priv.foo=hex\xB3 -metadata_header_padding 500" "-c copy -t 0.2" "" 
"-show_entries format_tags"
+
+FATE_OMA_REMUX-$(CONFIG_WAV_DEMUXER) += fate-oma-atrac3-remux
+fate-oma-atrac3-remux: CMD = transcode wav 
$(TARGET_SAMPLES)/atrac3/mc_sich_at3_132_small.wav oma "-c copy" "-c copy -t 
0.1"
+
+FATE_OMA_FFMPEG-$(call ALLYES, FILE_PROTOCOL OMA_MUXER\
+   OMA_DEMUXER FRAMECRC_MUXER \
+   PIPE_PROTOCOL) \
+   += $(FATE_OMA_REMUX-yes)
+FATE_OMA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL OMA_MUXER\
+   OMA_DEMUXER FRAMECRC_MUXER \
+   PIPE_PROTOCOL) \
+   += $(FATE_OMA_REMUX_FFPROBE-yes)
 FATE_SAMPLES_FFMPEG += $(FATE_OMA_FFMPEG-yes)
-fate-oma: $(FATE_OMA_FFMPEG-yes)
+FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_OMA_FFMPEG_FFPROBE-yes)
+fate-oma: $(FATE_OMA_FFMPEG-yes) $(FATE_OMA_FFMPEG_FFPROBE-yes)
diff --git a/tests/ref/fate/oma-atrac3-remux b/tests/ref/fate/oma-atrac3-remux
new file mode 100644
index 00..fb402c43c6
--- /dev/null
+++ b/tests/ref/fate/oma-atrac3-remux
@@ -0,0 +1,14 @@
+9f1825375316cb8d6109747def944856 *tests/data/fate/oma-atrac3-remux.oma
+50056 tests/data/fate/oma-atrac3-remux.oma
+#extradata 0:   14, 0x0aa600f2
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: atrac3
+#sample_rate 0: 44100
+#channel_layout 0: 3
+#channel_layout_name 0: stereo
+0,  0,  0, 1024,  384, 0xdfded1b5
+0,   1024,   1024, 1024,  384, 0xd8e3badd
+0,   2048,   2048, 1024,  384, 0xa316bdbb
+0,   3072,   3072, 1024,  384, 0xcea0ad2b
+0,   4096,   4096, 1024,  384, 0x88d7a98a
diff --git a/tests/ref/fate/oma-atrac3p-remux b/tests/ref/fate/oma-atrac3p-remux
new file mode 100644
index 00..d909fdaee9
--- /dev/null
+++ b/tests/ref/fate/oma-atrac3p-remux
@@ -0,0 +1,18 @@
+0053481795d07598bf2e7d931dfc4fa3 *tests/data/fate/oma-atrac3p-remux.oma
+671783 tests/data/fate/oma-atrac3p-remux.oma
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: atrac3p
+#sample_rate 0: 44100
+#channel_layout 0: 3
+#channel_layout_name 0: stereo
+0,  0,  0, 2048, 1488, 0x69b7fad9
+0,   2048,   2048, 2048, 1488, 0x3c43fdb8
+0,   4096,   4096, 2048, 1488, 0xdcd2dbcc
+0,   6144,   6144, 2048, 1488, 0x5708e4bd
+0,   8192,   8192, 2048, 1488, 0xdc7bf8a7
+[FORMAT]
+TAG:title=noise
+TAG:time=16:00
+TAG:date=2021-09-23
+[/FORMAT]
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 23/27] avformat/omaenc: Simplify writing padding

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/omaenc.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c
index ec71956fbd..1c4edcac5c 100644
--- a/libavformat/omaenc.c
+++ b/libavformat/omaenc.c
@@ -29,7 +29,6 @@
 
 static av_cold int oma_write_header(AVFormatContext *s)
 {
-int i;
 AVCodecParameters *par;
 int srate_index;
 int isjointstereo;
@@ -55,8 +54,7 @@ static av_cold int oma_write_header(AVFormatContext *s)
 avio_w8(s->pb, EA3_HEADER_SIZE >> 7);
 avio_w8(s->pb, EA3_HEADER_SIZE & 0x7F);
 avio_wl16(s->pb, 0x);   /* not encrypted */
-for (i = 0; i < 6; i++)
-avio_wl32(s->pb, 0);/* Padding + DRM id */
+ffio_fill(s->pb, 0, 6 * 4); /* Padding + DRM id */
 
 switch (par->codec_tag) {
 case OMA_CODECID_ATRAC3:
@@ -88,8 +86,7 @@ static av_cold int oma_write_header(AVFormatContext *s)
av_fourcc2str(par->codec_tag));
 return AVERROR(EINVAL);
 }
-for (i = 0; i < (EA3_HEADER_SIZE - 36)/4; i++)
-avio_wl32(s->pb, 0);/* Padding */
+ffio_fill(s->pb, 0, EA3_HEADER_SIZE - 36);  /* Padding */
 
 return 0;
 }
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 24/27] avformat/aviobuf: Extend ffio_fill to 64bits

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/avio_internal.h | 2 +-
 libavformat/aviobuf.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 8b9e048f73..11060e9ff9 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -100,7 +100,7 @@ void ffio_init_context(FFIOContext *s,
  */
 int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const 
unsigned char **data);
 
-void ffio_fill(AVIOContext *s, int b, int count);
+void ffio_fill(AVIOContext *s, int b, int64_t count);
 
 static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
 {
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 28db2c7dbd..d79e41ca77 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -201,7 +201,7 @@ void avio_w8(AVIOContext *s, int b)
 flush_buffer(s);
 }
 
-void ffio_fill(AVIOContext *s, int b, int count)
+void ffio_fill(AVIOContext *s, int b, int64_t count)
 {
 while (count > 0) {
 int len = FFMIN(s->buf_end - s->buf_ptr, count);
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 25/27] avformat/avienc: Simplify writing padding

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
write_odml_master() was responsible for 134406 of the 135347
calls to avio_wl64() during a fate-run.

 libavformat/avienc.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9eb072ce12..3b11841cd3 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -237,7 +237,6 @@ static void write_odml_master(AVFormatContext *s, int 
stream_index)
 AVCodecParameters *par = st->codecpar;
 AVIStream *avist = st->priv_data;
 unsigned char tag[5];
-int j;
 
 /* Starting to lay out AVI OpenDML master index.
 * We want to make it JUNK entry for now, since we'd
@@ -250,10 +249,8 @@ static void write_odml_master(AVFormatContext *s, int 
stream_index)
 avio_wl32(pb, 0);   /* nEntriesInUse (will fill out later on) */
 ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, par->codec_type));
 /* dwChunkId */
-avio_wl64(pb, 0);   /* dwReserved[3] */
-avio_wl32(pb, 0);   /* Must be 0.*/
-for (j = 0; j < avi->master_index_max_size * 2; j++)
-avio_wl64(pb, 0);
+ffio_fill(pb, 0, 3 * 4 /* dwReserved[3] */
+ + 16LL * avi->master_index_max_size);
 ff_end_tag(pb, avist->indexes.indx_start);
 }
 
@@ -351,10 +348,7 @@ static int avi_write_header(AVFormatContext *s)
 avio_wl32(pb, 0);
 avio_wl32(pb, 0);
 }
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 4 * 4); /* reserved */
 
 /* stream list */
 for (i = 0; i < n; i++) {
@@ -569,8 +563,7 @@ static int avi_write_header(AVFormatContext *s)
 ffio_wfourcc(pb, "odml");
 ffio_wfourcc(pb, "dmlh");
 avio_wl32(pb, 248);
-for (i = 0; i < 248; i += 4)
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, 248);
 ff_end_tag(pb, avi->odml_list);
 }
 
@@ -586,8 +579,7 @@ static int avi_write_header(AVFormatContext *s)
 /* some padding for easier tag editing */
 if (padding) {
 list2 = ff_start_tag(pb, "JUNK");
-for (i = padding; i > 0; i -= 4)
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, FFALIGN((uint32_t)padding, 4));
 ff_end_tag(pb, list2);
 }
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 26/27] avformat/gxfenc: Simplify writing padding/reserved elements

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/gxfenc.c | 30 +++---
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 1a80ecb603..8cc3bd456e 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -25,6 +25,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/timecode.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "internal.h"
 #include "gxf.h"
 
@@ -134,9 +135,7 @@ static int gxf_find_lines_index(AVStream *st)
 
 static void gxf_write_padding(AVIOContext *pb, int64_t to_pad)
 {
-for (; to_pad > 0; to_pad--) {
-avio_w8(pb, 0);
-}
+ffio_fill(pb, 0, to_pad);
 }
 
 static int64_t updatePacketSize(AVIOContext *pb, int64_t pos)
@@ -424,8 +423,7 @@ static int gxf_write_flt_packet(AVFormatContext *s)
 avio_wl32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
 }
 
-for (; i < 1000; i++)
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, (1000 - i) * 4);
 
 return updatePacketSize(pb, pos);
 }
@@ -542,13 +540,7 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, 
AVStream *st)
 static int gxf_write_umf_media_timecode(AVIOContext *pb, int drop)
 {
 avio_wl32(pb, drop); /* drop frame */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 7 * 4); /* reserved */
 return 32;
 }
 
@@ -559,13 +551,7 @@ static int gxf_write_umf_media_dv(AVIOContext *pb, 
GXFStreamContext *sc, AVStrea
 if (st->codecpar->format == AV_PIX_FMT_YUV420P)
 dv_umf_data |= 0x20; /* marks as DVCAM instead of DVPRO */
 avio_wl32(pb, dv_umf_data);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, 7 * 4);
 return 32;
 }
 
@@ -585,11 +571,10 @@ static int 
gxf_write_umf_media_description(AVFormatContext *s)
 GXFContext *gxf = s->priv_data;
 AVIOContext *pb = s->pb;
 int64_t pos;
-int i, j;
 
 pos = avio_tell(pb);
 gxf->umf_media_offset = pos - gxf->umf_start_offset;
-for (i = 0; i <= s->nb_streams; ++i) {
+for (unsigned i = 0; i <= s->nb_streams; ++i) {
 GXFStreamContext *sc;
 int64_t startpos, curpos;
 
@@ -609,8 +594,7 @@ static int gxf_write_umf_media_description(AVFormatContext 
*s)
 avio_wl32(pb, gxf->nb_fields); /* mark out */
 avio_write(pb, ES_NAME_PATTERN, strlen(ES_NAME_PATTERN));
 avio_wb16(pb, sc->media_info);
-for (j = strlen(ES_NAME_PATTERN)+2; j < 88; j++)
-avio_w8(pb, 0);
+ffio_fill(pb, 0, 88 - (strlen(ES_NAME_PATTERN) + 2));
 avio_wl32(pb, sc->track_type);
 avio_wl32(pb, sc->sample_rate);
 avio_wl32(pb, sc->sample_size);
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 27/27] avformat/mxfenc: Simplfy writing padding

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mxfenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index f37606ed89..56facbe4b7 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -965,7 +965,6 @@ static void mxf_write_structural_component(AVFormatContext 
*s, AVStream *st, MXF
 {
 MXFContext *mxf = s->priv_data;
 AVIOContext *pb = s->pb;
-int i;
 
 mxf_write_metadata_key(pb, 0x011100);
 PRINT_KEY(s, "sturctural component key", pb->buf_ptr - 16);
@@ -985,8 +984,7 @@ static void mxf_write_structural_component(AVFormatContext 
*s, AVStream *st, MXF
 // write source package uid, end of the reference
 mxf_write_local_tag(s, 32, 0x1101);
 if (!package->ref) {
-for (i = 0; i < 4; i++)
-avio_wb64(pb, 0);
+ffio_fill(pb, 0, 32);
 } else
 mxf_write_umid(s, package->ref->instance);
 
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 09/27] avformat/cafenc: Don't segfault upon allocation error

2021-09-23 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 17/27] avformat/movenchint: Simplify writing padding

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/movenchint.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 47276091f3..35212f2c5d 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -260,8 +260,7 @@ static void output_immediate(const uint8_t *data, int size,
 data += len;
 size -= len;
 
-for (; len < 14; len++)
-avio_w8(out, 0);
+ffio_fill(out, 0, 14 - len);
 
 (*entries)++;
 }
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 18/27] avformat/asfenc: Simplify writing error correction data

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
Equivalent to avio_w16(pb, 0x0).

 libavformat/asfenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 07588772c6..a0510df7dc 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -838,8 +838,7 @@ static int put_payload_parsing_info(AVFormatContext *s,
 av_assert0(padsize >= 0);
 
 avio_w8(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
-for (int i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++)
-avio_w8(pb, 0x0);
+ffio_fill(pb, 0x0, ASF_PACKET_ERROR_CORRECTION_DATA_SIZE);
 
 if (asf->multi_payloads_present)
 iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT;
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/2] avcodec/mmaldec: fix pointer type warning

2021-09-23 Thread Ho Ming Shun
Signed-off-by: Ho Ming Shun 
---
 libavcodec/mmaldec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 8c7d749742..5b75a1e74d 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -651,7 +651,7 @@ static int ffmal_copy_frame(AVCodecContext *avctx,  AVFrame 
*frame,
 av_image_fill_arrays(src, linesize,
  buffer->data + buffer->type->video.offset[0],
  avctx->pix_fmt, w, h, 1);
-av_image_copy(frame->data, frame->linesize, src, linesize,
+av_image_copy(frame->data, frame->linesize, (const uint8_t **)src, 
linesize,
   avctx->pix_fmt, avctx->width, avctx->height);
 }
 
-- 
2.33.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] avcodec/mmaldec: fix deprecation warning

2021-09-23 Thread Ho Ming Shun
Signed-off-by: Ho Ming Shun 
---
 libavcodec/mmaldec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 5b75a1e74d..96140bf53d 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -772,7 +772,9 @@ static int ffmmal_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 
 if (avctx->extradata_size && !ctx->extradata_sent) {
 AVPacket pkt = {0};
+FF_DISABLE_DEPRECATION_WARNINGS
 av_init_packet(&pkt);
+FF_ENABLE_DEPRECATION_WARNINGS
 pkt.data = avctx->extradata;
 pkt.size = avctx->extradata_size;
 ctx->extradata_sent = 1;
-- 
2.33.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mmaldec: fix deprecation warning

2021-09-23 Thread Andreas Rheinhardt
Ho Ming Shun:
> Signed-off-by: Ho Ming Shun 
> ---
>  libavcodec/mmaldec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> index 5b75a1e74d..96140bf53d 100644
> --- a/libavcodec/mmaldec.c
> +++ b/libavcodec/mmaldec.c
> @@ -772,7 +772,9 @@ static int ffmmal_decode(AVCodecContext *avctx, void 
> *data, int *got_frame,
>  
>  if (avctx->extradata_size && !ctx->extradata_sent) {
>  AVPacket pkt = {0};
> +FF_DISABLE_DEPRECATION_WARNINGS
>  av_init_packet(&pkt);
> +FF_ENABLE_DEPRECATION_WARNINGS
>  pkt.data = avctx->extradata;
>  pkt.size = avctx->extradata_size;
>  ctx->extradata_sent = 1;
> 

You did not fix the underlying issue (av_init_packet() is deprecated and
its use should therefore be discontinued), but just hid the warning.
This patch here:
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-March/277278.html intends
to fix the underlying issue (and also the warning). I have just not
found anyone to actually test whether it works. I presume you could do
it. Would you be so kind and do it?

- Andreas

PS: There is also a second patch of this patchset:
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-March/277279.html
You can get the patches from patchwork here if that is easier for you:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=3470
Or use this command line to apply the patches directly:
curl https://patchwork.ffmpeg.org/series/3470/mbox/ | git am -3
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/5] [IMF demuxer] build system

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Modify the FFMPEG build system to add support for an IMF demuxer. The 
Interoperable Master Format (IMF) is a file-based media format for the delivery 
and storage of professional audio-visual masters. An IMF Composition consists 
of an XML playlist (the Composition Playlist) and a collection of MXF files 
(the Track Files). The Composition Playlist (CPL) assembles the Track Files 
onto a timeline, which consists of multiple tracks. The location of the Track 
Files referenced by the Composition Playlist is stored in one or more XML 
documents called Asset Maps. More details at https://www.imfug.com/explainer. 
The IMF standard was first introduced in 2013 and is managed by the SMPTE.

 MAINTAINERS  | 1 +
 configure| 3 ++-
 doc/demuxers.texi| 6 ++
 libavformat/Makefile | 2 ++
 libavformat/allformats.c | 1 +
 5 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index dcac46003e..7a6972fe1a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -433,6 +433,7 @@ Muxers/Demuxers:
   idroqdec.cMike Melanson
   iff.c Jaikrishnan Menon
   img2*.c   Michael Niedermayer
+  imf*.cMarc-Antoine Arnaud, Pierre-Anthony 
Lemieux, Valentin Noël
   ipmovie.c Mike Melanson
   ircam*Paul B Mahol
   iss.c Stefan Gehrer
diff --git a/configure b/configure
index 231d0398a8..c9f815296b 100755
--- a/configure
+++ b/configure
@@ -297,7 +297,7 @@ External library support:
   --enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
   --enable-libxml2 enable XML parsing using the C library libxml2, 
needed
-   for dash demuxing support [no]
+   for dash and imf demuxing support [no]
   --enable-libzimg enable z.lib, needed for zscale filter [no]
   --enable-libzmq  enable message passing via libzmq [no]
   --enable-libzvbi enable teletext support via libzvbi [no]
@@ -3363,6 +3363,7 @@ hls_muxer_select="mpegts_muxer"
 hls_muxer_suggest="gcrypt openssl"
 image2_alias_pix_demuxer_select="image2_demuxer"
 image2_brender_pix_demuxer_select="image2_demuxer"
+imf_demuxer_deps="libxml2"
 ipod_muxer_select="mov_muxer"
 ismv_muxer_select="mov_muxer"
 ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 1c9575b2e8..37efe6ce1a 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -267,6 +267,12 @@ which streams to actually receive.
 Each stream mirrors the @code{id} and @code{bandwidth} properties from the
 @code{} as metadata keys named "id" and "variant_bitrate" 
respectively.
 
+@section imf
+
+Interoperable Master Format demuxer.
+
+This demuxer presents audio and video streams found in an IMF Composition.
+
 @section flv, live_flv, kux
 
 Adobe Flash Video Format demuxer.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index c45caa3eed..42ced953f6 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -284,6 +284,7 @@ OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)+= img2dec.o 
img2.o
 OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMF_DEMUXER)   += imfdec.o imf_cpl.o
 OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
 OBJS-$(CONFIG_IPMOVIE_DEMUXER)   += ipmovie.o
 OBJS-$(CONFIG_IPU_DEMUXER)   += ipudec.o rawdec.o
@@ -693,6 +694,7 @@ TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
 TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
 TESTPROGS-$(CONFIG_NETWORK)  += noproxy
 TESTPROGS-$(CONFIG_SRTP) += srtp
+TESTPROGS-$(CONFIG_IMF_DEMUXER)  += imf
 
 TOOLS = aviocat \
 ismindex\
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 5471f7c16f..bad4494981 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -211,6 +211,7 @@ extern const AVInputFormat  ff_image2pipe_demuxer;
 extern const AVOutputFormat ff_image2pipe_muxer;
 extern const AVInputFormat  ff_image2_alias_pix_demuxer;
 extern const AVInputFormat  ff_image2_brender_pix_demuxer;
+extern const AVInputFormat  ff_imf_demuxer;
 extern const AVInputFormat  ff_ingenient_demuxer;
 extern const AVInputFormat  ff_ipmovie_demuxer;
 extern const AVOutputFormat ff_ipod_muxer;
-- 
2.17.1

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

[FFmpeg-devel] [PATCH 2/5] [IMF demuxer] Headers

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Public and private header files for the IMF demuxer. The functions and 
constants defines in the public header file imf.h can be used by other modules.

 libavformat/imf.h  | 156 +
 libavformat/imf_internal.h | 100 
 2 files changed, 256 insertions(+)
 create mode 100644 libavformat/imf.h
 create mode 100644 libavformat/imf_internal.h

diff --git a/libavformat/imf.h b/libavformat/imf.h
new file mode 100644
index 00..8162cbc031
--- /dev/null
+++ b/libavformat/imf.h
@@ -0,0 +1,156 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Public header file for the processing of Interoperable Master Format (IMF) 
packages.
+ * 
+ * @author Pierre-Anthony Lemieux
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#ifndef AVFORMAT_IMF_H
+#define AVFORMAT_IMF_H
+
+#include "avformat.h"
+#include "libavformat/avio.h"
+#include "libavutil/rational.h"
+#include 
+
+/**
+ * UUID as defined in IETF RFC 422
+ */
+typedef uint8_t UUID[16];
+
+/**
+ * IMF Composition Playlist Base Resource
+ */
+typedef struct IMFBaseResource {
+AVRational edit_rate; /**< BaseResourceType/EditRate */
+unsigned long entry_point; /**< BaseResourceType/EntryPoint */
+unsigned long duration; /**< BaseResourceType/Duration */
+unsigned long repeat_count; /**< BaseResourceType/RepeatCount */
+} IMFBaseResource;
+
+/**
+ * IMF Composition Playlist Track File Resource
+ */
+typedef struct IMFTrackFileResource {
+IMFBaseResource base;
+UUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */
+} IMFTrackFileResource;
+
+/**
+ * IMF Marker
+ */
+typedef struct IMFMarker {
+xmlChar *label_utf8; /**< Marker/Label */
+xmlChar *scope_utf8; /**< Marker/Label/\@scope */
+unsigned long offset; /**< Marker/Offset */
+} IMFMarker;
+
+/**
+ * IMF Composition Playlist Marker Resource
+ */
+typedef struct IMFMarkerResource {
+IMFBaseResource base;
+unsigned long marker_count; /**< Number of Marker elements */
+IMFMarker *markers; /**< Marker elements */
+} IMFMarkerResource;
+
+/**
+ * IMF Composition Playlist Virtual Track
+ */
+typedef struct IMFBaseVirtualTrack {
+UUID id_uuid; /**< TrackId associated with the Virtual Track */
+} IMFBaseVirtualTrack;
+
+/**
+ * IMF Composition Playlist Virtual Track that consists of Track File Resources
+ */
+typedef struct IMFTrackFileVirtualTrack {
+IMFBaseVirtualTrack base;
+unsigned long resource_count; /**< Number of Resource elements present in 
the Virtual Track */
+IMFTrackFileResource *resources; /**< Resource elements of the Virtual 
Track */
+} IMFTrackFileVirtualTrack;
+
+/**
+ * IMF Composition Playlist Virtual Track that consists of Marker Resources
+ */
+typedef struct IMFMarkerVirtualTrack {
+IMFBaseVirtualTrack base;
+unsigned long resource_count; /**< Number of Resource elements present in 
the Virtual Track */
+IMFMarkerResource *resources; /**< Resource elements of the Virtual Track 
*/
+} IMFMarkerVirtualTrack;
+
+/**
+ * IMF Composition Playlist
+ */
+typedef struct IMFCPL {
+UUID id_uuid; /**< CompositionPlaylist/Id element */
+xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element 
*/
+AVRational edit_rate; /**< CompositionPlaylist/EditRate element */
+IMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track 
*/
+IMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual 
Track */
+unsigned long main_audio_track_count; /**< Number of Main Audio Virtual 
Track

[FFmpeg-devel] [PATCH 3/5] [IMF demuxer] CPL processor

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Implements IMF Composition Playlist (CPL) parsing. The IMF CPL is specified 
in SMTPE ST 2067-3 and defines a timeline onto which MXF files are placed.

 libavformat/imf_cpl.c | 652 ++
 1 file changed, 652 insertions(+)
 create mode 100644 libavformat/imf_cpl.c

diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
new file mode 100644
index 00..e0c8e2c58f
--- /dev/null
+++ b/libavformat/imf_cpl.c
@@ -0,0 +1,652 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Implements IMP CPL processing
+ *
+ * @author Pierre-Anthony Lemieux
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#include "imf.h"
+#include "imf_internal.h"
+#include "libavformat/mxf.h"
+#include "libavutil/bprint.h"
+#include "libavutil/error.h"
+#include 
+
+xmlNodePtr xml_get_child_element_by_name(xmlNodePtr parent, const char 
*name_utf8) {
+xmlNodePtr cur_element;
+
+cur_element = xmlFirstElementChild(parent);
+while (cur_element) {
+if (xmlStrcmp(cur_element->name, name_utf8) == 0)
+return cur_element;
+cur_element = xmlNextElementSibling(cur_element);
+}
+return NULL;
+}
+
+int xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]) {
+xmlChar *element_text = NULL;
+int scanf_ret;
+int ret = 0;
+
+element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
+scanf_ret = sscanf(element_text,
+UUID_FORMAT,
+&uuid[0],
+&uuid[1],
+&uuid[2],
+&uuid[3],
+&uuid[4],
+&uuid[5],
+&uuid[6],
+&uuid[7],
+&uuid[8],
+&uuid[9],
+&uuid[10],
+&uuid[11],
+&uuid[12],
+&uuid[13],
+&uuid[14],
+&uuid[15]);
+if (scanf_ret != 16) {
+av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
+ret = AVERROR_INVALIDDATA;
+}
+xmlFree(element_text);
+
+return ret;
+}
+
+int xml_read_rational(xmlNodePtr element, AVRational *rational) {
+xmlChar *element_text = NULL;
+int ret = 0;
+
+element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
+if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2) {
+av_log(NULL, AV_LOG_ERROR, "Invalid rational number\n");
+ret = AVERROR_INVALIDDATA;
+}
+xmlFree(element_text);
+
+return ret;
+}
+
+int xml_read_ulong(xmlNodePtr element, unsigned long *number) {
+xmlChar *element_text = NULL;
+int ret = 0;
+
+element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
+if (sscanf(element_text, "%lu", number) != 1) {
+av_log(NULL, AV_LOG_ERROR, "Invalid unsigned long");
+ret = AVERROR_INVALIDDATA;
+}
+xmlFree(element_text);
+
+return ret;
+}
+
+static void imf_base_virtual_track_init(IMFBaseVirtualTrack *track) {
+memset(track->id_uuid, 0, sizeof(track->id_uuid));
+}
+
+static void imf_marker_virtual_track_init(IMFMarkerVirtualTrack *track) {
+imf_base_virtual_track_init((IMFBaseVirtualTrack *)track);
+track->resource_count = 0;
+track->resources = NULL;
+}
+
+static void imf_trackfile_virtual_track_init(IMFTrackFileVirtualTrack *track) {
+imf_base_virtual_track_init((IMFBaseVirtualTrack *)track);
+track->resource_count = 0;
+track->resources = NULL;
+}
+
+static void imf_base_resource_init(IMFBaseResource *rsrc) {
+rsrc->duration = 0;
+rsrc->edit_rate = av_make_q(0, 0);
+rsrc->entry_point = 0;
+rsrc->repeat_count = 1;
+}
+
+static void imf_

[FFmpeg-devel] [PATCH 4/5] [IMF demuxer] Demuxer implementation

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Implements the IMF demuxer, which accepts as input an IMF CPL. The assets 
referenced by the CPL can be contained in multiple deliveries, each defined by 
an ASSETMAP file:./ffmpeg -assetmaps \,\,... -i \ If -assetmaps is not specified, FFMPEG looks 
for a file called ASSETMAP.xml in the same directory as the CPL.

 libavformat/imfdec.c | 646 +++
 1 file changed, 646 insertions(+)
 create mode 100644 libavformat/imfdec.c

diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
new file mode 100644
index 00..1dee2ba8bb
--- /dev/null
+++ b/libavformat/imfdec.c
@@ -0,0 +1,646 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Demuxes an IMF Composition
+ *
+ * References
+ * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format
+ * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core 
Constraints
+ * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — Composition 
Playlist
+ * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — Essence 
Component
+ * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — 
Application #2
+ * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — 
Application #2 Extended
+ * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — Common 
Image Pixel Color Schemes
+ * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping and 
File Segmentation
+ *
+ * @author Marc-Antoine Arnaud
+ * @author Valentin Noel
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#include "imf.h"
+#include "imf_internal.h"
+#include "internal.h"
+#include "libavutil/opt.h"
+#include "libavutil/bprint.h"
+#include "libavutil/avstring.h"
+#include "mxf.h"
+#include "url.h"
+#include 
+#include 
+
+#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1)
+#define DEFAULT_ASSETMAP_SIZE 8 * 1024
+
+typedef struct IMFVirtualTrackResourcePlaybackCtx {
+IMFAssetLocator *locator;
+IMFTrackFileResource *resource;
+AVFormatContext *ctx;
+} IMFVirtualTrackResourcePlaybackCtx;
+
+typedef struct IMFVirtualTrackPlaybackCtx {
+// Track index in playlist
+int32_t index;
+// Time counters
+AVRational current_timestamp;
+AVRational duration;
+// Resources
+unsigned int resource_count;
+IMFVirtualTrackResourcePlaybackCtx **resources;
+// Decoding cursors
+uint32_t current_resource_index;
+int64_t last_pts;
+} IMFVirtualTrackPlaybackCtx;
+
+typedef struct IMFContext {
+const AVClass *class;
+const char *base_url;
+char *asset_map_paths;
+AVIOInterruptCB *interrupt_callback;
+AVDictionary *avio_opts;
+IMFCPL *cpl;
+IMFAssetLocatorMap *asset_locator_map;
+unsigned int track_count;
+IMFVirtualTrackPlaybackCtx **tracks;
+} IMFContext;
+
+int is_url(const char *string) {
+char *substr = strstr(string, "://");
+return substr != NULL;
+}
+
+int is_unix_absolute_path(const char *string) {
+char *substr = strstr(string, "/");
+int index = (int)(substr - string);
+return index == 0;
+}
+
+int is_dos_absolute_path(const char *string) {
+// Absolute path case: `C:\path\to\somwhere`
+char *substr = strstr(string, ":\\");
+int index = (int)(substr - string);
+if (index == 1) {
+return 1;
+}
+
+// Absolute path case: `C:/path/to/somwhere`
+substr = strstr(string, ":/");
+index = (int)(substr - string);
+if (index == 1) {
+return 1;
+}
+
+// Network path case: `\\path\to\somwhere`
+substr = strstr(string, "");

[FFmpeg-devel] [PATCH 5/5] [IMF demuxer] Tests

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Tests for the public API of the IMF demuxer.

 libavformat/tests/imf.c | 476 
 1 file changed, 476 insertions(+)
 create mode 100644 libavformat/tests/imf.c

diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c
new file mode 100644
index 00..47f05d965d
--- /dev/null
+++ b/libavformat/tests/imf.c
@@ -0,0 +1,476 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Tests for IMF CPL and ASSETMAP processing
+ * 
+ * @author Valentin Noel
+ * @author Pierre-Anthony Lemieux
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#include "libavformat/imf.h"
+#include "libavformat/imf_internal.h"
+#include "libavformat/mxf.h"
+
+#include 
+
+const char *cpl_doc =
+"http://www.smpte-ra.org/schemas/2067-3/2016\"";
+" xmlns:cc=\"http://www.smpte-ra.org/schemas/2067-2/2016\"";
+" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\";>"
+"urn:uuid:8713c020-2489-45f5-a9f7-87be539e20b5"
+"2021-07-13T17:06:22Z"
+"FFMPEG"
+"FFMPEG sample content"
+""
+"  "
+"urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f"
+"  "
+""
+"24000 1001"
+""
+""
+"urn:uuid:81fed4e5-9722-400a-b9d1-7f2bd21df4b6"
+""
+""
+"urn:uuid:16327185-9205-47ef-a17b-ee28df251db7"
+"urn:uuid:461f5424-8f6e-48a9-a385-5eda46fda381"
+""
+""
+"urn:uuid:ea3d0f23-55d6-4e03-86ec-cfe0666f0e6a"
+"24"
+""
+"LFOA"
+"5"
+""
+""
+""
+""
+""
+"urn:uuid:6ae100b0-92d1-41be-9321-85e0933dfc42"
+"urn:uuid:e8ef9653-565c-479c-8039-82d4547973c5"
+""
+""
+"urn:uuid:7d418acb-07a3-4e57-984c-b8ea2f7de4ec"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:6f768ca4-c89e-4dac-9056-a29425d40ba1"
+""
+""
+""
+""
+"urn:uuid:754dae53-c25f-4f3c-97e4-2bfe5463f83b"
+"urn:uuid:68e3fae5-d94b-44d2-92a6-b94877fbcdb5"
+""
+""
+"urn:uuid:61ce2a70-10a2-4521-850b-4218755ff3c9"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:381dadd2-061e-46cc-a63a-e3d58ce7f488"
+""
+""
+""
+""
+"urn:uuid:d29b3884-6633-4dad-9c67-7154af342bc6"
+"urn:uuid:6978c106-95bc-424b-a17c-628206a5892d"
+""
+""
+"urn:uuid:001ea472-f5da-436c-86de-acaa68c1a7e4"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:381dadd2-061e-46cc-a63a-e3d58ce7f488"
+""
+""
+""
+""
+"urn:uuid:02af22bf-f776-488a-b001-eb6e16953119"
+"urn:uuid:19ff6da1-be79-4235-8d04-42201ad06e65"
+""
+""
+"urn:uuid:dfa84292-0609-4097-824c-8e2e15e2ce4d"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:bd6272b6-511e-47c1-93bc-d56ebd314a70"
+""
+""
+""
+""
+""
+""
+"urn:uuid:a94be493-cd55-4bf7-b496-ea87bfe38632"
+""
+""
+"urn:uuid:20c6020b-1fc0-4080-bcf7-89f09f95bea8"
+"urn:uuid:461f5424-8f6e-48a9-a385-5eda46fda381"
+""
+""
+"urn:uuid:d1f93845-d3e5-4c3b-aa67-8d96c45cfe9c"
+"36"
+""
+"FFOA"
+"20"
+""
+""
+"LFOC"
+"24"
+""
+""
+""
+""
+""
+"urn:uuid:9b509f42-e4e8-4f78-8c2a-12ddd79ef3c5"
+"urn:uuid:e8ef9653-565c-479c-8039-82d4547973c5"
+""
+""
+"urn:uuid:a733d812-a3d7-45e9-ba50-13b856d5d35a"
+"36"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:f3b263b3-096b-4360-a952-b1a9623cd0ca"
+""
+""
+""
+""
+"urn:uuid:19a282e6-beac-4d99-a008-afa61378eb6c"
+"urn:uuid:68e3fae5-

Re: [FFmpeg-devel] [PATCH 1/5] [IMF demuxer] build system

2021-09-23 Thread Pierre-Anthony Lemieux
Hi all,

Sample content is available at:

http://ffmpeg-imf-samples-public.s3-website-us-west-1.amazonaws.com/countdown/CPL_f5095caa-f204-4e1c-8a84-7af48c7ae16b.xml

Looking forward to the feedback.

Best,

-- Pierre

On Thu, Sep 23, 2021 at 10:01 AM  wrote:
>
> From: Pierre-Anthony Lemieux 
>
> Signed-off-by: Pierre-Anthony Lemieux 
> ---
>
> Notes:
> Modify the FFMPEG build system to add support for an IMF demuxer. The 
> Interoperable Master Format (IMF) is a file-based media format for the 
> delivery and storage of professional audio-visual masters. An IMF Composition 
> consists of an XML playlist (the Composition Playlist) and a collection of 
> MXF files (the Track Files). The Composition Playlist (CPL) assembles the 
> Track Files onto a timeline, which consists of multiple tracks. The location 
> of the Track Files referenced by the Composition Playlist is stored in one or 
> more XML documents called Asset Maps. More details at 
> https://www.imfug.com/explainer. The IMF standard was first introduced in 
> 2013 and is managed by the SMPTE.
>
>  MAINTAINERS  | 1 +
>  configure| 3 ++-
>  doc/demuxers.texi| 6 ++
>  libavformat/Makefile | 2 ++
>  libavformat/allformats.c | 1 +
>  5 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index dcac46003e..7a6972fe1a 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -433,6 +433,7 @@ Muxers/Demuxers:
>idroqdec.cMike Melanson
>iff.c Jaikrishnan Menon
>img2*.c   Michael Niedermayer
> +  imf*.cMarc-Antoine Arnaud, Pierre-Anthony 
> Lemieux, Valentin Noël
>ipmovie.c Mike Melanson
>ircam*Paul B Mahol
>iss.c Stefan Gehrer
> diff --git a/configure b/configure
> index 231d0398a8..c9f815296b 100755
> --- a/configure
> +++ b/configure
> @@ -297,7 +297,7 @@ External library support:
>--enable-libxvid enable Xvid encoding via xvidcore,
> native MPEG-4/Xvid encoder exists [no]
>--enable-libxml2 enable XML parsing using the C library libxml2, 
> needed
> -   for dash demuxing support [no]
> +   for dash and imf demuxing support [no]
>--enable-libzimg enable z.lib, needed for zscale filter [no]
>--enable-libzmq  enable message passing via libzmq [no]
>--enable-libzvbi enable teletext support via libzvbi [no]
> @@ -3363,6 +3363,7 @@ hls_muxer_select="mpegts_muxer"
>  hls_muxer_suggest="gcrypt openssl"
>  image2_alias_pix_demuxer_select="image2_demuxer"
>  image2_brender_pix_demuxer_select="image2_demuxer"
> +imf_demuxer_deps="libxml2"
>  ipod_muxer_select="mov_muxer"
>  ismv_muxer_select="mov_muxer"
>  ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
> diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> index 1c9575b2e8..37efe6ce1a 100644
> --- a/doc/demuxers.texi
> +++ b/doc/demuxers.texi
> @@ -267,6 +267,12 @@ which streams to actually receive.
>  Each stream mirrors the @code{id} and @code{bandwidth} properties from the
>  @code{} as metadata keys named "id" and "variant_bitrate" 
> respectively.
>
> +@section imf
> +
> +Interoperable Master Format demuxer.
> +
> +This demuxer presents audio and video streams found in an IMF Composition.
> +
>  @section flv, live_flv, kux
>
>  Adobe Flash Video Format demuxer.
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index c45caa3eed..42ced953f6 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -284,6 +284,7 @@ OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)+= img2dec.o 
> img2.o
>  OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER) += img2dec.o img2.o
>  OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o img2.o
>  OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
> +OBJS-$(CONFIG_IMF_DEMUXER)   += imfdec.o imf_cpl.o
>  OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
>  OBJS-$(CONFIG_IPMOVIE_DEMUXER)   += ipmovie.o
>  OBJS-$(CONFIG_IPU_DEMUXER)   += ipudec.o rawdec.o
> @@ -693,6 +694,7 @@ TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
>  TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
>  TESTPROGS-$(CONFIG_NETWORK)  += noproxy
>  TESTPROGS-$(CONFIG_SRTP) += srtp
> +TESTPROGS-$(CONFIG_IMF_DEMUXER)  += imf
>
>  TOOLS = aviocat \
>  ismindex\
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 5471f7c16f..bad4494981 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -211,6 +211,7 @@ extern const AVInputFormat  ff_image2pipe_demuxer;
>  extern const AVOutputFormat ff_image2pipe_

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mmaldec: fix deprecation warning

2021-09-23 Thread Ming Shun Ho
On Fri, Sep 24, 2021 at 12:52 AM Andreas Rheinhardt
 wrote:
>
> Ho Ming Shun:
> > Signed-off-by: Ho Ming Shun 
> > ---
> >  libavcodec/mmaldec.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> > index 5b75a1e74d..96140bf53d 100644
> > --- a/libavcodec/mmaldec.c
> > +++ b/libavcodec/mmaldec.c
> > @@ -772,7 +772,9 @@ static int ffmmal_decode(AVCodecContext *avctx, void 
> > *data, int *got_frame,
> >
> >  if (avctx->extradata_size && !ctx->extradata_sent) {
> >  AVPacket pkt = {0};
> > +FF_DISABLE_DEPRECATION_WARNINGS
> >  av_init_packet(&pkt);
> > +FF_ENABLE_DEPRECATION_WARNINGS
> >  pkt.data = avctx->extradata;
> >  pkt.size = avctx->extradata_size;
> >  ctx->extradata_sent = 1;
> >
>
> You did not fix the underlying issue (av_init_packet() is deprecated and
> its use should therefore be discontinued), but just hid the warning.

I was under the impression that it is deprecated to remove sizeof(AVPacket)
from libavcodec's ABI. Internally however it should be ok.

> This patch here:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2021-March/277278.html intends
> to fix the underlying issue (and also the warning). I have just not
> found anyone to actually test whether it works. I presume you could do
> it. Would you be so kind and do it?

Had to patch it to build:

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 0ea07ea787..2bed7309bb 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -779,7 +779,7 @@ static int ffmmal_decode(AVCodecContext *avctx,
void *data, int *got_frame,
return ret;
}

-if ((ret = ffmmal_add_packet(avctx, avpkt, pkt->data, pkt->size)) < 0)
+if ((ret = ffmmal_add_packet(avctx, avpkt, avpkt->data, avpkt->size)) < 0)
return ret;

if ((ret = ffmmal_fill_input_port(avctx)) < 0)

Seems to be working fine with the above patch applied.

Will this series likely be applied? I am asking because I am working on another
patch to convert this to the new dataflow API, and your patches look like they
might conflict.

>
> - Andreas
>
> PS: There is also a second patch of this patchset:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2021-March/277279.html
> You can get the patches from patchwork here if that is easier for you:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=3470
> Or use this command line to apply the patches directly:
> curl https://patchwork.ffmpeg.org/series/3470/mbox/ | git am -3
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] avformat/jvdec: Make sizeof(JVFrame) smaller to save memory

2021-09-23 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/jvdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index 8f21ea1893..93569c87df 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -36,8 +36,8 @@
 typedef struct JVFrame {
 int audio_size;/**< audio packet size (bytes) */
 int video_size;/**< video packet size (bytes) */
-int palette_size;  /**< palette size (bytes) */
-int video_type;/**< per-frame video compression type */
+uint16_t palette_size;  /**< palette size (bytes) */
+uint8_t video_type; /**< per-frame video compression type */
 } JVFrame;
 
 typedef struct JVDemuxContext {
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/5] [IMF demuxer] build system

2021-09-23 Thread Timo Rothenpieler

On 23/09/2021 19:00, p...@sandflow.com wrote:

From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
 Modify the FFMPEG build system to add support for an IMF demuxer. The 
Interoperable Master Format (IMF) is a file-based media format for the delivery 
and storage of professional audio-visual masters. An IMF Composition consists 
of an XML playlist (the Composition Playlist) and a collection of MXF files 
(the Track Files). The Composition Playlist (CPL) assembles the Track Files 
onto a timeline, which consists of multiple tracks. The location of the Track 
Files referenced by the Composition Playlist is stored in one or more XML 
documents called Asset Maps. More details at https://www.imfug.com/explainer. 
The IMF standard was first introduced in 2013 and is managed by the SMPTE.

  MAINTAINERS  | 1 +
  configure| 3 ++-
  doc/demuxers.texi| 6 ++
  libavformat/Makefile | 2 ++
  libavformat/allformats.c | 1 +
  5 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index dcac46003e..7a6972fe1a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -433,6 +433,7 @@ Muxers/Demuxers:
idroqdec.cMike Melanson
iff.c Jaikrishnan Menon
img2*.c   Michael Niedermayer
+  imf*.cMarc-Antoine Arnaud, Pierre-Anthony 
Lemieux, Valentin Noël
ipmovie.c Mike Melanson
ircam*Paul B Mahol
iss.c Stefan Gehrer
diff --git a/configure b/configure
index 231d0398a8..c9f815296b 100755
--- a/configure
+++ b/configure
@@ -297,7 +297,7 @@ External library support:
--enable-libxvid enable Xvid encoding via xvidcore,
 native MPEG-4/Xvid encoder exists [no]
--enable-libxml2 enable XML parsing using the C library libxml2, 
needed
-   for dash demuxing support [no]
+   for dash and imf demuxing support [no]
--enable-libzimg enable z.lib, needed for zscale filter [no]
--enable-libzmq  enable message passing via libzmq [no]
--enable-libzvbi enable teletext support via libzvbi [no]
@@ -3363,6 +3363,7 @@ hls_muxer_select="mpegts_muxer"
  hls_muxer_suggest="gcrypt openssl"
  image2_alias_pix_demuxer_select="image2_demuxer"
  image2_brender_pix_demuxer_select="image2_demuxer"
+imf_demuxer_deps="libxml2"
  ipod_muxer_select="mov_muxer"
  ismv_muxer_select="mov_muxer"
  ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 1c9575b2e8..37efe6ce1a 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -267,6 +267,12 @@ which streams to actually receive.
  Each stream mirrors the @code{id} and @code{bandwidth} properties from the
  @code{} as metadata keys named "id" and "variant_bitrate" 
respectively.
  
+@section imf

+
+Interoperable Master Format demuxer.
+
+This demuxer presents audio and video streams found in an IMF Composition.
+
  @section flv, live_flv, kux
  
  Adobe Flash Video Format demuxer.

diff --git a/libavformat/Makefile b/libavformat/Makefile
index c45caa3eed..42ced953f6 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -284,6 +284,7 @@ OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)+= img2dec.o 
img2.o
  OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER) += img2dec.o img2.o
  OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o img2.o
  OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMF_DEMUXER)   += imfdec.o imf_cpl.o


This commit does not contain those files, and thus will fail to compile.
Every commit individually has to compile and pass fate.

Just add the necessary bits to build along with the code itself.


  OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
  OBJS-$(CONFIG_IPMOVIE_DEMUXER)   += ipmovie.o
  OBJS-$(CONFIG_IPU_DEMUXER)   += ipudec.o rawdec.o
@@ -693,6 +694,7 @@ TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
  TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
  TESTPROGS-$(CONFIG_NETWORK)  += noproxy
  TESTPROGS-$(CONFIG_SRTP) += srtp
+TESTPROGS-$(CONFIG_IMF_DEMUXER)  += imf
  
  TOOLS = aviocat \

  ismindex\
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 5471f7c16f..bad4494981 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -211,6 +211,7 @@ extern const AVInputFormat  ff_image2pipe_demuxer;
  extern const AVOutputFormat ff_image2pipe_muxer;
  extern const AVInputFormat  ff_image2_alias_pix_demuxer;
  extern const AVInputFormat  ff_image2_brender_pix_demuxer;
+extern const AVInputFormat  ff_imf_dem

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mmaldec: fix deprecation warning

2021-09-23 Thread Andreas Rheinhardt
Ming Shun Ho:
> On Fri, Sep 24, 2021 at 12:52 AM Andreas Rheinhardt
>  wrote:
>>
>> Ho Ming Shun:
>>> Signed-off-by: Ho Ming Shun 
>>> ---
>>>  libavcodec/mmaldec.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
>>> index 5b75a1e74d..96140bf53d 100644
>>> --- a/libavcodec/mmaldec.c
>>> +++ b/libavcodec/mmaldec.c
>>> @@ -772,7 +772,9 @@ static int ffmmal_decode(AVCodecContext *avctx, void 
>>> *data, int *got_frame,
>>>
>>>  if (avctx->extradata_size && !ctx->extradata_sent) {
>>>  AVPacket pkt = {0};
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>>  av_init_packet(&pkt);
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>>  pkt.data = avctx->extradata;
>>>  pkt.size = avctx->extradata_size;
>>>  ctx->extradata_sent = 1;
>>>
>>
>> You did not fix the underlying issue (av_init_packet() is deprecated and
>> its use should therefore be discontinued), but just hid the warning.
> 
> I was under the impression that it is deprecated to remove sizeof(AVPacket)
> from libavcodec's ABI. Internally however it should be ok.
> 

Some devs actually want to move AVPacket to libavutil (because it is
supposed to be cleaner) in the long term, so we already try to avoid
AVPackets on the stack in general. Note that get_packet_defaults() (the
actual successor to av_init_packet()) is internal to libavcodec/avpacket.c.

>> This patch here:
>> https://ffmpeg.org/pipermail/ffmpeg-devel/2021-March/277278.html intends
>> to fix the underlying issue (and also the warning). I have just not
>> found anyone to actually test whether it works. I presume you could do
>> it. Would you be so kind and do it?
> 
> Had to patch it to build:
> 
> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> index 0ea07ea787..2bed7309bb 100644
> --- a/libavcodec/mmaldec.c
> +++ b/libavcodec/mmaldec.c
> @@ -779,7 +779,7 @@ static int ffmmal_decode(AVCodecContext *avctx,
> void *data, int *got_frame,
> return ret;
> }
> 
> -if ((ret = ffmmal_add_packet(avctx, avpkt, pkt->data, pkt->size)) < 0)
> +if ((ret = ffmmal_add_packet(avctx, avpkt, avpkt->data, avpkt->size)) < 
> 0)

How embarrassing. Good that it has never been applied in that form.

> return ret;
> 
> if ((ret = ffmmal_fill_input_port(avctx)) < 0)
> 
> Seems to be working fine with the above patch applied.
> 

Thanks for testing.

> Will this series likely be applied? I am asking because I am working on 
> another
> patch to convert this to the new dataflow API, and your patches look like they
> might conflict.
> 

What new dataflow API? While it is very likely to lead to conflicts when
applying, I think it is unlikely to lead to actual deep conflicts that
can't be easily resolved. Do you already have a scetch of your patches
for the dataflow API for me to take a look?

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/5] [IMF demuxer] build system

2021-09-23 Thread Pierre-Anthony Lemieux
Hi Timo,

> Every commit individually has to compile and pass fate.

Ok. This will reduce the number of patches.

Best,

-- Pierre

On Thu, Sep 23, 2021 at 11:07 AM Timo Rothenpieler
 wrote:
>
> On 23/09/2021 19:00, p...@sandflow.com wrote:
> > From: Pierre-Anthony Lemieux 
> >
> > Signed-off-by: Pierre-Anthony Lemieux 
> > ---
> >
> > Notes:
> >  Modify the FFMPEG build system to add support for an IMF demuxer. The 
> > Interoperable Master Format (IMF) is a file-based media format for the 
> > delivery and storage of professional audio-visual masters. An IMF 
> > Composition consists of an XML playlist (the Composition Playlist) and a 
> > collection of MXF files (the Track Files). The Composition Playlist (CPL) 
> > assembles the Track Files onto a timeline, which consists of multiple 
> > tracks. The location of the Track Files referenced by the Composition 
> > Playlist is stored in one or more XML documents called Asset Maps. More 
> > details at https://www.imfug.com/explainer. The IMF standard was first 
> > introduced in 2013 and is managed by the SMPTE.
> >
> >   MAINTAINERS  | 1 +
> >   configure| 3 ++-
> >   doc/demuxers.texi| 6 ++
> >   libavformat/Makefile | 2 ++
> >   libavformat/allformats.c | 1 +
> >   5 files changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index dcac46003e..7a6972fe1a 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -433,6 +433,7 @@ Muxers/Demuxers:
> > idroqdec.cMike Melanson
> > iff.c Jaikrishnan Menon
> > img2*.c   Michael Niedermayer
> > +  imf*.cMarc-Antoine Arnaud, 
> > Pierre-Anthony Lemieux, Valentin Noël
> > ipmovie.c Mike Melanson
> > ircam*Paul B Mahol
> > iss.c Stefan Gehrer
> > diff --git a/configure b/configure
> > index 231d0398a8..c9f815296b 100755
> > --- a/configure
> > +++ b/configure
> > @@ -297,7 +297,7 @@ External library support:
> > --enable-libxvid enable Xvid encoding via xvidcore,
> >  native MPEG-4/Xvid encoder exists [no]
> > --enable-libxml2 enable XML parsing using the C library 
> > libxml2, needed
> > -   for dash demuxing support [no]
> > +   for dash and imf demuxing support [no]
> > --enable-libzimg enable z.lib, needed for zscale filter [no]
> > --enable-libzmq  enable message passing via libzmq [no]
> > --enable-libzvbi enable teletext support via libzvbi [no]
> > @@ -3363,6 +3363,7 @@ hls_muxer_select="mpegts_muxer"
> >   hls_muxer_suggest="gcrypt openssl"
> >   image2_alias_pix_demuxer_select="image2_demuxer"
> >   image2_brender_pix_demuxer_select="image2_demuxer"
> > +imf_demuxer_deps="libxml2"
> >   ipod_muxer_select="mov_muxer"
> >   ismv_muxer_select="mov_muxer"
> >   ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
> > diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> > index 1c9575b2e8..37efe6ce1a 100644
> > --- a/doc/demuxers.texi
> > +++ b/doc/demuxers.texi
> > @@ -267,6 +267,12 @@ which streams to actually receive.
> >   Each stream mirrors the @code{id} and @code{bandwidth} properties from the
> >   @code{} as metadata keys named "id" and "variant_bitrate" 
> > respectively.
> >
> > +@section imf
> > +
> > +Interoperable Master Format demuxer.
> > +
> > +This demuxer presents audio and video streams found in an IMF Composition.
> > +
> >   @section flv, live_flv, kux
> >
> >   Adobe Flash Video Format demuxer.
> > diff --git a/libavformat/Makefile b/libavformat/Makefile
> > index c45caa3eed..42ced953f6 100644
> > --- a/libavformat/Makefile
> > +++ b/libavformat/Makefile
> > @@ -284,6 +284,7 @@ OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)+= img2dec.o 
> > img2.o
> >   OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER) += img2dec.o img2.o
> >   OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o img2.o
> >   OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
> > +OBJS-$(CONFIG_IMF_DEMUXER)   += imfdec.o imf_cpl.o
>
> This commit does not contain those files, and thus will fail to compile.
> Every commit individually has to compile and pass fate.
>
> Just add the necessary bits to build along with the code itself.
>
> >   OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
> >   OBJS-$(CONFIG_IPMOVIE_DEMUXER)   += ipmovie.o
> >   OBJS-$(CONFIG_IPU_DEMUXER)   += ipudec.o rawdec.o
> > @@ -693,6 +694,7 @@ TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
> >   TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
> >   TESTPROGS-$(CONFIG_NETWORK)  += noproxy
> >   TESTPROGS-$(CONFIG_SRTP) += srtp
> > +TESTPROGS-$(CONFIG_IMF_DEMUXER)  += imf
> >
> >   TOOLS = aviocat  

[FFmpeg-devel] [PATCH] avcodec/mmaldec: use decoupled dataflow

2021-09-23 Thread Ho Ming Shun
MMAL is an fundamentally an asynchronous decoder, which was a bad fit
for the legacy dataflow API. Often multiple packets are enqueued before
a flood of frames are returned from MMAL.

The previous lockstep dataflow meant that any delay in returning packets
from the VPU would cause ctx->queue_decoded_frames to grow with no way
of draining the queue.

Testing this with mpv streaming from an RTSP source reduced decode
latency from 2s to about 0.2s.

Signed-off-by: Ho Ming Shun 
---
 libavcodec/mmaldec.c | 30 +++---
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 96140bf53d..3d7cc90cd2 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -570,6 +570,7 @@ static int ffmmal_add_packet(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 done:
 av_buffer_unref(&buf);
+av_packet_unref(avpkt);
 return ret;
 }
 
@@ -655,6 +656,12 @@ static int ffmal_copy_frame(AVCodecContext *avctx,  
AVFrame *frame,
   avctx->pix_fmt, avctx->width, avctx->height);
 }
 
+frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
+frame->width = avctx->width;
+frame->width = avctx->width;
+frame->height = avctx->height;
+frame->format = avctx->pix_fmt;
+
 frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : 
buffer->pts;
 frame->pkt_dts = AV_NOPTS_VALUE;
 
@@ -763,12 +770,12 @@ done:
 return ret;
 }
 
-static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
+static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
 {
 MMALDecodeContext *ctx = avctx->priv_data;
-AVFrame *frame = data;
 int ret = 0;
+AVPacket avpkt;
+int got_frame = 0;
 
 if (avctx->extradata_size && !ctx->extradata_sent) {
 AVPacket pkt = {0};
@@ -782,7 +789,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return ret;
 }
 
-if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0)
+ret = ff_decode_get_packet(avctx, &avpkt);
+if(ret == 0) {
+if ((ret = ffmmal_add_packet(avctx, &avpkt, 0)) < 0)
+return ret;
+} else if(ret < 0 && !(ret == AVERROR(EAGAIN)))
 return ret;
 
 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
@@ -791,7 +802,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
 return ret;
 
-if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0)
+if ((ret = ffmmal_read_frame(avctx, frame, &got_frame)) < 0)
 return ret;
 
 // ffmmal_read_frame() can block for a while. Since the decoder is
@@ -803,7 +814,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
 return ret;
 
-return ret;
+if(!got_frame && ret == 0)
+return AVERROR(EAGAIN);
+else
+return ret;
+
+
 }
 
 static const AVCodecHWConfigInternal *const mmal_hw_configs[] = {
@@ -835,7 +851,7 @@ static const AVOption options[]={
 .priv_data_size = sizeof(MMALDecodeContext), \
 .init   = ffmmal_init_decoder, \
 .close  = ffmmal_close_decoder, \
-.decode = ffmmal_decode, \
+.receive_frame  = ffmmal_receive_frame, \
 .flush  = ffmmal_flush, \
 .priv_class = &ffmmal_##NAME##_dec_class, \
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \
-- 
2.33.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 24/27] avformat/aviobuf: Extend ffio_fill to 64bits

2021-09-23 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 19/27] avformat/riffenc: Fix indentation

2021-09-23 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 21/27] avformat/omadec: Don't output uninitialized values

2021-09-23 Thread Paul B Mahol
lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mmaldec: fix deprecation warning

2021-09-23 Thread Ming Shun Ho
On Fri, Sep 24, 2021 at 2:09 AM Andreas Rheinhardt
 wrote:
>
> Ming Shun Ho:
> > On Fri, Sep 24, 2021 at 12:52 AM Andreas Rheinhardt
> >  wrote:
> >>
> >> Ho Ming Shun:
> >>> Signed-off-by: Ho Ming Shun 
> >>> ---
> >>>  libavcodec/mmaldec.c | 2 ++
> >>>  1 file changed, 2 insertions(+)
> >>>
> >>> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> >>> index 5b75a1e74d..96140bf53d 100644
> >>> --- a/libavcodec/mmaldec.c
> >>> +++ b/libavcodec/mmaldec.c
> >>> @@ -772,7 +772,9 @@ static int ffmmal_decode(AVCodecContext *avctx, void 
> >>> *data, int *got_frame,
> >>>
> >>>  if (avctx->extradata_size && !ctx->extradata_sent) {
> >>>  AVPacket pkt = {0};
> >>> +FF_DISABLE_DEPRECATION_WARNINGS
> >>>  av_init_packet(&pkt);
> >>> +FF_ENABLE_DEPRECATION_WARNINGS
> >>>  pkt.data = avctx->extradata;
> >>>  pkt.size = avctx->extradata_size;
> >>>  ctx->extradata_sent = 1;
> >>>
> >>
> >> You did not fix the underlying issue (av_init_packet() is deprecated and
> >> its use should therefore be discontinued), but just hid the warning.
> >
> > I was under the impression that it is deprecated to remove sizeof(AVPacket)
> > from libavcodec's ABI. Internally however it should be ok.
> >
>
> Some devs actually want to move AVPacket to libavutil (because it is
> supposed to be cleaner) in the long term, so we already try to avoid
> AVPackets on the stack in general. Note that get_packet_defaults() (the
> actual successor to av_init_packet()) is internal to libavcodec/avpacket.c.
>
> >> This patch here:
> >> https://ffmpeg.org/pipermail/ffmpeg-devel/2021-March/277278.html intends
> >> to fix the underlying issue (and also the warning). I have just not
> >> found anyone to actually test whether it works. I presume you could do
> >> it. Would you be so kind and do it?
> >
> > Had to patch it to build:
> >
> > diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> > index 0ea07ea787..2bed7309bb 100644
> > --- a/libavcodec/mmaldec.c
> > +++ b/libavcodec/mmaldec.c
> > @@ -779,7 +779,7 @@ static int ffmmal_decode(AVCodecContext *avctx,
> > void *data, int *got_frame,
> > return ret;
> > }
> >
> > -if ((ret = ffmmal_add_packet(avctx, avpkt, pkt->data, pkt->size)) < 0)
> > +if ((ret = ffmmal_add_packet(avctx, avpkt, avpkt->data, avpkt->size)) 
> > < 0)
>
> How embarrassing. Good that it has never been applied in that form.
>
> > return ret;
> >
> > if ((ret = ffmmal_fill_input_port(avctx)) < 0)
> >
> > Seems to be working fine with the above patch applied.
> >
>
> Thanks for testing.
>
> > Will this series likely be applied? I am asking because I am working on 
> > another
> > patch to convert this to the new dataflow API, and your patches look like 
> > they
> > might conflict.
> >
>
> What new dataflow API? While it is very likely to lead to conflicts when
I meant the decoupled dataflow API.
> applying, I think it is unlikely to lead to actual deep conflicts that
> can't be easily resolved. Do you already have a scetch of your patches
> for the dataflow API for me to take a look?

Just sent out the patch here:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4935
>
> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 17/27] avformat/movenchint: Simplify writing padding

2021-09-23 Thread Paul B Mahol
lgtm if ffio_fill does not turn negative argument into very positive one.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 17/27] avformat/movenchint: Simplify writing padding

2021-09-23 Thread Andreas Rheinhardt
Paul B Mahol:
> lgtm if ffio_fill does not turn negative argument into very positive one.
> 

ffio_fill does not do that; and the argument here is always nonnegative.
Here is the loop:

while (size > 0) {
int len = size; // size is an int and > 0 and so is len is now
if (len > 14)
len = 14;
/* From here on len is always <= 14 */
avio_w8(out, 1); /* immediate constructor */
avio_w8(out, len); /* amount of valid data */
avio_write(out, data, len);
data += len;
size -= len;

for (; len < 14; len++)
avio_w8(out, 0);

(*entries)++;
}

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxf: support MCA audio information

2021-09-23 Thread Tomas Härdin
tor 2021-09-23 klockan 00:02 +0200 skrev Marton Balint:


On Fri, 17 Sep 2021, Marc-Antoine Arnaud wrote:

> ---
> libavformat/mxf.h    |   1 +
> libavformat/mxfdec.c | 277
> ++-
> 2 files changed, 272 insertions(+), 6 deletions(-)

I guess the questionable part of this patch is the internal reordering
of
audio channels. This might or might not be what the user expects.

Can we signal this and have the ffmpeg CLI automagically insert a
channel reordering filter? That way someone wanting to speed the
reordering up could write vectorized code for it
> 
> +static int mxf_read_mca_sub_descriptor(void *arg, AVIOContext *pb,
> int tag, int size, UID uid, int64_t klv_offset)
> +{
> +    MXFMCASubDescriptor *mca_sub_descriptor = arg;
> +
> +    if (IS_KLV_KEY(uid, mxf_mca_label_dictionnary_id)) {
> +    avio_read(pb, mca_sub_descriptor->mca_label_dictionnary_id,
> 16);
> +    }
> +    if (IS_KLV_KEY(uid, mxf_mca_link_id)) {
> +    avio_read(pb, mca_sub_descriptor->mca_link_id, 16);
> +    }
> +    if (IS_KLV_KEY(uid, mxf_soundfield_group_link_id)) {
> +    avio_read(pb, mca_sub_descriptor->mca_group_link_id, 16);
> +    }

You don't have to open braces for single-line blocks, ffmpeg tends to 
follow this style, so preferably you should too.

I actually prefer braces always. I've been bitten by lack of braces at
least once.

/Tomas

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/5] [IMF demuxer] Headers

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Public and private header files for the IMF demuxer. The functions and 
constants defines in the public header file imf.h can be used by other modules. 
The Interoperable Master Format (IMF) is a file-based media format for the 
delivery and storage of professional audio-visual masters. An IMF Composition 
consists of an XML playlist (the Composition Playlist) and a collection of MXF 
files (the Track Files). The Composition Playlist (CPL) assembles the Track 
Files onto a timeline, which consists of multiple tracks. The location of the 
Track Files referenced by the Composition Playlist is stored in one or more XML 
documents called Asset Maps. More details at https://www.imfug.com/explainer. 
The IMF standard was first introduced in 2013 and is managed by the SMPTE.

 libavformat/imf.h  | 156 +
 libavformat/imf_internal.h | 100 
 2 files changed, 256 insertions(+)
 create mode 100644 libavformat/imf.h
 create mode 100644 libavformat/imf_internal.h

diff --git a/libavformat/imf.h b/libavformat/imf.h
new file mode 100644
index 00..8162cbc031
--- /dev/null
+++ b/libavformat/imf.h
@@ -0,0 +1,156 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Public header file for the processing of Interoperable Master Format (IMF) 
packages.
+ * 
+ * @author Pierre-Anthony Lemieux
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#ifndef AVFORMAT_IMF_H
+#define AVFORMAT_IMF_H
+
+#include "avformat.h"
+#include "libavformat/avio.h"
+#include "libavutil/rational.h"
+#include 
+
+/**
+ * UUID as defined in IETF RFC 422
+ */
+typedef uint8_t UUID[16];
+
+/**
+ * IMF Composition Playlist Base Resource
+ */
+typedef struct IMFBaseResource {
+AVRational edit_rate; /**< BaseResourceType/EditRate */
+unsigned long entry_point; /**< BaseResourceType/EntryPoint */
+unsigned long duration; /**< BaseResourceType/Duration */
+unsigned long repeat_count; /**< BaseResourceType/RepeatCount */
+} IMFBaseResource;
+
+/**
+ * IMF Composition Playlist Track File Resource
+ */
+typedef struct IMFTrackFileResource {
+IMFBaseResource base;
+UUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */
+} IMFTrackFileResource;
+
+/**
+ * IMF Marker
+ */
+typedef struct IMFMarker {
+xmlChar *label_utf8; /**< Marker/Label */
+xmlChar *scope_utf8; /**< Marker/Label/\@scope */
+unsigned long offset; /**< Marker/Offset */
+} IMFMarker;
+
+/**
+ * IMF Composition Playlist Marker Resource
+ */
+typedef struct IMFMarkerResource {
+IMFBaseResource base;
+unsigned long marker_count; /**< Number of Marker elements */
+IMFMarker *markers; /**< Marker elements */
+} IMFMarkerResource;
+
+/**
+ * IMF Composition Playlist Virtual Track
+ */
+typedef struct IMFBaseVirtualTrack {
+UUID id_uuid; /**< TrackId associated with the Virtual Track */
+} IMFBaseVirtualTrack;
+
+/**
+ * IMF Composition Playlist Virtual Track that consists of Track File Resources
+ */
+typedef struct IMFTrackFileVirtualTrack {
+IMFBaseVirtualTrack base;
+unsigned long resource_count; /**< Number of Resource elements present in 
the Virtual Track */
+IMFTrackFileResource *resources; /**< Resource elements of the Virtual 
Track */
+} IMFTrackFileVirtualTrack;
+
+/**
+ * IMF Composition Playlist Virtual Track that consists of Marker Resources
+ */
+typedef struct IMFMarkerVirtualTrack {
+IMFBaseVirtualTrack base;
+unsigned long resource_count; /**< Number of Resource elements present in 
the Virtual Track */
+IMFMarker

[FFmpeg-devel] [PATCH 2/5] [IMF demuxer] CPL processor

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Implements IMF Composition Playlist (CPL) parsing. The IMF CPL is specified 
in SMTPE ST 2067-3 and defines a timeline onto which MXF files are placed.

 libavformat/imf_cpl.c | 652 ++
 1 file changed, 652 insertions(+)
 create mode 100644 libavformat/imf_cpl.c

diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
new file mode 100644
index 00..e0c8e2c58f
--- /dev/null
+++ b/libavformat/imf_cpl.c
@@ -0,0 +1,652 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Implements IMP CPL processing
+ *
+ * @author Pierre-Anthony Lemieux
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#include "imf.h"
+#include "imf_internal.h"
+#include "libavformat/mxf.h"
+#include "libavutil/bprint.h"
+#include "libavutil/error.h"
+#include 
+
+xmlNodePtr xml_get_child_element_by_name(xmlNodePtr parent, const char 
*name_utf8) {
+xmlNodePtr cur_element;
+
+cur_element = xmlFirstElementChild(parent);
+while (cur_element) {
+if (xmlStrcmp(cur_element->name, name_utf8) == 0)
+return cur_element;
+cur_element = xmlNextElementSibling(cur_element);
+}
+return NULL;
+}
+
+int xml_read_UUID(xmlNodePtr element, uint8_t uuid[16]) {
+xmlChar *element_text = NULL;
+int scanf_ret;
+int ret = 0;
+
+element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
+scanf_ret = sscanf(element_text,
+UUID_FORMAT,
+&uuid[0],
+&uuid[1],
+&uuid[2],
+&uuid[3],
+&uuid[4],
+&uuid[5],
+&uuid[6],
+&uuid[7],
+&uuid[8],
+&uuid[9],
+&uuid[10],
+&uuid[11],
+&uuid[12],
+&uuid[13],
+&uuid[14],
+&uuid[15]);
+if (scanf_ret != 16) {
+av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
+ret = AVERROR_INVALIDDATA;
+}
+xmlFree(element_text);
+
+return ret;
+}
+
+int xml_read_rational(xmlNodePtr element, AVRational *rational) {
+xmlChar *element_text = NULL;
+int ret = 0;
+
+element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
+if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2) {
+av_log(NULL, AV_LOG_ERROR, "Invalid rational number\n");
+ret = AVERROR_INVALIDDATA;
+}
+xmlFree(element_text);
+
+return ret;
+}
+
+int xml_read_ulong(xmlNodePtr element, unsigned long *number) {
+xmlChar *element_text = NULL;
+int ret = 0;
+
+element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
+if (sscanf(element_text, "%lu", number) != 1) {
+av_log(NULL, AV_LOG_ERROR, "Invalid unsigned long");
+ret = AVERROR_INVALIDDATA;
+}
+xmlFree(element_text);
+
+return ret;
+}
+
+static void imf_base_virtual_track_init(IMFBaseVirtualTrack *track) {
+memset(track->id_uuid, 0, sizeof(track->id_uuid));
+}
+
+static void imf_marker_virtual_track_init(IMFMarkerVirtualTrack *track) {
+imf_base_virtual_track_init((IMFBaseVirtualTrack *)track);
+track->resource_count = 0;
+track->resources = NULL;
+}
+
+static void imf_trackfile_virtual_track_init(IMFTrackFileVirtualTrack *track) {
+imf_base_virtual_track_init((IMFBaseVirtualTrack *)track);
+track->resource_count = 0;
+track->resources = NULL;
+}
+
+static void imf_base_resource_init(IMFBaseResource *rsrc) {
+rsrc->duration = 0;
+rsrc->edit_rate = av_make_q(0, 0);
+rsrc->entry_point = 0;
+rsrc->repeat_count = 1;
+}
+
+static void imf_

[FFmpeg-devel] [PATCH 3/5] [IMF demuxer] Demuxer implementation

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Implements the IMF demuxer, which accepts as input an IMF CPL. The assets 
referenced by the CPL can be contained in multiple deliveries, each defined by 
an ASSETMAP file:./ffmpeg -assetmaps \,\,... -i \ If -assetmaps is not specified, FFMPEG looks 
for a file called ASSETMAP.xml in the same directory as the CPL.

 libavformat/imfdec.c | 646 +++
 1 file changed, 646 insertions(+)
 create mode 100644 libavformat/imfdec.c

diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
new file mode 100644
index 00..1dee2ba8bb
--- /dev/null
+++ b/libavformat/imfdec.c
@@ -0,0 +1,646 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Demuxes an IMF Composition
+ *
+ * References
+ * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format
+ * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core 
Constraints
+ * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — Composition 
Playlist
+ * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — Essence 
Component
+ * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — 
Application #2
+ * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — 
Application #2 Extended
+ * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — Common 
Image Pixel Color Schemes
+ * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping and 
File Segmentation
+ *
+ * @author Marc-Antoine Arnaud
+ * @author Valentin Noel
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#include "imf.h"
+#include "imf_internal.h"
+#include "internal.h"
+#include "libavutil/opt.h"
+#include "libavutil/bprint.h"
+#include "libavutil/avstring.h"
+#include "mxf.h"
+#include "url.h"
+#include 
+#include 
+
+#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1)
+#define DEFAULT_ASSETMAP_SIZE 8 * 1024
+
+typedef struct IMFVirtualTrackResourcePlaybackCtx {
+IMFAssetLocator *locator;
+IMFTrackFileResource *resource;
+AVFormatContext *ctx;
+} IMFVirtualTrackResourcePlaybackCtx;
+
+typedef struct IMFVirtualTrackPlaybackCtx {
+// Track index in playlist
+int32_t index;
+// Time counters
+AVRational current_timestamp;
+AVRational duration;
+// Resources
+unsigned int resource_count;
+IMFVirtualTrackResourcePlaybackCtx **resources;
+// Decoding cursors
+uint32_t current_resource_index;
+int64_t last_pts;
+} IMFVirtualTrackPlaybackCtx;
+
+typedef struct IMFContext {
+const AVClass *class;
+const char *base_url;
+char *asset_map_paths;
+AVIOInterruptCB *interrupt_callback;
+AVDictionary *avio_opts;
+IMFCPL *cpl;
+IMFAssetLocatorMap *asset_locator_map;
+unsigned int track_count;
+IMFVirtualTrackPlaybackCtx **tracks;
+} IMFContext;
+
+int is_url(const char *string) {
+char *substr = strstr(string, "://");
+return substr != NULL;
+}
+
+int is_unix_absolute_path(const char *string) {
+char *substr = strstr(string, "/");
+int index = (int)(substr - string);
+return index == 0;
+}
+
+int is_dos_absolute_path(const char *string) {
+// Absolute path case: `C:\path\to\somwhere`
+char *substr = strstr(string, ":\\");
+int index = (int)(substr - string);
+if (index == 1) {
+return 1;
+}
+
+// Absolute path case: `C:/path/to/somwhere`
+substr = strstr(string, ":/");
+index = (int)(substr - string);
+if (index == 1) {
+return 1;
+}
+
+// Network path case: `\\path\to\somwhere`
+substr = strstr(string, "");

[FFmpeg-devel] [PATCH 4/5] [IMF demuxer] Tests

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Tests for the public API of the IMF demuxer.

 libavformat/tests/imf.c | 476 
 1 file changed, 476 insertions(+)
 create mode 100644 libavformat/tests/imf.c

diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c
new file mode 100644
index 00..47f05d965d
--- /dev/null
+++ b/libavformat/tests/imf.c
@@ -0,0 +1,476 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) Sandflow Consulting LLC
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Tests for IMF CPL and ASSETMAP processing
+ * 
+ * @author Valentin Noel
+ * @author Pierre-Anthony Lemieux
+ * @file
+ * @ingroup lavu_imf
+ */
+
+#include "libavformat/imf.h"
+#include "libavformat/imf_internal.h"
+#include "libavformat/mxf.h"
+
+#include 
+
+const char *cpl_doc =
+"http://www.smpte-ra.org/schemas/2067-3/2016\"";
+" xmlns:cc=\"http://www.smpte-ra.org/schemas/2067-2/2016\"";
+" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\";>"
+"urn:uuid:8713c020-2489-45f5-a9f7-87be539e20b5"
+"2021-07-13T17:06:22Z"
+"FFMPEG"
+"FFMPEG sample content"
+""
+"  "
+"urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f"
+"  "
+""
+"24000 1001"
+""
+""
+"urn:uuid:81fed4e5-9722-400a-b9d1-7f2bd21df4b6"
+""
+""
+"urn:uuid:16327185-9205-47ef-a17b-ee28df251db7"
+"urn:uuid:461f5424-8f6e-48a9-a385-5eda46fda381"
+""
+""
+"urn:uuid:ea3d0f23-55d6-4e03-86ec-cfe0666f0e6a"
+"24"
+""
+"LFOA"
+"5"
+""
+""
+""
+""
+""
+"urn:uuid:6ae100b0-92d1-41be-9321-85e0933dfc42"
+"urn:uuid:e8ef9653-565c-479c-8039-82d4547973c5"
+""
+""
+"urn:uuid:7d418acb-07a3-4e57-984c-b8ea2f7de4ec"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:6f768ca4-c89e-4dac-9056-a29425d40ba1"
+""
+""
+""
+""
+"urn:uuid:754dae53-c25f-4f3c-97e4-2bfe5463f83b"
+"urn:uuid:68e3fae5-d94b-44d2-92a6-b94877fbcdb5"
+""
+""
+"urn:uuid:61ce2a70-10a2-4521-850b-4218755ff3c9"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:381dadd2-061e-46cc-a63a-e3d58ce7f488"
+""
+""
+""
+""
+"urn:uuid:d29b3884-6633-4dad-9c67-7154af342bc6"
+"urn:uuid:6978c106-95bc-424b-a17c-628206a5892d"
+""
+""
+"urn:uuid:001ea472-f5da-436c-86de-acaa68c1a7e4"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:381dadd2-061e-46cc-a63a-e3d58ce7f488"
+""
+""
+""
+""
+"urn:uuid:02af22bf-f776-488a-b001-eb6e16953119"
+"urn:uuid:19ff6da1-be79-4235-8d04-42201ad06e65"
+""
+""
+"urn:uuid:dfa84292-0609-4097-824c-8e2e15e2ce4d"
+"24"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:bd6272b6-511e-47c1-93bc-d56ebd314a70"
+""
+""
+""
+""
+""
+""
+"urn:uuid:a94be493-cd55-4bf7-b496-ea87bfe38632"
+""
+""
+"urn:uuid:20c6020b-1fc0-4080-bcf7-89f09f95bea8"
+"urn:uuid:461f5424-8f6e-48a9-a385-5eda46fda381"
+""
+""
+"urn:uuid:d1f93845-d3e5-4c3b-aa67-8d96c45cfe9c"
+"36"
+""
+"FFOA"
+"20"
+""
+""
+"LFOC"
+"24"
+""
+""
+""
+""
+""
+"urn:uuid:9b509f42-e4e8-4f78-8c2a-12ddd79ef3c5"
+"urn:uuid:e8ef9653-565c-479c-8039-82d4547973c5"
+""
+""
+"urn:uuid:a733d812-a3d7-45e9-ba50-13b856d5d35a"
+"36"
+
"urn:uuid:f00e49a8-0dec-4e6c-95e7-078df988b751"
+"urn:uuid:f3b263b3-096b-4360-a952-b1a9623cd0ca"
+""
+""
+""
+""
+"urn:uuid:19a282e6-beac-4d99-a008-afa61378eb6c"
+"urn:uuid:68e3fae5-

[FFmpeg-devel] [PATCH 5/5] [IMF demuxer] build system

2021-09-23 Thread pal
From: Pierre-Anthony Lemieux 

Signed-off-by: Pierre-Anthony Lemieux 
---

Notes:
Modify the FFMPEG build system to add support for an IMF demuxer.

 MAINTAINERS  | 1 +
 configure| 3 ++-
 doc/demuxers.texi| 6 ++
 libavformat/Makefile | 2 ++
 libavformat/allformats.c | 1 +
 5 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index dcac46003e..7a6972fe1a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -433,6 +433,7 @@ Muxers/Demuxers:
   idroqdec.cMike Melanson
   iff.c Jaikrishnan Menon
   img2*.c   Michael Niedermayer
+  imf*.cMarc-Antoine Arnaud, Pierre-Anthony 
Lemieux, Valentin Noël
   ipmovie.c Mike Melanson
   ircam*Paul B Mahol
   iss.c Stefan Gehrer
diff --git a/configure b/configure
index 231d0398a8..c9f815296b 100755
--- a/configure
+++ b/configure
@@ -297,7 +297,7 @@ External library support:
   --enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
   --enable-libxml2 enable XML parsing using the C library libxml2, 
needed
-   for dash demuxing support [no]
+   for dash and imf demuxing support [no]
   --enable-libzimg enable z.lib, needed for zscale filter [no]
   --enable-libzmq  enable message passing via libzmq [no]
   --enable-libzvbi enable teletext support via libzvbi [no]
@@ -3363,6 +3363,7 @@ hls_muxer_select="mpegts_muxer"
 hls_muxer_suggest="gcrypt openssl"
 image2_alias_pix_demuxer_select="image2_demuxer"
 image2_brender_pix_demuxer_select="image2_demuxer"
+imf_demuxer_deps="libxml2"
 ipod_muxer_select="mov_muxer"
 ismv_muxer_select="mov_muxer"
 ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 1c9575b2e8..37efe6ce1a 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -267,6 +267,12 @@ which streams to actually receive.
 Each stream mirrors the @code{id} and @code{bandwidth} properties from the
 @code{} as metadata keys named "id" and "variant_bitrate" 
respectively.
 
+@section imf
+
+Interoperable Master Format demuxer.
+
+This demuxer presents audio and video streams found in an IMF Composition.
+
 @section flv, live_flv, kux
 
 Adobe Flash Video Format demuxer.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index c45caa3eed..42ced953f6 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -284,6 +284,7 @@ OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)+= img2dec.o 
img2.o
 OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMF_DEMUXER)   += imfdec.o imf_cpl.o
 OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
 OBJS-$(CONFIG_IPMOVIE_DEMUXER)   += ipmovie.o
 OBJS-$(CONFIG_IPU_DEMUXER)   += ipudec.o rawdec.o
@@ -693,6 +694,7 @@ TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
 TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
 TESTPROGS-$(CONFIG_NETWORK)  += noproxy
 TESTPROGS-$(CONFIG_SRTP) += srtp
+TESTPROGS-$(CONFIG_IMF_DEMUXER)  += imf
 
 TOOLS = aviocat \
 ismindex\
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 5471f7c16f..bad4494981 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -211,6 +211,7 @@ extern const AVInputFormat  ff_image2pipe_demuxer;
 extern const AVOutputFormat ff_image2pipe_muxer;
 extern const AVInputFormat  ff_image2_alias_pix_demuxer;
 extern const AVInputFormat  ff_image2_brender_pix_demuxer;
+extern const AVInputFormat  ff_imf_demuxer;
 extern const AVInputFormat  ff_ingenient_demuxer;
 extern const AVInputFormat  ff_ipmovie_demuxer;
 extern const AVOutputFormat ff_ipod_muxer;
-- 
2.17.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/5] [IMF demuxer] build system

2021-09-23 Thread Pierre-Anthony Lemieux
I have reordered the patches so that each patch individually compiles,
when applied in order.

Let me know if this does not work.

Best,

-- Pierre

On Thu, Sep 23, 2021 at 11:13 AM Pierre-Anthony Lemieux
 wrote:
>
> Hi Timo,
>
> > Every commit individually has to compile and pass fate.
>
> Ok. This will reduce the number of patches.
>
> Best,
>
> -- Pierre
>
> On Thu, Sep 23, 2021 at 11:07 AM Timo Rothenpieler
>  wrote:
> >
> > On 23/09/2021 19:00, p...@sandflow.com wrote:
> > > From: Pierre-Anthony Lemieux 
> > >
> > > Signed-off-by: Pierre-Anthony Lemieux 
> > > ---
> > >
> > > Notes:
> > >  Modify the FFMPEG build system to add support for an IMF demuxer. 
> > > The Interoperable Master Format (IMF) is a file-based media format for 
> > > the delivery and storage of professional audio-visual masters. An IMF 
> > > Composition consists of an XML playlist (the Composition Playlist) and a 
> > > collection of MXF files (the Track Files). The Composition Playlist (CPL) 
> > > assembles the Track Files onto a timeline, which consists of multiple 
> > > tracks. The location of the Track Files referenced by the Composition 
> > > Playlist is stored in one or more XML documents called Asset Maps. More 
> > > details at https://www.imfug.com/explainer. The IMF standard was first 
> > > introduced in 2013 and is managed by the SMPTE.
> > >
> > >   MAINTAINERS  | 1 +
> > >   configure| 3 ++-
> > >   doc/demuxers.texi| 6 ++
> > >   libavformat/Makefile | 2 ++
> > >   libavformat/allformats.c | 1 +
> > >   5 files changed, 12 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > index dcac46003e..7a6972fe1a 100644
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -433,6 +433,7 @@ Muxers/Demuxers:
> > > idroqdec.cMike Melanson
> > > iff.c Jaikrishnan Menon
> > > img2*.c   Michael Niedermayer
> > > +  imf*.cMarc-Antoine Arnaud, 
> > > Pierre-Anthony Lemieux, Valentin Noël
> > > ipmovie.c Mike Melanson
> > > ircam*Paul B Mahol
> > > iss.c Stefan Gehrer
> > > diff --git a/configure b/configure
> > > index 231d0398a8..c9f815296b 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -297,7 +297,7 @@ External library support:
> > > --enable-libxvid enable Xvid encoding via xvidcore,
> > >  native MPEG-4/Xvid encoder exists [no]
> > > --enable-libxml2 enable XML parsing using the C library 
> > > libxml2, needed
> > > -   for dash demuxing support [no]
> > > +   for dash and imf demuxing support [no]
> > > --enable-libzimg enable z.lib, needed for zscale filter [no]
> > > --enable-libzmq  enable message passing via libzmq [no]
> > > --enable-libzvbi enable teletext support via libzvbi [no]
> > > @@ -3363,6 +3363,7 @@ hls_muxer_select="mpegts_muxer"
> > >   hls_muxer_suggest="gcrypt openssl"
> > >   image2_alias_pix_demuxer_select="image2_demuxer"
> > >   image2_brender_pix_demuxer_select="image2_demuxer"
> > > +imf_demuxer_deps="libxml2"
> > >   ipod_muxer_select="mov_muxer"
> > >   ismv_muxer_select="mov_muxer"
> > >   ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
> > > diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> > > index 1c9575b2e8..37efe6ce1a 100644
> > > --- a/doc/demuxers.texi
> > > +++ b/doc/demuxers.texi
> > > @@ -267,6 +267,12 @@ which streams to actually receive.
> > >   Each stream mirrors the @code{id} and @code{bandwidth} properties from 
> > > the
> > >   @code{} as metadata keys named "id" and 
> > > "variant_bitrate" respectively.
> > >
> > > +@section imf
> > > +
> > > +Interoperable Master Format demuxer.
> > > +
> > > +This demuxer presents audio and video streams found in an IMF 
> > > Composition.
> > > +
> > >   @section flv, live_flv, kux
> > >
> > >   Adobe Flash Video Format demuxer.
> > > diff --git a/libavformat/Makefile b/libavformat/Makefile
> > > index c45caa3eed..42ced953f6 100644
> > > --- a/libavformat/Makefile
> > > +++ b/libavformat/Makefile
> > > @@ -284,6 +284,7 @@ OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)+= 
> > > img2dec.o img2.o
> > >   OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER) += img2dec.o img2.o
> > >   OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o img2.o
> > >   OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
> > > +OBJS-$(CONFIG_IMF_DEMUXER)   += imfdec.o imf_cpl.o
> >
> > This commit does not contain those files, and thus will fail to compile.
> > Every commit individually has to compile and pass fate.
> >
> > Just add the necessary bits to build along with the code itself.
> >
> > >   OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
> > >   OBJS-$(CO

Re: [FFmpeg-devel] [PATCH 14/14] avcodec/elbg: Mark ELBGContext as being unaliased by using av_restrict

2021-09-23 Thread Tomas Härdin
mån 2021-09-20 klockan 23:18 +0200 skrev Andreas Rheinhardt:
> This improves performance: For msvideo1, the performance improved by
> 4.8% when encoding the sample from the fate-vsynth1-msvideo1 test;
> when encoding the sample from fate-vsynth1-cinepak, performance
> improved by 2%. The compiler user was GCC 10 and the calls to encode2
> have been timed.

Median wall time for three cinepak runs went from 1m36,455s to
1m35,251s. Not a huge difference. Not worse anyway.

/Tomas

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avcodec/mmaldec: use decoupled dataflow

2021-09-23 Thread Andreas Rheinhardt
Ho Ming Shun:
> MMAL is an fundamentally an asynchronous decoder, which was a bad fit
> for the legacy dataflow API. Often multiple packets are enqueued before
> a flood of frames are returned from MMAL.
> 
> The previous lockstep dataflow meant that any delay in returning packets
> from the VPU would cause ctx->queue_decoded_frames to grow with no way
> of draining the queue.
> 
> Testing this with mpv streaming from an RTSP source reduced decode
> latency from 2s to about 0.2s.
> 
> Signed-off-by: Ho Ming Shun 
> ---
>  libavcodec/mmaldec.c | 30 +++---
>  1 file changed, 23 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> index 96140bf53d..3d7cc90cd2 100644
> --- a/libavcodec/mmaldec.c
> +++ b/libavcodec/mmaldec.c
> @@ -570,6 +570,7 @@ static int ffmmal_add_packet(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  
>  done:
>  av_buffer_unref(&buf);
> +av_packet_unref(avpkt);
>  return ret;
>  }
>  
> @@ -655,6 +656,12 @@ static int ffmal_copy_frame(AVCodecContext *avctx,  
> AVFrame *frame,
>avctx->pix_fmt, avctx->width, avctx->height);
>  }
>  
> +frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
> +frame->width = avctx->width;
> +frame->width = avctx->width;
> +frame->height = avctx->height;
> +frame->format = avctx->pix_fmt;
> +
>  frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : 
> buffer->pts;
>  frame->pkt_dts = AV_NOPTS_VALUE;
>  
> @@ -763,12 +770,12 @@ done:
>  return ret;
>  }
>  
> -static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame,
> - AVPacket *avpkt)
> +static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>  {
>  MMALDecodeContext *ctx = avctx->priv_data;
> -AVFrame *frame = data;
>  int ret = 0;
> +AVPacket avpkt;

You are adding a new AVPacket; and you are not even zeroing it. This is
even worse than the current code (and it might even be dangerous:
ff_decode_get_packet() expects initialized, blank packets, not
uninitialized ones; what you are doing only works because this decoder
does not have an automatically inserted bitstream filter).

You will have to add an actually allocated packet for this; or one could
reuse the spare packet of the DecodeSimpleContext that is unused for
decoders implementing the receive_frame API.

It is easy to fix the deprecation issue if one already has a spare
packet: Just put the extradata into said packet.
My guess that your patch does not exhibit any deep conflicts with mine
turned out to be correct: the only part where there is a real conflict
is in the fact that it doesn't make any sense any more to treat the
packet as const, given that a decoder implementing the receive_frame API
is supposed to unref the packets it receives on its own.
While I regard not wrapping the extradata in a packet as cleaner, the
code actually becomes simpler if one does so (as I will demonstrate
lateron). In other words: I drop my patches.

> +int got_frame = 0;
>  
>  if (avctx->extradata_size && !ctx->extradata_sent) {
>  AVPacket pkt = {0};
> @@ -782,7 +789,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  return ret;
>  }
>  
> -if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0)
> +ret = ff_decode_get_packet(avctx, &avpkt);
> +if(ret == 0) {
> +if ((ret = ffmmal_add_packet(avctx, &avpkt, 0)) < 0)
> +return ret;
> +} else if(ret < 0 && !(ret == AVERROR(EAGAIN)))
>  return ret;
>  
>  if ((ret = ffmmal_fill_input_port(avctx)) < 0)
> @@ -791,7 +802,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  if ((ret = ffmmal_fill_output_port(avctx)) < 0)
>  return ret;
>  
> -if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0)
> +if ((ret = ffmmal_read_frame(avctx, frame, &got_frame)) < 0)
>  return ret;
>  
>  // ffmmal_read_frame() can block for a while. Since the decoder is
> @@ -803,7 +814,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  if ((ret = ffmmal_fill_input_port(avctx)) < 0)
>  return ret;
>  
> -return ret;
> +if(!got_frame && ret == 0)
> +return AVERROR(EAGAIN);
> +else
> +return ret;
> +
> +

Unnecessary newlines.

>  }
>  
>  static const AVCodecHWConfigInternal *const mmal_hw_configs[] = {
> @@ -835,7 +851,7 @@ static const AVOption options[]={
>  .priv_data_size = sizeof(MMALDecodeContext), \
>  .init   = ffmmal_init_decoder, \
>  .close  = ffmmal_close_decoder, \
> -.decode = ffmmal_decode, \
> +.receive_frame  = ffmmal_receive_frame, \
>  .flush  = ffmmal_flush, \
>  .priv_class = &ffmmal_##NAME##_dec_class, \
>  .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailma

[FFmpeg-devel] [PATCH 01/02] configure: Add macro defination for SVC decoding function based on Temporal scalability for H.264/AVC

2021-09-23 Thread ??????
Dear,
  According to Mr. Zhao's advice last time, I made some modifications 
to my patch.
  This patch just adds a macro defination named "TMP_SVC_DEC_H264" to the 
configure file that controls switching on and off SVC decoding capabilities 
based on temporal scalability.
  Thank you for you review!

configure.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 02/02] libavcodec/: Add the parsing procedure of SVC decoding function based on Temporal scalability for H.264/AVC

2021-09-23 Thread ??????
Dear,
  According to Mr. Zhao's advice last time, I made some modifications to 
my patch.
  According to the official document of H.264, this patch adds the code to 
parse the temporal scalable information in the parsing process.
  Thank you for you review!

h264_parsing_procedure_of_SVC.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/2] avformat/jacosubenc: Fix writing extradata

2021-09-23 Thread Andreas Rheinhardt
The terminating '\0' is no longer included in the size of
the extradata output by the demuxer since commit
36e61e24e7ac737b38c4382d439329352d9e0c29.
E.g. if one remuxes the JACOsub sample JACOsub_capability_tester.jss
from the FATE suite, one receives a file not recognized as JACOsub
before this patch.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/jacosubenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/jacosubenc.c b/libavformat/jacosubenc.c
index 324f2957fb..f0548bb282 100644
--- a/libavformat/jacosubenc.c
+++ b/libavformat/jacosubenc.c
@@ -24,7 +24,7 @@ static int jacosub_write_header(AVFormatContext *s)
 const AVCodecParameters *par = s->streams[0]->codecpar;
 
 if (par->extradata_size) {
-avio_write(s->pb, par->extradata, par->extradata_size - 1);
+avio_write(s->pb, par->extradata, par->extradata_size);
 }
 return 0;
 }
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] fate/subtitles: Add JACOsub remuxing test

2021-09-23 Thread Andreas Rheinhardt
This muxer was untested up until now; had it been tested, it would
have been obvious that it has been broken for years.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/subtitles.mak |  4 
 tests/ref/fate/sub-jacosub-remux | 17 +
 2 files changed, 21 insertions(+)
 create mode 100644 tests/ref/fate/sub-jacosub-remux

diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak
index ee65afe35b..cd162786d4 100644
--- a/tests/fate/subtitles.mak
+++ b/tests/fate/subtitles.mak
@@ -22,6 +22,10 @@ fate-binsub-mksenc: CMD = md5pipe -i 
$(TARGET_SAMPLES)/sub/1ededcbd7b.ass -c cop
 FATE_SUBTITLES_ASS-$(call DEMDEC, JACOSUB, JACOSUB) += fate-sub-jacosub
 fate-sub-jacosub: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/JACOsub_capability_tester.jss
 
+FATE_SUBTITLES-$(call DEMMUX, JACOSUB, JACOSUB) += fate-sub-jacosub-remux
+fate-sub-jacosub-remux: CMD = transcode jacosub 
$(TARGET_SAMPLES)/sub/JACOsub_capability_tester.jss jacosub "-map 0 -c copy" 
"-map 0 -c copy"
+fate-sub-jacosub-remux: CMP = diff
+
 FATE_SUBTITLES_ASS-$(call DEMDEC, MICRODVD, MICRODVD) += fate-sub-microdvd
 fate-sub-microdvd: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/MicroDVD_capability_tester.sub
 
diff --git a/tests/ref/fate/sub-jacosub-remux b/tests/ref/fate/sub-jacosub-remux
new file mode 100644
index 00..b8868db891
--- /dev/null
+++ b/tests/ref/fate/sub-jacosub-remux
@@ -0,0 +1,17 @@
+51da69c384709ecfaec940bdecfbce9a *tests/data/fate/sub-jacosub-remux.jacosub
+1065 tests/data/fate/sub-jacosub-remux.jacosub
+#extradata 0:   15, 0x15a10293
+#tb 0: 1/100
+#media_type 0: subtitle
+#codec_id 0: jacosub
+0, 12, 12,  400,  152, 0xab022660
+0,412,412,  250,   60, 0xd3dc114d
+0,512,512,  210,   33, 0x778307d9
+0,612,612,  170,   50, 0x32990db4
+0,812,812,  300,  180, 0xc92530ed
+0,   1112,   1112,  250,  122, 0xbfc222a9
+0,   1362,   1362,  125,  111, 0x4c3a1dca
+0,   1487,   1487,  125,   52, 0x57a40f01
+0,   2242,   2242,  550,  122, 0xed8d20a2
+0,   7612,   7612,  500,   86, 0x530d1b76
+0,   7612,   7612,  500,   82, 0xc99119aa
-- 
2.30.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/jvdec: Make sizeof(JVFrame) smaller to save memory

2021-09-23 Thread Peter Ross
On Thu, Sep 23, 2021 at 06:29:35PM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/jvdec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
> index 8f21ea1893..93569c87df 100644
> --- a/libavformat/jvdec.c
> +++ b/libavformat/jvdec.c
> @@ -36,8 +36,8 @@
>  typedef struct JVFrame {
>  int audio_size;/**< audio packet size (bytes) */
>  int video_size;/**< video packet size (bytes) */
> -int palette_size;  /**< palette size (bytes) */
> -int video_type;/**< per-frame video compression type */
> +uint16_t palette_size;  /**< palette size (bytes) */
> +uint8_t video_type; /**< per-frame video compression type */
>  } JVFrame;

ok

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v9 00/13] Subtitle Filtering

2021-09-23 Thread Soft Works
v9 Update:

- Addressed all review comments (thanks Andreas!)
- Move ass utility functions to avutil as public API
- Handle subtitle decoding via new decode API
  (removed av_decode_subtitle3)
- Change 'subtitle_header' to use refcounted buffers
- Allow mapping subtitle streams to filter graph
  and direct outputs simultaneously
- Added explanation and justification for test changes
  to commit message 
  
v8 Update:

- Added new subtitle filters:
  graphicsub2text, censor, show_speaker (see below)
- Added parameters to load words from file 
  for textmod and censor
- Copied copyright owners from vf_overlay to
  vf_overlay_graphicsubs
- Remove "convenience" pointers (data) from AVSubtitleArea
  (not needed, will avoid migration errors)
- Minor fixes

--

This patchset introduces filtering support for subtitles.

Besides the ground work, this patchset includes a range
of new filters for subtitle processing:

- graphicsubs2text (S -> S)
  Convert graphic subtitles to text subtitles via OCR
  
- censor {S -> S)
  Allows censoring word in subtitles by a configurable
  word list
  
- show_speaker {S -> S)
  Prepend the speaker names to text lines
  (those are often available in ass subs)  
  
- split_cc (V -> VS)
  Splits out Closed-Caption data as a subtitle stream
  for filtering and encoding
  
- overlay_graphicsubs (VS -> V)
  Overlay graphic subtitles onto a video stream

- graphicsub2video {S -> V)
  Converts graphic subtitles to (transparent) video frames
  
- overlay_textsubs {VS -> V)
  Overlay text subtitles onto a video stream.
  
- textsubs2video {S -> V)
  Converts text subtitles to video frames
  
- textmod {S -> S)
  Modify subtitle text in a number of ways

- stripstyles {S -> S)
  Remove all inline styles from subtitle events

Regards,
softworkz

softworkz (13):
  global: Prepare AVFrame for subtitle handling
  global: Move ass helper functions to avutil and extend ass dialog
parsing
  fftools/play,probe: Adjust for subtitle changes
  avfilter/subtitles: Add subtitles.c for subtitle frame allocation
  avfilter/avfilter: Handle subtitle frames
  avfilter/sbuffer: Add sbuffersrc and sbuffersink filters
  avfilter/overlay_graphicsubs: Add overlay_graphicsubs and
graphicsub2video filters
  fftools/ffmpeg: Replace sub2video with subtitle frame filtering
  avfilter/overlay_textsubs: Add overlay_textsubs and textsubs2video
filters
  avfilter/textmod: Add textmod, censor and show_speaker filters
  avfilter/stripstyles: Add stripstyles filter
  avfilter/split_cc: Add split_cc filter for closed caption handling
  avfilter/graphicsub2text: Add new graphicsub2text filter (OCR)

 configure |   6 +-
 doc/filters.texi  | 502 +++
 fftools/ffmpeg.c  | 472 +++---
 fftools/ffmpeg.h  |  14 +-
 fftools/ffmpeg_filter.c   | 207 +--
 fftools/ffmpeg_hw.c   |   2 +-
 fftools/ffmpeg_opt.c  |   3 +-
 fftools/ffplay.c  | 102 ++-
 fftools/ffprobe.c |  48 +-
 libavcodec/Makefile   |  56 +-
 libavcodec/ass_internal.h |  68 ++
 libavcodec/assdec.c   |   2 +-
 libavcodec/assenc.c   |   2 +-
 libavcodec/avcodec.c  |  19 -
 libavcodec/avcodec.h  |  75 +--
 libavcodec/ccaption_dec.c |  15 +-
 libavcodec/decode.c   |  51 +-
 libavcodec/jacosubdec.c   |   2 +-
 libavcodec/microdvddec.c  |   7 +-
 libavcodec/movtextdec.c   |   3 +-
 libavcodec/movtextenc.c   |   4 +-
 libavcodec/mpl2dec.c  |   2 +-
 libavcodec/pgssubdec.c|   1 +
 libavcodec/realtextdec.c  |   2 +-
 libavcodec/samidec.c  |   2 +-
 libavcodec/srtdec.c   |   2 +-
 libavcodec/srtenc.c   |   4 +-
 libavcodec/subviewerdec.c |   2 +-
 libavcodec/textdec.c  |   2 +-
 libavcodec/ttmlenc.c  |   3 +-
 libavcodec/utils.c|  11 +
 libavcodec/webvttdec.c|   2 +-
 libavcodec/webvttenc.c|   4 +-
 libavfilter/Makefile  |  13 +
 libavfilter/allfilters.c  |  12 +
 libavfilter/avfilter.c|  30 +-
 libavfilter/avfiltergraph.c   |   5 +
 libavfilter/buffersink.c  |  63 ++
 libavfilter/buffersink.h  |  15 +
 libavfilter/buffersrc.c   |  72 +++
 libavfilter/buffersrc.h   |   1 +
 libavfilter/formats.c |  14 +
 libavfilter/formats.h |   3 +
 libavfilter/internal.h

[FFmpeg-devel] [PATCH v9 01/13] global: Prepare AVFrame for subtitle handling

2021-09-23 Thread Soft Works
Root commit for adding subtitle filtering capabilities.
In detail:

- Add type (AVMediaType) field to AVFrame
  Replaces previous way of distinction which was based on checking
  width and height to determine whether a frame is audio or video
- Add subtitle fields to AVFrame
- Add new struct AVSubtitleArea, similar to AVSubtitleRect, but different
  allocation logic. Cannot and must not be used interchangeably, hence
  the new struct
- Move enum AVSubtitleType, AVSubtitle and AVSubtitleRect to avutil
- Add public-named members to enum AVSubtitleType (AV_SUBTITLE_FMT_)
- Add avcodec_decode_subtitle3 which takes subtitle frames,
  serving as compatibility shim to legacy subtitle decoding
- Add additional methods for conversion between old and new API

Signed-off-by: softworkz 
---
 libavcodec/avcodec.c   |  19 ---
 libavcodec/avcodec.h   |  75 ++--
 libavcodec/decode.c|  51 ++--
 libavcodec/pgssubdec.c |   1 +
 libavcodec/utils.c |  11 ++
 libavfilter/vf_subtitles.c |  50 ++--
 libavformat/utils.c|   1 +
 libavutil/Makefile |   2 +
 libavutil/frame.c  | 191 +
 libavutil/frame.h  |  93 +-
 libavutil/subfmt.c | 240 +
 libavutil/subfmt.h | 185 
 12 files changed, 794 insertions(+), 125 deletions(-)
 create mode 100644 libavutil/subfmt.c
 create mode 100644 libavutil/subfmt.h

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 2dd7dd84e0..963f52c4bd 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -426,25 +426,6 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 av_bsf_flush(avci->bsf);
 }
 
-void avsubtitle_free(AVSubtitle *sub)
-{
-int i;
-
-for (i = 0; i < sub->num_rects; i++) {
-av_freep(&sub->rects[i]->data[0]);
-av_freep(&sub->rects[i]->data[1]);
-av_freep(&sub->rects[i]->data[2]);
-av_freep(&sub->rects[i]->data[3]);
-av_freep(&sub->rects[i]->text);
-av_freep(&sub->rects[i]->ass);
-av_freep(&sub->rects[i]);
-}
-
-av_freep(&sub->rects);
-
-memset(sub, 0, sizeof(*sub));
-}
-
 av_cold int avcodec_close(AVCodecContext *avctx)
 {
 int i;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7ee8bc2b7c..0c5819b116 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -35,6 +35,7 @@
 #include "libavutil/frame.h"
 #include "libavutil/log.h"
 #include "libavutil/pixfmt.h"
+#include "libavutil/subfmt.h"
 #include "libavutil/rational.h"
 
 #include "codec.h"
@@ -1674,7 +1675,7 @@ typedef struct AVCodecContext {
 
 /**
  * Header containing style information for text subtitles.
- * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
+ * For AV_SUBTITLE_FMT_ASS subtitle type, it should contain the whole ASS
  * [Script Info] and [V4+ Styles] section, plus the [Events] line and
  * the Format line following. It shouldn't include any Dialogue line.
  * - encoding: Set/allocated/freed by user (before avcodec_open2())
@@ -2238,63 +2239,8 @@ typedef struct AVHWAccel {
  * @}
  */
 
-enum AVSubtitleType {
-SUBTITLE_NONE,
-
-SUBTITLE_BITMAP,///< A bitmap, pict will be set
-
-/**
- * Plain text, the text field must be set by the decoder and is
- * authoritative. ass and pict fields may contain approximations.
- */
-SUBTITLE_TEXT,
-
-/**
- * Formatted text, the ass field must be set by the decoder and is
- * authoritative. pict and text fields may contain approximations.
- */
-SUBTITLE_ASS,
-};
-
 #define AV_SUBTITLE_FLAG_FORCED 0x0001
 
-typedef struct AVSubtitleRect {
-int x; ///< top left corner  of pict, undefined when pict is not 
set
-int y; ///< top left corner  of pict, undefined when pict is not 
set
-int w; ///< widthof pict, undefined when pict is not 
set
-int h; ///< height   of pict, undefined when pict is not 
set
-int nb_colors; ///< number of colors in pict, undefined when pict is not 
set
-
-/**
- * data+linesize for the bitmap of this subtitle.
- * Can be set for text/ass as well once they are rendered.
- */
-uint8_t *data[4];
-int linesize[4];
-
-enum AVSubtitleType type;
-
-char *text; ///< 0 terminated plain UTF-8 text
-
-/**
- * 0 terminated ASS/SSA compatible event line.
- * The presentation of this is unaffected by the other values in this
- * struct.
- */
-char *ass;
-
-int flags;
-} AVSubtitleRect;
-
-typedef struct AVSubtitle {
-uint16_t format; /* 0 = graphics */
-uint32_t start_display_time; /* relative to packet pts, in ms */
-uint32_t end_display_time; /* relative to packet pts, in ms */
-unsigned num_rects;
-AVSubtitleRect **rects;
-int64_t pts;///< Same as packet pts, in AV_TIME_BASE
-

[FFmpeg-devel] [PATCH v9 02/13] global: Move ass helper functions to avutil and extend ass dialog parsing

2021-09-23 Thread Soft Works
Signed-off-by: softworkz 
---
 libavcodec/Makefile   | 56 +++---
 libavcodec/ass_internal.h | 68 +++
 libavcodec/assdec.c   |  2 +-
 libavcodec/assenc.c   |  2 +-
 libavcodec/ccaption_dec.c | 15 +++---
 libavcodec/jacosubdec.c   |  2 +-
 libavcodec/microdvddec.c  |  7 +--
 libavcodec/movtextdec.c   |  3 +-
 libavcodec/movtextenc.c   |  4 +-
 libavcodec/mpl2dec.c  |  2 +-
 libavcodec/realtextdec.c  |  2 +-
 libavcodec/samidec.c  |  2 +-
 libavcodec/srtdec.c   |  2 +-
 libavcodec/srtenc.c   |  4 +-
 libavcodec/subviewerdec.c |  2 +-
 libavcodec/textdec.c  |  2 +-
 libavcodec/ttmlenc.c  |  3 +-
 libavcodec/webvttdec.c|  2 +-
 libavcodec/webvttenc.c|  4 +-
 libavutil/Makefile|  4 ++
 {libavcodec => libavutil}/ass.c   | 63 -
 {libavcodec => libavutil}/ass.h   | 64 -
 {libavcodec => libavutil}/ass_split.c | 12 -
 {libavcodec => libavutil}/ass_split.h |  8 ++--
 24 files changed, 206 insertions(+), 129 deletions(-)
 create mode 100644 libavcodec/ass_internal.h
 rename {libavcodec => libavutil}/ass.c (77%)
 rename {libavcodec => libavutil}/ass.h (71%)
 rename {libavcodec => libavutil}/ass_split.c (97%)
 rename {libavcodec => libavutil}/ass_split.h (96%)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 11873eecae..f1643e3845 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -209,10 +209,10 @@ OBJS-$(CONFIG_APNG_DECODER)+= png.o pngdec.o 
pngdsp.o
 OBJS-$(CONFIG_APNG_ENCODER)+= png.o pngenc.o
 OBJS-$(CONFIG_ARBC_DECODER)+= arbc.o
 OBJS-$(CONFIG_ARGO_DECODER)+= argo.o
-OBJS-$(CONFIG_SSA_DECODER) += assdec.o ass.o
-OBJS-$(CONFIG_SSA_ENCODER) += assenc.o ass.o
-OBJS-$(CONFIG_ASS_DECODER) += assdec.o ass.o
-OBJS-$(CONFIG_ASS_ENCODER) += assenc.o ass.o
+OBJS-$(CONFIG_SSA_DECODER) += assdec.o
+OBJS-$(CONFIG_SSA_ENCODER) += assenc.o
+OBJS-$(CONFIG_ASS_DECODER) += assdec.o
+OBJS-$(CONFIG_ASS_ENCODER) += assenc.o
 OBJS-$(CONFIG_ASV1_DECODER)+= asvdec.o asv.o mpeg12data.o
 OBJS-$(CONFIG_ASV1_ENCODER)+= asvenc.o asv.o mpeg12data.o
 OBJS-$(CONFIG_ASV2_DECODER)+= asvdec.o asv.o mpeg12data.o
@@ -252,7 +252,7 @@ OBJS-$(CONFIG_BRENDER_PIX_DECODER) += brenderpix.o
 OBJS-$(CONFIG_C93_DECODER) += c93.o
 OBJS-$(CONFIG_CAVS_DECODER)+= cavs.o cavsdec.o cavsdsp.o \
   cavsdata.o
-OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o ass.o
+OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o
 OBJS-$(CONFIG_CDGRAPHICS_DECODER)  += cdgraphics.o
 OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o
 OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o
@@ -423,7 +423,7 @@ OBJS-$(CONFIG_INTERPLAY_ACM_DECODER)   += interplayacm.o
 OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER)  += dpcm.o
 OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
 OBJS-$(CONFIG_IPU_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
-OBJS-$(CONFIG_JACOSUB_DECODER) += jacosubdec.o ass.o
+OBJS-$(CONFIG_JACOSUB_DECODER) += jacosubdec.o
 OBJS-$(CONFIG_JPEG2000_ENCODER)+= j2kenc.o mqcenc.o mqc.o jpeg2000.o \
   jpeg2000dwt.o
 OBJS-$(CONFIG_JPEG2000_DECODER)+= jpeg2000dec.o jpeg2000.o 
jpeg2000dsp.o \
@@ -445,7 +445,7 @@ OBJS-$(CONFIG_MAGICYUV_ENCODER)+= magicyuvenc.o
 OBJS-$(CONFIG_MDEC_DECODER)+= mdec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_METASOUND_DECODER)   += metasound.o metasound_data.o \
   twinvq.o
-OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o
+OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o
 OBJS-$(CONFIG_MIMIC_DECODER)   += mimic.o
 OBJS-$(CONFIG_MJPEG_DECODER)   += mjpegdec.o mjpegdec_common.o
 OBJS-$(CONFIG_MJPEG_QSV_DECODER)   += qsvdec.o
@@ -460,8 +460,8 @@ OBJS-$(CONFIG_MLP_ENCODER) += mlpenc.o mlp.o
 OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
 OBJS-$(CONFIG_MOBICLIP_DECODER)+= mobiclip.o
 OBJS-$(CONFIG_MOTIONPIXELS_DECODER)+= motionpixels.o
-OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o ass.o
-OBJS-$(CONFIG_MOVTEXT_ENCODER) += movtextenc.o ass_split.o
+OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o
+OBJS-$(CONFIG_MOVTEXT_ENCODER) += movtextenc.o
 OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec_fixed.o
 OBJS-$(CONFIG_MP1FLOAT_DECODER)+= mpegaudiodec_float.o
 OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec_fixed.o
@@ -500,7 +500,7 @@

[FFmpeg-devel] [PATCH v9 03/13] fftools/play, probe: Adjust for subtitle changes

2021-09-23 Thread Soft Works
Signed-off-by: softworkz 
---
 fftools/ffplay.c  | 102 +-
 fftools/ffprobe.c |  48 ++
 2 files changed, 79 insertions(+), 71 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index ccea0e4578..9237752cab 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -152,7 +152,6 @@ typedef struct Clock {
 /* Common struct for handling all types of decoded data and allocated render 
buffers. */
 typedef struct Frame {
 AVFrame *frame;
-AVSubtitle sub;
 int serial;
 double pts;   /* presentation timestamp for the frame */
 double duration;  /* estimated duration of the frame */
@@ -586,7 +585,7 @@ static int decoder_init(Decoder *d, AVCodecContext *avctx, 
PacketQueue *queue, S
 return 0;
 }
 
-static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
+static int decoder_decode_frame(Decoder *d, AVFrame *frame) {
 int ret = AVERROR(EAGAIN);
 
 for (;;) {
@@ -620,6 +619,9 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, 
AVSubtitle *sub) {
 }
 }
 break;
+case AVMEDIA_TYPE_SUBTITLE:
+ret = avcodec_receive_frame(d->avctx, frame);
+break;
 }
 if (ret == AVERROR_EOF) {
 d->finished = d->pkt_serial;
@@ -652,25 +654,11 @@ static int decoder_decode_frame(Decoder *d, AVFrame 
*frame, AVSubtitle *sub) {
 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 (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 {
-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);
-}
+av_packet_unref(d->pkt);
 }
 }
 }
@@ -683,7 +671,6 @@ static void decoder_destroy(Decoder *d) {
 static void frame_queue_unref_item(Frame *vp)
 {
 av_frame_unref(vp->frame);
-avsubtitle_free(&vp->sub);
 }
 
 static int frame_queue_init(FrameQueue *f, PacketQueue *pktq, int max_size, 
int keep_last)
@@ -981,7 +968,7 @@ static void video_image_display(VideoState *is)
 if (frame_queue_nb_remaining(&is->subpq) > 0) {
 sp = frame_queue_peek(&is->subpq);
 
-if (vp->pts >= sp->pts + ((float) sp->sub.start_display_time / 
1000)) {
+if (vp->pts >= sp->pts + ((float) sp->frame->subtitle_start_time / 
1000)) {
 if (!sp->uploaded) {
 uint8_t* pixels[4];
 int pitch[4];
@@ -993,25 +980,27 @@ static void video_image_display(VideoState *is)
 if (realloc_texture(&is->sub_texture, 
SDL_PIXELFORMAT_ARGB, sp->width, sp->height, SDL_BLENDMODE_BLEND, 1) < 0)
 return;
 
-for (i = 0; i < sp->sub.num_rects; i++) {
-AVSubtitleRect *sub_rect = sp->sub.rects[i];
+for (i = 0; i < sp->frame->num_subtitle_areas; i++) {
+AVSubtitleArea *area = sp->frame->subtitle_areas[i];
+SDL_Rect sdl_rect = { .x = area->x, .y = area->y, .w = 
area->w, .h = area->h };
 
-sub_rect->x = av_clip(sub_rect->x, 0, sp->width );
-sub_rect->y = av_clip(sub_rect->y, 0, sp->height);
-sub_rect->w = av_clip(sub_rect->w, 0, sp->width  - 
sub_rect->x);
-sub_rect->h = av_clip(sub_rect->h, 0, sp->height - 
sub_rect->y);
+area->x = av_clip(area->x, 0, sp->width );
+area->y = av_clip(area->y, 0, sp->height);
+area->w = av_clip(area->w, 0, sp->width  - area->x);
+area->h = av_clip(area->h, 0, sp->height - area->y);
 
 is->sub_convert_ctx = 
sws_getCachedContext(is->sub_convert_ctx,
-sub_rect->w, sub_rect->h, AV_PIX_FMT_PAL8,
-sub_rect->w, sub_rec

[FFmpeg-devel] [PATCH v9 04/13] avfilter/subtitles: Add subtitles.c for subtitle frame allocation

2021-09-23 Thread Soft Works
Analog to avfilter/video.c and avfilter/audio.c

Signed-off-by: softworkz 
---
 libavfilter/Makefile|  1 +
 libavfilter/avfilter.c  |  4 +++
 libavfilter/internal.h  |  1 +
 libavfilter/subtitles.c | 63 +
 libavfilter/subtitles.h | 44 
 5 files changed, 113 insertions(+)
 create mode 100644 libavfilter/subtitles.c
 create mode 100644 libavfilter/subtitles.h

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index f059f3fef8..041d3c5382 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -19,6 +19,7 @@ OBJS = allfilters.o   
  \
framequeue.o \
graphdump.o  \
graphparser.o\
+   subtitles.o  \
video.o  \
 
 OBJS-$(HAVE_THREADS) += pthread.o
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index f325918021..ef349a67f9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -43,6 +43,7 @@
 #include "formats.h"
 #include "framepool.h"
 #include "internal.h"
+#include "subtitles.h"
 
 #include "libavutil/ffversion.h"
 const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
@@ -1476,6 +1477,9 @@ int ff_inlink_make_frame_writable(AVFilterLink *link, 
AVFrame **rframe)
 case AVMEDIA_TYPE_AUDIO:
 out = ff_get_audio_buffer(link, frame->nb_samples);
 break;
+case AVMEDIA_TYPE_SUBTITLE:
+out = ff_get_subtitles_buffer(link, link->format);
+break;
 default:
 return AVERROR(EINVAL);
 }
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index e7c154aff0..8977dda2b3 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -90,6 +90,7 @@ struct AVFilterPad {
 union {
 AVFrame *(*video)(AVFilterLink *link, int w, int h);
 AVFrame *(*audio)(AVFilterLink *link, int nb_samples);
+AVFrame *(*subtitle)(AVFilterLink *link, int format);
 } get_buffer;
 
 /**
diff --git a/libavfilter/subtitles.c b/libavfilter/subtitles.c
new file mode 100644
index 00..951bfd612c
--- /dev/null
+++ b/libavfilter/subtitles.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2021 softworkz
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+
+#include "subtitles.h"
+#include "avfilter.h"
+#include "internal.h"
+
+
+AVFrame *ff_null_get_subtitles_buffer(AVFilterLink *link, int format)
+{
+return ff_get_subtitles_buffer(link->dst->outputs[0], format);
+}
+
+AVFrame *ff_default_get_subtitles_buffer(AVFilterLink *link, int format)
+{
+AVFrame *frame;
+
+frame = av_frame_alloc();
+if (!frame)
+return NULL;
+
+frame->format = format;
+frame->type = AVMEDIA_TYPE_SUBTITLE;
+
+if (av_frame_get_buffer2(frame, 0) < 0) {
+av_frame_free(&frame);
+return NULL;
+}
+
+return frame;
+}
+
+AVFrame *ff_get_subtitles_buffer(AVFilterLink *link, int format)
+{
+AVFrame *ret = NULL;
+
+if (link->dstpad->get_buffer.subtitle)
+ret = link->dstpad->get_buffer.subtitle(link, format);
+
+if (!ret)
+ret = ff_default_get_subtitles_buffer(link, format);
+
+return ret;
+}
diff --git a/libavfilter/subtitles.h b/libavfilter/subtitles.h
new file mode 100644
index 00..4a9115126e
--- /dev/null
+++ b/libavfilter/subtitles.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 softworkz
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have recei

[FFmpeg-devel] [PATCH v9 05/13] avfilter/avfilter: Handle subtitle frames

2021-09-23 Thread Soft Works
Signed-off-by: softworkz 
---
 libavfilter/avfilter.c  |  8 +---
 libavfilter/avfiltergraph.c |  5 +
 libavfilter/formats.c   | 14 ++
 libavfilter/formats.h   |  3 +++
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index ef349a67f9..c567b7893b 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -57,7 +57,8 @@ void ff_tlog_ref(void *ctx, AVFrame *ref, int end)
 ref->linesize[0], ref->linesize[1], ref->linesize[2], 
ref->linesize[3],
 ref->pts, ref->pkt_pos);
 
-if (ref->width) {
+switch(ref->type) {
+case AVMEDIA_TYPE_VIDEO:
 ff_tlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c",
 ref->sample_aspect_ratio.num, ref->sample_aspect_ratio.den,
 ref->width, ref->height,
@@ -65,12 +66,13 @@ void ff_tlog_ref(void *ctx, AVFrame *ref, int end)
 ref->top_field_first ? 'T' : 'B',/* Top / Bottom */
 ref->key_frame,
 av_get_picture_type_char(ref->pict_type));
-}
-if (ref->nb_samples) {
+break;
+case AVMEDIA_TYPE_AUDIO:
 ff_tlog(ctx, " cl:%"PRId64"d n:%d r:%d",
 ref->channel_layout,
 ref->nb_samples,
 ref->sample_rate);
+break;
 }
 
 ff_tlog(ctx, "]%s", end ? "\n" : "");
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 45b028cd9c..7a5a4ea419 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -314,6 +314,8 @@ static int filter_link_check_formats(void *log, 
AVFilterLink *link, AVFilterForm
 return ret;
 break;
 
+case AVMEDIA_TYPE_SUBTITLE:
+return 0;
 default:
 av_assert0(!"reached");
 }
@@ -444,6 +446,9 @@ static int query_formats(AVFilterGraph *graph, void 
*log_ctx)
 if (!link)
 continue;
 
+if (link->type == AVMEDIA_TYPE_SUBTITLE)
+continue;
+
 neg = ff_filter_get_negotiation(link);
 av_assert0(neg);
 for (neg_step = 1; neg_step < neg->nb_mergers; neg_step++) {
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 1bf7d36195..704774d763 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcodec/avcodec.h"
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
@@ -430,6 +431,12 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, 
uint64_t channel_layout)
 return 0;
 }
 
+int ff_add_subtitle_type(AVFilterFormats **avff, int64_t fmt)
+{
+ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats);
+return 0;
+}
+
 AVFilterFormats *ff_all_formats(enum AVMediaType type)
 {
 AVFilterFormats *ret = NULL;
@@ -447,6 +454,13 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type)
 return NULL;
 fmt++;
 }
+} else if (type == AVMEDIA_TYPE_SUBTITLE) {
+if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_BITMAP) < 0)
+return NULL;
+if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_ASS) < 0)
+return NULL;
+if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_TEXT) < 0)
+return NULL;
 }
 
 return ret;
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 471cb42bc4..25ae511fc1 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -180,6 +180,9 @@ int ff_set_common_formats_from_list(AVFilterContext *ctx, 
const int *fmts);
 av_warn_unused_result
 int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout);
 
+av_warn_unused_result
+int ff_add_subtitle_type(AVFilterFormats **avff, int64_t fmt);
+
 /**
  * Add *ref as a new reference to f.
  */
-- 
2.30.2.windows.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v9 06/13] avfilter/sbuffer: Add sbuffersrc and sbuffersink filters

2021-09-23 Thread Soft Works
Signed-off-by: softworkz 
---
 configure|  2 +-
 libavfilter/allfilters.c |  2 ++
 libavfilter/buffersink.c | 63 +++
 libavfilter/buffersink.h | 15 +
 libavfilter/buffersrc.c  | 72 
 libavfilter/buffersrc.h  |  1 +
 libavfilter/version.h|  2 +-
 7 files changed, 155 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 231d0398a8..d18bb73ed6 100755
--- a/configure
+++ b/configure
@@ -7720,7 +7720,7 @@ print_enabled_components(){
 fi
 done
 if [ "$name" = "filter_list" ]; then
-for c in asrc_abuffer vsrc_buffer asink_abuffer vsink_buffer; do
+for c in asrc_abuffer vsrc_buffer ssrc_sbuffer asink_abuffer 
vsink_buffer ssink_sbuffer; do
 printf "&ff_%s,\n" $c >> $TMPH
 done
 fi
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index ddd6404228..c395b4bbc0 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -535,8 +535,10 @@ extern const AVFilter ff_avsrc_movie;
  * being the same while having different 'types'). */
 extern  const AVFilter ff_asrc_abuffer;
 extern  const AVFilter ff_vsrc_buffer;
+extern  const AVFilter ff_ssrc_sbuffer;
 extern  const AVFilter ff_asink_abuffer;
 extern  const AVFilter ff_vsink_buffer;
+extern  const AVFilter ff_ssink_sbuffer;
 extern const AVFilter ff_af_afifo;
 extern const AVFilter ff_vf_fifo;
 
diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 8b46dcb15e..cd038e1782 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -29,6 +29,8 @@
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 
+#include "libavcodec/avcodec.h"
+
 #define FF_INTERNAL_FIELDS 1
 #include "framequeue.h"
 
@@ -57,6 +59,10 @@ typedef struct BufferSinkContext {
 int *sample_rates;  ///< list of accepted sample 
rates, terminated by -1
 int sample_rates_size;
 
+/* only used for subtitles */
+enum AVSubtitleType *subtitle_types; ///< list of accepted subtitle 
types, must be terminated with -1
+int subtitle_types_size;
+
 AVFrame *peeked_frame;
 } BufferSinkContext;
 
@@ -168,6 +174,15 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void)
 return NULL;
 return params;
 }
+
+AVSBufferSinkParams *av_sbuffersink_params_alloc(void)
+{
+AVSBufferSinkParams *params = av_mallocz(sizeof(AVSBufferSinkParams));
+
+if (!params)
+return NULL;
+return params;
+}
 #endif
 
 static av_cold int common_init(AVFilterContext *ctx)
@@ -305,6 +320,28 @@ static int asink_query_formats(AVFilterContext *ctx)
 return 0;
 }
 
+static int ssink_query_formats(AVFilterContext *ctx)
+{
+BufferSinkContext *buf = ctx->priv;
+AVFilterFormats *formats = NULL;
+unsigned i;
+int ret;
+
+CHECK_LIST_SIZE(subtitle_types)
+if (buf->subtitle_types_size) {
+for (i = 0; i < NB_ITEMS(buf->subtitle_types); i++)
+if ((ret = ff_add_subtitle_type(&formats, buf->subtitle_types[i])) 
< 0)
+return ret;
+if ((ret = ff_set_common_formats(ctx, formats)) < 0)
+return ret;
+} else {
+if ((ret = ff_default_query_formats(ctx)) < 0)
+return ret;
+}
+
+return 0;
+}
+
 #define OFFSET(x) offsetof(BufferSinkContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption buffersink_options[] = {
@@ -322,9 +359,16 @@ static const AVOption abuffersink_options[] = {
 { NULL },
 };
 #undef FLAGS
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_SUBTITLE_PARAM
+static const AVOption sbuffersink_options[] = {
+{ "subtitle_types", "set the supported subtitle formats", 
OFFSET(subtitle_types), AV_OPT_TYPE_BINARY, .flags = FLAGS },
+{ NULL },
+};
+#undef FLAGS
 
 AVFILTER_DEFINE_CLASS(buffersink);
 AVFILTER_DEFINE_CLASS(abuffersink);
+AVFILTER_DEFINE_CLASS(sbuffersink);
 
 static const AVFilterPad avfilter_vsink_buffer_inputs[] = {
 {
@@ -363,3 +407,22 @@ const AVFilter ff_asink_abuffer = {
 FILTER_INPUTS(avfilter_asink_abuffer_inputs),
 .outputs   = NULL,
 };
+
+static const AVFilterPad avfilter_ssink_sbuffer_inputs[] = {
+{
+.name = "default",
+.type = AVMEDIA_TYPE_SUBTITLE,
+},
+};
+
+const AVFilter ff_ssink_sbuffer = {
+.name  = "sbuffersink",
+.description   = NULL_IF_CONFIG_SMALL("Buffer subtitle frames, and make 
them available to the end of the filter graph."),
+.priv_class= &sbuffersink_class,
+.priv_size = sizeof(BufferSinkContext),
+.init  = common_init,
+.query_formats = ssink_query_formats,
+.activate  = activate,
+FILTER_INPUTS(avfilter_ssink_sbuffer_inputs),
+.outputs   = NULL,
+};
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 69ed0f29a8..b439b586c5 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -129,6 +

[FFmpeg-devel] [PATCH v9 07/13] avfilter/overlay_graphicsubs: Add overlay_graphicsubs and graphicsub2video filters

2021-09-23 Thread Soft Works
- overlay_graphicsubs (VS -> V)
  Overlay graphic subtitles onto a video stream

- graphicsub2video {S -> V)
  Converts graphic subtitles to video frames (with alpha)
  Gets auto-inserted for retaining compatibility with
  sub2video command lines

Signed-off-by: softworkz 
---
 doc/filters.texi | 104 
 libavfilter/Makefile |   2 +
 libavfilter/allfilters.c |   2 +
 libavfilter/vf_overlay_graphicsubs.c | 724 +++
 4 files changed, 832 insertions(+)
 create mode 100644 libavfilter/vf_overlay_graphicsubs.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 94161003c3..9ce956e507 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25079,6 +25079,110 @@ tools.
 
 @c man end VIDEO SINKS
 
+@chapter Subtitle Filters
+@c man begin SUBTITLE FILTERS
+
+When you configure your FFmpeg build, you can disable any of the
+existing filters using @code{--disable-filters}.
+
+Below is a description of the currently available subtitle filters.
+
+@section graphicsub2video
+
+Renders graphic subtitles as video frames. 
+
+This filter replaces the previous "sub2video" hack which did the conversion 
implicitly and up-front as subtitle filtering wasn't possible at that time.
+To retain compatibility with earlier sub2video command lines, this filter is 
being auto-inserted in those cases.
+
+For overlaying graphicsal subtitles it is recommended to use the 
'overlay_graphicsubs' filter which is more efficient and takes less processing 
resources.
+
+This filter is still useful in cases where the overlay is done with hardware 
acceleration (e.g. overlay_qsv, overlay_vaapi, overlay_cuda) for preparing the 
overlay frames.
+
+It accepts the following parameters:
+
+@table @option
+@item size, s
+Set the size of the output video frame.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Overlay PGS subtitles
+(not recommended - better use overlay_graphicsubs)
+@example
+ffmpeg -i 
"https://streams.videolan.org/samples/sub/PGS/Girl_With_The_Dragon_Tattoo_2%3A23%3A56.mkv";
 -filter_complex "[0:1]graphicsub2video[subs];[0:0][subs]overlay" output.mp4
+@end example
+
+@item
+Overlay PGS subtitles implicitly 
+The graphicsub2video is inserted automatically for compatibility with legacy 
command lines. 
+@example
+ffmpeg -i 
"https://streams.videolan.org/samples/sub/PGS/Girl_With_The_Dragon_Tattoo_2%3A23%3A56.mkv";
 -filter_complex "[0:0][0:1]overlay" output.mp4
+@end example
+@end itemize
+
+@section overlay_graphicsubs
+
+Overlay graphic subtitles onto a video stream.
+
+This filter can blend graphical subtitles on a video stream directly, i.e. 
without creating full-size alpha images first.
+The blending operation is limited to the area of the subtitle rectangles, 
which also means that no processing is done at times where no subtitles are to 
be displayed.
+
+
+It accepts the following parameters:
+
+@table @option
+@item x
+@item y
+Set the expression for the x and y coordinates of the overlaid video
+on the main video. Default value is "0" for both expressions. In case
+the expression is invalid, it is set to a huge value (meaning that the
+overlay will not be displayed within the output visible area).
+
+@item eof_action
+See @ref{framesync}.
+
+@item eval
+Set when the expressions for @option{x}, and @option{y} are evaluated.
+
+It accepts the following values:
+@table @samp
+@item init
+only evaluate expressions once during the filter initialization or
+when a command is processed
+
+@item frame
+evaluate expressions for each incoming frame
+@end table
+
+Default value is @samp{frame}.
+
+@item shortest
+See @ref{framesync}.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Overlay PGS subtitles
+@example
+ffmpeg -i 
"https://streams.videolan.org/samples/sub/PGS/Girl_With_The_Dragon_Tattoo_2%3A23%3A56.mkv";
 -filter_complex "[0:1]graphicsub2video[subs];[0:0][subs]overlay" output.mp4
+@end example
+
+@item
+Overlay PGS subtitles implicitly 
+The graphicsub2video is inserted automatically for compatibility with legacy 
command lines. 
+@example
+ffmpeg -i 
"https://streams.videolan.org/samples/sub/PGS/Girl_With_The_Dragon_Tattoo_2%3A23%3A56.mkv";
 -filter_complex "[0:0][0:1]overlay" output.mp4
+@end example
+@end itemize
+@c man end SUBTITLE FILTERS
+
 @chapter Multimedia Filters
 @c man begin MULTIMEDIA FILTERS
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 041d3c5382..8fcc25989e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -290,6 +290,7 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o 
qp_table.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
+OBJS-$(CONFIG_GRAPHICSUB2VIDEO_FILTER)   += vf_overlay_graphicsubs.o 
framesync.o
 OBJS-$(CONFIG_GRAPHMONITOR_FILTER)   += f_graphmonitor.o
 OBJS-$(CONFIG_GRAYWORLD_FILTER)  += vf_grayworld.o
 

[FFmpeg-devel] [PATCH v9 08/13] fftools/ffmpeg: Replace sub2video with subtitle frame filtering

2021-09-23 Thread Soft Works
This commit actually enables subtitle filtering in ffmpeg by
sending and receiving subtitle frames to and from a filtergraph.

The heartbeat functionality from the previous sub2video implementation
is retained and applied to all subtitle frames (bitmap, text, ..).

The other part of sub2video functionality is retained by
auto-insertion of the new graphicsub2video filter.

Justification for changed test refs:

- sub2video
  The new results are identical excepting the last frame which
  is due to the implementation changes

- sub2video_basic
  The previous results had some incorrect output because multiple
  frames had the same dts (even the first one was incorrect).
  The non-empty content frames are visually identical, the different
  CRC is due to the different blending algorithm that is being used.

- sub2video_time_limited
  The previous results were incorrect. There was an initial empty frame
  with the same dts generated. This is no longer happening.
  The third frame was a repetition, which doesn't happen anymore with
  the new subtitle filtering.
  The source file contains a single subtitle event and the new and
  correct result is a single output frame

- sub-dvb
  Running ffprobe -show_frames on the source file shows that there
  are 7 subtitle frames with 0 rects in the source at the start
  and 2 at the end. This translates to the 14 and 4 additional
  entries in the new test results.

- filter-overlay-dvdsub-2397
  Overlay results have slightly different CRCs due to different
  blending implementation

Signed-off-by: softworkz 
---
 fftools/ffmpeg.c  | 472 ++
 fftools/ffmpeg.h  |  14 +-
 fftools/ffmpeg_filter.c   | 207 +++---
 fftools/ffmpeg_hw.c   |   2 +-
 fftools/ffmpeg_opt.c  |   3 +-
 tests/ref/fate/filter-overlay-dvdsub-2397 | 181 +
 tests/ref/fate/sub-dvb| 162 
 tests/ref/fate/sub2video  |   1 -
 tests/ref/fate/sub2video_basic|  93 ++---
 tests/ref/fate/sub2video_time_limited |   4 +-
 10 files changed, 592 insertions(+), 547 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 98c2421938..8f8d7a70ac 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -169,163 +169,6 @@ static int restore_tty;
 static void free_input_threads(void);
 #endif
 
-/* sub2video hack:
-   Convert subtitles to video with alpha to insert them in filter graphs.
-   This is a temporary solution until libavfilter gets real subtitles support.
- */
-
-static int sub2video_get_blank_frame(InputStream *ist)
-{
-int ret;
-AVFrame *frame = ist->sub2video.frame;
-
-av_frame_unref(frame);
-ist->sub2video.frame->width  = ist->dec_ctx->width  ? ist->dec_ctx->width  
: ist->sub2video.w;
-ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height 
: ist->sub2video.h;
-ist->sub2video.frame->format = AV_PIX_FMT_RGB32;
-if ((ret = av_frame_get_buffer(frame, 0)) < 0)
-return ret;
-memset(frame->data[0], 0, frame->height * frame->linesize[0]);
-return 0;
-}
-
-static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h,
-AVSubtitleRect *r)
-{
-uint32_t *pal, *dst2;
-uint8_t *src, *src2;
-int x, y;
-
-if (r->type != SUBTITLE_BITMAP) {
-av_log(NULL, AV_LOG_WARNING, "sub2video: non-bitmap subtitle\n");
-return;
-}
-if (r->x < 0 || r->x + r->w > w || r->y < 0 || r->y + r->h > h) {
-av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle (%d %d %d %d) 
overflowing %d %d\n",
-r->x, r->y, r->w, r->h, w, h
-);
-return;
-}
-
-dst += r->y * dst_linesize + r->x * 4;
-src = r->data[0];
-pal = (uint32_t *)r->data[1];
-for (y = 0; y < r->h; y++) {
-dst2 = (uint32_t *)dst;
-src2 = src;
-for (x = 0; x < r->w; x++)
-*(dst2++) = pal[*(src2++)];
-dst += dst_linesize;
-src += r->linesize[0];
-}
-}
-
-static void sub2video_push_ref(InputStream *ist, int64_t pts)
-{
-AVFrame *frame = ist->sub2video.frame;
-int i;
-int ret;
-
-av_assert1(frame->data[0]);
-ist->sub2video.last_pts = frame->pts = pts;
-for (i = 0; i < ist->nb_filters; i++) {
-ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
-   AV_BUFFERSRC_FLAG_KEEP_REF |
-   AV_BUFFERSRC_FLAG_PUSH);
-if (ret != AVERROR_EOF && ret < 0)
-av_log(NULL, AV_LOG_WARNING, "Error while add the frame to buffer 
source(%s).\n",
-   av_err2str(ret));
-}
-}
-
-void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub)
-{
-AVFrame *frame = ist->sub2video.frame;
-int8_t *dst;
-int dst_linesize;
-int num_rects, i;
-int64_t pts, end_pts;
-
-if (

[FFmpeg-devel] [PATCH v9 09/13] avfilter/overlay_textsubs: Add overlay_textsubs and textsubs2video filters

2021-09-23 Thread Soft Works
- overlay_textsubs {VS -> V)
  Overlay text subtitles onto a video stream.

- textsubs2video {S -> V)
  Converts text subtitles to video frames

Signed-off-by: softworkz 
---
 configure |   2 +
 doc/filters.texi  |  69 
 libavfilter/Makefile  |   2 +
 libavfilter/allfilters.c  |   2 +
 libavfilter/avfilter.c|  18 +-
 libavfilter/vf_overlay_textsubs.c | 609 ++
 6 files changed, 697 insertions(+), 5 deletions(-)
 create mode 100644 libavfilter/vf_overlay_textsubs.c

diff --git a/configure b/configure
index d18bb73ed6..37fc4c20e7 100755
--- a/configure
+++ b/configure
@@ -3624,6 +3624,7 @@ openclsrc_filter_deps="opencl"
 overlay_opencl_filter_deps="opencl"
 overlay_qsv_filter_deps="libmfx"
 overlay_qsv_filter_select="qsvvpp"
+overlay_textsubs_filter_deps="avcodec libass"
 overlay_vulkan_filter_deps="vulkan_lib libglslang"
 owdenoise_filter_deps="gpl"
 pad_opencl_filter_deps="opencl"
@@ -3669,6 +3670,7 @@ superequalizer_filter_deps="avcodec"
 superequalizer_filter_select="rdft"
 surround_filter_deps="avcodec"
 surround_filter_select="rdft"
+textsub2video_filter_deps="avcodec libass"
 tinterlace_filter_deps="gpl"
 tinterlace_merge_test_deps="tinterlace_filter"
 tinterlace_pad_test_deps="tinterlace_filter"
diff --git a/doc/filters.texi b/doc/filters.texi
index 9ce956e507..416bda5efb 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25181,6 +25181,75 @@ The graphicsub2video is inserted automatically for 
compatibility with legacy com
 ffmpeg -i 
"https://streams.videolan.org/samples/sub/PGS/Girl_With_The_Dragon_Tattoo_2%3A23%3A56.mkv";
 -filter_complex "[0:0][0:1]overlay" output.mp4
 @end example
 @end itemize
+
+@section overlay_textsubs
+
+Overlay text subtitles onto a video stream.
+
+This filter supersedes the classic @ref{subtitles} filter opposed to which it 
does no longer require to open and access the source stream separately, which 
is often causing problems or doesn't even work for non-local or slow sources.
+
+Inputs:
+- 0: Video [YUV420P, YUV422P, YUV444P, ARGB, RGBA, ABGR, BGRA, RGB24, BGR24]
+- 1: Subtitles [text]
+
+Outputs:
+- 0: Video (same as input)
+
+It accepts the following parameters:
+
+@table @option
+
+@item alpha
+Process alpha channel, by default alpha channel is untouched.
+
+@item fonts_dir
+Set a directory path containing fonts that can be used by the filter.
+These fonts will be used in addition to whatever the font provider uses.
+
+@item force_style
+Override default style or script info parameters of the subtitles. It accepts a
+string containing ASS style format @code{KEY=VALUE} couples separated by ",".
+
+@end table
+
+@section textsub2video
+
+Converts text subtitles to video frames.
+
+For overlaying text subtitles onto video frames it is recommended to use the 
overlay_textsubs filter.
+The textsub2video is useful for for creating transparent text-frames when 
overlay is done via hw acceleration 
+
+Inputs:
+- 0: Subtitles [text]
+
+Outputs:
+- 0: Video [ARGB, RGBA, ABGR, BGRA]
+
+It accepts the following parameters:
+
+@table @option
+
+@item rate, r
+Set the framerate for updating overlay frames.
+Normally, overlay frames will only be updated each time when the subtitles to 
display are changing.
+In cases where subtitles include advanced features (like animation), this 
parameter determines the frequency by which the overlay frames should be 
updated.
+
+@item size, s
+Set the output frame size.
+Allows to override the size of output video frames.
+
+@item alpha
+Process alpha channel, by default alpha channel is untouched.
+
+@item fonts_dir
+Set a directory path containing fonts that can be used by the filter.
+These fonts will be used in addition to whatever the font provider uses.
+
+@item force_style
+Override default style or script info parameters of the subtitles. It accepts a
+string containing ASS style format @code{KEY=VALUE} couples separated by ",".
+
+@end table
 @c man end SUBTITLE FILTERS
 
 @chapter Multimedia Filters
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8fcc25989e..c0b1cc7001 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -365,6 +365,7 @@ OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) += 
vf_overlay_opencl.o opencl.o \
 opencl/overlay.o framesync.o
 OBJS-$(CONFIG_OVERLAY_QSV_FILTER)+= vf_overlay_qsv.o framesync.o
 OBJS-$(CONFIG_OVERLAY_GRAPHICSUBS_FILTER)+= vf_overlay_graphicsubs.o 
framesync.o
+OBJS-$(CONFIG_OVERLAY_TEXTSUBS_FILTER)   += vf_overlay_textsubs.o
 OBJS-$(CONFIG_OVERLAY_VULKAN_FILTER) += vf_overlay_vulkan.o vulkan.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
@@ -453,6 +454,7 @@ OBJS-$(CONFIG_SWAPRECT_FILTER)   += 
vf_swaprect.o
 OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o
 OBJS-$(CONFIG_TBLEND_FILTER)  

[FFmpeg-devel] [PATCH v9 10/13] avfilter/textmod: Add textmod, censor and show_speaker filters

2021-09-23 Thread Soft Works
- textmod {S -> S)
  Modify subtitle text in a number of ways

- censor {S -> S)
  Censor subtitles using a word list

- show_speaker {S -> S)
  Prepend speaker names from ASS subtitles to the visible text lines

Signed-off-by: softworkz 
---
 doc/filters.texi | 229 +
 libavfilter/Makefile |   5 +
 libavfilter/allfilters.c |   3 +
 libavfilter/sf_textmod.c | 719 +++
 4 files changed, 956 insertions(+)
 create mode 100644 libavfilter/sf_textmod.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 416bda5efb..2d3dcdd7e6 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25079,6 +25079,7 @@ tools.
 
 @c man end VIDEO SINKS
 
+
 @chapter Subtitle Filters
 @c man begin SUBTITLE FILTERS
 
@@ -25087,6 +25088,166 @@ existing filters using @code{--disable-filters}.
 
 Below is a description of the currently available subtitle filters.
 
+
+@section censor
+
+Censor selected words in text subtitles.
+
+Inputs:
+- 0: Subtitles [text]
+
+Outputs:
+- 0: Subtitles [text]
+
+It accepts the following parameters:
+
+@table @option
+@item mode
+The censoring mode to apply.
+
+Supported censoring modes are:
+
+@table @var
+@item 0, keep_first_last
+Replace all characters with the 'censor_char' except the first and the last 
character of a word.
+For words with less than 4 characters, the last character will be replaced as 
well.
+For words with less than 3 characters, the first character will be replaced as 
well.
+@item 1, keep_first
+Replace all characters with the 'censor_char' except the first character of a 
word.
+For words with less than 3 characters, the first character will be replaced as 
well.
+@item 2, all
+Replace all characters with the 'censor_char'.
+@end table
+
+@item words
+A list of words to censor, separated by 'separator'.
+
+@item words_file
+Specify a file from which to load the contents for the 'words' parameter.
+
+@item censor_char
+Single character used as replacement for censoring.
+
+@item separator
+Delimiter character for words. Used with replace_words and remove_words- Must 
be a single character.
+The default is '.'.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Change all characters to upper case while keeping all styles and animations:
+@example
+ffmpeg -i "https://streams.videolan.org/ffmpeg/mkv_subtitles.mkv"; 
-filter_complex "[0:s]textmod=mode=to_upper" -map 0 -y out.mkv
+@end example
+@item
+Remove a set of symbol characters for am improved and smoother visual 
apperance:
+@example
+ffmpeg -i "https://streams.videolan.org/ffmpeg/mkv_subtitles.mkv"; 
-filter_complex "[0:s]textmod=mode=remove_chars:find='$&#@*§'" -map 0 -y 
out.mkv
+@end example
+@end itemize
+
+
+@section stripstyles
+
+Remove all inline styles from subtitle events.
+
+It accepts the following parameters:
+
+@table @option
+@item remove_animated
+Also remove text which is subject to animation (default: true)
+Usually, animated text elements are used used in addition to static subtitle 
lines for creating effects, so in most cases it is safe to remove the animation 
content.
+If subtitle text is missing, try setting this to false.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Remove all styles and animations from subtitles:
+@example
+ffmpeg -i 
"https://streams.videolan.org/samples/sub/SSA/subtitle_testing_complex.mkv"; 
-filter_complex "[0:1]stripstyles" -map 0 output.mkv
+@end example
+@end itemize
+
+@section textmod
+
+Modify subtitle text in a number of ways.
+
+Inputs:
+- 0: Subtitles [text]
+
+Outputs:
+- 0: Subtitles [text]
+
+It accepts the following parameters:
+
+@table @option
+@item mode
+The kind of text modification to apply
+
+Supported operation modes are:
+
+@table @var
+@item 0, leet
+Convert subtitle text to 'leet speak'. It's primarily useful for testing as 
the modification will be visible with almost all text lines.
+@item 1, to_upper
+Change all text to upper case. Might improve readability.
+@item 2, to_lower
+Change all text to lower case.
+@item 3, replace_chars
+Replace one or more characters. Requires the find and replace parameters to be 
specified. 
+Both need to be equal in length.
+The first char in find is replaced by the first char in replace, same for all 
subsequent chars.
+@item 4, remove_chars
+Remove certain characters. Requires the find parameter to be specified. 
+All chars in the find parameter string will be removed from all subtitle text.
+@item 5, replace_words
+Replace one or more words. Requires the find and replace parameters to be 
specified. Multiple words must be separated by the delimiter char specified vie 
the separator parameter (default: ','). 
+The number of words in the find and replace parameters needs to be equal.
+The first word in find is replaced by the first word in replace, same for all 
subsequent words
+@item 6, remove_words
+Remove certain words. Requires the find parameter to be specified. Multiple 
words must be separated by the delimiter char specified v

[FFmpeg-devel] [PATCH v9 11/13] avfilter/stripstyles: Add stripstyles filter

2021-09-23 Thread Soft Works
- stripstyles {S -> S)
  Remove all inline styles from subtitle events

Signed-off-by: softworkz 
---
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/sf_stripstyles.c | 211 +++
 3 files changed, 213 insertions(+)
 create mode 100644 libavfilter/sf_stripstyles.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e6fef97c08..309c404bf7 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -540,6 +540,7 @@ OBJS-$(CONFIG_NULLSINK_FILTER)   += 
vsink_nullsink.o
 OBJS-$(CONFIG_CENSOR_FILTER) += sf_textmod.o
 OBJS-$(CONFIG_SHOW_SPEAKER_FILTER)   += sf_textmod.o
 OBJS-$(CONFIG_TEXTMOD_FILTER)+= sf_textmod.o
+OBJS-$(CONFIG_STRIPSTYLES_FILTER)+= sf_stripstyles.o
 
 # multimedia filters
 OBJS-$(CONFIG_ABITSCOPE_FILTER)  += avf_abitscope.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 8929080b46..b482f68286 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -528,6 +528,7 @@ extern const AVFilter ff_avf_showwavespic;
 extern const AVFilter ff_vaf_spectrumsynth;
 extern const AVFilter ff_sf_censor;
 extern const AVFilter ff_sf_show_speaker;
+extern const AVFilter ff_sf_stripstyles;
 extern const AVFilter ff_sf_textmod;
 extern const AVFilter ff_svf_graphicsub2video;
 extern const AVFilter ff_svf_textsub2video;
diff --git a/libavfilter/sf_stripstyles.c b/libavfilter/sf_stripstyles.c
new file mode 100644
index 00..255fa7bf70
--- /dev/null
+++ b/libavfilter/sf_stripstyles.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2021 softworkz
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * text subtitle filter which removes inline-styles from subtitles
+ */
+
+#include "libavutil/opt.h"
+#include "internal.h"
+#include "libavutil/ass_split.h"
+#include "libavutil/bprint.h"
+
+typedef struct StripStylesContext {
+const AVClass *class;
+enum AVSubtitleType format;
+int remove_animated;
+} StripStylesContext;
+
+typedef struct DialogContext {
+StripStylesContext* ss_ctx;
+AVBPrint buffer;
+int drawing_scale;
+int is_animated;
+} DialogContext;
+
+static void dialog_text_cb(void *priv, const char *text, int len)
+{
+DialogContext *s = priv;
+
+av_log(s->ss_ctx, AV_LOG_DEBUG, "dialog_text_cb: %s\n", text);
+
+if (!s->drawing_scale && (!s->is_animated || !s->ss_ctx->remove_animated))
+av_bprint_append_data(&s->buffer, text, len);
+}
+
+static void dialog_new_line_cb(void *priv, int forced)
+{
+DialogContext *s = priv;
+if (!s->drawing_scale && !s->is_animated)
+av_bprint_append_data(&s->buffer, forced ? "\\N" : "\\n", 2);
+}
+
+static void dialog_drawing_mode_cb(void *priv, int scale)
+{
+DialogContext *s = priv;
+s->drawing_scale = scale;
+}
+
+static void dialog_animate_cb(void *priv, int t1, int t2, int accel, char 
*style)
+{
+DialogContext *s = priv;
+s->is_animated = 1;
+}
+
+static void dialog_move_cb(void *priv, int x1, int y1, int x2, int y2, int t1, 
int t2)
+{
+DialogContext *s = priv;
+if (t1 >= 0 || t2 >= 0)
+s->is_animated = 1;
+}
+
+static const ASSCodesCallbacks dialog_callbacks = {
+.text = dialog_text_cb,
+.new_line = dialog_new_line_cb,
+.drawing_mode = dialog_drawing_mode_cb,
+.animate  = dialog_animate_cb,
+.move = dialog_move_cb,
+};
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats;
+AVFilterLink *inlink = ctx->inputs[0];
+AVFilterLink *outlink = ctx->outputs[0];
+static const enum AVSubtitleType subtitle_fmts[] = { AV_SUBTITLE_FMT_ASS, 
AV_SUBTITLE_FMT_NONE };
+int ret;
+
+/* set input subtitle format */
+formats = ff_make_format_list(subtitle_fmts);
+if ((ret = ff_formats_ref(formats, &inlink->outcfg.formats)) < 0)
+return ret;
+
+/* set output video format */
+if ((ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0)
+return ret;
+
+return 0;
+}
+
+static char *ass_get_line(int readorder, int layer, const char *style,
+const char *speaker, const char *effect, const char 
*text)
+{
+

[FFmpeg-devel] [PATCH v9 12/13] avfilter/split_cc: Add split_cc filter for closed caption handling

2021-09-23 Thread Soft Works
- split_cc {V -> VS)
  Extract closed-caption (A53) data from video
  frames as subtitle Frames

ffmpeg -y -loglevel verbose -i 
"https://streams.videolan.org/streams/ts/CC/NewsStream-608-ac3.ts"; 
-filter_complex 
"[0:v]split_cc[vid1],textmod=mode=remove_chars:find='@',[vid1]overlay_textsubs" 
output.mkv

Signed-off-by: softworkz 
---
 configure |   1 +
 doc/filters.texi  |  45 ++
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/sf_split_cc.c | 298 ++
 5 files changed, 346 insertions(+)
 create mode 100644 libavfilter/sf_split_cc.c

diff --git a/configure b/configure
index 37fc4c20e7..6da059e6ee 100755
--- a/configure
+++ b/configure
@@ -3663,6 +3663,7 @@ spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp"
 sr_filter_deps="avformat swscale"
 sr_filter_select="dnn"
 stereo3d_filter_deps="gpl"
+split_cc_filter_deps="cc_dec_decoder"
 subtitles_filter_deps="avformat avcodec libass"
 super2xsai_filter_deps="gpl"
 pixfmts_super2xsai_test_deps="super2xsai_filter"
diff --git a/doc/filters.texi b/doc/filters.texi
index 2d3dcdd7e6..c48e1fcf11 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25378,6 +25378,16 @@ string containing ASS style format @code{KEY=VALUE} 
couples separated by ",".
 
 @end table
 
+@subsection Examples
+
+@itemize
+@item
+Overlay ASS subtitles with animations:
+@example
+ffmpeg -i 
"http://streams.videolan.org/samples/sub/SSA/subtitle_testing_complex.mkv"; 
-filter_complex "[0:v]overlay_textsubs" -map 0 -y out.mkv
+@end example
+@end itemize
+
 @section show_speaker
 
 Prepend speaker names to subtitle lines (when available).
@@ -25441,6 +25451,41 @@ ffmpeg -i INPUT -filter_complex 
"show_speaker=format=colon:style='@{\\c&HDD&
 @end example
 @end itemize
 
+
+@section split_cc
+
+Split-out closed-caption/A53 subtitles from video frame side data.
+
+This filter provides an input and an output for video frames, which are just 
passed through without modification.
+The second out provides subtitle frames which are extracted from video frame 
side data.
+
+Inputs:
+- 0: Video
+
+Outputs:
+- 0: Video (same as input)
+- 1: Subtitles [text]
+
+It accepts the following parameters:
+
+@table @option
+
+@item use_cc_styles
+Emit closed caption style header. This will make closed captions look like on 
normal TV devices.
+(white font on black background rectangles)
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Extract closed captions as text subtitle stream and overlay it onto the video:
+@example
+ffmpeg -i "https://streams.videolan.org/streams/ts/CC/NewsStream-608-ac3.ts"; 
-filter_complex  "[0:v:0]split_cc[vid1][sub1];[vid1][sub1]overlay_textsubs" 
output.mkv
+@end example
+@end itemize
+
 @section textsub2video
 
 Converts text subtitles to video frames.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 309c404bf7..39abf6d2a6 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -540,6 +540,7 @@ OBJS-$(CONFIG_NULLSINK_FILTER)   += 
vsink_nullsink.o
 OBJS-$(CONFIG_CENSOR_FILTER) += sf_textmod.o
 OBJS-$(CONFIG_SHOW_SPEAKER_FILTER)   += sf_textmod.o
 OBJS-$(CONFIG_TEXTMOD_FILTER)+= sf_textmod.o
+OBJS-$(CONFIG_SPLIT_CC_FILTER)   += sf_split_cc.o
 OBJS-$(CONFIG_STRIPSTYLES_FILTER)+= sf_stripstyles.o
 
 # multimedia filters
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index b482f68286..802465fce2 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -528,6 +528,7 @@ extern const AVFilter ff_avf_showwavespic;
 extern const AVFilter ff_vaf_spectrumsynth;
 extern const AVFilter ff_sf_censor;
 extern const AVFilter ff_sf_show_speaker;
+extern const AVFilter ff_sf_split_cc;
 extern const AVFilter ff_sf_stripstyles;
 extern const AVFilter ff_sf_textmod;
 extern const AVFilter ff_svf_graphicsub2video;
diff --git a/libavfilter/sf_split_cc.c b/libavfilter/sf_split_cc.c
new file mode 100644
index 00..d96912a90b
--- /dev/null
+++ b/libavfilter/sf_split_cc.c
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2021 softworkz
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * subtitle filter for splitting out closed-caption/A

[FFmpeg-devel] [PATCH v9 13/13] avfilter/graphicsub2text: Add new graphicsub2text filter (OCR)

2021-09-23 Thread Soft Works
Signed-off-by: softworkz 
---
 configure|   1 +
 doc/filters.texi |  55 ++
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/sf_graphicsub2text.c | 322 +++
 5 files changed, 380 insertions(+)
 create mode 100644 libavfilter/sf_graphicsub2text.c

diff --git a/configure b/configure
index 6da059e6ee..9108742122 100755
--- a/configure
+++ b/configure
@@ -3601,6 +3601,7 @@ frei0r_deps_any="libdl LoadLibrary"
 frei0r_filter_deps="frei0r"
 frei0r_src_filter_deps="frei0r"
 fspp_filter_deps="gpl"
+graphicsub2text_filter_deps="libtesseract"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
 interlace_filter_deps="gpl"
diff --git a/doc/filters.texi b/doc/filters.texi
index c48e1fcf11..36113e5c4b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25248,6 +25248,61 @@ ffmpeg -i 
"https://streams.videolan.org/ffmpeg/mkv_subtitles.mkv"; -filter_comple
 @end example
 @end itemize
 
+@section graphicsub2text
+
+Converts graphic subtitles to text subtitles by performing OCR.
+
+For this filter to be available, ffmpeg needs to be compiled with libtesseract 
(see https://github.com/tesseract-ocr/tesseract).
+Language models need to be downloaded from 
https://github.com/tesseract-ocr/tessdata and put into as subfolder named 
'tessdata' or into a folder specified via the environment variable 
'TESSDATA_PREFIX'. 
+The path can also be specified via filter option (see below).
+
+Note: These models are including the data for both OCR modes.
+
+Inputs:
+- 0: Subtitles [bitmap]
+
+Outputs:
+- 0: Subtitles [text]
+
+It accepts the following parameters:
+
+@table @option
+@item ocr_mode
+The character recognition mode to use.
+
+Supported OCR modes are:
+
+@table @var
+@item 0, tesseract
+This is the classic libtesseract operation mode. It is fast but less accurate 
than LSTM.
+@item 1, lstm
+Newer OCR implementation based on ML models. Provides usually better results, 
requires more processing resources.
+@item 2, both
+Use a combination of both modes.
+@end table
+
+@item tessdata_path
+The path to a folder containing the language models to be used.
+
+@item language
+The recognition language. It needs to match the first three characters of a  
language model file in the tessdata path.
+
+@end table
+
+
+@subsection Examples
+
+@itemize
+@item
+Convert DVB graphic subtitles to ASS (text) subtitles
+
+Note: For this to work, you need to have the data file 'eng.traineddata' in a 
'tessdata' subfolder (see above).
+@example
+ffmpeg ffmpeg -loglevel verbose -i 
"https://streams.videolan.org/streams/ts/video_subs_ttxt%2Bdvbsub.ts"; 
-filter_complex "[0:13]graphicsub2text=ocr_mode=both" -c:s ass -y output.mkv
+@end example
+@end itemize
+
+
 @section graphicsub2video
 
 Renders graphic subtitles as video frames. 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 39abf6d2a6..312b67982c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -290,6 +290,7 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o 
qp_table.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
+OBJS-$(CONFIG_GRAPHICSUB2TEXT_FILTER)+= sf_graphicsub2text.o
 OBJS-$(CONFIG_GRAPHICSUB2VIDEO_FILTER)   += vf_overlay_graphicsubs.o 
framesync.o
 OBJS-$(CONFIG_GRAPHMONITOR_FILTER)   += f_graphmonitor.o
 OBJS-$(CONFIG_GRAYWORLD_FILTER)  += vf_grayworld.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 802465fce2..f3437789bf 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -527,6 +527,7 @@ extern const AVFilter ff_avf_showwaves;
 extern const AVFilter ff_avf_showwavespic;
 extern const AVFilter ff_vaf_spectrumsynth;
 extern const AVFilter ff_sf_censor;
+extern const AVFilter ff_sf_graphicsub2text;
 extern const AVFilter ff_sf_show_speaker;
 extern const AVFilter ff_sf_split_cc;
 extern const AVFilter ff_sf_stripstyles;
diff --git a/libavfilter/sf_graphicsub2text.c b/libavfilter/sf_graphicsub2text.c
new file mode 100644
index 00..c644f5b46c
--- /dev/null
+++ b/libavfilter/sf_graphicsub2text.c
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 2021 softworkz
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the

Re: [FFmpeg-devel] [PATCH v8 06/13] avfilter/overlay_graphicsubs: Add overlay_graphicsubs and graphicsub2video filters

2021-09-23 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Andreas
> Rheinhardt
> Sent: Wednesday, 22 September 2021 06:24
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v8 06/13] avfilter/overlay_graphicsubs:
> Add overlay_graphicsubs and graphicsub2video filters
> 
> Soft Works:
> > - overlay_graphicsubs (VS -> V)
> >   Overlay graphic subtitles onto a video stream
> >
> > - graphicsub2video {S -> V)
> >   Converts graphic subtitles to video frames (with alpha)
> >   Gets auto-inserted for retaining compatibility with
> >   sub2video command lines
> >
> > Signed-off-by: softworkz 
> > ---
> >  doc/filters.texi | 104 
> >  libavfilter/Makefile |   2 +
> >  libavfilter/allfilters.c |   2 +
> >  libavfilter/vf_overlay_graphicsubs.c | 730 +++
> >  4 files changed, 838 insertions(+)
> >  create mode 100644 libavfilter/vf_overlay_graphicsubs.c
> >
> > +
> > +/**
> > + * Blend image in src to destination buffer dst at position (x, y).
> > + */
> 
> This whole code looks quite duplicated from the ordinary overlay.

Yes - it looks like and it is derived from vf_overlay, but it's
not really a duplication.

The code in vf_overlay is for blending images of similar formats which
may only differ by an alpha component, while the code here is 
about blending a PAL8 images over multiple main formats.

As an example, when blending the PAL8 image over yuv420, I'm only 
converting the palette to yuv for better efficiency, and in case
of subsampling, there's a different stepping for main and overlay
data.

Mangling those specifics into the existing vf_overlay code, would
neither improve execution performance nor code readability and
ease maintenance.

Paul had initially criticised this initially as well, but eventually
agreed that it's better to keep it separate from vf_overlay.

This is the only comment of yours on which I didn’t take action,
and I wanted to explain why.

Kind regards,
softworkz




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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH V2] libavutil/hwcontext_qsv: fix a bug for mapping qsv frame to vaapi

2021-09-23 Thread Chen, Wenbin
> Command below failed.
> ffmpeg -v verbose -init_hw_device vaapi=va:/dev/dri/renderD128
> -init_hw_device qsv=qs@va -hwaccel qsv -hwaccel_device qs
> -filter_hw_device va -c:v h264_qsv
> -i 1080P.264 -vf "hwmap,format=vaapi" -c:v h264_vaapi output.264
> 
> Cause: Assign pair->first directly to data[3] in vaapi frame.
> pair->first is *VASurfaceID while data[3] in vaapi frame is
> VASurfaceID. I fix this line of code. Now the command above works.
> 
> Signed-off-by: Wenbin Chen 
> ---
>  libavutil/hwcontext_qsv.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index d431e71eab..b01236889e 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -781,7 +781,11 @@ static int qsv_map_from(AVHWFramesContext *ctx,
>  case AV_HWDEVICE_TYPE_VAAPI:
>  {
>  mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId;
> -child_data = pair->first;
> +/* pair->first is *VASurfaceID while data[3] in vaapi frame is
> VASurfaceID, so
> + * we need this casting for vaapi.
> + * Add intptr_t to force cast from VASurfaceID(uint) type to
> pointer(long) type
> + * to avoid compile warning */
> +child_data = (uint8_t*)(intptr_t)*(VASurfaceID*)pair->first;
>  break;
>  }
>  #endif
> --
> 2.25.1

Ping

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH V2] libavutil/hwcontext_qsv: fix a bug for mapping qsv frame to vaapi

2021-09-23 Thread James Almer

On 9/13/2021 3:22 AM, Wenbin Chen wrote:

Command below failed.
ffmpeg -v verbose -init_hw_device vaapi=va:/dev/dri/renderD128
-init_hw_device qsv=qs@va -hwaccel qsv -hwaccel_device qs
-filter_hw_device va -c:v h264_qsv
-i 1080P.264 -vf "hwmap,format=vaapi" -c:v h264_vaapi output.264

Cause: Assign pair->first directly to data[3] in vaapi frame.
pair->first is *VASurfaceID while data[3] in vaapi frame is
VASurfaceID. I fix this line of code. Now the command above works.

Signed-off-by: Wenbin Chen 
---
  libavutil/hwcontext_qsv.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index d431e71eab..b01236889e 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -781,7 +781,11 @@ static int qsv_map_from(AVHWFramesContext *ctx,
  case AV_HWDEVICE_TYPE_VAAPI:
  {
  mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId;
-child_data = pair->first;
+/* pair->first is *VASurfaceID while data[3] in vaapi frame is 
VASurfaceID, so
+ * we need this casting for vaapi.
+ * Add intptr_t to force cast from VASurfaceID(uint) type to 
pointer(long) type
+ * to avoid compile warning */
+child_data = (uint8_t*)(intptr_t)*(VASurfaceID*)pair->first;
  break;
  }
  #endif


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v3 1/3] swscale/yuv2rgb: fix conversion to X2RGB10

2021-09-23 Thread Manuel Stoeckl
This resolves a problem where conversions from YUV to X2RGB10LE
would produce color values a factor 4 too small, because an 8-bit
value was placed in a 10-bit channel.

Signed-off-by: Manuel Stoeckl 
---
 libswscale/yuv2rgb.c | 2 +-
 tests/ref/fate/filter-pixdesc-x2rgb10le  | 2 +-
 tests/ref/fate/filter-pixfmts-copy   | 2 +-
 tests/ref/fate/filter-pixfmts-crop   | 2 +-
 tests/ref/fate/filter-pixfmts-field  | 2 +-
 tests/ref/fate/filter-pixfmts-fieldorder | 2 +-
 tests/ref/fate/filter-pixfmts-hflip  | 2 +-
 tests/ref/fate/filter-pixfmts-il | 2 +-
 tests/ref/fate/filter-pixfmts-null   | 2 +-
 tests/ref/fate/filter-pixfmts-pad| 2 +-
 tests/ref/fate/filter-pixfmts-scale  | 2 +-
 tests/ref/fate/filter-pixfmts-transpose  | 2 +-
 tests/ref/fate/filter-pixfmts-vflip  | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index cac82f4c6f..c2e8d4894c 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -976,7 +976,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const 
int inv_table[4],
 y_table32   = c->yuvTable;
 yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy;
 for (i = 0; i < table_plane_size; i++) {
-unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
+unsigned yval = av_clip_uintp2((yb + 0x8000) >> 14, 10);
 y_table32[i]= (yval << rbase) + (needAlpha ? 0 : (255u << abase));
 y_table32[i + table_plane_size] = yval << gbase;
 y_table32[i + 2 * table_plane_size] = yval << bbase;
diff --git a/tests/ref/fate/filter-pixdesc-x2rgb10le 
b/tests/ref/fate/filter-pixdesc-x2rgb10le
index 94c8640a56..6fab74137f 100644
--- a/tests/ref/fate/filter-pixdesc-x2rgb10le
+++ b/tests/ref/fate/filter-pixdesc-x2rgb10le
@@ -1 +1 @@
-pixdesc-x2rgb10le98d697ed4668daf535163d5e08c903bb
+pixdesc-x2rgb10le   b50c6ddaf37214a06251c29798f94d6d
diff --git a/tests/ref/fate/filter-pixfmts-copy 
b/tests/ref/fate/filter-pixfmts-copy
index 1d7657c2af..1941ce37a1 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -80,7 +80,7 @@ rgbab6e1b441c365e03b5ffdf9b7b68d9a0c
 rgba64beae2ae04b5efedca3505f47c4dd6ea6ea
 rgba64leb91e1d77f799eb92241a2d2d28437b15
 uyvy422 3bcf3c80047592f2211fae3260b1b65d
-x2rgb10le   b0a0c8056521beeaa3fea4985ca87176
+x2rgb10le   c1e3ac21be04a16bb157b22784524520
 xyz12be a1ef56bf746d71f59669c28e48fc8450
 xyz12le 831ff03c1ba4ef19374686f16a064d8c
 ya16be  37c07787e544f900c87b853253bfc8dd
diff --git a/tests/ref/fate/filter-pixfmts-crop 
b/tests/ref/fate/filter-pixfmts-crop
index 8fc7614192..1d1c143869 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -77,7 +77,7 @@ rgb89b364a8f112ad9459fec47a51cc03b30
 rgba9488ac85abceaf99a9309eac5a87697e
 rgba64be89910046972ab3c68e2a348302cc8ca9
 rgba64lefea8ebfc869b52adf353778f29eac7a7
-x2rgb10le   5c0789f76a713f343c2ed42a371d441d
+x2rgb10le   f4265aca7a67dbfa9354370098ca6f33
 xyz12be cb4571f9aaa7b59f999ef327276104b7
 xyz12le cd6aae8d26b18bdb4b9d068586276d91
 ya16be  a3d18014454942a96f15a49947c0c55d
diff --git a/tests/ref/fate/filter-pixfmts-field 
b/tests/ref/fate/filter-pixfmts-field
index ce8e53571f..2d8a7bfc54 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -80,7 +80,7 @@ rgbaee616262ca6d67b7ecfba4b36c602ce3
 rgba64be23c8c0edaabe3eaec89ce69633fb0048
 rgba64ledfdba4de4a7cac9abf08852666c341d3
 uyvy422 1c49e44ab3f060e85fc4a3a9464f045e
-x2rgb10le   a7a5dcdfe1d4b6bd71e40b01c735f144
+x2rgb10le   a18bc4ae5274e0a8cca9137ecd50c677
 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437
 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5
 ya16be  40403b5277364777e0671da4d38e01ac
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder 
b/tests/ref/fate/filter-pixfmts-fieldorder
index 90d36add83..3d612c9391 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -71,7 +71,7 @@ rgba1fdf872a087a32cd35b80cc7be399578
 rgba64be5598f44514d122b9a57c5c92c20bbc61
 rgba64leb34e6e30621ae579519a2d91a96a0acf
 uyvy422 75de70e31c435dde878002d3f22b238a
-x2rgb10le   636c90498c64abba1cc0624c5209a61f
+x2rgb10le   cdf6a9e8a8d081aa768c6ae2e6221676
 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc
 xyz12le 7be6c8781f38c21a6b8f602f62ca31e6
 ya16be  0f13e0f52586d172aaa07710fa3e8f31
diff --git a/tests/ref/fate/filter-pixfmts-hflip 
b/tests/ref/fate/filter-pixfmts-hflip
index 0d40b93e97..d6b99757d8 100644
--- a/tests/ref/fate/filter-pixfmts-hflip

[FFmpeg-devel] [PATCH v3 2/3] lavu/pix_fmt: add pixel format for x2bgr10

2021-09-23 Thread Manuel Stoeckl
The new format (given in big/little endian forms) matches the
existing X2RGB10 format, except with B and R channels switched.

AV_PIX_FMT_X2BGR10 data often is created by OpenGL programs
whose buffers use the GL_RGB10 internal format.

Signed-off-by: Manuel Stoeckl 
---
 doc/APIchanges   |  3 +++
 libavutil/pixdesc.c  | 24 
 libavutil/pixfmt.h   |  3 +++
 libavutil/version.h  |  2 +-
 tests/ref/fate/imgutils  |  2 ++
 tests/ref/fate/sws-pixdesc-query | 11 +++
 6 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5b5c2a6f11..7b267a79ac 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2021-09-21 - xx - lavu 57.7.100 - pixfmt.h
+  Add AV_PIX_FMT_X2BGR10.
+
 2021-09-20 - xx - lavu 57.6.100 - mem.h
   Deprecate av_mallocz_array() as it is identical to av_calloc().
 
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 2346138d04..69cb198646 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -272,6 +272,30 @@ static const AVPixFmtDescriptor 
av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
 },
 .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
 },
+[AV_PIX_FMT_X2BGR10LE] = {
+.name = "x2bgr10le",
+.nb_components= 3,
+.log2_chroma_w= 0,
+.log2_chroma_h= 0,
+.comp = {
+{ 0, 4, 0, 0, 10 },   /* R */
+{ 0, 4, 1, 2, 10 },   /* G */
+{ 0, 4, 2, 4, 10 },   /* B */
+},
+.flags = AV_PIX_FMT_FLAG_RGB,
+},
+[AV_PIX_FMT_X2BGR10BE] = {
+.name = "x2bgr10be",
+.nb_components= 3,
+.log2_chroma_w= 0,
+.log2_chroma_h= 0,
+.comp = {
+{ 0, 4, 2, 0, 10 },   /* R */
+{ 0, 4, 1, 2, 10 },   /* G */
+{ 0, 4, 0, 4, 10 },   /* B */
+},
+.flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
+},
 [AV_PIX_FMT_YUV422P] = {
 .name = "yuv422p",
 .nb_components = 3,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 5814f3f3da..53bdecfcb7 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -350,6 +350,8 @@ enum AVPixelFormat {
 
 AV_PIX_FMT_X2RGB10LE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 
10B(lsb), little-endian, X=unused/undefined
 AV_PIX_FMT_X2RGB10BE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 
10B(lsb), big-endian, X=unused/undefined
+AV_PIX_FMT_X2BGR10LE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 
10R(lsb), little-endian, X=unused/undefined
+AV_PIX_FMT_X2BGR10BE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 
10R(lsb), big-endian, X=unused/undefined
 AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you 
want to link with shared libav* because the number of formats might differ 
between versions
 };
 
@@ -440,6 +442,7 @@ enum AVPixelFormat {
 
 #define AV_PIX_FMT_Y210   AV_PIX_FMT_NE(Y210BE,  Y210LE)
 #define AV_PIX_FMT_X2RGB10AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE)
+#define AV_PIX_FMT_X2BGR10AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE)
 
 /**
   * Chromaticity coordinates of the source primaries.
diff --git a/libavutil/version.h b/libavutil/version.h
index a62f73639b..896e348d80 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR   6
+#define LIBAVUTIL_VERSION_MINOR   7
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index f510150ea1..495bbd46f0 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -236,3 +236,5 @@ y210be  planes: 1, linesizes: 256   0   0   0, 
plane_sizes: 12288 0
 y210le  planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
 x2rgb10le   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
 x2rgb10be   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
+x2bgr10le   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
+x2bgr10be   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query
index c3cccfa492..a74109c3d7 100644
--- a/tests/ref/fate/sws-pixdesc-query
+++ b/tests/ref/fate/sws-pixdesc-query
@@ -57,6 +57,8 @@ isNBPS:
   nv20le
   p010be
   p010le
+  x2bgr10be
+  x2bgr10le
   x2rgb10be
   x2rgb10le

[FFmpeg-devel] [PATCH v3 3/3] swscale: add input/output support for X2BGR10LE

2021-09-23 Thread Manuel Stoeckl
Signed-off-by: Manuel Stoeckl 
---
 libswscale/input.c   | 15 +--
 libswscale/output.c  |  9 -
 libswscale/utils.c   |  1 +
 libswscale/yuv2rgb.c |  9 ++---
 tests/ref/fate/filter-pixdesc-x2bgr10le  |  1 +
 tests/ref/fate/filter-pixfmts-copy   |  1 +
 tests/ref/fate/filter-pixfmts-crop   |  1 +
 tests/ref/fate/filter-pixfmts-field  |  1 +
 tests/ref/fate/filter-pixfmts-fieldorder |  1 +
 tests/ref/fate/filter-pixfmts-hflip  |  1 +
 tests/ref/fate/filter-pixfmts-il |  1 +
 tests/ref/fate/filter-pixfmts-null   |  1 +
 tests/ref/fate/filter-pixfmts-pad|  1 +
 tests/ref/fate/filter-pixfmts-scale  |  1 +
 tests/ref/fate/filter-pixfmts-transpose  |  1 +
 tests/ref/fate/filter-pixfmts-vflip  |  1 +
 16 files changed, 40 insertions(+), 6 deletions(-)
 create mode 100644 tests/ref/fate/filter-pixdesc-x2bgr10le

diff --git a/libswscale/input.c b/libswscale/input.c
index b65aaf7c06..477dc3d6b2 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -245,7 +245,8 @@ rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE)
  origin == AV_PIX_FMT_ARGB ||  \
  origin == AV_PIX_FMT_ABGR)\
 ? AV_RN32A(&src[(i) * 4])  \
-: ((origin == AV_PIX_FMT_X2RGB10LE)\
+: ((origin == AV_PIX_FMT_X2RGB10LE ||  \
+origin == AV_PIX_FMT_X2BGR10LE)\
? AV_RL32(&src[(i) * 4])\
: (isBE(origin) ? AV_RB16(&src[(i) * 2])\
   : AV_RL16(&src[(i) * 2]
@@ -393,6 +394,7 @@ rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0,  0, 0, 
  0xF800, 0x07E0,
 rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0,  0, 0,   0x7C00, 0x03E0,  
 0x001F,  0, 5, 10, RGB2YUV_SHIFT + 7)
 rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0,  0, 0,   0x0F00, 0x00F0,  
 0x000F,  0, 4,  8, RGB2YUV_SHIFT + 4)
 rgb16_32_wrapper(AV_PIX_FMT_X2RGB10LE, rgb30le, 16, 6, 0, 0, 0x3FF0, 
0xFFC00, 0x3FF, 0, 0, 4, RGB2YUV_SHIFT + 6)
+rgb16_32_wrapper(AV_PIX_FMT_X2BGR10LE, bgr30le, 0, 6, 16, 0, 0x3FF, 0xFFC00, 
0x3FF0, 4, 0, 0, RGB2YUV_SHIFT + 6)
 
 static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
  const uint8_t *gsrc, const uint8_t *bsrc, const 
uint8_t *rsrc,
@@ -1344,6 +1346,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_X2RGB10LE:
 c->chrToYV12 = rgb30leToUV_half_c;
 break;
+case AV_PIX_FMT_X2BGR10LE:
+c->chrToYV12 = bgr30leToUV_half_c;
+break;
 }
 } else {
 switch (srcFormat) {
@@ -1428,6 +1433,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_X2RGB10LE:
 c->chrToYV12 = rgb30leToUV_c;
 break;
+case AV_PIX_FMT_X2BGR10LE:
+c->chrToYV12 = bgr30leToUV_c;
+break;
 }
 }
 
@@ -1708,7 +1716,10 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 c->lumToYV12 = y210le_Y_c;
 break;
 case AV_PIX_FMT_X2RGB10LE:
-c->lumToYV12 =rgb30leToY_c;
+c->lumToYV12 = rgb30leToY_c;
+break;
+case AV_PIX_FMT_X2BGR10LE:
+c->lumToYV12 = bgr30leToY_c;
 break;
 }
 if (c->needAlpha) {
diff --git a/libswscale/output.c b/libswscale/output.c
index f1d9a61d53..58b10f85a5 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1603,7 +1603,7 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
 
 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
-} else if (target == AV_PIX_FMT_X2RGB10) {
+} else if (target == AV_PIX_FMT_X2RGB10 || target == AV_PIX_FMT_X2BGR10) {
 uint32_t *dest = (uint32_t *) _dest;
 const uint32_t *r = (const uint32_t *) _r;
 const uint32_t *g = (const uint32_t *) _g;
@@ -1848,6 +1848,7 @@ YUV2RGBWRAPPER(yuv2rgb,,   8,AV_PIX_FMT_RGB8,  0)
 YUV2RGBWRAPPER(yuv2rgb,,   4,AV_PIX_FMT_RGB4,  0)
 YUV2RGBWRAPPER(yuv2rgb,,   4b,   AV_PIX_FMT_RGB4_BYTE, 0)
 YUV2RGBWRAPPER(yuv2, rgb, x2rgb10, AV_PIX_FMT_X2RGB10, 0)
+YUV2RGBWRAPPER(yuv2, rgb, x2bgr10, AV_PIX_FMT_X2BGR10, 0)
 
 static av_always_inline void yuv2rgb_write_full(SwsContext *c,
 uint8_t *dest, int i, int Y, int A, int U, int V,
@@ -3000,6 +3001,12 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
 *yuv2packed2 = yuv2x2rgb10_2_c;
 *yuv2packedX = yuv2x2rgb10_X_c;
 break;
+case AV_PIX_FMT_X2BGR10LE:
+case AV_PIX_FMT_X2BGR10BE:
+*yuv2packed1 = yuv2x2bgr10_1_c;
+*yuv2packed2 = yuv2x2bgr10_2_c;
+  

Re: [FFmpeg-devel] [PATCH] swscale/yuv2rgb: fix shift values for conversion to X2RGB10

2021-09-23 Thread Manuel Stoeckl
> On Mon, Sep 20, 2021 at 10:21:23PM -0400, Manuel Stoeckl wrote:
> > This resolves a problem where conversions from YUV to X2RGB10LE
> > would produce color values a factor 4 too small.
> > 
> > The variable 'yval' used later in the switch case 30 has range
> > [0,255], but the color channel values in X2RGB10 have two more
> > bits than 'yval' and can go up to 1023. Increasing (r|g|b)base
> > by 2 effectively multiplies yval by 4 and fixes this discrepancy.  
> 
> does white have 1023 ? or 1020 ?
> a multiplication by 4 would not in general produce a correctly scaled
> 10bit per channel value from 8bit

I've replied to this email with a new version of the patch set, that
now ensures the channel values in the YUV->RGB table created in
ff_yuv2rgb_c_init_tables go up to 1023.

However, this does not mean the code will always convert 1.0 white to
1.0 white; for example, pure 0x RGBA64 white gets converted to
X2RGB10 grey level 1019. Presumably there is an off-by-one rounding
error somewhere in the RGB->YUV->RGB conversion path, but I don't think
tracking it down is worth it at the moment.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avcodec/mmaldec: use decoupled dataflow

2021-09-23 Thread Ming Shun Ho
On Fri, Sep 24, 2021 at 3:40 AM Andreas Rheinhardt
 wrote:
>
> Ho Ming Shun:
> > MMAL is an fundamentally an asynchronous decoder, which was a bad fit
> > for the legacy dataflow API. Often multiple packets are enqueued before
> > a flood of frames are returned from MMAL.
> >
> > The previous lockstep dataflow meant that any delay in returning packets
> > from the VPU would cause ctx->queue_decoded_frames to grow with no way
> > of draining the queue.
> >
> > Testing this with mpv streaming from an RTSP source reduced decode
> > latency from 2s to about 0.2s.
> >
> > Signed-off-by: Ho Ming Shun 
> > ---
> >  libavcodec/mmaldec.c | 30 +++---
> >  1 file changed, 23 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> > index 96140bf53d..3d7cc90cd2 100644
> > --- a/libavcodec/mmaldec.c
> > +++ b/libavcodec/mmaldec.c
> > @@ -570,6 +570,7 @@ static int ffmmal_add_packet(AVCodecContext *avctx, 
> > AVPacket *avpkt,
> >
> >  done:
> >  av_buffer_unref(&buf);
> > +av_packet_unref(avpkt);
> >  return ret;
> >  }
> >
> > @@ -655,6 +656,12 @@ static int ffmal_copy_frame(AVCodecContext *avctx,  
> > AVFrame *frame,
> >avctx->pix_fmt, avctx->width, avctx->height);
> >  }
> >
> > +frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
> > +frame->width = avctx->width;
> > +frame->width = avctx->width;
> > +frame->height = avctx->height;
> > +frame->format = avctx->pix_fmt;
> > +
> >  frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : 
> > buffer->pts;
> >  frame->pkt_dts = AV_NOPTS_VALUE;
> >
> > @@ -763,12 +770,12 @@ done:
> >  return ret;
> >  }
> >
> > -static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame,
> > - AVPacket *avpkt)
> > +static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
> >  {
> >  MMALDecodeContext *ctx = avctx->priv_data;
> > -AVFrame *frame = data;
> >  int ret = 0;
> > +AVPacket avpkt;
>
> You are adding a new AVPacket; and you are not even zeroing it. This is
> even worse than the current code (and it might even be dangerous:
> ff_decode_get_packet() expects initialized, blank packets, not
> uninitialized ones; what you are doing only works because this decoder
> does not have an automatically inserted bitstream filter).

Ah thanks for that.

>
> You will have to add an actually allocated packet for this; or one could
> reuse the spare packet of the DecodeSimpleContext that is unused for
> decoders implementing the receive_frame API.

Ok. Kind of scary because I don't see anyone else doing this.

>
> It is easy to fix the deprecation issue if one already has a spare
> packet: Just put the extradata into said packet.

I realized I do not need another spare packet. Previous decode based API
needed another AVPacket for extra_data because avpkt was passed in as
a function parameter.

Will post another version of this series to fix all warnings and switch to
receive_frame (for latency reasons most importantly).

> My guess that your patch does not exhibit any deep conflicts with mine
> turned out to be correct: the only part where there is a real conflict
> is in the fact that it doesn't make any sense any more to treat the
> packet as const, given that a decoder implementing the receive_frame API
> is supposed to unref the packets it receives on its own.
> While I regard not wrapping the extradata in a packet as cleaner, the
> code actually becomes simpler if one does so (as I will demonstrate
> lateron). In other words: I drop my patches.
>
> > +int got_frame = 0;
> >
> >  if (avctx->extradata_size && !ctx->extradata_sent) {
> >  AVPacket pkt = {0};
> > @@ -782,7 +789,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >  return ret;
> >  }
> >
> > -if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0)
> > +ret = ff_decode_get_packet(avctx, &avpkt);
> > +if(ret == 0) {
> > +if ((ret = ffmmal_add_packet(avctx, &avpkt, 0)) < 0)
> > +return ret;
> > +} else if(ret < 0 && !(ret == AVERROR(EAGAIN)))
> >  return ret;
> >
> >  if ((ret = ffmmal_fill_input_port(avctx)) < 0)
> > @@ -791,7 +802,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >  if ((ret = ffmmal_fill_output_port(avctx)) < 0)
> >  return ret;
> >
> > -if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0)
> > +if ((ret = ffmmal_read_frame(avctx, frame, &got_frame)) < 0)
> >  return ret;
> >
> >  // ffmmal_read_frame() can block for a while. Since the decoder is
> > @@ -803,7 +814,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >  if ((ret = ffmmal_fill_input_port(avctx)) < 0)
> >  return ret;
> >
> > -return ret;
> > +if(!got_frame && ret == 0)
> > +return AVERROR(EAGAIN);
> > +else
> > +return ret;
> > +
> > +
>
> Unnecessary newlines.
>
> >  }
> >
> >  static const AVCodecHWConfigInternal

[FFmpeg-devel] [PATCH 0/4] Switch mmaldec to decoupled dataflow

2021-09-23 Thread Ho Ming Shun
This series switches mmaldec to use the decoupled dataflow API to reduce
excessive buffering in the driver.

At the same time, remove dependency on sizeof(AVPacket) which is
deprecated. Also fix all compile warnings.


Ho Ming Shun (4):
  avcodec/mmaldec: use decoupled dataflow
  avcodec/mmaldec: use avpkt from DecodeSimpleContext
  avcodec/mmaldec: re-use AVPacket for extra_data
  avcodec/mmaldec: fix pointer type warning

 libavcodec/mmaldec.c | 40 +++-
 1 file changed, 27 insertions(+), 13 deletions(-)

-- 
2.33.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/4] avcodec/mmaldec: use decoupled dataflow

2021-09-23 Thread Ho Ming Shun
MMAL is an fundamentally an asynchronous decoder, which was a bad fit
for the legacy dataflow API. Often multiple packets are enqueued before
a flood of frames are returned from MMAL.

The previous lockstep dataflow meant that any delay in returning packets
from the VPU would cause ctx->queue_decoded_frames to grow with no way
of draining the queue.

Testing this with mpv streaming from a live RTSP source visibly reduced
latency introduced by frames waiting in queue_decoded_frames from
roughly 2s to 0.

Signed-off-by: Ho Ming Shun 
---
 libavcodec/mmaldec.c | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 03e15420ce..b97cc6ff5e 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -578,6 +578,7 @@ static int ffmmal_add_packet(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 done:
 av_buffer_unref(&buf);
+av_packet_unref(avpkt);
 return ret;
 }
 
@@ -663,6 +664,12 @@ static int ffmal_copy_frame(AVCodecContext *avctx,  
AVFrame *frame,
   avctx->pix_fmt, avctx->width, avctx->height);
 }
 
+frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
+frame->width = avctx->width;
+frame->width = avctx->width;
+frame->height = avctx->height;
+frame->format = avctx->pix_fmt;
+
 frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : 
buffer->pts;
 #if FF_API_PKT_PTS
 FF_DISABLE_DEPRECATION_WARNINGS
@@ -776,12 +783,12 @@ done:
 return ret;
 }
 
-static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
+static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
 {
 MMALDecodeContext *ctx = avctx->priv_data;
-AVFrame *frame = data;
+AVPacket avpkt = {0};
 int ret = 0;
+int got_frame = 0;
 
 if (avctx->extradata_size && !ctx->extradata_sent) {
 AVPacket pkt = {0};
@@ -793,7 +800,11 @@ static int ffmmal_decode(AVCodecContext *avctx, void 
*data, int *got_frame,
 return ret;
 }
 
-if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0)
+ret = ff_decode_get_packet(avctx, &avpkt);
+if(ret == 0) {
+if ((ret = ffmmal_add_packet(avctx, &avpkt, 0)) < 0)
+return ret;
+} else if(ret < 0 && !(ret == AVERROR(EAGAIN)))
 return ret;
 
 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
@@ -802,7 +813,7 @@ static int ffmmal_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
 return ret;
 
-if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0)
+if ((ret = ffmmal_read_frame(avctx, frame, &got_frame)) < 0)
 return ret;
 
 // ffmmal_read_frame() can block for a while. Since the decoder is
@@ -814,7 +825,10 @@ static int ffmmal_decode(AVCodecContext *avctx, void 
*data, int *got_frame,
 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
 return ret;
 
-return ret;
+if(!got_frame && ret == 0)
+return AVERROR(EAGAIN);
+else
+return ret;
 }
 
 static const AVCodecHWConfigInternal *const mmal_hw_configs[] = {
@@ -846,7 +860,7 @@ static const AVOption options[]={
 .priv_data_size = sizeof(MMALDecodeContext), \
 .init   = ffmmal_init_decoder, \
 .close  = ffmmal_close_decoder, \
-.decode = ffmmal_decode, \
+.receive_frame  = ffmmal_receive_frame, \
 .flush  = ffmmal_flush, \
 .priv_class = &ffmmal_##NAME##_dec_class, \
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \
-- 
2.33.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/4] avcodec/mmaldec: use avpkt from DecodeSimpleContext

2021-09-23 Thread Ho Ming Shun
Use spare packet allocated in DecodeSimpleContext to handle packet
submission into ffmmal_add_packet.
---
 libavcodec/mmaldec.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index b97cc6ff5e..aab107d325 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -786,10 +786,12 @@ done:
 static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
 {
 MMALDecodeContext *ctx = avctx->priv_data;
-AVPacket avpkt = {0};
 int ret = 0;
 int got_frame = 0;
 
+// use spare packet from DecodeSimpleContext meant for simple API
+AVPacket *avpkt = avctx->internal->ds.in_pkt;
+
 if (avctx->extradata_size && !ctx->extradata_sent) {
 AVPacket pkt = {0};
 av_init_packet(&pkt);
@@ -800,9 +802,9 @@ static int ffmmal_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 return ret;
 }
 
-ret = ff_decode_get_packet(avctx, &avpkt);
+ret = ff_decode_get_packet(avctx, avpkt);
 if(ret == 0) {
-if ((ret = ffmmal_add_packet(avctx, &avpkt, 0)) < 0)
+if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0)
 return ret;
 } else if(ret < 0 && !(ret == AVERROR(EAGAIN)))
 return ret;
-- 
2.33.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


  1   2   >