Re: [FFmpeg-devel] [PATCH 7/30] avformat/matroskaenc: Avoid allocations for SeekHead

2020-03-09 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Andreas Rheinhardt:
>> On Fri, Feb 28, 2020 at 6:10 AM Andreas Rheinhardt <
>> andreas.rheinha...@gmail.com> wrote:
>>
>>> On Tue, Feb 25, 2020 at 2:24 PM Andreas Rheinhardt <
>>> andreas.rheinha...@gmail.com> wrote:
>>>
 Andreas Rheinhardt:
> Andreas Rheinhardt:
>> Andreas Rheinhardt:
>>> Up until e7ddafd5, the Matroska muxer wrote two SeekHeads: One at the
>>> beginning referencing the main level 1 elements (i.e. not the Clusters)
>>> and one at the end, referencing the Clusters. This second SeekHead was
>>> useless and has therefore been removed. Yet the SeekHead-related
>>> functions and structures are still geared towards this usecase: They
>>> are built around an allocated array of variable size that gets
>>> reallocated every time an element is added to it although the maximum
>>> number of Seek entries is a small compile-time constant, so that one 
>>> should
>>> rather include the array in the SeekHead structure itself; and said
>>> structure should be contained in the MatroskaMuxContext instead of being
>>> allocated separately.
>>>
>>> The earlier code reserved space for a SeekHead with 10 entries, although
>>> we currently write at most 6. Reducing said number implied that every
>>> Matroska/Webm file will be 84 bytes smaller and required to adapt
>>> several FATE tests; furthermore, the reserved amount overestimated the
>>> amount needed for for the SeekHead's length field and how many bytes
>>> need to be reserved to write a EBML Void element, bringing the total
>>> reduction to 89 bytes.
>>>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>
>> Ping.
>>
>> - Andreas
>>
> Ping (the actual patch (which has been omitted for brevity) is here:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/256997.html).
>
> - Andreas
>
 Another ping.

 - Andreas

>>>
>>> Ping.
>>>
>>> - Andreas
>>>
>>
>> Ping.
>>
>> - Andreas
>>
> Ping.
> 
> - Andreas
> 
Ping.

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

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

[FFmpeg-devel] New pixel format uyvy422i12le

2020-03-09 Thread Damien Chabannes
Hi everyone,

I'm trying to implement a new pixel format in FFmpeg but it appears that my
implementation is not correct. Indeed, when I do a ffplay on a raw video in
this new pixel format, the output is not correct.

The pixel format I want to implement is the uyvy422i12le. Data y, u and v
are stored in the same buffer, in this interlaced way : u0, y0, v0, y1, u1,
y2, v1, y3, u2, y4, v2, y5, ..., each data is encoded on 12 bits and stored
on 16 bits Little Endian.

For adding this new pix_fmt, I have done the following modifications :

   - in libavutil/pixfmt.h, add "AV_PIX_FMT_UYVY422I12LE" in enum
   AVPixelFormat


   - in libavutil/pixdesc.c, add AV_PIX_FMT_UYVY422I12LE in
   av_pix_fmt_descriptors :

[AV_PIX_FMT_UYVY422I12LE] = {
.name = "uyvy422i12le",
.nb_components = 3,
.log2_chroma_w = 1,
.log2_chroma_h = 0,
.comp = {
{ 0, 4, 2, 0, 12, 3, 11, 3 },/* Y */
{ 0, 8, 0, 0, 12, 7, 11, 1 },/* U */
{ 0, 8, 4, 0, 12, 7, 11, 5 },/* V */

   - in libswscale/utils.c, add "[AV_PIX_FMT_UYVY422I12LE]= { 1, 1 }," in
   format_entries

Once FFmpeg compiled with these modifications, if a do a ffplay on a raw
image in uyvy422i12le, I have this output which is uncorrect :
https://ibb.co/g7jG3ss

Here's the command line and the output :

./ffplay -f rawvideo -video_size 3840x2160 -pixel_format uyvy422i12le
test_in
ffplay version 48.1 Copyright (c) 2003-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration:
  libavutil  56. 31.100 / 56. 31.100
  libavcodec 58. 54.100 / 58. 54.100
  libavformat58. 29.100 / 58. 29.100
  libavdevice58.  8.100 / 58.  8.100
  libavfilter 7. 57.100 /  7. 57.100
  libswscale  5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
[rawvideo @ 0x7f47bc000940] Estimating duration from bitrate, this may be
inaccurate
Input #0, rawvideo, from 'test_in':
  Duration: 00:00:00.04, start: 0.00, bitrate: 6635520 kb/s
Stream #0:0: Video: rawvideo, uyvy422i12le, 3840x2160, 6635520 kb/s, 25
tbr, 25 tbn, 25 tbc
   1.87 M-V: -0.000 fd=   0 aq=0KB vq=0KB sq=0B f=0/0


you can found the original image here : https://ibb.co/zZrvt5K (colorimetry
is strange but that's normal it's an HDR content).

It looks like I have set bad values in the struct AVComponentDescriptor of
AV_PIX_FMT_UYVY422I12LE, but I do not see which one... Or have I forgotten
to add other modifications necessary to a new pixel format ?

The FFmpeg used is from tag n.42 of the FFmpeg 's official repo.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/decode: remove unused AVCodecInternal compat_decode field

2020-03-09 Thread Hendrik Leppkes
On Mon, Mar 9, 2020 at 3:20 AM James Almer  wrote:
>
> Signed-off-by: James Almer 
> ---
>  libavcodec/decode.c   | 1 -
>  libavcodec/internal.h | 1 -
>  2 files changed, 2 deletions(-)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 03b9da25f9..0e3d7e17e4 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -826,7 +826,6 @@ static int compat_decode(AVCodecContext *avctx, AVFrame 
> *frame,
>  }
>
>  *got_frame = 0;
> -avci->compat_decode = 1;
>
>  if (avci->compat_decode_partial_size > 0 &&
>  avci->compat_decode_partial_size != pkt->size) {
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index bccd9222d4..972e93bcfa 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -208,7 +208,6 @@ typedef struct AVCodecInternal {
>  AVFrame *buffer_frame;
>  int draining_done;
>  /* set to 1 when the caller is using the old decoding API */
> -int compat_decode;
>  int compat_decode_warned;
>  /* this variable is set by the decoder internals to signal to the old
>   * API compat wrappers the amount of data consumed from the last packet 
> */

The comment above it seems to want to reference the removed field?

- 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] New pixel format uyvy422i12le

2020-03-09 Thread Carl Eugen Hoyos


> Am 09.03.2020 um 10:05 schrieb Damien Chabannes 
> :
> 
> The pixel format I want to implement is the uyvy422i12le.

What produces this format?

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] New pixel format uyvy422i12le

2020-03-09 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Damien Chabannes
> Sent: Monday, March 9, 2020 17:05
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] New pixel format uyvy422i12le
> 
> Hi everyone,
> 
> I'm trying to implement a new pixel format in FFmpeg but it appears that my
> implementation is not correct. Indeed, when I do a ffplay on a raw video in
> this new pixel format, the output is not correct.
> 
> The pixel format I want to implement is the uyvy422i12le. Data y, u and v
> are stored in the same buffer, in this interlaced way : u0, y0, v0, y1, u1,
> y2, v1, y3, u2, y4, v2, y5, ..., each data is encoded on 12 bits and stored
> on 16 bits Little Endian.
> 
> For adding this new pix_fmt, I have done the following modifications :
> 
>- in libavutil/pixfmt.h, add "AV_PIX_FMT_UYVY422I12LE" in enum
>AVPixelFormat
> 
> 
>- in libavutil/pixdesc.c, add AV_PIX_FMT_UYVY422I12LE in
>av_pix_fmt_descriptors :
> 
> [AV_PIX_FMT_UYVY422I12LE] = {
> .name = "uyvy422i12le",
> .nb_components = 3,
> .log2_chroma_w = 1,
> .log2_chroma_h = 0,
> .comp = {
> { 0, 4, 2, 0, 12, 3, 11, 3 },/* Y */
> { 0, 8, 0, 0, 12, 7, 11, 1 },/* U */
> { 0, 8, 4, 0, 12, 7, 11, 5 },/* V */
> 
>- in libswscale/utils.c, add "[AV_PIX_FMT_UYVY422I12LE]= { 1, 1 }," in
>format_entries

With this format entry declared for your format, you are supposed to implement 
input and
output function support in swscale. Otherwise it may fallback to other existed 
functions to
do color space conversion. (Perhaps it may be the reason for your garbage)

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

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

[FFmpeg-devel] [PATCH] avformat/alp: tweak probe function to return MAX-1

2020-03-09 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/alp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/alp.c b/libavformat/alp.c
index c0c7905380..4c2e8f0652 100644
--- a/libavformat/alp.c
+++ b/libavformat/alp.c
@@ -51,7 +51,7 @@ static int alp_probe(const AVProbeData *p)
 if (strncmp("ADPCM", p->buf + 8, 6) != 0)
 return 0;
 
-return AVPROBE_SCORE_EXTENSION + 1;
+return AVPROBE_SCORE_MAX - 1;
 }
 
 static int alp_read_header(AVFormatContext *s)
-- 
2.17.1


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/decode: remove unused AVCodecInternal compat_decode field

2020-03-09 Thread James Almer
On 3/9/2020 6:09 AM, Hendrik Leppkes wrote:
> On Mon, Mar 9, 2020 at 3:20 AM James Almer  wrote:
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/decode.c   | 1 -
>>  libavcodec/internal.h | 1 -
>>  2 files changed, 2 deletions(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 03b9da25f9..0e3d7e17e4 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -826,7 +826,6 @@ static int compat_decode(AVCodecContext *avctx, AVFrame 
>> *frame,
>>  }
>>
>>  *got_frame = 0;
>> -avci->compat_decode = 1;
>>
>>  if (avci->compat_decode_partial_size > 0 &&
>>  avci->compat_decode_partial_size != pkt->size) {
>> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
>> index bccd9222d4..972e93bcfa 100644
>> --- a/libavcodec/internal.h
>> +++ b/libavcodec/internal.h
>> @@ -208,7 +208,6 @@ typedef struct AVCodecInternal {
>>  AVFrame *buffer_frame;
>>  int draining_done;
>>  /* set to 1 when the caller is using the old decoding API */
>> -int compat_decode;
>>  int compat_decode_warned;
>>  /* this variable is set by the decoder internals to signal to the old
>>   * API compat wrappers the amount of data consumed from the last packet 
>> */
> 
> The comment above it seems to want to reference the removed field?

Good catch. Removed locally.

> 
> - 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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/alp: tweak probe function to return MAX-1

2020-03-09 Thread Carl Eugen Hoyos
Am Mo., 9. März 2020 um 12:55 Uhr schrieb Zane van Iperen
:
>
> Signed-off-by: Zane van Iperen 
> ---
>  libavformat/alp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/alp.c b/libavformat/alp.c
> index c0c7905380..4c2e8f0652 100644
> --- a/libavformat/alp.c
> +++ b/libavformat/alp.c
> @@ -51,7 +51,7 @@ static int alp_probe(const AVProbeData *p)
>  if (strncmp("ADPCM", p->buf + 8, 6) != 0)
>  return 0;
>
> -return AVPROBE_SCORE_EXTENSION + 1;
> +return AVPROBE_SCORE_MAX - 1;

Patch applied.

Thank you, 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".

[FFmpeg-devel] [PATCH] fate/adpcm: add adpcm_ima_alp tests

2020-03-09 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 tests/fate/adpcm.mak| 6 ++
 tests/ref/fate/adpcm-ima-alp-mono   | 1 +
 tests/ref/fate/adpcm-ima-alp-stereo | 1 +
 3 files changed, 8 insertions(+)
 create mode 100644 tests/ref/fate/adpcm-ima-alp-mono
 create mode 100644 tests/ref/fate/adpcm-ima-alp-stereo

diff --git a/tests/fate/adpcm.mak b/tests/fate/adpcm.mak
index ba8aa64fc5..3e6d4ecdd1 100644
--- a/tests/fate/adpcm.mak
+++ b/tests/fate/adpcm.mak
@@ -106,5 +106,11 @@ fate-adpcm-ima-apm-mono: CMD = md5 -i 
$(TARGET_SAMPLES)/apm/outro1.apm -f s16le
 FATE_ADPCM-$(call DEMDEC, APM, ADPCM_IMA_APM) += fate-adpcm-ima-apm-stereo
 fate-adpcm-ima-apm-stereo: CMD = md5 -i $(TARGET_SAMPLES)/apm/AS01.apm -f s16le
 
+FATE_ADPCM-$(call DEMDEC, ALP, ADPCM_IMA_ALP) += fate-adpcm-ima-alp-mono
+fate-adpcm-ima-alp-mono: CMD = md5 -i $(TARGET_SAMPLES)/alp/AD_P11.PCM -f s16le
+
+FATE_ADPCM-$(call DEMDEC, ALP, ADPCM_IMA_ALP) += fate-adpcm-ima-alp-stereo
+fate-adpcm-ima-alp-stereo: CMD = md5 -i $(TARGET_SAMPLES)/alp/theme-cut.tun -f 
s16le
+
 FATE_SAMPLES_AVCONV += $(FATE_ADPCM-yes)
 fate-adpcm: $(FATE_ADPCM-yes)
diff --git a/tests/ref/fate/adpcm-ima-alp-mono 
b/tests/ref/fate/adpcm-ima-alp-mono
new file mode 100644
index 00..4110a24c3c
--- /dev/null
+++ b/tests/ref/fate/adpcm-ima-alp-mono
@@ -0,0 +1 @@
+288d1ce2e92240ccebfe2586fc22d01b
diff --git a/tests/ref/fate/adpcm-ima-alp-stereo 
b/tests/ref/fate/adpcm-ima-alp-stereo
new file mode 100644
index 00..8cf281e92b
--- /dev/null
+++ b/tests/ref/fate/adpcm-ima-alp-stereo
@@ -0,0 +1 @@
+a100877e7e02b8a6ad63154682c844f4
-- 
2.17.1


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

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

[FFmpeg-devel] [PATCH 1/2] checkasm/hevc_add_res: prepare test data only if the fuction is not tested

2020-03-09 Thread Linjie Fu
check_func will return NULL for functions that have already been tested. If
the func is tested and skipped (which happens several times), there is no
need to prepare data(randomize_buffers and memcpy).

Move relative code in compare_add_res(), prepare data and do check only if
the function is not tested.

Signed-off-by: Linjie Fu 
---
 tests/checkasm/hevc_add_res.c | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/tests/checkasm/hevc_add_res.c b/tests/checkasm/hevc_add_res.c
index e92c6b4..a68d574 100644
--- a/tests/checkasm/hevc_add_res.c
+++ b/tests/checkasm/hevc_add_res.c
@@ -42,31 +42,38 @@
 AV_WN16A(buf + j * 2, rnd() & 0x3FF); \
 } while (0)
 
-static void check_add_res(HEVCDSPContext h, int bit_depth)
+static void compare_add_res(int size, ptrdiff_t stride)
 {
-int i;
 LOCAL_ALIGNED_32(int16_t, res0, [32 * 32]);
 LOCAL_ALIGNED_32(int16_t, res1, [32 * 32]);
 LOCAL_ALIGNED_32(uint8_t, dst0, [32 * 32 * 2]);
 LOCAL_ALIGNED_32(uint8_t, dst1, [32 * 32 * 2]);
 
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *res, 
ptrdiff_t stride);
+
+randomize_buffers(res0, size);
+randomize_buffers2(dst0, size);
+memcpy(res1, res0, sizeof(*res0) * size);
+memcpy(dst1, dst0, sizeof(int16_t) * size);
+
+call_ref(dst0, res0, stride);
+call_new(dst1, res1, stride);
+if (memcmp(dst0, dst1, size))
+fail();
+bench_new(dst1, res1, stride);
+}
+
+static void check_add_res(HEVCDSPContext h, int bit_depth)
+{
+int i;
+
 for (i = 2; i <= 5; i++) {
 int block_size = 1 << i;
 int size = block_size * block_size;
 ptrdiff_t stride = block_size << (bit_depth > 8);
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *res, 
ptrdiff_t stride);
-
-randomize_buffers(res0, size);
-randomize_buffers2(dst0, size);
-memcpy(res1, res0, sizeof(*res0) * size);
-memcpy(dst1, dst0, sizeof(int16_t) * size);
 
 if (check_func(h.add_residual[i - 2], "hevc_add_res_%dx%d_%d", 
block_size, block_size, bit_depth)) {
-call_ref(dst0, res0, stride);
-call_new(dst1, res1, stride);
-if (memcmp(dst0, dst1, size))
-fail();
-bench_new(dst1, res1, stride);
+compare_add_res(size, stride);
 }
 }
 }
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 2/2] tests/checkasm: add overflow test for hevc_add_res

2020-03-09 Thread Linjie Fu
Add overflow test for hevc_add_res when int16_t coeff = -32768.

The result of C is good, while ASM is not.

To verify:
make fate-checkasm-hevc_add_res
ffmpeg/tests/checkasm/checkasm --test=hevc_add_res

./checkasm --test=hevc_add_res
checkasm: using random seed 679391863
MMXEXT:
hevc_add_res_4x4_8_mmxext (hevc_add_res.c:69)
  - hevc_add_res.add_residual [FAILED]
SSE2:
hevc_add_res_8x8_8_sse2 (hevc_add_res.c:69)
hevc_add_res_16x16_8_sse2 (hevc_add_res.c:69)
hevc_add_res_32x32_8_sse2 (hevc_add_res.c:69)
  - hevc_add_res.add_residual [FAILED]
AVX:
hevc_add_res_8x8_8_avx (hevc_add_res.c:69)
hevc_add_res_16x16_8_avx (hevc_add_res.c:69)
hevc_add_res_32x32_8_avx (hevc_add_res.c:69)
  - hevc_add_res.add_residual [FAILED]
AVX2:
hevc_add_res_32x32_8_avx2 (hevc_add_res.c:69)
  - hevc_add_res.add_residual [FAILED]
checkasm: 8 of 14 tests have failed

Signed-off-by: Xu Guangxin 
Signed-off-by: Linjie Fu 
---
[v2/v3]: test 2x cases to make sure enough random residuals

Should be applied after the 3 fixing patch, otherwise this
would break fate.
[1] 
https://patchwork.ffmpeg.org/project/ffmpeg/patch/1583394457-21484-1-git-send-email-linjie...@intel.com/
[2] 
https://patchwork.ffmpeg.org/project/ffmpeg/patch/1583394474-21605-1-git-send-email-linjie...@intel.com/
[3] 
https://patchwork.ffmpeg.org/project/ffmpeg/patch/1583394489-21717-1-git-send-email-linjie...@intel.com/

 tests/checkasm/hevc_add_res.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/checkasm/hevc_add_res.c b/tests/checkasm/hevc_add_res.c
index a68d574..0a3bcbb 100644
--- a/tests/checkasm/hevc_add_res.c
+++ b/tests/checkasm/hevc_add_res.c
@@ -42,7 +42,7 @@
 AV_WN16A(buf + j * 2, rnd() & 0x3FF); \
 } while (0)
 
-static void compare_add_res(int size, ptrdiff_t stride)
+static void compare_add_res(int size, ptrdiff_t stride, int overflow_test)
 {
 LOCAL_ALIGNED_32(int16_t, res0, [32 * 32]);
 LOCAL_ALIGNED_32(int16_t, res1, [32 * 32]);
@@ -53,6 +53,8 @@ static void compare_add_res(int size, ptrdiff_t stride)
 
 randomize_buffers(res0, size);
 randomize_buffers2(dst0, size);
+if (overflow_test)
+res0[0] = 0x8000;
 memcpy(res1, res0, sizeof(*res0) * size);
 memcpy(dst1, dst0, sizeof(int16_t) * size);
 
@@ -73,7 +75,9 @@ static void check_add_res(HEVCDSPContext h, int bit_depth)
 ptrdiff_t stride = block_size << (bit_depth > 8);
 
 if (check_func(h.add_residual[i - 2], "hevc_add_res_%dx%d_%d", 
block_size, block_size, bit_depth)) {
-compare_add_res(size, stride);
+compare_add_res(size, stride, 0);
+// overflow test for res = -32768
+compare_add_res(size, stride, 1);
 }
 }
 }
-- 
2.7.4

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

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

Re: [FFmpeg-devel] [PATCH 0/5] adding ICC profile support to MOV decode/encode

2020-03-09 Thread Derek Buitenhuis
On 07/10/2019 11:40, vectronic wrote:
> Hello,
> 
> Wondering if anyone would be able to review these changes? I’m currently 
> using this in production and it is working well.

The patch set looks OK to me. I will push in 24h if nobody objects.

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

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

Re: [FFmpeg-devel] [PATCH 0/5] adding ICC profile support to MOV decode/encode

2020-03-09 Thread James Almer
On 3/9/2020 5:09 PM, Derek Buitenhuis wrote:
> On 07/10/2019 11:40, vectronic wrote:
>> Hello,
>>
>> Wondering if anyone would be able to review these changes? I’m currently 
>> using this in production and it is working well.
> 
> The patch set looks OK to me. I will push in 24h if nobody objects.

The second patch is very outdated, and should be squashed with the first
(alongside a lavc minor version bump that would be reflected in the
APIChanges entry).

> 
> - Derek
> ___
> 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 2/2] avcodec/cbs_h2645: Avoid more cases of 0 size slices

2020-03-09 Thread Michael Niedermayer
On Mon, Mar 09, 2020 at 05:57:50AM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: Assertion failure
> > Fixes: 
> > 19629/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5676822528524288
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/cbs_h2645.c | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> > index c8347ba5fa..7427eefa30 100644
> > --- a/libavcodec/cbs_h2645.c
> > +++ b/libavcodec/cbs_h2645.c
> > @@ -870,7 +870,8 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
> > *ctx,
> > "from slice data.\n", z);
> >  len -= z;
> >  }
> > -
> > +if (len <= pos / 8)
> > +return AVERROR_INVALIDDATA;
> >  slice->data_size = len - pos / 8;
> >  slice->data_ref  = av_buffer_ref(unit->data_ref);
> >  if (!slice->data_ref)
> > @@ -1052,7 +1053,8 @@ static int 
> > cbs_h265_read_nal_unit(CodedBitstreamContext *ctx,
> > "from slice data.\n", z);
> >  len -= z;
> >  }
> > -
> > +if (len <= pos / 8)
> > +return AVERROR_INVALIDDATA;
> >  slice->data_size = len - pos / 8;
> >  slice->data_ref  = av_buffer_ref(unit->data_ref);
> >  if (!slice->data_ref)
> > 
> 
> Imagine you have CAVLC encoded H.264 where there is nothing after the
> header except zero bits and where the slice header is not
> byte-aligned. Then av_assert0(temp) in cbs_h2645_write_slice_data()
> will be triggered both now as well as with your patch, because your
> check is too crude.
> 
> I have already sent a patch [2] for this. It presupposes [1].

the assert you speak about wasnt the one failing for this.
but your patches are a nicer solution so ill apply them

Thanks


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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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 v4 1/2] avformat: Add AMQP version 0-9-1 protocol support

2020-03-09 Thread Marton Balint



On Sun, 8 Mar 2020, Andriy Gelman wrote:


From: Andriy Gelman 

Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.

Signed-off-by: Andriy Gelman 
---

Changes in v4:
   - Fixed leak from user_decoded/password_decoded when amqp_new_connection()
 fails 


Changes in v3:
   - Fixed a bug when parsing username that contained a url encoded ":"
   - Fixed documentation error and improved logging

Changes in v2:
   - Addressed comments from Marton
   - Updated documentation

Compilation notes:
   - Requires librabbitmq-dev package (on ubuntu).
   - The pkg-config libprabbitmq.pc has a corrupt entry.
 **update: fixed on the github master branch**
 The line "Libs.private: rt; -lpthread" should be changed to
 "Libs.private: -lrt -pthread".
   - Compile FFmpeg with --enable-librabbitmq

Changelog   |   1 +
configure   |   5 +
doc/general.texi|   1 +
doc/protocols.texi  |  60 
libavformat/Makefile|   1 +
libavformat/libamqp.c   | 298 
libavformat/protocols.c |   1 +
libavformat/version.h   |   4 +-
8 files changed, 369 insertions(+), 2 deletions(-)
create mode 100644 libavformat/libamqp.c


And finally applied the series.

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

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

Re: [FFmpeg-devel] [PATCH 0/5] adding ICC profile support to MOV decode/encode

2020-03-09 Thread Derek Buitenhuis
On 09/03/2020 21:43, James Almer wrote:
> The second patch is very outdated, and should be squashed with the first
> (alongside a lavc minor version bump that would be reflected in the
> APIChanges entry).

Yes, the update and bump before pushing is implied, I thought.

- Derek
___
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] avcodec/wavpack: add DSD support

2020-03-09 Thread David Bryant
Hi,

My patch from last July to add WavPack DSD support was rejected because I 
created another codec ID for WavPack DSD audio and
duplicated some existing WavPack code.

This patch simply adds the DSD support to the existing wavpack.c file. As 
suggested, I now use ff_thread_report/await_progress()
to keep the final dsd2pcm operation serialized between frame threads, and I 
also put in slice threading for that because the
channels can be independently converted.

This has been tested extensively on both X64 and ARM and appears quite stable. 
I have also tested it on various sanitizers and
valgrind. Also, essentially the same DSD decoder has been extensively fuzzed on 
OSS-Fuzz because WavPack is also part of that
project now.

Kind regards,

David


From 5d033a4628bdaa13694c5df88b185e7b099bfea5 Mon Sep 17 00:00:00 2001
From: David Bryant 
Date: Mon, 9 Mar 2020 15:23:53 -0700
Subject: [PATCH] avcodec/wavpack: add support for DSD files

Add support for WavPack DSD files to the existing WavPack decoder using
avcodec/dsd to perform the 8:1 decimation to 32-bit float samples. We must
serialize the dsd2pcm operation (cross-boundary filtering) but would like
to use frame-level multithreading for the CPU-intensive DSD decompression,
and this is accomplished with ff_thread_report/await_progress(). Because
the dsd2pcm operation is independent across channels we use slice-based
multithreading for that part.

Also a few things were removed from the existing WavPack decoder that
weren't being used (primarily the SavedContext stuff) and the WavPack
demuxer was enhanced to correctly determine the sampling rate of DSD
files (and of course to no longer reject them).

Signed-off-by: David Bryant 
---
 libavcodec/Makefile  |   2 +-
 libavcodec/wavpack.c | 692 ---
 libavcodec/wavpack.h |   2 +
 libavformat/wvdec.c  |  28 ++-
 4 files changed, 616 insertions(+), 108 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0fd374f..a3326a4 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -693,7 +693,7 @@ OBJS-$(CONFIG_VP9_QSV_ENCODER) += qsvenc_vp9.o
 OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o
 OBJS-$(CONFIG_VP9_V4L2M2M_DECODER) += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
-OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
+OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o dsd.o
 OBJS-$(CONFIG_WAVPACK_ENCODER) += wavpackenc.o
 OBJS-$(CONFIG_WCMV_DECODER)+= wcmv.o
 OBJS-$(CONFIG_WEBP_DECODER)+= webp.o
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index edc0f79..bb36f43 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -1,6 +1,7 @@
 /*
  * WavPack lossless audio decoder
  * Copyright (c) 2006,2011 Konstantin Shishkov
+ * Copyright (c) 2020 David Bryant
  *
  * This file is part of FFmpeg.
  *
@@ -29,18 +30,37 @@
 #include "thread.h"
 #include "unary.h"
 #include "wavpack.h"
+#include "dsd.h"
 
 /**
  * @file
  * WavPack lossless audio decoder
  */
 
-typedef struct SavedContext {
-int offset;
-int size;
-int bits_used;
-uint32_t crc;
-} SavedContext;
+#define DSD_BYTE_READY(low,high) (!(((low) ^ (high)) & 0xff00))
+
+#define PTABLE_BITS 8
+#define PTABLE_BINS (1<> 8)
@@ -365,12 +394,6 @@ static float wv_get_value_float(WavpackFrameContext *s, 
uint32_t *crc, int S)
 return value.f;
 }
 
-static void wv_reset_saved_context(WavpackFrameContext *s)
-{
-s->pos= 0;
-s->sc.crc = s->extra_sc.crc = 0x;
-}
-
 static inline int wv_check_crc(WavpackFrameContext *s, uint32_t crc,
uint32_t crc_extra_bits)
 {
@@ -386,15 +409,372 @@ static inline int wv_check_crc(WavpackFrameContext *s, 
uint32_t crc,
 return 0;
 }
 
+static void init_ptable(int *table, int rate_i, int rate_s)
+{
+int value = 0x808000, rate = rate_i << 8;
+
+for (int c = (rate + 128) >> 8; c--;)
+value += (DOWN - value) >> DECAY;
+
+for (int i = 0; i < PTABLE_BINS/2; i++) {
+table[i] = value;
+table[PTABLE_BINS-1-i] = 0x100 - value;
+
+if (value > 0x01) {
+rate += (rate * rate_s + 128) >> 8;
+
+for (int c = (rate + 64) >> 7; c--;)
+value += (DOWN - value) >> DECAY;
+}
+}
+}
+
+typedef struct {
+int32_t value, fltr0, fltr1, fltr2, fltr3, fltr4, fltr5, fltr6, factor;
+unsigned int byte;
+} DSDfilters;
+
+static int wv_unpack_dsd_high(WavpackFrameContext *s, uint8_t *dst_left, 
uint8_t *dst_right)
+{
+uint32_t checksum = 0x;
+uint8_t *dst_l = dst_left, *dst_r = dst_right;
+int total_samples = s->samples, stereo = dst_r ? 1 : 0;
+DSDfilters filters[2], *sp = filters;
+int rate_i, rate_s;
+uint32_t low, high, value;
+
+if (bytestream2_get_bytes_left(&s->gbyte) < (stereo ? 20 : 13))
+return AVERROR_INVALIDDATA;
+
+rate_i = bytestream2_get_byte(&s->gbyte);
+

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-09 Thread Mark Thompson
On 08/03/2020 08:28, Linjie Fu wrote:
> Use desc->log2_chroma_w/h to calculate the sps->conf_win_right/bottom_offset.
> 
> Based on Table 6-1, SubWidthC and SubHeightC depend on chroma 
> format(log2_chroma_w/h).
> 
> Based on D-28 and D-29, set the correct cropped width/height.
> 
> croppedWidth  = pic_width_in_luma_samples −
> SubWidthC * ( conf_win_right_offset + conf_win_left_offset );
> 
> croppedHeight = pic_height_in_luma_samples −
> SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset );
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: use desc->log2_chroma_w/h.
> 
>  libavcodec/vaapi_encode_h265.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index ace7696..bebb0f9 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -410,10 +410,10 @@ static int 
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  sps->conformance_window_flag = 1;
>  sps->conf_win_left_offset   = 0;
>  sps->conf_win_right_offset  =
> -(ctx->surface_width - avctx->width) / 2;
> +(ctx->surface_width - avctx->width) >> desc->log2_chroma_w;
>  sps->conf_win_top_offset= 0;
>  sps->conf_win_bottom_offset =
> -(ctx->surface_height - avctx->height) / 2;
> +(ctx->surface_height - avctx->height) >> desc->log2_chroma_h;
>  } else {
>  sps->conformance_window_flag = 0;
>  }
> 

Yep, applied.

Thanks,

- Mark
___
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] fate/adpcm: add adpcm_ima_alp tests

2020-03-09 Thread Michael Niedermayer
On Mon, Mar 09, 2020 at 01:07:47PM +, Zane van Iperen wrote:
> Signed-off-by: Zane van Iperen 
> ---
>  tests/fate/adpcm.mak| 6 ++
>  tests/ref/fate/adpcm-ima-alp-mono   | 1 +
>  tests/ref/fate/adpcm-ima-alp-stereo | 1 +
>  3 files changed, 8 insertions(+)
>  create mode 100644 tests/ref/fate/adpcm-ima-alp-mono
>  create mode 100644 tests/ref/fate/adpcm-ima-alp-stereo

works on x86-32/64, arm, mips, mingw32/64
will apply

thx

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

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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] Reimbursement request

2020-03-09 Thread Carl Eugen Hoyos
Hi!

The Chemnitzer Linuxtage were canceled yesterday because of the Coronavirus.
I request reimbursement of €138,86 for the flight to Germany I had
booked last month.

Thank you, 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] Reimbursement request

2020-03-09 Thread Lou Logan
On Mon, Mar 9, 2020, at 4:59 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> The Chemnitzer Linuxtage were canceled yesterday because of the Coronavirus.
> I request reimbursement of €138,86 for the flight to Germany I had
> booked last month.
> 
> Thank you, Carl Eugen

Some airlines are providing a more generous refund policy lately.
Is your purchase covered by something like that?
___
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] Reimbursement request

2020-03-09 Thread Carl Eugen Hoyos
Am Di., 10. März 2020 um 02:45 Uhr schrieb Lou Logan :
>
> On Mon, Mar 9, 2020, at 4:59 PM, Carl Eugen Hoyos wrote:

> > The Chemnitzer Linuxtage were canceled yesterday because of the Coronavirus.
> > I request reimbursement of €138,86 for the flight to Germany I had
> > booked last month.
>
> Some airlines are providing a more generous refund policy lately.
> Is your purchase covered by something like that?

Given that travel to Germany is in no way restricted, I don't see how.

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] Reimbursement request

2020-03-09 Thread Lou Logan
On Mon, Mar 9, 2020, at 5:49 PM, Carl Eugen Hoyos wrote:
>
> Given that travel to Germany is in no way restricted, I don't see how.

There is no travel restriction in the US either, but here's what the main
airline in my region offers:

* No change or cancellation fees for travel through 2020-03-31,
   regardless of purchase date.

* No change or cancellation fees for new tickets purchased
   between 2020-02-27 and 2020-03-31.

Please verify that you are unable to get a similar refund from the
airline first.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 2/2] avcodec/v4l2_m2m{enc, dec}: Fix leaks when init fails

2020-03-09 Thread Andriy Gelman
From: Andriy Gelman 

v4l2_m2m_{enc,dec} doesn't call its close function when initialization
fails because FF_CODEC_CAP_INIT_CLEANUP is not set. This causes a couple
possible leaks, which are fixed in the commit.

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_m2m_dec.c | 9 ++---
 libavcodec/v4l2_m2m_enc.c | 7 ++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index d666edffe46..a515f3ca720 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -205,13 +205,16 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx)
 ret = ff_v4l2_m2m_codec_init(priv);
 if (ret) {
 av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");
-s->self_ref = NULL;
-av_buffer_unref(&priv->context_ref);
+ff_v4l2_m2m_codec_end(priv);
 
 return ret;
 }
 
-return v4l2_prepare_decoder(s);
+ret = v4l2_prepare_decoder(s);
+if (ret < 0)
+ff_v4l2_m2m_codec_end(priv);
+
+return ret;
 }
 
 static av_cold int v4l2_decode_close(AVCodecContext *avctx)
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index ff9ff267ea2..ca58669a976 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -329,10 +329,15 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
 if (pix_fmt_output != avctx->pix_fmt) {
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt_output);
 av_log(avctx, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", 
desc->name);
+ff_v4l2_m2m_codec_end(priv);
 return AVERROR(EINVAL);
 }
 
-return v4l2_prepare_encoder(s);
+ret = v4l2_prepare_encoder(s);
+if (ret < 0)
+ff_v4l2_m2m_codec_end(priv);
+
+return ret;
 }
 
 static av_cold int v4l2_encode_close(AVCodecContext *avctx)
-- 
2.25.0

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

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

[FFmpeg-devel] [PATCH 1/2] avcodec/v4l2_m2m_enc: Fix leak when device init fails

2020-03-09 Thread Andriy Gelman
From: Colin NG 

Fixes ticket #8285

Signed-off-by: Andriy Gelman 
---

This was sent to the mailing list by Colin NG some time ago, but was never
applied.

 libavcodec/v4l2_m2m_enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index c9f1741bfd0..ff9ff267ea2 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -316,6 +316,7 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
 ret = ff_v4l2_m2m_codec_init(priv);
 if (ret) {
 av_log(avctx, AV_LOG_ERROR, "can't configure encoder\n");
+ff_v4l2_m2m_codec_end(priv);
 return ret;
 }
 
-- 
2.25.0

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

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

[FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-09 Thread Andriy Gelman
From: Andriy Gelman 

Should be squashed with:
http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_m2m.c |  8 
 libavcodec/v4l2_m2m.h |  3 +++
 libavcodec/v4l2_m2m_enc.c | 15 ++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index 2d21f910bcc..dab04313a8a 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t 
*context)
 sem_destroy(&s->refsync);
 
 close(s->fd);
+av_frame_free(&s->frame);
 
 av_free(s);
 }
@@ -417,5 +418,12 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
V4L2m2mContext **s)
 priv->context->self_ref = priv->context_ref;
 priv->context->fd = -1;
 
+priv->context->frame = av_frame_alloc();
+if (!priv->context->frame) {
+av_buffer_unref(&priv->context_ref);
+*s = NULL; /* freed when unreferencing context_ref */
+return AVERROR(ENOMEM);
+}
+
 return 0;
 }
diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index 456281f48c5..b67b2163310 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
 int draining;
 AVPacket buf_pkt;
 
+/* Reference to a frame. Only used during encoding */
+AVFrame *frame;
+
 /* Reference to self; only valid while codec is active. */
 AVBufferRef *self_ref;
 
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index c9f1741bfd0..a52a3d9ad3b 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include "encode.h"
 #include "libavcodec/avcodec.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
@@ -259,11 +260,24 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
AVPacket *avpkt)
 V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
 V4L2Context *const capture = &s->capture;
 V4L2Context *const output = &s->output;
+AVFrame *frame = s->frame;
 int ret;
 
 if (s->draining)
 goto dequeue;
 
+ret = ff_encode_get_frame(avctx, frame);
+if (ret < 0 && ret != AVERROR_EOF)
+return ret;
+
+if (ret == AVERROR_EOF)
+frame = NULL;
+
+ret = v4l2_send_frame(avctx, frame);
+av_frame_unref(frame);
+if (ret < 0)
+return ret;
+
 if (!output->streamon) {
 ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
 if (ret) {
@@ -367,7 +381,6 @@ static const AVOption options[] = {
 .priv_data_size = sizeof(V4L2m2mPriv), \
 .priv_class = &v4l2_m2m_ ## NAME ##_enc_class, \
 .init   = v4l2_encode_init, \
-.send_frame = v4l2_send_frame, \
 .receive_packet = v4l2_receive_packet, \
 .close  = v4l2_encode_close, \
 .capabilities   = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
-- 
2.25.0

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/v4l2_m2m: Avoid using intermediate buffer

2020-03-09 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Up until now, v4l2_m2m would write via snprintf() into an intermediate
> buffer and then copy from there (via strncpy()) to the end buffer. This
> commit changes this by removing the intermediate buffer.
> 
> The call to strncpy() was actually of the form strncpy(dst, src,
> strlen(src) + 1) which is unsafe in general, but safe in this instance
> because dst and src were both of the same size and src was a proper
> zero-terminated string. But this nevertheless led to a compiler warning
> "‘strncpy’ specified bound depends on the length of the source argument
> [-Wstringop-overflow=]" in GCC 9.2. strlen() was unnecessary anyway.
> 
> Reviewed-by: Andriy Gelman 
> Signed-off-by: Andreas Rheinhardt 
> ---
> Thanks to Andriy for testing and reviewing.
> 
>  libavcodec/v4l2_m2m.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
> index 2d21f910bc..e48b3a8ccf 100644
> --- a/libavcodec/v4l2_m2m.c
> +++ b/libavcodec/v4l2_m2m.c
> @@ -358,7 +358,6 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
>  {
>  int ret = AVERROR(EINVAL);
>  struct dirent *entry;
> -char node[PATH_MAX];
>  DIR *dirp;
>  
>  V4L2m2mContext *s = priv->context;
> @@ -372,9 +371,8 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
>  if (strncmp(entry->d_name, "video", 5))
>  continue;
>  
> -snprintf(node, sizeof(node), "/dev/%s", entry->d_name);
> -av_log(s->avctx, AV_LOG_DEBUG, "probing device %s\n", node);
> -strncpy(s->devname, node, strlen(node) + 1);
> +snprintf(s->devname, sizeof(s->devname), "/dev/%s", entry->d_name);
> +av_log(s->avctx, AV_LOG_DEBUG, "probing device %s\n", s->devname);
>  ret = v4l2_probe_driver(s);
>  if (!ret)
>  break;
> @@ -389,7 +387,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
>  return ret;
>  }
>  
> -av_log(s->avctx, AV_LOG_INFO, "Using device %s\n", node);
> +av_log(s->avctx, AV_LOG_INFO, "Using device %s\n", s->devname);
>  
>  return v4l2_configure_contexts(s);
>  }
> 

Ping for this patchset.

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

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