Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-09 Thread Lynne
Aug 9, 2019, 22:54 by geo...@nsup.org:

> Juan De León (12019-08-09):
>
>> AVEncodeInfoFrame data structure to store as AVFrameSideData of type
>> AV_FRAME_DATA_ENCODE_INFO.
>> The structure stores quantization index for each plane, DC/AC deltas
>> for luma and chroma planes, and an array of AVEncodeInfoBlock type
>> denoting position, size, and delta quantizer for each block in the
>> frame.
>> Can be extended to support extraction of other block information.
>>
>> Signed-off-by: Juan De León 
>> ---
>>  libavutil/Makefile  |  2 +
>>  libavutil/encode_info.c | 68 +++
>>  libavutil/encode_info.h | 90 +
>>  libavutil/frame.c   |  1 +
>>  libavutil/frame.h   |  7 
>>  5 files changed, 168 insertions(+)
>>  create mode 100644 libavutil/encode_info.c
>>  create mode 100644 libavutil/encode_info.h
>>
>> diff --git a/libavutil/Makefile b/libavutil/Makefile
>> index 57e6e3d7e8..37cfb099e9 100644
>> --- a/libavutil/Makefile
>> +++ b/libavutil/Makefile
>> @@ -24,6 +24,7 @@ HEADERS = adler32.h
>>  \
>>  dict.h\
>>  display.h \
>>  downmix_info.h\
>> +  encode_info.h \
>>  encryption_info.h \
>>  error.h   \
>>  eval.h\
>> @@ -111,6 +112,7 @@ OBJS = adler32.o 
>>\
>>  dict.o   \
>>  display.o\
>>  downmix_info.o   \
>> +   encode_info.o\
>>  encryption_info.o\
>>  error.o  \
>>  eval.o   \
>> diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
>> new file mode 100644
>> index 00..6d832b2e36
>> --- /dev/null
>> +++ b/libavutil/encode_info.c
>> @@ -0,0 +1,68 @@
>> +/*
>> + * 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/encode_info.h"
>> +#include "libavutil/mem.h"
>> +
>> +static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
>> +ptr->nb_blocks = nb_blocks;
>> +ptr->dc_q = ptr->ac_q = -1;
>> +ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
>> +
>> +for(int i=0;i> +ptr->plane_q[i] = -1;
>> +
>> +return 0;
>> +}
>> +
>> +AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
>> +{
>> +AVEncodeInfoFrame *ptr;
>> +//AVEncodeInfoFrame already allocates size for one element of 
>> AVEncodeInfoBlock
>> +size_t size = sizeof(AVEncodeInfoFrame) + 
>> sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks-1, 0);
>> +
>> +if (nb_blocks < 0 || size >= INT_MAX)
>> +return NULL;
>> +
>> +ptr = av_mallocz(size);
>> +if (!ptr)
>> +return NULL;
>> +
>> +init_encode_info_data(ptr, nb_blocks);
>> +
>> +return ptr;
>> +}
>> +
>> +AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
>> nb_blocks)
>> +{
>> +size_t size = sizeof(AVEncodeInfoFrame) + 
>> sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks-1, 0);
>> +
>> +if (nb_blocks < 0 || size >= INT_MAX)
>> +return NULL;
>> +
>> +AVFrameSideData *sd = av_frame_new_side_data(frame,
>> + AV_FRAME_DATA_ENCODE_INFO,
>> + size);
>> +if (!sd)
>> +return NULL;
>> +
>> +memset(sd->data, 0, size);
>> +init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
>> +
>> +return (AVEncodeInfoFrame*)sd->data;
>> +}
>> diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
>> new file mode 100644
>> index 00..f4175b43c9
>> --- /dev/null

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures

2019-08-09 Thread Nicolas George
Juan De León (12019-08-09):
> AVEncodeInfoFrame data structure to store as AVFrameSideData of type
> AV_FRAME_DATA_ENCODE_INFO.
> The structure stores quantization index for each plane, DC/AC deltas
> for luma and chroma planes, and an array of AVEncodeInfoBlock type
> denoting position, size, and delta quantizer for each block in the
> frame.
> Can be extended to support extraction of other block information.
> 
> Signed-off-by: Juan De León 
> ---
>  libavutil/Makefile  |  2 +
>  libavutil/encode_info.c | 68 +++
>  libavutil/encode_info.h | 90 +
>  libavutil/frame.c   |  1 +
>  libavutil/frame.h   |  7 
>  5 files changed, 168 insertions(+)
>  create mode 100644 libavutil/encode_info.c
>  create mode 100644 libavutil/encode_info.h
> 
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 57e6e3d7e8..37cfb099e9 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -24,6 +24,7 @@ HEADERS = adler32.h 
> \
>dict.h\
>display.h \
>downmix_info.h\
> +  encode_info.h \
>encryption_info.h \
>error.h   \
>eval.h\
> @@ -111,6 +112,7 @@ OBJS = adler32.o  
>   \
> dict.o   \
> display.o\
> downmix_info.o   \
> +   encode_info.o\
> encryption_info.o\
> error.o  \
> eval.o   \
> diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
> new file mode 100644
> index 00..6d832b2e36
> --- /dev/null
> +++ b/libavutil/encode_info.c
> @@ -0,0 +1,68 @@
> +/*
> + * 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/encode_info.h"
> +#include "libavutil/mem.h"
> +
> +static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
> +ptr->nb_blocks = nb_blocks;
> +ptr->dc_q = ptr->ac_q = -1;
> +ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
> +
> +for(int i=0;i +ptr->plane_q[i] = -1;
> +
> +return 0;
> +}
> +
> +AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
> +{
> +AVEncodeInfoFrame *ptr;
> +//AVEncodeInfoFrame already allocates size for one element of 
> AVEncodeInfoBlock
> +size_t size = sizeof(AVEncodeInfoFrame) + 
> sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks-1, 0);
> +
> +if (nb_blocks < 0 || size >= INT_MAX)
> +return NULL;
> +
> +ptr = av_mallocz(size);
> +if (!ptr)
> +return NULL;
> +
> +init_encode_info_data(ptr, nb_blocks);
> +
> +return ptr;
> +}
> +
> +AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
> nb_blocks)
> +{
> +size_t size = sizeof(AVEncodeInfoFrame) + 
> sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks-1, 0);
> +
> +if (nb_blocks < 0 || size >= INT_MAX)
> +return NULL;
> +
> +AVFrameSideData *sd = av_frame_new_side_data(frame,
> + AV_FRAME_DATA_ENCODE_INFO,
> + size);
> +if (!sd)
> +return NULL;
> +
> +memset(sd->data, 0, size);
> +init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
> +
> +return (AVEncodeInfoFrame*)sd->data;
> +}
> diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
> new file mode 100644
> index 00..f4175b43c9
> --- /dev/null
> +++ b/libavutil/encode_info.h
> @@ -0,0 +1,90 @@
> +/*
> + * 

Re: [FFmpeg-devel] [PATCH] tools/zmqsend: Avoid mem copy past the end of input buffer

2019-08-09 Thread Michael Niedermayer
On Thu, Aug 08, 2019 at 05:19:54PM +0200, Paul B Mahol wrote:
> On Thu, Aug 8, 2019 at 4:44 PM Andriy Gelman 
> wrote:
> 
> > From: Andriy Gelman 
> >
> > This patch avoids a read past the end of the input buffer in memcpy since
> > the size
> > of the received zmq message is recv_buf_size - 1.
> > ---
> >  tools/zmqsend.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/zmqsend.c b/tools/zmqsend.c
> > index 7bd7fe4199..f26fa9c1c2 100644
> > --- a/tools/zmqsend.c
> > +++ b/tools/zmqsend.c
> > @@ -155,7 +155,7 @@ int main(int argc, char **argv)
> >  ret = 1;
> >  goto end;
> >  }
> > -memcpy(recv_buf, zmq_msg_data(), recv_buf_size);
> > +memcpy(recv_buf, zmq_msg_data(), recv_buf_size - 1);
> >  recv_buf[recv_buf_size-1] = 0;
> >  printf("%s\n", recv_buf);
> >  zmq_msg_close();
> > --
> > 2.22.0
> >
> >
> LGTM

will apply

thanks

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


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] Fix integer parameters size check in SDP fmtp line

2019-08-09 Thread Michael Niedermayer
On Thu, Aug 08, 2019 at 03:39:00PM +0200, Olivier MAIGNIAL wrote:
> Hello here,
> 
> Just a mail to ping this patch

will apply

thanks

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

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


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] libavutil: AVEncodeInfo data structures

2019-08-09 Thread Juan De León
AVEncodeInfoFrame data structure to store as AVFrameSideData of type
AV_FRAME_DATA_ENCODE_INFO.
The structure stores quantization index for each plane, DC/AC deltas
for luma and chroma planes, and an array of AVEncodeInfoBlock type
denoting position, size, and delta quantizer for each block in the
frame.
Can be extended to support extraction of other block information.

Signed-off-by: Juan De León 
---
 libavutil/Makefile  |  2 +
 libavutil/encode_info.c | 68 +++
 libavutil/encode_info.h | 90 +
 libavutil/frame.c   |  1 +
 libavutil/frame.h   |  7 
 5 files changed, 168 insertions(+)
 create mode 100644 libavutil/encode_info.c
 create mode 100644 libavutil/encode_info.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..37cfb099e9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -24,6 +24,7 @@ HEADERS = adler32.h   
  \
   dict.h\
   display.h \
   downmix_info.h\
+  encode_info.h \
   encryption_info.h \
   error.h   \
   eval.h\
@@ -111,6 +112,7 @@ OBJS = adler32.o
\
dict.o   \
display.o\
downmix_info.o   \
+   encode_info.o\
encryption_info.o\
error.o  \
eval.o   \
diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
new file mode 100644
index 00..6d832b2e36
--- /dev/null
+++ b/libavutil/encode_info.c
@@ -0,0 +1,68 @@
+/*
+ * 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/encode_info.h"
+#include "libavutil/mem.h"
+
+static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
+ptr->nb_blocks = nb_blocks;
+ptr->dc_q = ptr->ac_q = -1;
+ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
+
+for(int i=0;iplane_q[i] = -1;
+
+return 0;
+}
+
+AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
+{
+AVEncodeInfoFrame *ptr;
+//AVEncodeInfoFrame already allocates size for one element of 
AVEncodeInfoBlock
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks-1, 0);
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+ptr = av_mallocz(size);
+if (!ptr)
+return NULL;
+
+init_encode_info_data(ptr, nb_blocks);
+
+return ptr;
+}
+
+AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
nb_blocks)
+{
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*FFMIN(nb_blocks-1, 0);
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+AVFrameSideData *sd = av_frame_new_side_data(frame,
+ AV_FRAME_DATA_ENCODE_INFO,
+ size);
+if (!sd)
+return NULL;
+
+memset(sd->data, 0, size);
+init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
+
+return (AVEncodeInfoFrame*)sd->data;
+}
diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
new file mode 100644
index 00..f4175b43c9
--- /dev/null
+++ b/libavutil/encode_info.h
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ *
+ * 

Re: [FFmpeg-devel] [PATCH] avcodec/mlpenc: fix invalid checks, sample buffers are internally all in 24 depth

2019-08-09 Thread Carl Eugen Hoyos
Am Fr., 9. Aug. 2019 um 11:42 Uhr schrieb Paul B Mahol :

> patch attached.
>
> If you still encounter hash failures please share input file.

Not sure if this is related but ticket #6216 contains a file that
cannot be encoded to mlp / thd so it is decoded bit-exact.

Carl Eugen
___
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] libavutil: AVEncodeInfo data structures and AV_FRAME_DATA_ENCODE_INFO AVFrameSideDataType

2019-08-09 Thread James Almer
On 8/9/2019 3:28 PM, Nicolas George wrote:
> James Almer (12019-08-09):
>> Or just a pointer that points to the first byte after itself.
> 
> The pointer takes places by itself. And it prevents the structure from
> being copied flatly, which IIRC is forbidden with side data.

Yeah, you're right, make_writable() and similar functions would break it.

> 
> By the way, the lines of the commit message are too long.
> 
> Regards,
> 
> 
> ___
> 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] libavutil: AVEncodeInfo data structures and AV_FRAME_DATA_ENCODE_INFO AVFrameSideDataType

2019-08-09 Thread Nicolas George
James Almer (12019-08-09):
> Or just a pointer that points to the first byte after itself.

The pointer takes places by itself. And it prevents the structure from
being copied flatly, which IIRC is forbidden with side data.

By the way, the lines of the commit message are too long.

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] libavutil: AVEncodeInfo data structures and AV_FRAME_DATA_ENCODE_INFO AVFrameSideDataType

2019-08-09 Thread James Almer
On 8/9/2019 2:58 PM, Hendrik Leppkes wrote:
> On Fri, Aug 9, 2019 at 7:52 PM James Almer  wrote:
>>
>> On 8/9/2019 2:38 PM, Juan De León wrote:
>>> AVEncodeInfoFrame data structure to store as AVFrameSideData of type 
>>> AV_FRAME_DATA_ENCODE_INFO.
>>> The structure stores quantization index for each plane, DC/AC deltas for 
>>> luma and chroma planes, and an array of AVEncodeInfoBlock struct denoting 
>>> position, size, and delta quantizer for each block in the frame.
>>> Can be extended to support extraction of other block information.
>>>
>>> Signed-off-by: Juan De León 
>>> ---
>>> fixed a typo in frame.h comment
>>>  libavutil/Makefile  |  2 +
>>>  libavutil/encode_info.c | 67 +++
>>>  libavutil/encode_info.h | 87 +
>>>  libavutil/frame.c   |  1 +
>>>  libavutil/frame.h   |  7 
>>>  5 files changed, 164 insertions(+)
>>>  create mode 100644 libavutil/encode_info.c
>>>  create mode 100644 libavutil/encode_info.h
>>>
>>> diff --git a/libavutil/Makefile b/libavutil/Makefile
>>> index 57e6e3d7e8..37cfb099e9 100644
>>> --- a/libavutil/Makefile
>>> +++ b/libavutil/Makefile
>>> @@ -24,6 +24,7 @@ HEADERS = adler32.h   
>>>   \
>>>dict.h\
>>>display.h \
>>>downmix_info.h\
>>> +  encode_info.h \
>>>encryption_info.h \
>>>error.h   \
>>>eval.h\
>>> @@ -111,6 +112,7 @@ OBJS = adler32.o
>>> \
>>> dict.o   \
>>> display.o\
>>> downmix_info.o   \
>>> +   encode_info.o\
>>> encryption_info.o\
>>> error.o  \
>>> eval.o   \
>>> diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
>>> new file mode 100644
>>> index 00..68c30af4d7
>>> --- /dev/null
>>> +++ b/libavutil/encode_info.c
>>> @@ -0,0 +1,67 @@
>>> +/*
>>> + * 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/encode_info.h"
>>> +#include "libavutil/mem.h"
>>> +
>>> +static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
>>> +ptr->nb_blocks = nb_blocks;
>>> +ptr->dc_q = ptr->ac_q = -1;
>>> +ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
>>> +
>>> +for(int i=0;i>> +ptr->plane_q[i] = -1;
>>> +
>>> +return 0;
>>> +}
>>> +
>>> +AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
>>> +{
>>> +AVEncodeInfoFrame *ptr;
>>> +size_t size = sizeof(AVEncodeInfoFrame) + 
>>> sizeof(AVEncodeInfoBlock)*nb_blocks;
>>> +
>>> +if (nb_blocks < 0 || size >= INT_MAX)
>>> +return NULL;
>>> +
>>> +ptr = av_mallocz(size);
>>> +if (!ptr)
>>> +return NULL;
>>> +
>>> +init_encode_info_data(ptr, nb_blocks);
>>> +
>>> +return ptr;
>>> +}
>>> +
>>> +AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
>>> nb_blocks)
>>> +{
>>> +size_t size = sizeof(AVEncodeInfoFrame) + 
>>> sizeof(AVEncodeInfoBlock)*nb_blocks;
>>> +
>>> +if (nb_blocks < 0 || size >= INT_MAX)
>>> +return NULL;
>>> +
>>> +AVFrameSideData *sd = av_frame_new_side_data(frame,
>>> + AV_FRAME_DATA_ENCODE_INFO,
>>> + size);
>>> +if (!sd)
>>> +return NULL;
>>> +
>>> +memset(sd->data, 0, size);
>>> +

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures and AV_FRAME_DATA_ENCODE_INFO AVFrameSideDataType

2019-08-09 Thread Hendrik Leppkes
On Fri, Aug 9, 2019 at 7:52 PM James Almer  wrote:
>
> On 8/9/2019 2:38 PM, Juan De León wrote:
> > AVEncodeInfoFrame data structure to store as AVFrameSideData of type 
> > AV_FRAME_DATA_ENCODE_INFO.
> > The structure stores quantization index for each plane, DC/AC deltas for 
> > luma and chroma planes, and an array of AVEncodeInfoBlock struct denoting 
> > position, size, and delta quantizer for each block in the frame.
> > Can be extended to support extraction of other block information.
> >
> > Signed-off-by: Juan De León 
> > ---
> > fixed a typo in frame.h comment
> >  libavutil/Makefile  |  2 +
> >  libavutil/encode_info.c | 67 +++
> >  libavutil/encode_info.h | 87 +
> >  libavutil/frame.c   |  1 +
> >  libavutil/frame.h   |  7 
> >  5 files changed, 164 insertions(+)
> >  create mode 100644 libavutil/encode_info.c
> >  create mode 100644 libavutil/encode_info.h
> >
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index 57e6e3d7e8..37cfb099e9 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -24,6 +24,7 @@ HEADERS = adler32.h   
> >   \
> >dict.h\
> >display.h \
> >downmix_info.h\
> > +  encode_info.h \
> >encryption_info.h \
> >error.h   \
> >eval.h\
> > @@ -111,6 +112,7 @@ OBJS = adler32.o
> > \
> > dict.o   \
> > display.o\
> > downmix_info.o   \
> > +   encode_info.o\
> > encryption_info.o\
> > error.o  \
> > eval.o   \
> > diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
> > new file mode 100644
> > index 00..68c30af4d7
> > --- /dev/null
> > +++ b/libavutil/encode_info.c
> > @@ -0,0 +1,67 @@
> > +/*
> > + * 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/encode_info.h"
> > +#include "libavutil/mem.h"
> > +
> > +static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
> > +ptr->nb_blocks = nb_blocks;
> > +ptr->dc_q = ptr->ac_q = -1;
> > +ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
> > +
> > +for(int i=0;i > +ptr->plane_q[i] = -1;
> > +
> > +return 0;
> > +}
> > +
> > +AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
> > +{
> > +AVEncodeInfoFrame *ptr;
> > +size_t size = sizeof(AVEncodeInfoFrame) + 
> > sizeof(AVEncodeInfoBlock)*nb_blocks;
> > +
> > +if (nb_blocks < 0 || size >= INT_MAX)
> > +return NULL;
> > +
> > +ptr = av_mallocz(size);
> > +if (!ptr)
> > +return NULL;
> > +
> > +init_encode_info_data(ptr, nb_blocks);
> > +
> > +return ptr;
> > +}
> > +
> > +AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
> > nb_blocks)
> > +{
> > +size_t size = sizeof(AVEncodeInfoFrame) + 
> > sizeof(AVEncodeInfoBlock)*nb_blocks;
> > +
> > +if (nb_blocks < 0 || size >= INT_MAX)
> > +return NULL;
> > +
> > +AVFrameSideData *sd = av_frame_new_side_data(frame,
> > + AV_FRAME_DATA_ENCODE_INFO,
> > + size);
> > +if (!sd)
> > +return NULL;
> > +
> > +memset(sd->data, 0, size);
> > +init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
> > +
> > +return 

Re: [FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures and AV_FRAME_DATA_ENCODE_INFO AVFrameSideDataType

2019-08-09 Thread James Almer
On 8/9/2019 2:38 PM, Juan De León wrote:
> AVEncodeInfoFrame data structure to store as AVFrameSideData of type 
> AV_FRAME_DATA_ENCODE_INFO.
> The structure stores quantization index for each plane, DC/AC deltas for luma 
> and chroma planes, and an array of AVEncodeInfoBlock struct denoting 
> position, size, and delta quantizer for each block in the frame.
> Can be extended to support extraction of other block information.
> 
> Signed-off-by: Juan De León 
> ---
> fixed a typo in frame.h comment
>  libavutil/Makefile  |  2 +
>  libavutil/encode_info.c | 67 +++
>  libavutil/encode_info.h | 87 +
>  libavutil/frame.c   |  1 +
>  libavutil/frame.h   |  7 
>  5 files changed, 164 insertions(+)
>  create mode 100644 libavutil/encode_info.c
>  create mode 100644 libavutil/encode_info.h
> 
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 57e6e3d7e8..37cfb099e9 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -24,6 +24,7 @@ HEADERS = adler32.h 
> \
>dict.h\
>display.h \
>downmix_info.h\
> +  encode_info.h \
>encryption_info.h \
>error.h   \
>eval.h\
> @@ -111,6 +112,7 @@ OBJS = adler32.o  
>   \
> dict.o   \
> display.o\
> downmix_info.o   \
> +   encode_info.o\
> encryption_info.o\
> error.o  \
> eval.o   \
> diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
> new file mode 100644
> index 00..68c30af4d7
> --- /dev/null
> +++ b/libavutil/encode_info.c
> @@ -0,0 +1,67 @@
> +/*
> + * 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/encode_info.h"
> +#include "libavutil/mem.h"
> +
> +static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
> +ptr->nb_blocks = nb_blocks;
> +ptr->dc_q = ptr->ac_q = -1;
> +ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
> +
> +for(int i=0;i +ptr->plane_q[i] = -1;
> +
> +return 0;
> +}
> +
> +AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
> +{
> +AVEncodeInfoFrame *ptr;
> +size_t size = sizeof(AVEncodeInfoFrame) + 
> sizeof(AVEncodeInfoBlock)*nb_blocks;
> +
> +if (nb_blocks < 0 || size >= INT_MAX)
> +return NULL;
> +
> +ptr = av_mallocz(size);
> +if (!ptr)
> +return NULL;
> +
> +init_encode_info_data(ptr, nb_blocks);
> +
> +return ptr;
> +}
> +
> +AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
> nb_blocks)
> +{
> +size_t size = sizeof(AVEncodeInfoFrame) + 
> sizeof(AVEncodeInfoBlock)*nb_blocks;
> +
> +if (nb_blocks < 0 || size >= INT_MAX)
> +return NULL;
> +
> +AVFrameSideData *sd = av_frame_new_side_data(frame,
> + AV_FRAME_DATA_ENCODE_INFO,
> + size);
> +if (!sd)
> +return NULL;
> +
> +memset(sd->data, 0, size);
> +init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
> +
> +return (AVEncodeInfoFrame*)sd->data;
> +}
> diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
> new file mode 100644
> index 00..cbe8be2891
> --- /dev/null
> +++ b/libavutil/encode_info.h
> @@ -0,0 +1,87 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; 

[FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures and AV_FRAME_DATA_ENCODE_INFO AVFrameSideDataType

2019-08-09 Thread Juan De León
AVEncodeInfoFrame data structure to store as AVFrameSideData of type 
AV_FRAME_DATA_ENCODE_INFO.
The structure stores quantization index for each plane, DC/AC deltas for luma 
and chroma planes, and an array of AVEncodeInfoBlock struct denoting position, 
size, and delta quantizer for each block in the frame.
Can be extended to support extraction of other block information.

Signed-off-by: Juan De León 
---
 libavutil/Makefile  |  2 +
 libavutil/encode_info.c | 67 +++
 libavutil/encode_info.h | 87 +
 libavutil/frame.c   |  1 +
 libavutil/frame.h   |  7 
 5 files changed, 164 insertions(+)
 create mode 100644 libavutil/encode_info.c
 create mode 100644 libavutil/encode_info.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..37cfb099e9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -24,6 +24,7 @@ HEADERS = adler32.h   
  \
   dict.h\
   display.h \
   downmix_info.h\
+  encode_info.h \
   encryption_info.h \
   error.h   \
   eval.h\
@@ -111,6 +112,7 @@ OBJS = adler32.o
\
dict.o   \
display.o\
downmix_info.o   \
+   encode_info.o\
encryption_info.o\
error.o  \
eval.o   \
diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
new file mode 100644
index 00..68c30af4d7
--- /dev/null
+++ b/libavutil/encode_info.c
@@ -0,0 +1,67 @@
+/*
+ * 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/encode_info.h"
+#include "libavutil/mem.h"
+
+static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
+ptr->nb_blocks = nb_blocks;
+ptr->dc_q = ptr->ac_q = -1;
+ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
+
+for(int i=0;iplane_q[i] = -1;
+
+return 0;
+}
+
+AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
+{
+AVEncodeInfoFrame *ptr;
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*nb_blocks;
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+ptr = av_mallocz(size);
+if (!ptr)
+return NULL;
+
+init_encode_info_data(ptr, nb_blocks);
+
+return ptr;
+}
+
+AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
nb_blocks)
+{
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*nb_blocks;
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+AVFrameSideData *sd = av_frame_new_side_data(frame,
+ AV_FRAME_DATA_ENCODE_INFO,
+ size);
+if (!sd)
+return NULL;
+
+memset(sd->data, 0, size);
+init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
+
+return (AVEncodeInfoFrame*)sd->data;
+}
diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
new file mode 100644
index 00..cbe8be2891
--- /dev/null
+++ b/libavutil/encode_info.h
@@ -0,0 +1,87 @@
+/*
+ * 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 

[FFmpeg-devel] [PATCH] libavutil: AVEncodeInfo data structures and AV_FRAME_DATA_ENCODE_INFO AVFrameSideDataType

2019-08-09 Thread Juan De León
AVEncodeInfoFrame data structure to store as AVFrameSideData of type 
AV_FRAME_DATA_ENCODE_INFO.
The structure stores quantization index for each plane, DC/AC deltas for luma 
and chroma planes, and an array of AVEncodeInfoBlock struct denoting position, 
size, and delta quantizer for each block in the frame.
Can be extended to support extraction of other block information.

Signed-off-by: Juan De León 
---
fixed a typo in frame.h comment
 libavutil/Makefile  |  2 +
 libavutil/encode_info.c | 67 +++
 libavutil/encode_info.h | 87 +
 libavutil/frame.c   |  1 +
 libavutil/frame.h   |  7 
 5 files changed, 164 insertions(+)
 create mode 100644 libavutil/encode_info.c
 create mode 100644 libavutil/encode_info.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..37cfb099e9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -24,6 +24,7 @@ HEADERS = adler32.h   
  \
   dict.h\
   display.h \
   downmix_info.h\
+  encode_info.h \
   encryption_info.h \
   error.h   \
   eval.h\
@@ -111,6 +112,7 @@ OBJS = adler32.o
\
dict.o   \
display.o\
downmix_info.o   \
+   encode_info.o\
encryption_info.o\
error.o  \
eval.o   \
diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c
new file mode 100644
index 00..68c30af4d7
--- /dev/null
+++ b/libavutil/encode_info.c
@@ -0,0 +1,67 @@
+/*
+ * 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/encode_info.h"
+#include "libavutil/mem.h"
+
+static int init_encode_info_data(AVEncodeInfoFrame *ptr, int nb_blocks) {
+ptr->nb_blocks = nb_blocks;
+ptr->dc_q = ptr->ac_q = -1;
+ptr->dc_chroma_q = ptr->ac_chroma_q = -1;
+
+for(int i=0;iplane_q[i] = -1;
+
+return 0;
+}
+
+AVEncodeInfoFrame *av_encode_info_alloc(int nb_blocks)
+{
+AVEncodeInfoFrame *ptr;
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*nb_blocks;
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+ptr = av_mallocz(size);
+if (!ptr)
+return NULL;
+
+init_encode_info_data(ptr, nb_blocks);
+
+return ptr;
+}
+
+AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, int 
nb_blocks)
+{
+size_t size = sizeof(AVEncodeInfoFrame) + 
sizeof(AVEncodeInfoBlock)*nb_blocks;
+
+if (nb_blocks < 0 || size >= INT_MAX)
+return NULL;
+
+AVFrameSideData *sd = av_frame_new_side_data(frame,
+ AV_FRAME_DATA_ENCODE_INFO,
+ size);
+if (!sd)
+return NULL;
+
+memset(sd->data, 0, size);
+init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks);
+
+return (AVEncodeInfoFrame*)sd->data;
+}
diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h
new file mode 100644
index 00..cbe8be2891
--- /dev/null
+++ b/libavutil/encode_info.h
@@ -0,0 +1,87 @@
+/*
+ * 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 

[FFmpeg-devel] [PATCH v12 09/14] lavc/mjpegdec: Enable decoding of single-component bayer images

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Also, ensure no false positives when determining DNG bayer images, by
setting them in tiff.c instead of relying on a heuristic.  There's no
way to determine this just from the JPEG data, so we have to pass this
information from outside the MJPEG decoder.

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 32 +---
 libavcodec/tiff.c |  7 +++
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 6391107f78..0a920a7144 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,13 +412,17 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
-/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
-   interleaved components and the width stored in their SOF3 markers is the
-   width of each one.  We only output a single component, therefore we need
-   to adjust the output image width. */
-if (s->lossless == 1 && nb_components == 2) {
-s->bayer = 1;
-width *= 2;
+if (s->bayer) {
+if (nb_components == 2) {
+/* Bayer images embedded in DNGs can contain 2 interleaved 
components and the
+   width stored in their SOF3 markers is the width of each one.  
We only output
+   a single component, therefore we need to adjust the output 
image width.  We
+   handle the deinterleaving (but not the debayering) in this 
file. */
+width *= 2;
+}
+/* They can also contain 1 component, which is double the width and 
half the height
+of the final image (rows are interleaved).  We don't handle the 
decoding in this
+file, but leave that to the TIFF/DNG decoder. */
 }
 
 /* if different size, realloc/alloc picture */
@@ -1184,10 +1188,16 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
-} else if (s->bayer && nb_components == 2) {
-for (mb_x = 0; mb_x < width; mb_x++) {
-((uint16_t*)ptr)[2*mb_x + 0] = buffer[mb_x][0];
-((uint16_t*)ptr)[2*mb_x + 1] = buffer[mb_x][1];
+} else if (s->bayer) {
+if (nb_components == 1) {
+/* Leave decoding to the TIFF/DNG decoder (see comment in 
ff_mjpeg_decode_sof) */
+for (mb_x = 0; mb_x < width; mb_x++)
+((uint16_t*)ptr)[mb_x] = buffer[mb_x][0];
+} else if (nb_components == 2) {
+for (mb_x = 0; mb_x < width; mb_x++) {
+((uint16_t*)ptr)[2*mb_x + 0] = buffer[mb_x][0];
+((uint16_t*)ptr)[2*mb_x + 1] = buffer[mb_x][1];
+}
 }
 } else {
 for(i=0; igb.buffer;
 jpkt.size = tile_byte_count;
 
+if (s->is_bayer) {
+MJpegDecodeContext *mjpegdecctx = s->avctx_mjpeg->priv_data;
+/* We have to set this information here, there is no way to know if a 
given JPEG is a DNG-embedded
+   image or not from its own data (and we need that information when 
decoding it). */
+mjpegdecctx->bayer = 1;
+}
+
 ret = avcodec_send_packet(s->avctx_mjpeg, );
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
-- 
2.21.0.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 v12 04/14] lavc/tiff: Apply color scaling to uncompressed DNGs

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index a118c37c41..4620508d53 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -556,6 +556,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) &&
  (desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
  desc->nb_components >= 3;
+int is_dng;
 
 if (s->planar)
 width /= s->bppcount;
@@ -657,6 +658,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 bytestream2_init(>gb, src, size);
 bytestream2_init_writer(, dst, is_yuv ? s->yuv_line_size : (stride * 
lines));
 
+is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+
 for (line = 0; line < lines; line++) {
 if (src - ssrc > size) {
 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
@@ -679,6 +682,25 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 for (i = 0; i < width; i++)
 dst[i] = ff_reverse[src[i]];
 }
+
+/* Color processing for DNG images with uncompressed strips 
(non-tiled) */
+if (is_dng) {
+int is_u16, pixel_size_bytes, pixel_size_bits;
+
+is_u16 = (s->bpp > 8);
+pixel_size_bits = (is_u16 ? 16 : 8);
+pixel_size_bytes = (is_u16 ? sizeof(uint16_t) : 
sizeof(uint8_t));
+
+dng_blit(s,
+ dst,
+ 0, // no stride, only 1 line
+ dst,
+ 0, // no stride, only 1 line
+ width / pixel_size_bytes * pixel_size_bits / s->bpp, 
// need to account for [1, 16] bpp
+ 1,
+ is_u16);
+}
+
 src += width;
 break;
 case TIFF_PACKBITS:
@@ -1947,7 +1969,8 @@ again:
 FFSWAP(int,  p->linesize[0], p->linesize[1]);
 }
 
-if (s->is_bayer && s->white_level && s->bpp == 16) {
+if (s->is_bayer && s->white_level && s->bpp == 16 &&
+!(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)) {
 uint16_t *dst = (uint16_t *)p->data[0];
 for (i = 0; i < s->height; i++) {
 for (j = 0; j < s->width; j++)
-- 
2.21.0.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 v12 13/14] lavc/tiff: Support DNGs with striped (non-tiled) JPEGs images

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

DNG samples here can now be decoded:
- https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 73 +++
 1 file changed, 42 insertions(+), 31 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 0d931641c2..b9aa4efd02 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -550,6 +550,8 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, 
int stride,
 return ret;
 }
 
+static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame);
+
 static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int 
stride,
  const uint8_t *src, int size, int strip_start, 
int lines)
 {
@@ -665,6 +667,17 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 
 is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
 
+/* Decode JPEG-encoded DNGs with strips */
+if (s->compr == TIFF_NEWJPEG && is_dng) {
+if (s->strips > 1) {
+av_log(s->avctx, AV_LOG_ERROR, "More than one DNG JPEG strips 
unsupported\n");
+return AVERROR_PATCHWELCOME;
+}
+if ((ret = dng_decode_strip(s->avctx, p)) < 0)
+return ret;
+return 0;
+}
+
 for (line = 0; line < lines; line++) {
 if (src - ssrc > size) {
 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
@@ -859,8 +872,8 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 }
 }
 
-static int dng_decode_jpeg_tile(AVCodecContext *avctx, AVFrame *frame,
-int tile_byte_count, int x, int y, int w, int 
h)
+static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame,
+   int tile_byte_count, int dst_x, int dst_y, int w, 
int h)
 {
 TiffContext *s = avctx->priv_data;
 AVPacket jpkt;
@@ -912,7 +925,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 return AVERROR_PATCHWELCOME;
 }
 
-dst_offset = x + frame->linesize[0] * y / pixel_size;
+dst_offset = dst_x + frame->linesize[0] * dst_y / pixel_size;
 dst_data = frame->data[0] + dst_offset * pixel_size;
 src_data = s->jpgframe->data[0];
 
@@ -931,7 +944,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 return 0;
 }
 
-static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame)
+static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame, AVPacket 
*avpkt)
 {
 TiffContext *s = avctx->priv_data;
 int tile_idx;
@@ -944,6 +957,12 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame 
*frame)
 int pos_x = 0, pos_y = 0;
 int ret;
 
+s->jpgframe->width  = s->tile_width;
+s->jpgframe->height = s->tile_length;
+
+s->avctx_mjpeg->width = s->tile_width;
+s->avctx_mjpeg->height = s->tile_length;
+
 has_width_leftover = (s->width % s->tile_width != 0);
 has_height_leftover = (s->height % s->tile_length != 0);
 
@@ -980,7 +999,7 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame 
*frame)
 bytestream2_seek(>gb, tile_offset, SEEK_SET);
 
 /* Decode JPEG tile and copy it in the reference frame */
-ret = dng_decode_jpeg_tile(avctx, frame, tile_byte_count, pos_x, 
pos_y, tile_width, tile_length);
+ret = dng_decode_jpeg(avctx, frame, tile_byte_count, pos_x, pos_y, 
tile_width, tile_length);
 
 if (ret < 0)
 return ret;
@@ -993,30 +1012,24 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 }
 }
 
-return 0;
-}
+/* Frame is ready to be output */
+frame->pict_type = AV_PICTURE_TYPE_I;
+frame->key_frame = 1;
 
-static int dng_decode(AVCodecContext *avctx, AVFrame *frame, AVPacket *avpkt) {
-int ret;
+return avpkt->size;
+}
 
+static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame)
+{
 TiffContext *s = avctx->priv_data;
 
-s->jpgframe->width  = s->tile_width;
-s->jpgframe->height = s->tile_length;
-
-s->avctx_mjpeg->width = s->tile_width;
-s->avctx_mjpeg->height = s->tile_length;
-
-/* Decode all tiles in a frame */
-ret = dng_decode_tiles(avctx, frame);
-if (ret < 0)
-return ret;
+s->jpgframe->width  = s->width;
+s->jpgframe->height = s->height;
 
-/* Frame is ready to be output */
-frame->pict_type = AV_PICTURE_TYPE_I;
-frame->key_frame = 1;
+s->avctx_mjpeg->width = s->width;
+s->avctx_mjpeg->height = s->height;
 
-return avpkt->size;
+return dng_decode_jpeg(avctx, frame, s->stripsize, 0, 0, s->width, 
s->height);
 }
 
 static int init_image(TiffContext *s, ThreadFrame *frame)
@@ -1880,17 +1893,15 @@ again:
 
 /* Handle DNG images with JPEG-compressed tiles */
 
-if (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG) {
-if (!s->is_jpeg && 

[FFmpeg-devel] [PATCH v12 03/14] lavc/tiff: Convert DNGs to sRGB color space

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index d5673abb19..a118c37c41 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -731,14 +731,23 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+static float av_always_inline linear_to_srgb(float value) {
+if (value <= 0.0031308)
+return value * 12.92;
+else
+return pow(value * 1.055, 1.0 / 2.4) - 0.055;
+}
+
 /**
- * Map stored raw sensor values into linear reference values.
- * See: DNG Specification - Chapter 5
+ * Map stored raw sensor values into linear reference values (see: DNG 
Specification - Chapter 5)
+ * Then convert to sRGB color space.
  */
-static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
-const uint16_t *lut,
-uint16_t black_level,
-float scale_factor) {
+static uint16_t av_always_inline dng_process_color16(uint16_t value,
+ const uint16_t *lut,
+ uint16_t black_level,
+ float scale_factor) {
+float value_norm;
+
 // Lookup table lookup
 if (lut)
 value = lut[value];
@@ -747,16 +756,19 @@ static uint16_t av_always_inline 
dng_raw_to_linear16(uint16_t value,
 value = av_clip_uint16_c((unsigned)value - black_level);
 
 // Color scaling
-value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+value_norm = (float)value * scale_factor;
+
+// Color space conversion (sRGB)
+value = av_clip_uint16_c((uint16_t)(linear_to_srgb(value_norm) * 0x));
 
 return value;
 }
 
-static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+static uint16_t av_always_inline dng_process_color8(uint16_t value,
 const uint16_t *lut,
 uint16_t black_level,
 float scale_factor) {
-return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+return dng_process_color16(value, lut, black_level, scale_factor) >> 8;
 }
 
 static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
@@ -774,7 +786,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 uint16_t *src_u16 = (uint16_t *)src;
 
 for (col = 0; col < width; col++)
-*dst_u16++ = dng_raw_to_linear16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
 
 dst += dst_stride * sizeof(uint16_t);
 src += src_stride * sizeof(uint16_t);
@@ -782,7 +794,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 } else {
 for (line = 0; line < height; line++) {
 for (col = 0; col < width; col++)
-*dst++ = dng_raw_to_linear8(*src++, s->dng_lut, 
s->black_level, scale_factor);
+*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
 
 dst += dst_stride;
 src += src_stride;
-- 
2.21.0.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 v12 02/14] lavc/tiff: Decode embedded JPEGs in DNG images

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Used a technique similar to lavc/tdsc.c for invoking the MJPEG decoder.

This commit adds support for:
- DNG tiles
- DNG tile huffman lossless JPEG decoding
- DNG 8-bpp ("packed" as dcraw calls it) decoding
- DNG color scaling [1]
  - LinearizationTable tag
  - BlackLevel tag

[1]: As specified in the DNG Specification - Chapter 5

Signed-off-by: Nick Renieris 
---
 configure   |   1 +
 libavcodec/Makefile |   2 +-
 libavcodec/tiff.c   | 315 +++-
 libavcodec/tiff.h   |   2 +
 4 files changed, 312 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 34c2adb4a4..112b84f0ba 100755
--- a/configure
+++ b/configure
@@ -2817,6 +2817,7 @@ tdsc_decoder_deps="zlib"
 tdsc_decoder_select="mjpeg_decoder"
 theora_decoder_select="vp3_decoder"
 thp_decoder_select="mjpeg_decoder"
+tiff_decoder_select="mjpeg_decoder"
 tiff_decoder_suggest="zlib lzma"
 tiff_encoder_suggest="zlib"
 truehd_decoder_select="mlp_parser"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..f814c69996 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -616,7 +616,7 @@ OBJS-$(CONFIG_TARGA_ENCODER)   += targaenc.o rle.o
 OBJS-$(CONFIG_TARGA_Y216_DECODER)  += targa_y216dec.o
 OBJS-$(CONFIG_TDSC_DECODER)+= tdsc.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
-OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o
+OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o mjpegdec.o
 OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o tiff_data.o
 OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
 OBJS-$(CONFIG_TRUEHD_DECODER)  += mlpdec.o mlpdsp.o
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c520d7df83..d5673abb19 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -35,6 +35,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avstring.h"
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -46,6 +47,7 @@
 #include "mathops.h"
 #include "tiff.h"
 #include "tiff_data.h"
+#include "mjpegdec.h"
 #include "thread.h"
 #include "get_bits.h"
 
@@ -54,6 +56,10 @@ typedef struct TiffContext {
 AVCodecContext *avctx;
 GetByteContext gb;
 
+/* JPEG decoding for DNG */
+AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG
+AVFrame *jpgframe;   // decoded JPEG tile
+
 int get_subimage;
 uint16_t get_page;
 int get_thumbnail;
@@ -76,7 +82,9 @@ typedef struct TiffContext {
 
 int is_bayer;
 uint8_t pattern[4];
+unsigned black_level;
 unsigned white_level;
+const uint16_t *dng_lut; // Pointer to DNG linearization table
 
 uint32_t sub_ifd;
 uint16_t cur_page;
@@ -86,6 +94,14 @@ typedef struct TiffContext {
 int stripsizesoff, stripsize, stripoff, strippos;
 LZWState *lzw;
 
+/* Tile support */
+int is_tiled;
+int tile_byte_counts_offset, tile_offsets_offset;
+int tile_width, tile_length;
+int tile_count;
+
+int is_jpeg;
+
 uint8_t *deinvert_buf;
 int deinvert_buf_size;
 uint8_t *yuv_line;
@@ -257,6 +273,9 @@ static int add_metadata(int count, int type,
 };
 }
 
+static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
+  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
  int usePtr, const uint8_t *src,
@@ -712,6 +731,204 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+/**
+ * Map stored raw sensor values into linear reference values.
+ * See: DNG Specification - Chapter 5
+ */
+static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+// Lookup table lookup
+if (lut)
+value = lut[value];
+
+// Black level subtraction
+value = av_clip_uint16_c((unsigned)value - black_level);
+
+// Color scaling
+value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+
+return value;
+}
+
+static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+}
+
+static void dng_blit(TiffContext 

[FFmpeg-devel] [PATCH v12 11/14] lavc/tiff: Decode 14-bit DNG images

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Sample file: 
https://drive.google.com/open?id=0B4JyRT3Lth5HVndyOTVOdWktM3J4TFEydTk1MnY3RWlpSzVB

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index ecd87c0b2f..0d931641c2 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -309,14 +309,18 @@ static void av_always_inline horizontal_fill(TiffContext 
*s,
 dst[(width+offset)*2+0] = (usePtr ? src[width] : c) >> 4;
 }
 break;
-case 12: {
- uint16_t *dst16 = (uint16_t *)dst;
- GetBitContext gb;
- init_get_bits8(, src, width);
- for (int i = 0; i < s->width; i++) {
- dst16[i] = get_bits(, 12) << 4;
- }
- }
+case 12:
+case 14: {
+uint16_t *dst16 = (uint16_t *)dst;
+int is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+uint8_t shift = is_dng ? 0 : 16 - bpp;
+GetBitContext gb;
+
+init_get_bits8(, src, width);
+for (int i = 0; i < s->width; i++) {
+dst16[i] = get_bits(, bpp) << shift;
+}
+}
 break;
 default:
 if (usePtr) {
@@ -1068,6 +1072,7 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
 }
 break;
 case 10121:
+case 10141:
 switch (AV_RL32(s->pattern)) {
 case 0x02010100:
 s->avctx->pix_fmt = s->le ? AV_PIX_FMT_BAYER_RGGB16LE : 
AV_PIX_FMT_BAYER_RGGB16BE;
-- 
2.21.0.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 v12 12/14] lavc/mjpegdec: Skip useless APPx marker on bayer images

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Samples:
- Embedded JPEG images in the DNG images here:
  https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 0a920a7144..e7b273a363 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1807,8 +1807,15 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
 int len, id, i;
 
 len = get_bits(>gb, 16);
-if (len < 6)
-return AVERROR_INVALIDDATA;
+if (len < 6) {
+if (s->bayer) {
+// Pentax K-1 (digital camera) JPEG images embedded in DNG images 
contain useless APP0 markers
+av_log(s->avctx, AV_LOG_WARNING, "skipping APPx (len=%"PRId32") 
for bayer-encoded image\n", len);
+skip_bits(>gb, len);
+return 0;
+} else
+return AVERROR_INVALIDDATA;
+}
 if (8 * len > get_bits_left(>gb))
 return AVERROR_INVALIDDATA;
 
-- 
2.21.0.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 v12 14/14] lavc/tiff: Initialize WhiteLevel DNG tag value

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Inited to (2^BitsPerSample)-1 as per the DNG Specification

This fixes decoding for "X7 CinemaDNG" samples here:
- https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index b9aa4efd02..aeb80a70a9 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1773,6 +1773,7 @@ static int decode_frame(AVCodecContext *avctx,
 GetByteContext stripsizes;
 GetByteContext stripdata;
 int retry_for_subifd, retry_for_page;
+int is_dng;
 
 bytestream2_init(>gb, avpkt->data, avpkt->size);
 
@@ -1841,6 +1842,10 @@ again:
 goto again;
 }
 
+/* At this point we've decided on which (Sub)IFD to process */
+
+is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG);
+
 for (i = 0; igeotag_count; i++) {
 const char *keyname = get_geokey_name(s->geotags[i].key);
 if (!keyname) {
@@ -1858,10 +1863,13 @@ again:
 }
 }
 
+s->white_level = (1 << s->bpp) - 1; /* Default value as per the spec */
+
 if (!s->is_tiled && !s->strippos && !s->stripoff) {
 av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
 return AVERROR_INVALIDDATA;
 }
+
 /* now we have the data and may start decoding */
 if ((ret = init_image(s, )) < 0)
 return ret;
@@ -1893,7 +1901,7 @@ again:
 
 /* Handle DNG images with JPEG-compressed tiles */
 
-if ((s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG) 
&& s->is_tiled) {
+if (is_dng && s->is_tiled) {
 if (!s->is_jpeg) {
 avpriv_report_missing_feature(avctx, "DNG uncompressed tiled 
images");
 return AVERROR_PATCHWELCOME;
@@ -2051,8 +2059,7 @@ again:
 FFSWAP(int,  p->linesize[0], p->linesize[1]);
 }
 
-if (s->is_bayer && s->white_level && s->bpp == 16 &&
-!(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)) {
+if (s->is_bayer && s->bpp == 16 && !is_dng && (s->white_level != (1 << 
s->bpp) - 1)) {
 uint16_t *dst = (uint16_t *)p->data[0];
 for (i = 0; i < s->height; i++) {
 for (j = 0; j < s->width; j++)
-- 
2.21.0.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 v12 07/14] lavc/tiff: Don't apply strips-related logic to tiled images

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 42 ++
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 37fda15162..174ca168c6 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1780,7 +1780,7 @@ again:
 }
 }
 
-if (!s->strippos && !s->stripoff) {
+if (!s->is_tiled && !s->strippos && !s->stripoff) {
 av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
 return AVERROR_INVALIDDATA;
 }
@@ -1788,27 +1788,29 @@ again:
 if ((ret = init_image(s, )) < 0)
 return ret;
 
-if (s->strips == 1 && !s->stripsize) {
-av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
-s->stripsize = avpkt->size - s->stripoff;
-}
+if (!s->is_tiled) {
+if (s->strips == 1 && !s->stripsize) {
+av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
+s->stripsize = avpkt->size - s->stripoff;
+}
 
-if (s->stripsizesoff) {
-if (s->stripsizesoff >= (unsigned)avpkt->size)
-return AVERROR_INVALIDDATA;
-bytestream2_init(, avpkt->data + s->stripsizesoff,
- avpkt->size - s->stripsizesoff);
-}
-if (s->strippos) {
-if (s->strippos >= (unsigned)avpkt->size)
-return AVERROR_INVALIDDATA;
-bytestream2_init(, avpkt->data + s->strippos,
- avpkt->size - s->strippos);
-}
+if (s->stripsizesoff) {
+if (s->stripsizesoff >= (unsigned)avpkt->size)
+return AVERROR_INVALIDDATA;
+bytestream2_init(, avpkt->data + s->stripsizesoff,
+avpkt->size - s->stripsizesoff);
+}
+if (s->strippos) {
+if (s->strippos >= (unsigned)avpkt->size)
+return AVERROR_INVALIDDATA;
+bytestream2_init(, avpkt->data + s->strippos,
+avpkt->size - s->strippos);
+}
 
-if (s->rps <= 0 || s->rps % s->subsampling[1]) {
-av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
-return AVERROR_INVALIDDATA;
+if (s->rps <= 0 || s->rps % s->subsampling[1]) {
+av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
+return AVERROR_INVALIDDATA;
+}
 }
 
 /* Handle DNG images with JPEG-compressed tiles */
-- 
2.21.0.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 v12 08/14] lavc/tiff: Force DNG pixel data endianness on an edge case

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 174ca168c6..9d20763186 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1038,6 +1038,18 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
AV_RL32(s->pattern));
 return AVERROR_PATCHWELCOME;
 }
+/* Force endianness as mentioned in 'DNG Specification: Chapter 3: 
BitsPerSample'
+NOTE: The spec actually specifies big-endian, not sure why we need 
little-endian,
+  but such images don't work otherwise. */
+if ((s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
TIFF_TYPE_CINEMADNG)
+&& (s->bpp != 8 && s->bpp != 16 && s->bpp != 32)) {
+switch (s->avctx->pix_fmt) {
+case AV_PIX_FMT_BAYER_RGGB16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_RGGB16LE; break;
+case AV_PIX_FMT_BAYER_BGGR16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_BGGR16LE; break;
+case AV_PIX_FMT_BAYER_GBRG16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_GBRG16LE; break;
+case AV_PIX_FMT_BAYER_GRBG16BE: s->avctx->pix_fmt = 
AV_PIX_FMT_BAYER_GRBG16LE; break;
+}
+}
 break;
 case 10161:
 switch (AV_RL32(s->pattern)) {
-- 
2.21.0.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 v12 05/14] lavc/jpegtables: Handle multiple mappings to the same value

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Some JPEGs [1] have incorrect DHT entries that map 2 codes to
the same value.

The second (last) mapping does not ever actually appear in the
code stream, therefore ignoring any mappings after the first one
fixes this.

Without this, an "mjpeg_decode_dc: bad vlc: 0:0" error is thrown.

---

[1]: Embedded JPEGs in "X7 RAW" and "X7 CinemaDNG" samples here:
 https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/jpegtables.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c
index cbe5523cb4..6f596cfc92 100644
--- a/libavcodec/jpegtables.c
+++ b/libavcodec/jpegtables.c
@@ -130,14 +130,27 @@ void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, 
uint16_t *huff_code,
 {
 int i, j, k,nb, code, sym;
 
-code = 0;
+/* Zero-initialize huff_size (needed for multiple mappings check below) */
+k = 0;
+for(i=1;i<=16;i++) {
+nb = bits_table[i];
+for(j=0;jhttps://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v12 06/14] lavc/tiff: Fix edge case with full-length/width tiles

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

In an image [1], the height was equal to the tile length (full-height
tile) and after `height % tile_length` was applied to them with the
current code, it resulted in the operating tile_length to be 0.  This
commit makes this leftover logic only applies if it's necessary.

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 4620508d53..37fda15162 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -887,10 +887,14 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 int tile_byte_count_offset, tile_byte_count;
 int tile_count_x, tile_count_y;
 int tile_width, tile_length;
+int has_width_leftover, has_height_leftover;
 int tile_x = 0, tile_y = 0;
 int pos_x = 0, pos_y = 0;
 int ret;
 
+has_width_leftover = (s->width % s->tile_width != 0);
+has_height_leftover = (s->height % s->tile_length != 0);
+
 /* Calculate tile counts (round up) */
 tile_count_x = (s->width + s->tile_width - 1) / s->tile_width;
 tile_count_y = (s->height + s->tile_length - 1) / s->tile_length;
@@ -900,12 +904,12 @@ static int dng_decode_tiles(AVCodecContext *avctx, 
AVFrame *frame)
 tile_x = tile_idx % tile_count_x;
 tile_y = tile_idx / tile_count_x;
 
-if (tile_x == tile_count_x - 1) // If on the right edge
+if (has_width_leftover && tile_x == tile_count_x - 1) // If on the 
right-most tile
 tile_width = s->width % s->tile_width;
 else
 tile_width = s->tile_width;
 
-if (tile_y == tile_count_y - 1) // If on the bottom edge
+if (has_height_leftover && tile_y == tile_count_y - 1) // If on the 
bottom-most tile
 tile_length = s->height % s->tile_length;
 else
 tile_length = s->tile_length;
-- 
2.21.0.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 v12 10/14] lavc/tiff: Support decoding of DNGs with single-component JPEGs

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

This enables decoding of DNG images generated by the 'DJI Zenmuse X7'
digital camera
Samples: https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris 
---
 libavcodec/tiff.c | 61 +++
 1 file changed, 51 insertions(+), 10 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index cf8965453c..ecd87c0b2f 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -274,7 +274,8 @@ static int add_metadata(int count, int type,
 }
 
 static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
-  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+  const uint8_t *src, int src_stride, int 
width, int height,
+  int is_single_comp, int is_u16);
 
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
@@ -698,6 +699,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
  0, // no stride, only 1 line
  width / pixel_size_bytes * pixel_size_bits / s->bpp, 
// need to account for [1, 16] bpp
  1,
+ 0, // single-component variation is only preset in 
JPEG-encoded DNGs
  is_u16);
 }
 
@@ -795,18 +797,32 @@ static uint16_t av_always_inline 
dng_process_color8(uint16_t value,
 
 static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
  const uint8_t *src, int src_stride,
- int width, int height, int is_u16)
+ int width, int height, int is_single_comp, int is_u16)
 {
 int line, col;
 float scale_factor;
 
 scale_factor = 1.0f / (s->white_level - s->black_level);
 
-if (is_u16) {
-for (line = 0; line < height; line++) {
+if (is_single_comp) {
+if (!is_u16)
+return; /* <= 8bpp unsupported */
+
+/* Image is double the width and half the height we need, each row 
comprises 2 rows of the output
+   (split vertically in the middle). */
+for (line = 0; line < height / 2; line++) {
 uint16_t *dst_u16 = (uint16_t *)dst;
 uint16_t *src_u16 = (uint16_t *)src;
 
+/* Blit first half of input row row to initial row of output */
+for (col = 0; col < width; col++)
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+
+/* Advance the destination pointer by a row (source pointer 
remains in the same place) */
+dst += dst_stride * sizeof(uint16_t);
+dst_u16 = (uint16_t *)dst;
+
+/* Blit second half of input row row to next row of output */
 for (col = 0; col < width; col++)
 *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
 
@@ -814,12 +830,27 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
 src += src_stride * sizeof(uint16_t);
 }
 } else {
-for (line = 0; line < height; line++) {
-for (col = 0; col < width; col++)
-*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
+/* Input and output image are the same size and the MJpeg decoder has 
done per-component
+   deinterleaving, so blitting here is straightforward. */
+if (is_u16) {
+for (line = 0; line < height; line++) {
+uint16_t *dst_u16 = (uint16_t *)dst;
+uint16_t *src_u16 = (uint16_t *)src;
+
+for (col = 0; col < width; col++)
+*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, 
s->black_level, scale_factor);
+
+dst += dst_stride * sizeof(uint16_t);
+src += src_stride * sizeof(uint16_t);
+}
+} else {
+for (line = 0; line < height; line++) {
+for (col = 0; col < width; col++)
+*dst++ = dng_process_color8(*src++, s->dng_lut, 
s->black_level, scale_factor);
 
-dst += dst_stride;
-src += src_stride;
+dst += dst_stride;
+src += src_stride;
+}
 }
 }
 }
@@ -831,7 +862,7 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 AVPacket jpkt;
 uint8_t *dst_data, *src_data;
 uint32_t dst_offset; /* offset from dst buffer in pixels */
-int is_u16, pixel_size;
+int is_single_comp, is_u16, pixel_size;
 int ret;
 
 /* Prepare a packet and send to the MJPEG decoder */
@@ -865,9 +896,18 @@ static int dng_decode_jpeg_tile(AVCodecContext *avctx, 
AVFrame *frame,
 
 /* Copy the outputted tile's pixels from 

[FFmpeg-devel] [PATCH v12 01/14] lavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs

2019-08-09 Thread Nick Renieris
From: Nick Renieris 

Main image data in DNGs is usually comprised of tiles, each of which is a 
Huffman-encoded lossless JPEG.

Tested for ljpeg regressions with:
`ffmpeg -f lavfi -i testsrc=d=1 -vcodec ljpeg test.avi`
`ffmpeg test.avi out.avi`
The modified code in ljpeg_decode_rgb_scan runs without issues.

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 52 +--
 libavcodec/mjpegdec.h |  1 +
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a65bc8df15..6391107f78 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,6 +412,14 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
+/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
+   interleaved components and the width stored in their SOF3 markers is the
+   width of each one.  We only output a single component, therefore we need
+   to adjust the output image width. */
+if (s->lossless == 1 && nb_components == 2) {
+s->bayer = 1;
+width *= 2;
+}
 
 /* if different size, realloc/alloc picture */
 if (width != s->width || height != s->height || bits != s->bits ||
@@ -488,6 +496,9 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 }
 
 switch (pix_fmt_id) {
+case 0x: /* for bayer-encoded huffman lossless JPEGs embedded 
in DNGs */
+s->avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
+break;
 case 0x1100:
 if (s->rgb)
 s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : 
AV_PIX_FMT_BGR48;
@@ -1041,17 +1052,20 @@ static int handle_rstn(MJpegDecodeContext *s, int 
nb_components)
 return reset;
 }
 
+/* Handles 1 to 4 components */
 static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int 
predictor, int point_transform)
 {
 int i, mb_x, mb_y;
+unsigned width;
 uint16_t (*buffer)[4];
 int left[4], top[4], topleft[4];
 const int linesize = s->linesize[0];
 const int mask = ((1 << s->bits) - 1) << point_transform;
 int resync_mb_y = 0;
 int resync_mb_x = 0;
+int vpred[6];
 
-if (s->nb_components != 3 && s->nb_components != 4)
+if (s->nb_components <= 0 || s->nb_components > 4)
 return AVERROR_INVALIDDATA;
 if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
 return AVERROR_INVALIDDATA;
@@ -1059,8 +1073,15 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 
 s->restart_count = s->restart_interval;
 
-av_fast_malloc(>ljpeg_buffer, >ljpeg_buffer_size,
-   (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
+if (s->restart_interval == 0)
+s->restart_interval = INT_MAX;
+
+if (s->bayer)
+width = s->mb_width / nb_components; /* Interleaved, width stored is 
the total so need to divide */
+else
+width = s->mb_width;
+
+av_fast_malloc(>ljpeg_buffer, >ljpeg_buffer_size, width * 4 * 
sizeof(s->ljpeg_buffer[0][0]));
 if (!s->ljpeg_buffer)
 return AVERROR(ENOMEM);
 
@@ -1078,7 +1099,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 for (i = 0; i < 4; i++)
 top[i] = left[i] = topleft[i] = buffer[0][i];
 
-for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
+if ((mb_y * s->width) % s->restart_interval == 0) {
+for (i = 0; i < 6; i++)
+vpred[i] = 1 << (s->bits-1);
+}
+
+for (mb_x = 0; mb_x < width; mb_x++) {
 int modified_predictor = predictor;
 
 if (get_bits_left(>gb) < 1) {
@@ -1102,12 +1128,19 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 topleft[i] = top[i];
 top[i] = buffer[mb_x][i];
 
-PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-
 dc = mjpeg_decode_dc(s, s->dc_index[i]);
 if(dc == 0xF)
 return -1;
 
+if (!s->bayer || mb_x) {
+pred = left[i];
+} else { /* This path runs only for the first line in bayer 
images */
+vpred[i] += dc;
+pred = vpred[i] - dc;
+}
+
+PREDICT(pred, topleft[i], top[i], pred, modified_predictor);
+
 left[i] = buffer[mb_x][i] =
 mask & (pred + (unsigned)(dc * (1 << point_transform)));
 }
@@ -1151,6 +1184,11 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
+} else if (s->bayer && nb_components == 2) {
+for (mb_x = 0; mb_x < width; 

Re: [FFmpeg-devel] [PATCH 2/2] convert_from_tensorflow.py: support conv2d with dilation

2019-08-09 Thread Guo, Yejun


> -Original Message-
> From: Guo, Yejun
> Sent: Tuesday, July 30, 2019 9:26 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun 
> Subject: [PATCH 2/2] convert_from_tensorflow.py: support conv2d with dilation
> 
> conv2d with dilation > 1 generates tens of nodes in graph, it is not
> easy to parse each node one by one, so we do special tricks to parse
> the conv2d layer.
> 
> Signed-off-by: Guo, Yejun 
> ---
>  tools/python/convert_from_tensorflow.py | 80
> -
>  1 file changed, 59 insertions(+), 21 deletions(-)

this patch set asks for review, thanks.

I've locally finished more patches to improve dnn module, plan to send more 
them set by set, since the patches have dependency.

Just in case you are interested in these new patches, I've uploaded to 
https://github.com/guoyejun/ffmpeg/tree/dnn0809. 
for your convenient, I also copy the oneline log here for each patch (from 
newer to older) with 4 patch sets.

7eced90 libavfilter/dnn: support multiple outputs for native mode
28a7054 libavfilter/dnn/dnn_backend_native: find the input operand according to 
input name

256e657 FATE/dnn: add unit test for layer maximum
8c616a0 libavfilter/dnn: add layer maximum for native mode.

8ec6c0c FATE/dnn: add unit test for dnn depth_to_space layer
09ef108 libavfilter/dnn: separate depth_to_space layer from 
dnn_backend_native.c to a new file
c65b59d FATE/dnn: add unit test for dnn conv2d layer
a5d69a7 libavfilter/dnn: separate conv2d layer from dnn_backend_native.c to a 
new file

202d323 dnn: export operand info in python script and load in c code
3c706a0 dnn: change .model file format to put layer number at the end of file
0256731 dnn: introduce dnn operand (in c code) to hold operand infos within 
network


Besides continuous dnn improvement, I also plan to add two generic video 
filters for dnn.
- a generic filter to process the content of AVFrame with different dnn 
networks.
and so the current specific filters such as vf_sr (some changes needed) and 
vf_derain are no longer needed, since they can be
included in this specific filter. And of course, in practice I'll not remove 
them.

- a generic filter to analyze the content of AVFrame to generate some side data 
with different dnn networks. The content of AVFrame does not change.
The application, which invokes the filter with a given dnn network, has the 
responsibility/knowledge to parse the side data (analyze result).

___
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/3] avfilter: Rename jedec-p22 to ebu3213

2019-08-09 Thread James Almer
On 8/8/2019 10:29 PM, rzu...@tebako.net wrote:
> From: Raphaël Zumer 
> 
> This matches a name change in avutil/pixdesc.
> 
> Signed-off-by: Raphaël Zumer 
> ---
>  libavfilter/version.h   | 2 +-
>  libavfilter/vf_colorspace.c | 2 +-
>  libavfilter/vf_setparams.c  | 2 +-
>  libavfilter/vf_zscale.c | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index dd829160fc..58a0221f43 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>  
>  #define LIBAVFILTER_VERSION_MAJOR   7
>  #define LIBAVFILTER_VERSION_MINOR  58
> -#define LIBAVFILTER_VERSION_MICRO 100
> +#define LIBAVFILTER_VERSION_MICRO 101
>  
>  
>  #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> index df6efffb3d..5f22f92507 100644
> --- a/libavfilter/vf_colorspace.c
> +++ b/libavfilter/vf_colorspace.c
> @@ -968,7 +968,7 @@ static const AVOption colorspace_options[] = {
>  ENUM("smpte431", AVCOL_PRI_SMPTE431,   "prm"),
>  ENUM("smpte432", AVCOL_PRI_SMPTE432,   "prm"),
>  ENUM("bt2020",   AVCOL_PRI_BT2020, "prm"),
> -ENUM("jedec-p22",AVCOL_PRI_JEDEC_P22,  "prm"),
> +ENUM("ebu3213",  AVCOL_PRI_JEDEC_P22,  "prm"),
>  
>  { "trc","Output transfer characteristics",
>OFFSET(user_trc),   AV_OPT_TYPE_INT, { .i64 = AVCOL_TRC_UNSPECIFIED },
> diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
> index fe298e5a06..80e61f851e 100644
> --- a/libavfilter/vf_setparams.c
> +++ b/libavfilter/vf_setparams.c
> @@ -74,7 +74,7 @@ static const AVOption setparams_options[] = {
>  {"smpte428",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  {"smpte431",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  {"smpte432",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> -{"jedec-p22",   NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> +{"ebu3213", NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  
>  {"color_trc", "select color transfer", OFFSET(color_trc), 
> AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, FLAGS, "color_trc"},
>  {"auto", "keep the same color transfer",  0, AV_OPT_TYPE_CONST, 
> {.i64=-1}, INT_MIN, INT_MAX, FLAGS, "color_trc"},
> diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
> index f0309272fa..e53d7c1ae0 100644
> --- a/libavfilter/vf_zscale.c
> +++ b/libavfilter/vf_zscale.c
> @@ -788,7 +788,7 @@ static const AVOption zscale_options[] = {
>  { "smpte428", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST428},   0, 0, FLAGS, "primaries" },
>  { "smpte431", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, "primaries" },
>  { "smpte432", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, "primaries" },
> -{ "jedec-p22",0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
> +{ "ebu3213",  0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
>  { "transfer", "set transfer characteristic", OFFSET(trc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
>  { "t","set transfer characteristic", OFFSET(trc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
>  { "input",0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = -1}, 0, 0, FLAGS, "transfer" },
> 

You missed the second part of my review, were i asked you to add new
values for ebu3213 and leave the jedec-p22 ones alone, since they are
public facing and can't be removed without a deprecation period.
___
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] colorspace: Rename jedec-p22 to ebu3213

2019-08-09 Thread Kevin Wheatley
On Fri, Aug 9, 2019 at 12:40 PM Hendrik Leppkes  wrote:
> The enum and our values are aligned to the H.273 / ISO/IEC 23001-8
> standards, which documents this entry to correspond to the primaries
> in use by vf_colorspace

That makes sense, although I'm now interested to find out where those
numbers came from as they didn't come out of the EBU document, guess
I'll have to ask next time I bump into somebody from the ITU or EBU,
the EBU numbers do come with allowable tolerances, but the blue
co-ordinate appears to fall outside of that.

Thanks

Kevin
___
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/2] avcodec/mlpenc: encode last frame too

2019-08-09 Thread Paul B Mahol
On Wed, Nov 29, 2017 at 4:26 AM James Almer  wrote:

> On 11/28/2017 4:55 PM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libavcodec/mlpenc.c | 22 +++---
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
> > index 7536d3b2f5..c588f5b904 100644
> > --- a/libavcodec/mlpenc.c
> > +++ b/libavcodec/mlpenc.c
> > @@ -2225,29 +2225,27 @@ static int mlp_encode_frame(AVCodecContext
> *avctx, AVPacket *avpkt,
> >  int restart_frame, ret;
> >  uint8_t *data;
> >
> > -if ((ret = ff_alloc_packet2(avctx, avpkt, 87500 * avctx->channels,
> 0)) < 0)
> > -return ret;
> > -
> > -if (!frame)
> > -return 1;
> > -
> >  /* add current frame to queue */
> >  if (frame) {
> >  if ((ret = ff_af_queue_add(>afq, frame)) < 0)
> >  return ret;
> > +} else {
> > +if (ctx->last_frame == ctx->inout_buffer) {
> > +return 0;
> > +}
> >  }
> >
> > -data = frame->data[0];
> > +
> > +if ((ret = ff_alloc_packet2(avctx, avpkt, 87500 * avctx->channels,
> 0)) < 0)
> > +return ret;
> > +
> > +data = frame ? frame->data[0] : NULL;
> >
> >  ctx->frame_index = avctx->frame_number % ctx->max_restart_interval;
> >
> >  ctx->inout_buffer = ctx->major_inout_buffer
> >+ ctx->frame_index * ctx->one_sample_buffer_size;
> >
> > -if (ctx->last_frame == ctx->inout_buffer) {
> > -return 0;
> > -}
> > -
> >  ctx->sample_buffer = ctx->major_scratch_buffer
> > + ctx->frame_index * ctx->one_sample_buffer_size;
> >
> > @@ -2333,6 +2331,8 @@ input_and_return:
> >  number_of_samples +=
> ctx->frame_size[(ctx->starting_frame_index + index) %
> ctx->max_restart_interval];
> >  }
> >  ctx->number_of_samples = number_of_samples;
> > +if (!ctx->number_of_samples)
> > +break;
> >
> >  for (index = 0; index < ctx->seq_size[seq_index]; index++) {
> >  clear_channel_params(ctx, ctx->seq_channel_params +
> index*(ctx->avctx->channels));
> >
>
> After this patch the sample from ticket 6216 prints a "Trying to remove
> 40 samples, but the queue is empty" warning during encoding.
>
>
Because frame queue is never actually used, its just dead code here.
___
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/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2019-08-09 Thread Paul B Mahol
On Fri, Aug 9, 2019 at 1:34 PM Moritz Barsnick  wrote:

> On Thu, Aug 08, 2019 at 22:09:04 +0100, Cameron Cawley wrote:
> > Signed-off-by: Cameron Cawley 
> > ---
> >  doc/general.texi|  1 +
> >  libavcodec/Makefile |  1 +
> >  libavcodec/adpcm.c  | 14 ++
> >  libavcodec/allcodecs.c  |  1 +
> >  libavcodec/avcodec.h|  1 +
> >  libavcodec/codec_desc.c |  7 +++
> >  libavcodec/utils.c  |  1 +
> >  7 files changed, 26 insertions(+)
>
> You should also bump the micro version when adding a new decoder.
>

Nope. Developer documentation clearly states that minor should be bumped.

>
> Cheers,
> Moritz
> ___
> 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 1/3] avutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries value

2019-08-09 Thread Raphaël Zumer

On 2019-08-09 7:51 a.m., Vittorio Giovara wrote:

this value was already present, this is just a rename


I think it counts as a new enum value (variant), even though it aliases 
another.


I initially wrote "rename", but reworded the commit message based on 
James Almer's comment:



The subject should be something like "avutil/pixfmt:
Add EBU Tech. 3213-E AVColorPrimaries value"




I'd do the opposite, similarly to what is done for AVCOL_PRI_SMPTEST428_1

AVCOL_PRI_EBU3213 = 22, ///< JEDEC P22 phosphors, EBU Tech 3213 E
AVCOL_PRI_JEDEC_P22   = AVCOL_PRI_EBU3213,

  AVCOL_PRI_NB///< Not part of ABI
  };


Will do. I will also replace internal usage of JEDEC_P22 with EBU3213 
elsewhere.


I just noticed I missed the same comment (and a few others) in JA's 
review earlier, sorry about that. Will apply all corrections in my next 
revision.


___
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/3] avutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries value

2019-08-09 Thread Vittorio Giovara
On Fri, Aug 9, 2019 at 3:29 AM  wrote:

> From: Raphaël Zumer 
>
> This is an alias for JEDEC P22.
>
> The name associated with the value is also changed
> from "jedec-p22" to "ebu3213" to match ITU-T H.273.
>
> Signed-off-by: Raphaël Zumer 
> ---
>  doc/APIchanges  | 3 +++
>  libavutil/pixdesc.c | 2 +-
>  libavutil/pixfmt.h  | 1 +
>  libavutil/version.h | 2 +-
>  4 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 6603a8229e..f71b0c4a75 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>
>  API changes, most recent first:
>
> +2019-08-08 - xx - lavu 56.34.100 - pixfmt.h
> +  Add EBU Tech. 3213-E AVColorPrimaries value
>

this value was already present, this is just a rename


> +
>  2019-07-27 - xx - lavu 56.33.100 - tx.h
>Add AV_TX_DOUBLE_FFT and AV_TX_DOUBLE_MDCT
>
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index b97b0665b0..3b2d3b3123 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -2369,7 +2369,7 @@ static const char * const
> color_primaries_names[AVCOL_PRI_NB] = {
>  [AVCOL_PRI_SMPTE428] = "smpte428",
>  [AVCOL_PRI_SMPTE431] = "smpte431",
>  [AVCOL_PRI_SMPTE432] = "smpte432",
> -[AVCOL_PRI_JEDEC_P22] = "jedec-p22",
> +[AVCOL_PRI_JEDEC_P22] = "ebu3213",
>  };
>
>  static const char * const color_transfer_names[] = {
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index 8b54c9415b..7f7b537721 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -457,6 +457,7 @@ enum AVColorPrimaries {
>  AVCOL_PRI_SMPTE431= 11, ///< SMPTE ST 431-2 (2011) / DCI P3
>  AVCOL_PRI_SMPTE432= 12, ///< SMPTE ST 432-1 (2010) / P3 D65 /
> Display P3
>  AVCOL_PRI_JEDEC_P22   = 22, ///< JEDEC P22 phosphors
> +AVCOL_PRI_EBU3213 = AVCOL_PRI_JEDEC_P22,
>

I'd do the opposite, similarly to what is done for AVCOL_PRI_SMPTEST428_1

   AVCOL_PRI_EBU3213 = 22, ///< JEDEC P22 phosphors, EBU Tech 3213 E
   AVCOL_PRI_JEDEC_P22   = AVCOL_PRI_EBU3213,

 AVCOL_PRI_NB///< Not part of ABI
>  };
>
> --
Vittorio
___
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 2/2] lavc/vaapi_decode: recreate hw_frames_ctx for vp9 without destroy va_context

2019-08-09 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Hendrik Leppkes
> Sent: Friday, August 9, 2019 17:40
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode: recreate
> hw_frames_ctx for vp9 without destroy va_context
> 
> On Tue, Aug 6, 2019 at 10:55 AM Fu, Linjie  wrote:
> >
> > > -Original Message-
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > > Of Hendrik Leppkes
> > > Sent: Tuesday, August 6, 2019 16:27
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode:
> recreate
> > > hw_frames_ctx for vp9 without destroy va_context
> > >
> > > On Thu, Jul 11, 2019 at 10:20 AM Linjie Fu  wrote:
> > > >
> > > > VP9 allows resolution changes per frame. Currently in VAAPI, resolution
> > > > changes leads to va context destroy and reinit. This will cause
> > > > reference frame surface lost and produce garbage.
> > > >
> > > > Though refs surface id could be passed to media driver and found in
> > > > RTtbl, vp9RefList[] in hal layer has already been destroyed. Thus the
> > > > new created VaContext could only got an empty RefList.
> > > >
> > > > As libva allows re-create surface separately without changing the
> > > > context, this issue could be handled by only recreating hw_frames_ctx.
> > > >
> > > > Set hwaccel_priv_data_keeping flag for vp9 to only recreating
> > > > hw_frame_ctx when dynamic resolution changing happens.
> > > >
> > > > Could be verified by:
> > > > ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i
> > > >   ./resolutions.ivf -pix_fmt p010le -f rawvideo -vframes 20 -y vaapi.yuv
> > > >
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > >  libavcodec/decode.c| 10 +-
> > > >  libavcodec/internal.h  |  1 +
> > > >  libavcodec/pthread_frame.c |  2 ++
> > > >  libavcodec/vaapi_decode.c  | 40 ++---
> -
> > > --
> > > >  libavcodec/vaapi_vp9.c |  4 
> > > >  5 files changed, 34 insertions(+), 23 deletions(-)
> > > >
> > > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> > > > index 0863b82..7b15fa5 100644
> > > > --- a/libavcodec/decode.c
> > > > +++ b/libavcodec/decode.c
> > > > @@ -1254,7 +1254,6 @@ int
> > > ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,
> > > >
> > > >  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
> > > >
> > > > -
> > > >  if (frames_ctx->initial_pool_size) {
> > > >  // We guarantee 4 base work surfaces. The function above
> guarantees
> > > 1
> > > >  // (the absolute minimum), so add the missing count.
> > >
> > > Unrelated whitespace change
> >
> > There is  a redundant whitespace here, so I removed it within this patch.
> >
> > > > @@ -1333,7 +1332,7 @@ static int hwaccel_init(AVCodecContext
> *avctx,
> > > >  return AVERROR_PATCHWELCOME;
> > > >  }
> > > >
> > > > -if (hwaccel->priv_data_size) {
> > > > +if (hwaccel->priv_data_size && !avctx->internal-
> >hwaccel_priv_data) {
> > > >  avctx->internal->hwaccel_priv_data =
> > > >  av_mallocz(hwaccel->priv_data_size);
> > > >  if (!avctx->internal->hwaccel_priv_data)
> > > > @@ -1396,9 +1395,10 @@ int ff_get_format(AVCodecContext *avctx,
> > > const enum AVPixelFormat *fmt)
> > > >  memcpy(choices, fmt, (n + 1) * sizeof(*choices));
> > > >
> > > >  for (;;) {
> > > > -// Remove the previous hwaccel, if there was one.
> > > > -hwaccel_uninit(avctx);
> > > > -
> > > > +// Remove the previous hwaccel, if there was one,
> > > > +// and no need for keeping.
> > > > +if (!avctx->internal->hwaccel_priv_data_keeping)
> > > > +hwaccel_uninit(avctx);
> > > >  user_choice = avctx->get_format(avctx, choices);
> > > >  if (user_choice == AV_PIX_FMT_NONE) {
> > > >  // Explicitly chose nothing, give up.
> > >
> > > There could be a dozen special cases how stuff can go wrong here. What
> > > if get_format actually returns a different format then the one
> > > currently in use? Or a software format?
> > > Just removing this alone is not safe.
> >
> > Didn't quite get your point.
> > IMHO,  avctx->internal->hwaccel_priv_data_keeping won't be set in other
> cases
> > other than vaapi_vp9, so this patch won't break the default pipeline, and
> > hwaccel_uninit(avctx) will always be called.
> >
> 
> The point is that you cannot rely on get_format to return the same
> format that it previously did. It could return a software format, or
> in some cases possibly even a different hardware format. And you just
> don't handle that.

Got it. Thanks for the explanation, it should be reconsidered in case it 
happens.

> The entire approach here smells a bit of hack. Lets try to think this
> through and do it properly. One idea that 

Re: [FFmpeg-devel] [PATCH] colorspace: Rename jedec-p22 to ebu3213

2019-08-09 Thread Hendrik Leppkes
On Fri, Aug 9, 2019 at 12:32 PM Kevin Wheatley
 wrote:
>
> Is there a change to include the EBU primaries?
>
> https://tech.ebu.ch/docs/tech/tech3213.pdf
>
> White 0.313 0.329
> Red 0.64 0.33
> Green 0.29 0.60
> Blue 0.15 0.06
>
> as the ones currently called AVCOL_PRI_JEDEC_P22 are not those ones at
> least in vf_colorspace.c
>
> [AVCOL_PRI_JEDEC_P22] = { WP_D65, { 0.630, 0.340, 0.295, 0.605,
> 0.155, 0.077 } },
>

The enum and our values are aligned to the H.273 / ISO/IEC 23001-8
standards, which documents this entry to correspond to the primaries
in use by vf_colorspace

- Hendrik
___
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] avdevice/decklink: adjust for timecode lag

2019-08-09 Thread Ilinca Tudose
Hi Marton,

The issue with the out of sync TC was reproducible on all tapes and decks
that we tested. I don't have the exact number now, but a few dozens, less
than 100. They all had between 7 and 17 frames out of sync. We were not
able to obtain anything more in sync than 7 frames.

The TC sync was tested by setting up the deck to "burn" the TC with the
image while capturing the content with TC through ffmpeg. We then play the
file in a player that supports timecodes and compare the burned-in TC with
the one captured in the metadata.

We used Decklink quad 2 and several Sony decks: J30, J3, JH3. We tested on
multiple decks from each model and confirmed the issue was present + that
Gyan's patch seemed to fix it. We have used several types of Betacam tapes
and HDCAM tapes. I can not comment on whether this is the best solution,
but can confirm it works.

Let me know if you need more info.

Thanks,
ilinca

On Fri, Aug 9, 2019 at 1:08 PM Gyan  wrote:

>
> > On 28-07-2019 01:37 AM, Marton Balint wrote:
> >>
> >>
> >> On Fri, 26 Jul 2019, Gyan wrote:
> >>
> >>>
> >>> Patch supported by and tested at Google.
> >>
> >> Seems like a huge hack for a decklink issue... ;)
> >>
> >> I wonder if there are better approaches to work around this. Like
> >> dropping all frames until we have a valid signal.
> >
> > Let's say the scenario is like this,
> >
> > Frame #TC Status
> >  1   no   dropped
> >  2   no   demuxed
> >  3   no   demuxed
> >  4   no   dropped
> >  5  04:11:21:04   dropped
> >  6  04:11:21:05   demuxed
> >
> >
> > We don't want to drop frames before 6; they still should be digitized
> > (sometimes the TC appears after ~15 frames). But the stored TC needs
> > to be 04:11:21:04 + (2 - 5) =  04:11:21:01
> >
> >> How is this repoducible? do you have an exact model / signal type /
> >> TC source requirement?
>
> (Anchor for reply)
> ___
> 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 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2019-08-09 Thread Moritz Barsnick
On Thu, Aug 08, 2019 at 22:09:04 +0100, Cameron Cawley wrote:
> Signed-off-by: Cameron Cawley 
> ---
>  doc/general.texi|  1 +
>  libavcodec/Makefile |  1 +
>  libavcodec/adpcm.c  | 14 ++
>  libavcodec/allcodecs.c  |  1 +
>  libavcodec/avcodec.h|  1 +
>  libavcodec/codec_desc.c |  7 +++
>  libavcodec/utils.c  |  1 +
>  7 files changed, 26 insertions(+)

You should also bump the micro version when adding a new decoder.

Cheers,
Moritz
___
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] avdevice/decklink: adjust for timecode lag

2019-08-09 Thread Gyan



On 28-07-2019 01:37 AM, Marton Balint wrote:



On Fri, 26 Jul 2019, Gyan wrote:



Patch supported by and tested at Google.


Seems like a huge hack for a decklink issue... ;)

I wonder if there are better approaches to work around this. Like 
dropping all frames until we have a valid signal.


Let's say the scenario is like this,

Frame #    TC     Status
 1       no       dropped
 2       no       demuxed
 3       no       demuxed
 4       no       dropped
 5  04:11:21:04   dropped
 6  04:11:21:05   demuxed


We don't want to drop frames before 6; they still should be digitized 
(sometimes the TC appears after ~15 frames). But the stored TC needs 
to be 04:11:21:04 + (2 - 5) =  04:11:21:01


How is this repoducible? do you have an exact model / signal type / 
TC source requirement?


(Anchor for reply)
___
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] colorspace: Rename jedec-p22 to ebu3213

2019-08-09 Thread Kevin Wheatley
Is there a change to include the EBU primaries?

https://tech.ebu.ch/docs/tech/tech3213.pdf

White 0.313 0.329
Red 0.64 0.33
Green 0.29 0.60
Blue 0.15 0.06

as the ones currently called AVCOL_PRI_JEDEC_P22 are not those ones at
least in vf_colorspace.c

[AVCOL_PRI_JEDEC_P22] = { WP_D65, { 0.630, 0.340, 0.295, 0.605,
0.155, 0.077 } },

Kevin


On Fri, Aug 9, 2019 at 1:48 AM James Almer  wrote:
>
> On 8/8/2019 9:01 PM, rzu...@tebako.net wrote:
> > From: Raphaël Zumer 
> >
> > Internally, this adds an EBU3213 alias to JEDEC_P22,
> > and changes the name string to match ITU-T H.273.
> > ---
> >  libavcodec/options_table.h  | 2 +-
> >  libavfilter/vf_colorspace.c | 2 +-
> >  libavfilter/vf_setparams.c  | 2 +-
> >  libavfilter/vf_zscale.c | 2 +-
> >  libavutil/pixdesc.c | 2 +-
> >  libavutil/pixfmt.h  | 1 +
> >  6 files changed, 6 insertions(+), 5 deletions(-)
>
> This should be split into three patches. The first one adding the enum
> value to pixfmt.h, changing the string in pixdesc.c, bumping libavutil
> minor version, and adding an entry to doc/APIChanges. The subject should
> be something like "avutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries
> value" plus the explanation that it's an alias for Jedec P22 (Or that
> one becoming an alias for the new one) after it.
> Then another patch changing the libavfilter option values and bumping
> libavfilter micro version, and another doing the same with libavcodec.
>
> >
> > diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> > index 4a266eca16..9d82188171 100644
> > --- a/libavcodec/options_table.h
> > +++ b/libavcodec/options_table.h
> > @@ -365,7 +365,7 @@ static const AVOption avcodec_options[] = {
> >  {"smpte428_1",  "SMPTE 428-1",0, AV_OPT_TYPE_CONST, {.i64 = 
> > AVCOL_PRI_SMPTE428 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> >  {"smpte431","SMPTE 431-2",0, AV_OPT_TYPE_CONST, {.i64 = 
> > AVCOL_PRI_SMPTE431 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> >  {"smpte432","SMPTE 422-1",0, AV_OPT_TYPE_CONST, {.i64 = 
> > AVCOL_PRI_SMPTE432 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> > -{"jedec-p22",   "JEDEC P22",  0, AV_OPT_TYPE_CONST, {.i64 = 
> > AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> > +{"ebu3213", "EBU 3213-E", 0, AV_OPT_TYPE_CONST, {.i64 = 
> > AVCOL_PRI_JEDEC_P22 },INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> >  {"unspecified", "Unspecified",0, AV_OPT_TYPE_CONST, {.i64 = 
> > AVCOL_PRI_UNSPECIFIED },  INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
> >  {"color_trc", "color transfer characteristics", OFFSET(color_trc), 
> > AV_OPT_TYPE_INT, {.i64 = AVCOL_TRC_UNSPECIFIED }, 1, INT_MAX, V|E|D, 
> > "color_trc_type"},
> >  {"bt709","BT.709",   0, AV_OPT_TYPE_CONST, {.i64 = 
> > AVCOL_TRC_BT709 },INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
> > diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> > index df6efffb3d..5f22f92507 100644
> > --- a/libavfilter/vf_colorspace.c
> > +++ b/libavfilter/vf_colorspace.c
> > @@ -968,7 +968,7 @@ static const AVOption colorspace_options[] = {
> >  ENUM("smpte431", AVCOL_PRI_SMPTE431,   "prm"),
> >  ENUM("smpte432", AVCOL_PRI_SMPTE432,   "prm"),
> >  ENUM("bt2020",   AVCOL_PRI_BT2020, "prm"),
> > -ENUM("jedec-p22",AVCOL_PRI_JEDEC_P22,  "prm"),
> > +ENUM("ebu3213",  AVCOL_PRI_JEDEC_P22,  "prm"),
> >
> >  { "trc","Output transfer characteristics",
> >OFFSET(user_trc),   AV_OPT_TYPE_INT, { .i64 = AVCOL_TRC_UNSPECIFIED 
> > },
> > diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
> > index fe298e5a06..80e61f851e 100644
> > --- a/libavfilter/vf_setparams.c
> > +++ b/libavfilter/vf_setparams.c
> > @@ -74,7 +74,7 @@ static const AVOption setparams_options[] = {
> >  {"smpte428",NULL,  0, AV_OPT_TYPE_CONST, 
> > {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> >  {"smpte431",NULL,  0, AV_OPT_TYPE_CONST, 
> > {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> >  {"smpte432",NULL,  0, AV_OPT_TYPE_CONST, 
> > {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> > -{"jedec-p22",   NULL,  0, AV_OPT_TYPE_CONST, 
> > {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> > +{"ebu3213", NULL,  0, AV_OPT_TYPE_CONST, 
> > {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> >
> >  {"color_trc", "select color transfer", OFFSET(color_trc), 
> > AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, FLAGS, "color_trc"},
> >  {"auto", "keep the same color transfer",  0, AV_OPT_TYPE_CONST, 
> > {.i64=-1}, INT_MIN, INT_MAX, FLAGS, "color_trc"},
> > diff --git 

Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode: recreate hw_frames_ctx for vp9 without destroy va_context

2019-08-09 Thread Hendrik Leppkes
On Tue, Aug 6, 2019 at 10:55 AM Fu, Linjie  wrote:
>
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Hendrik Leppkes
> > Sent: Tuesday, August 6, 2019 16:27
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH, v2 2/2] lavc/vaapi_decode: recreate
> > hw_frames_ctx for vp9 without destroy va_context
> >
> > On Thu, Jul 11, 2019 at 10:20 AM Linjie Fu  wrote:
> > >
> > > VP9 allows resolution changes per frame. Currently in VAAPI, resolution
> > > changes leads to va context destroy and reinit. This will cause
> > > reference frame surface lost and produce garbage.
> > >
> > > Though refs surface id could be passed to media driver and found in
> > > RTtbl, vp9RefList[] in hal layer has already been destroyed. Thus the
> > > new created VaContext could only got an empty RefList.
> > >
> > > As libva allows re-create surface separately without changing the
> > > context, this issue could be handled by only recreating hw_frames_ctx.
> > >
> > > Set hwaccel_priv_data_keeping flag for vp9 to only recreating
> > > hw_frame_ctx when dynamic resolution changing happens.
> > >
> > > Could be verified by:
> > > ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i
> > >   ./resolutions.ivf -pix_fmt p010le -f rawvideo -vframes 20 -y vaapi.yuv
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > >  libavcodec/decode.c| 10 +-
> > >  libavcodec/internal.h  |  1 +
> > >  libavcodec/pthread_frame.c |  2 ++
> > >  libavcodec/vaapi_decode.c  | 40 ++
> > --
> > >  libavcodec/vaapi_vp9.c |  4 
> > >  5 files changed, 34 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> > > index 0863b82..7b15fa5 100644
> > > --- a/libavcodec/decode.c
> > > +++ b/libavcodec/decode.c
> > > @@ -1254,7 +1254,6 @@ int
> > ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,
> > >
> > >  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
> > >
> > > -
> > >  if (frames_ctx->initial_pool_size) {
> > >  // We guarantee 4 base work surfaces. The function above 
> > > guarantees
> > 1
> > >  // (the absolute minimum), so add the missing count.
> >
> > Unrelated whitespace change
>
> There is  a redundant whitespace here, so I removed it within this patch.
>
> > > @@ -1333,7 +1332,7 @@ static int hwaccel_init(AVCodecContext *avctx,
> > >  return AVERROR_PATCHWELCOME;
> > >  }
> > >
> > > -if (hwaccel->priv_data_size) {
> > > +if (hwaccel->priv_data_size && !avctx->internal->hwaccel_priv_data) {
> > >  avctx->internal->hwaccel_priv_data =
> > >  av_mallocz(hwaccel->priv_data_size);
> > >  if (!avctx->internal->hwaccel_priv_data)
> > > @@ -1396,9 +1395,10 @@ int ff_get_format(AVCodecContext *avctx,
> > const enum AVPixelFormat *fmt)
> > >  memcpy(choices, fmt, (n + 1) * sizeof(*choices));
> > >
> > >  for (;;) {
> > > -// Remove the previous hwaccel, if there was one.
> > > -hwaccel_uninit(avctx);
> > > -
> > > +// Remove the previous hwaccel, if there was one,
> > > +// and no need for keeping.
> > > +if (!avctx->internal->hwaccel_priv_data_keeping)
> > > +hwaccel_uninit(avctx);
> > >  user_choice = avctx->get_format(avctx, choices);
> > >  if (user_choice == AV_PIX_FMT_NONE) {
> > >  // Explicitly chose nothing, give up.
> >
> > There could be a dozen special cases how stuff can go wrong here. What
> > if get_format actually returns a different format then the one
> > currently in use? Or a software format?
> > Just removing this alone is not safe.
>
> Didn't quite get your point.
> IMHO,  avctx->internal->hwaccel_priv_data_keeping won't be set in other cases
> other than vaapi_vp9, so this patch won't break the default pipeline, and
> hwaccel_uninit(avctx) will always be called.
>

The point is that you cannot rely on get_format to return the same
format that it previously did. It could return a software format, or
in some cases possibly even a different hardware format. And you just
don't handle that.

The entire approach here smells a bit of hack. Lets try to think this
through and do it properly. One idea that comes to mind is a new
hwaccel callback that checks if a in-place re-init is possible without
destroying everything. This could be used for a multitude of different
situations, and not just this one special case.

- Hendrik
___
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] avcodec/mlpenc: fix invalid checks, sample buffers are internally all in 24 depth

2019-08-09 Thread Paul B Mahol
Hi,

patch attached.

If you still encounter hash failures please share input file.


0001-avcodec-mlpenc-fix-invalid-checks-sample-buffers-are.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".

Re: [FFmpeg-devel] [PATCH v4] avformat/hlsenc: merge mpegts and fmp4 workflow to one workflow

2019-08-09 Thread Liu Steven


> 在 2019年8月5日,上午10:29,Steven Liu  写道:
> 
> just remove the 'i' of the v3 mail subject.
> write mpegts or fmp4 context into buffer, and flush the buffer into
> output file when split fragment. merge two format split workflow into
> one workflow
> 
> Signed-off-by: Steven Liu 
> ---
> libavformat/hlsenc.c | 251 +--
> 1 file changed, 124 insertions(+), 127 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 51310fb528..f6f9c8161d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -815,7 +815,7 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
> *vs)
> vs->start_pos = 0;
> vs->new_start = 1;
> 
> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> +if (hls->segment_type == SEGMENT_TYPE_FMP4 && hls->max_seg_size > 0) {
> if (hls->http_persistent > 0) {
> //TODO: Support fragment fmp4 for http persistent in HLS muxer.
> av_log(s, AV_LOG_WARNING, "http persistent mode is currently 
> unsupported for fragment mp4 in the HLS muxer.\n");
> @@ -824,34 +824,38 @@ static int hls_mux_init(AVFormatContext *s, 
> VariantStream *vs)
> av_log(s, AV_LOG_WARNING, "Multi-file byterange mode is currently 
> unsupported in the HLS muxer.\n");
> return AVERROR_PATCHWELCOME;
> }
> +}
> 
> -vs->packets_written = 0;
> -vs->init_range_length = 0;
> -set_http_options(s, , hls);
> -if ((ret = avio_open_dyn_buf(>pb)) < 0)
> -return ret;
> +vs->packets_written = 0;
> +vs->init_range_length = 0;
> +set_http_options(s, , hls);
> +if ((ret = avio_open_dyn_buf(>pb)) < 0)
> +return ret;
> 
> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> if (byterange_mode) {
> ret = hlsenc_io_open(s, >out, vs->basename, );
> } else {
> ret = hlsenc_io_open(s, >out, vs->base_output_dirname, 
> );
> }
> -av_dict_free();
> +}
> +av_dict_free();
> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
> vs->fmp4_init_filename);
> +return ret;
> +}
> +
> +if (hls->format_options_str) {
> +ret = av_dict_parse_string(>format_options, 
> hls->format_options_str, "=", ":", 0);
> if (ret < 0) {
> -av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
> vs->fmp4_init_filename);
> +av_log(s, AV_LOG_ERROR, "Could not parse format options list 
> '%s'\n",
> +   hls->format_options_str);
> return ret;
> }
> +}
> 
> -if (hls->format_options_str) {
> -ret = av_dict_parse_string(>format_options, 
> hls->format_options_str, "=", ":", 0);
> -if (ret < 0) {
> -av_log(s, AV_LOG_ERROR, "Could not parse format options list 
> '%s'\n",
> -   hls->format_options_str);
> -return ret;
> -}
> -}
> -
> -av_dict_copy(, hls->format_options, 0);
> +av_dict_copy(, hls->format_options, 0);
> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> av_dict_set(, "fflags", "-autobsf", 0);
> av_dict_set(, "movflags", "+frag_custom+dash+delay_moov", 
> AV_DICT_APPEND);
> ret = avformat_init_output(oc, );
> @@ -862,9 +866,9 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
> *vs)
> av_dict_free();
> return AVERROR(EINVAL);
> }
> -avio_flush(oc->pb);
> -av_dict_free();
> }
> +avio_flush(oc->pb);
> +av_dict_free();
> return 0;
> }
> 
> @@ -1435,7 +1439,6 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> {
> HLSContext *hls = s->priv_data;
> HLSSegment *en;
> -AVFormatContext *oc = vs->avf;
> int target_duration = 0;
> int ret = 0;
> char temp_filename[MAX_URL_SIZE];
> @@ -1471,7 +1474,7 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> 
> set_http_options(s, , hls);
> snprintf(temp_filename, sizeof(temp_filename), use_temp_file ? "%s.tmp" : 
> "%s", vs->m3u8_name);
> -if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? >m3u8_out : >pb, temp_filename, )) < 0) 
> {
> +if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename, )) < 
> 0) {
> if (hls->ignore_io_errors)
> ret = 0;
> goto fail;
> @@ -1483,33 +1486,33 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> }
> 
> vs->discontinuity_set = 0;
> -ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? hls->m3u8_out : oc->pb, hls->version, hls->allowcache,
> +ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? hls->m3u8_out : vs->out, 

Re: [FFmpeg-devel] [PATCH v2] libavcodec/amfenc: Vulkan initialization support for encoder.

2019-08-09 Thread Timo Rothenpieler

On 08/08/2019 20:33, OvchinnikovDmitrii wrote:

Added linux support for amf encoder through vulkan.

To use h.264(AMD VCE) encoder on linux amdgru-pro version 19.20+ and 
amf-amdgpu-pro package(amdgru-pro contains, but does not install automatically) 
are required.
This driver can be installed using amdgpu-pro-install script in official amd 
driver archive.

Initialization of amf encoder occurs in this order:
1) trying to initialize through dx11(only windows)
2) trying to initialize through dx9(only windows)
3) trying to initialize through vulkan

Only Vulkan initialization available on linux.



Is it possible to use Vulkan on Windows? For Interop with OpenCL and the 
like that could come very handy.




smime.p7s
Description: S/MIME Cryptographic 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 v1] avfilter/showinfo: support Content Light Level information

2019-08-09 Thread Nicolas George
Limin Wang (12019-08-09):
> IMO, the medata memory is allocate by 
> av_content_light_metadata_create_side_data() api, it's valid already,
> there is no need to check the size.

Unless somebody made a programming mistake somewhere else.

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 2/3] avfilter: Rename jedec-p22 to ebu3213

2019-08-09 Thread Nicolas George
rzu...@tebako.net (12019-08-08):
> From: Raphaël Zumer 
> 
> This matches a name change in avutil/pixdesc.
> 
> Signed-off-by: Raphaël Zumer 
> ---
>  libavfilter/version.h   | 2 +-
>  libavfilter/vf_colorspace.c | 2 +-
>  libavfilter/vf_setparams.c  | 2 +-
>  libavfilter/vf_zscale.c | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index dd829160fc..58a0221f43 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>  
>  #define LIBAVFILTER_VERSION_MAJOR   7
>  #define LIBAVFILTER_VERSION_MINOR  58
> -#define LIBAVFILTER_VERSION_MICRO 100
> +#define LIBAVFILTER_VERSION_MICRO 101
>  
>  
>  #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> index df6efffb3d..5f22f92507 100644
> --- a/libavfilter/vf_colorspace.c
> +++ b/libavfilter/vf_colorspace.c
> @@ -968,7 +968,7 @@ static const AVOption colorspace_options[] = {
>  ENUM("smpte431", AVCOL_PRI_SMPTE431,   "prm"),
>  ENUM("smpte432", AVCOL_PRI_SMPTE432,   "prm"),
>  ENUM("bt2020",   AVCOL_PRI_BT2020, "prm"),
> -ENUM("jedec-p22",AVCOL_PRI_JEDEC_P22,  "prm"),
> +ENUM("ebu3213",  AVCOL_PRI_JEDEC_P22,  "prm"),
>  
>  { "trc","Output transfer characteristics",
>OFFSET(user_trc),   AV_OPT_TYPE_INT, { .i64 = AVCOL_TRC_UNSPECIFIED },
> diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
> index fe298e5a06..80e61f851e 100644
> --- a/libavfilter/vf_setparams.c
> +++ b/libavfilter/vf_setparams.c
> @@ -74,7 +74,7 @@ static const AVOption setparams_options[] = {
>  {"smpte428",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  {"smpte431",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},
>  {"smpte432",NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, FLAGS, "color_primaries"},

> -{"jedec-p22",   NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},
> +{"ebu3213", NULL,  0, AV_OPT_TYPE_CONST, 
> {.i64=AVCOL_PRI_JEDEC_P22},INT_MIN, INT_MAX, FLAGS, "color_primaries"},

Unless I am mistaken, this is breaking the user interface: a script that
did use -vf setparams=color_primaries=jedec-p22 will stop working. Just
like the enum value for the API, the options names for the UI need to
become an alias, at least for some time.

Same is true for the other patch, of course.

>  
>  {"color_trc", "select color transfer", OFFSET(color_trc), 
> AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, FLAGS, "color_trc"},
>  {"auto", "keep the same color transfer",  0, AV_OPT_TYPE_CONST, 
> {.i64=-1}, INT_MIN, INT_MAX, FLAGS, "color_trc"},
> diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
> index f0309272fa..e53d7c1ae0 100644
> --- a/libavfilter/vf_zscale.c
> +++ b/libavfilter/vf_zscale.c
> @@ -788,7 +788,7 @@ static const AVOption zscale_options[] = {
>  { "smpte428", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST428},   0, 0, FLAGS, "primaries" },
>  { "smpte431", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST431_2}, 0, 0, FLAGS, "primaries" },
>  { "smpte432", 0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, "primaries" },
> -{ "jedec-p22",0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
> +{ "ebu3213",  0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_PRIMARIES_EBU3213_E},   0, 0, FLAGS, "primaries" },
>  { "transfer", "set transfer characteristic", OFFSET(trc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
>  { "t","set transfer characteristic", OFFSET(trc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, FLAGS, "transfer" },
>  { "input",0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = -1}, 0, 0, FLAGS, "transfer" },

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] MpegTS contribution question

2019-08-09 Thread Anthony Delannoy
For now I'm just reading and storing EPG data, once this part is done I'd
like to do what you said.
But first we will have to think of an easy way to change/insert descriptors
inside a specific table.

Thanks for your response :)

Le jeu. 8 août 2019 à 17:57, Phil Burr  a écrit :

> Hello Anthony,
>
> I'm not really the best to answer your questions, as I'm also a fairly new
> contributor (my patches seem to be languishing due to a lack of feedback
> and a lack of time on my part pushing the issue).  I've been working on
> getting support into mpegts for ATSC compliant descriptors of which EIT
> tables are a glaring omission in large part due to the amount of work
> needed to support them.  So to say the least, I'm excited about your
> patches!  I'll take a look at your patches but one thing I would like to
> know if you've considered, is whether or not your code supports modifying
> the EIT tables, ie updating tables_version when the tables are modified?
>
> Thanks,
> Phil
>
> On Thu, Aug 8, 2019 at 4:13 AM Anthony Delannoy  >
> wrote:
>
> > Hi,
> >
> > I'm currently doing my first contribution to ffmpeg by adding EPG support
> > in the mpegts format.
> > For now, i succeeded to add support for EIT table and majority of its
> > descriptors and can read/export EPG
> > events in a .csv file.
> > But I don't know on how to organize it now. Do I make a new codec for epg
> > and a data stream? Do I keep those
> > information « hidden » and present them only in metadatas plus functions
> > api to export them?
> >
> > For those who wants to see where I am at:
> > https://github.com/spnngl/FFmpeg/tree/epg2
> >
> > Some remarks:
> >   * For now I use linked list to store EPG events but I may change for
> > something simpler.
> >   * I made separate descriptors code to be able to use it on others
> tables
> > later. I want to add NIT table
> >   support and maybe others if i succeed to finish EPG.
> >   * EPG/descriptors files are all in libavformat for now, they need to be
> > moved
> >
> > 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".
> ___
> 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] libavfilter/vf_scale: Ensure scaled video is divisible by n

2019-08-09 Thread Lars Kiesow
Well… then, can anyone merge this patch?
Best regards,
Lars

On Mon, 5 Aug 2019 14:31:43 +0200
Paul B Mahol  wrote:

> On Mon, Aug 5, 2019 at 1:31 PM Lars Kiesow  wrote:
> 
> > Hi everyone,
> > this is now open for nearly a month with no more comments or change
> > requests. Anything else I should do to get this merged?
> > Best regards,
> >  
> 
> Yes, ping it more frequently, until its merged.
> Waiting for months will not help as people are busy.
> 
> 
> > Lars
> >
> >
> > On Mon,  8 Jul 2019 17:43:40 +0200
> > Lars Kiesow  wrote:
> >  
> > > This patch adds a new option to the scale filter which ensures
> > > that the output resolution is divisible by the given integer when
> > > used together with `force_original_aspect_ratio`. This works
> > > similar to using `-n` in the `w` and `h` options.
> > >
> > > This option respects the value set for
> > > `force_original_aspect_ratio`, increasing or decreasing the
> > > resolution accordingly.
> > >
> > > The use case for this is to set a fixed target resolution using
> > > `w` and `h`, to use the `force_original_aspect_ratio` option to
> > > make sure that the video always fits in the defined bounding box
> > > regardless of aspect ratio, but to also make sure that the
> > > calculated output resolution is divisible by n so in can be
> > > encoded with certain encoders/options if that is required.
> > >
> > > Signed-off-by: Lars Kiesow 
> > > ---
> > >  doc/filters.texi   | 12 
> > >  libavfilter/vf_scale.c | 13 -
> > >  2 files changed, 24 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/doc/filters.texi b/doc/filters.texi
> > > index ee6a93ffbf..2de71d9820 100644
> > > --- a/doc/filters.texi
> > > +++ b/doc/filters.texi
> > > @@ -15231,6 +15231,18 @@ Please note that this is a different
> > > thing than specifying -1 for @option{w} or @option{h}, you still
> > > need to specify the output resolution for this option to work.
> > >
> > > +@item force_divisible_by Ensures that the output resolution is
> > > divisible by the +given integer when used together with
> > > @option{force_original_aspect_ratio}. This +works similar to
> > > using -n in the @option{w} and @option{h} options. +
> > > +This option respects the value set for
> > > @option{force_original_aspect_ratio}, +increasing or decreasing
> > > the resolution accordingly. This may slightly modify +the video's
> > > aspect ration. +
> > > +This can be handy, for example, if you want to have a video fit
> > > within a defined +resolution using the
> > > @option{force_original_aspect_ratio} option but have +encoder
> > > restrictions when it comes to width or height. +
> > >  @end table
> > >
> > >  The values of the @option{w} and @option{h} options are
> > > expressions diff --git a/libavfilter/vf_scale.c
> > > b/libavfilter/vf_scale.c index 7aebf56ad8..3ce6cdd1d5 100644
> > > --- a/libavfilter/vf_scale.c
> > > +++ b/libavfilter/vf_scale.c
> > > @@ -86,6 +86,7 @@ typedef struct ScaleContext {
> > >  int in_v_chr_pos;
> > >
> > >  int force_original_aspect_ratio;
> > > +int force_divisible_by;
> > >
> > >  int nb_slices;
> > >
> > > @@ -237,7 +238,8 @@ static int config_props(AVFilterLink *outlink)
> > >  goto fail;
> > >
> > >  /* Note that force_original_aspect_ratio may overwrite the
> > > previous set
> > > - * dimensions so that it is not divisible by the set factors
> > > anymore. */
> > > + * dimensions so that it is not divisible by the set factors
> > > anymore
> > > + * unless force_divisible_by is defined as well */
> > >  if (scale->force_original_aspect_ratio) {
> > >  int tmp_w = av_rescale(h, inlink->w, inlink->h);
> > >  int tmp_h = av_rescale(w, inlink->h, inlink->w);
> > > @@ -245,9 +247,17 @@ static int config_props(AVFilterLink
> > > *outlink) if (scale->force_original_aspect_ratio == 1) {
> > >   w = FFMIN(tmp_w, w);
> > >   h = FFMIN(tmp_h, h);
> > > + if (scale->force_divisible_by > 1) {
> > > + w = w / scale->force_divisible_by *
> > > scale->force_divisible_by;
> > > + h = h / scale->force_divisible_by *
> > > scale->force_divisible_by;
> > > + }
> > >  } else {
> > >   w = FFMAX(tmp_w, w);
> > >   h = FFMAX(tmp_h, h);
> > > + if (scale->force_divisible_by > 1) {
> > > + w = ceil(w / (float)scale->force_divisible_by) *
> > > scale->force_divisible_by;
> > > + h = ceil(h / (float)scale->force_divisible_by) *
> > > scale->force_divisible_by;
> > > + }
> > >  }
> > >  }
> > >
> > > @@ -600,6 +610,7 @@ static const AVOption scale_options[] = {
> > >  { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0,
> > > FLAGS, "force_oar" }, { "decrease", NULL, 0, AV_OPT_TYPE_CONST,
> > > {.i64 = 1 }, 0, 0, FLAGS, "force_oar" }, { "increase", NULL, 0,
> > > AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, 

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2019-08-09 Thread Paul B Mahol
On Thu, Aug 8, 2019 at 11:20 PM Cameron Cawley 
wrote:

> Signed-off-by: Cameron Cawley 
> ---
>  doc/general.texi|  1 +
>  libavcodec/Makefile |  1 +
>  libavcodec/adpcm.c  | 14 ++
>  libavcodec/allcodecs.c  |  1 +
>  libavcodec/avcodec.h|  1 +
>  libavcodec/codec_desc.c |  7 +++
>  libavcodec/utils.c  |  1 +
>  7 files changed, 26 insertions(+)
>
> diff --git a/doc/general.texi b/doc/general.texi
> index 3c0c803449..db30738716 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -1072,6 +1072,7 @@ following image formats are supported:
>  @item ADPCM Electronic Arts XAS @tab @tab  X
>  @item ADPCM G.722@tab  X  @tab  X
>  @item ADPCM G.726@tab  X  @tab  X
> +@item ADPCM IMA Acorn Replay @tab @tab  X
>  @item ADPCM IMA AMV  @tab @tab  X
>  @tab Used in AMV files
>  @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 3cd73fbcc6..c0a038495f 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -825,6 +825,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
>  OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
>  OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
>  OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
> +OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)+= adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> index fb126503d6..70503fc0b1 100644
> --- a/libavcodec/adpcm.c
> +++ b/libavcodec/adpcm.c
> @@ -599,6 +599,7 @@ static int get_nb_samples(AVCodecContext *avctx,
> GetByteContext *gb,
>  switch (avctx->codec->id) {
>  case AV_CODEC_ID_ADPCM_4XM:
>  case AV_CODEC_ID_ADPCM_AGM:
> +case AV_CODEC_ID_ADPCM_IMA_ACORN:
>  case AV_CODEC_ID_ADPCM_IMA_DAT4:
>  case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;
> break;
>  case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8;
>  break;
> @@ -1441,6 +1442,18 @@ static int adpcm_decode_frame(AVCodecContext
> *avctx, void *data,
>  }
>  }
>  break;
> +case AV_CODEC_ID_ADPCM_IMA_ACORN:
> +for (i=0; i<=st; i++) {
> +bytestream2_skip(, 2); // TODO: What does this do?
>

Have you checked this is not some state that helps with seeking?


> +c->status[i].step_index = bytestream2_get_le16u();
> +}
> +
> +for (n = nb_samples >> (1 - st); n > 0; n--) {
> +int byte = bytestream2_get_byteu();
> +*samples++ = adpcm_ima_expand_nibble(>status[0],  byte &
> 0x0F, 6);
> +*samples++ = adpcm_ima_expand_nibble(>status[st], byte >>
> 4,   6);
> +}
> +break;
>  case AV_CODEC_ID_ADPCM_IMA_AMV:
>  c->status[0].predictor = sign_extend(bytestream2_get_le16u(),
> 16);
>  c->status[0].step_index = bytestream2_get_byteu();
> @@ -1825,6 +1838,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1,
>  sample_fmts_s16p, adpcm_ea_r1,
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2,   sample_fmts_s16p,
> adpcm_ea_r2,   "ADPCM Electronic Arts R2");
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3,   sample_fmts_s16p,
> adpcm_ea_r3,   "ADPCM Electronic Arts R3");
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,  sample_fmts_s16p,
> adpcm_ea_xas,  "ADPCM Electronic Arts XAS");
> +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ACORN,   sample_fmts_s16,
> adpcm_ima_acorn,   "ADPCM IMA Acorn Replay");
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16,
> adpcm_ima_amv, "ADPCM IMA AMV");
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16,
> adpcm_ima_apc, "ADPCM IMA CRYO APC");
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DAT4,sample_fmts_s16,
> adpcm_ima_dat4,"ADPCM IMA Eurocom DAT4");
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index d2f9a39ce5..78177a1255 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -592,6 +592,7 @@ extern AVCodec ff_adpcm_g726_encoder;
>  extern AVCodec ff_adpcm_g726_decoder;
>  extern AVCodec ff_adpcm_g726le_encoder;
>  extern AVCodec ff_adpcm_g726le_decoder;
> +extern AVCodec ff_adpcm_ima_acorn_decoder;
>  extern AVCodec ff_adpcm_ima_amv_decoder;
>  extern AVCodec ff_adpcm_ima_apc_decoder;
>  extern AVCodec ff_adpcm_ima_dat4_decoder;
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index d234271c5b..c8b6ec7f3c 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -542,6 +542,7 @@ enum AVCodecID {
>  AV_CODEC_ID_ADPCM_IMA_DAT4,
>  AV_CODEC_ID_ADPCM_MTAF,
>  AV_CODEC_ID_ADPCM_AGM,
> +AV_CODEC_ID_ADPCM_IMA_ACORN,
>
>  /* AMR */
>  AV_CODEC_ID_AMR_NB = 0x12000,
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 

Re: [FFmpeg-devel] [PATCH 5/6] avformat/mpegtsenc: fix PCR generation intervals

2019-08-09 Thread Andreas Håkon
Hi Marton,

‐‐‐ Original Message ‐‐‐
On Thursday, 8 de August de 2019 23:27, Marton Balint  wrote:

> PCR generation was based on counting packets for both CBR and VBR streams.
> Couting packets might have worked for CBR streams (when muxrate was specified)
> but it only took into account the packets of a service (or the packets of the
> PCR stream lately), so even that was problematic for multi program streams.
>
> The new code works on actual PCR for CBR and packet DTS values for VBR 
> streams,
> so the default 20ms PCR retransmission time is now respected for both CBR and
> VBR.
>
> The accuracy of PCR packets for CBR streams was greatly improved by 
> preemtively
> sending them at PCR intervals even if sending the payload of another stream
> is in progress.
>
> Signed-off-by: Marton Balint c...@passwd.hu

[...]

This new version LGTM.
Regards.
A.H.

---

___
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/6] avformat/mpegtsenc: fix incorrect PCR selection with multiple programs

2019-08-09 Thread Andreas Håkon
Hi Marton,

‐‐‐ Original Message ‐‐‐
On Thursday, 8 de August de 2019 23:27, Marton Balint  wrote:

> The MPEG-TS muxer had a serious bug related to the use of multiple programs:
> in that case, the PCR pid selection was incomplete for all services except 
> one.
> This patch solves this problem and selects a stream to become PCR for each
> service, preferably the video stream.
>
> This patch also moves pcr calculation attributes to MpegTSWriteStream from
> MpegTSService. PCR is a per-stream and not per-service thing, so it was
> misleading to refer to it as something that is per-service.
>
> Also remove *service from MpegTSWriteStream because a stream can belong to
> multiple services so it was misleading to select one for each stream.
>
> You can check the result with this example command:
>
> ./ffmpeg -loglevel verbose -y -f lavfi -i \
> "testsrc=s=64x64:d=10,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=10,asetnsamples=1152[out2]"
>  \
> -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact \
> -codec:v libx264 -codec:a mp2 -pix_fmt yuv420p \
> -map '0:v:0' \
> -map '0:v:1' \
> -map '0:a:0' \
> -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 -f mpegts 
> out.ts

I recommend this small change to the test:

./ffmpeg -loglevel verbose -y -f lavfi -i \
  
"testsrc=s=64x64:d=10,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=10,asetnsamples=1152[out2]"
 \
  -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact  \
  -codec:v libx264 -r:v:0 1 -r:v:1 25 -b:v:0 1000k -b:v:1 1500k -pix_fmt 
yuv420p \
  -codec:a mp2 \
  -map '0:v:0' \
  -map '0:v:1' \
  -map '0:a:0' \
  -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 \
  -f mpegts -muxrate 1M out.ts

CBR it's required and the use of different bitrates it's desirable.

> You should now see this:
>
> [mpegts @ 0x37505c0] service 1 using PCR in pid=256
> [mpegts @ 0x37505c0] service 2 using PCR in pid=257
> [mpegts @ 0x37505c0] service 3 using PCR in pid=258
> [mpegts @ 0x37505c0] service 4 using PCR in pid=256

Updated output:

[mpegts @ 0x33473c0] service 1 using PCR in pid=256, pcr_period=20ms
[mpegts @ 0x33473c0] service 2 using PCR in pid=257, pcr_period=20ms
[mpegts @ 0x33473c0] service 3 using PCR in pid=258, pcr_period=20ms
[mpegts @ 0x33473c0] service 4 using PCR in pid=256, pcr_period=20ms
[mpegts @ 0x33473c0] muxrate 100, sdt every 332, pat/pmt every 66 pkts

[...]

Regards.
A.H.

---

___
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/5] avcodec/alac: Check for bps of 0

2019-08-09 Thread Paul B Mahol
On Fri, Aug 9, 2019 at 1:26 AM Michael Niedermayer 
wrote:

> Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
> Fixes:
> 15764/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5102101203517440
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> :
> Michael Niedermayer 
> ---
>  libavcodec/alac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/alac.c b/libavcodec/alac.c
> index 6086e2caa8..1196925aa7 100644
> --- a/libavcodec/alac.c
> +++ b/libavcodec/alac.c
> @@ -250,7 +250,7 @@ static int decode_element(AVCodecContext *avctx,
> AVFrame *frame, int ch_index,
>
>  alac->extra_bits = get_bits(>gb, 2) << 3;
>  bps = alac->sample_size - alac->extra_bits + channels - 1;
> -if (bps > 32U) {
> +if (bps > 32 || bps < 1) {
>  avpriv_report_missing_feature(avctx, "bps %d", bps);
>  return AVERROR_PATCHWELCOME;
>  }
> --
> 2.22.0
>

I'm not sure reporting for missing feature in this case (bps == 0) is valid.



> ___
> 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] libavcodec: add timeshift bitstream filter [v3]

2019-08-09 Thread Andreas Håkon
Hi Gyan, Nicolas and Alexander,


‐‐‐ Original Message ‐‐‐
On Friday, 9 de August de 2019 3:18, Alexander Strasser  
wrote:

>
> [...]
> Gyan
>
> [...]
>   Nicolas George
>
> [...]
> Alexander

I appreciate your suggestions with the name. But, we need to select one.
So I propose a short list:

- "timeshift" (the current name)
- "pts_offset"
- "editpts"

I don't like "ts_offset" as "ts" can be understood as Transport Stream.
I don't want "add_delay" as it can add (aka delay) or substract (aka advance).
And I don't recommend "editpts" since at present it can't edit time stamps 
freely.

I expect your answers.
Regards.
A.H.

---

___
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".